babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757
  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/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. 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>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. 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;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. 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;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. import { WebRequest } from "babylonjs/Misc/webRequest";
  1476. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1478. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1479. /** @hidden */
  1480. export class ShaderProcessor {
  1481. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1482. private static _ProcessPrecision;
  1483. private static _ExtractOperation;
  1484. private static _BuildSubExpression;
  1485. private static _BuildExpression;
  1486. private static _MoveCursorWithinIf;
  1487. private static _MoveCursor;
  1488. private static _EvaluatePreProcessors;
  1489. private static _PreparePreProcessors;
  1490. private static _ProcessShaderConversion;
  1491. private static _ProcessIncludes;
  1492. /**
  1493. * Loads a file from a url
  1494. * @param url url to load
  1495. * @param onSuccess callback called when the file successfully loads
  1496. * @param onProgress callback called while file is loading (if the server supports this mode)
  1497. * @param offlineProvider defines the offline provider for caching
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @returns a file request object
  1501. * @hidden
  1502. */
  1503. 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;
  1504. }
  1505. }
  1506. declare module "babylonjs/Maths/math.like" {
  1507. import { float, int, DeepImmutable } from "babylonjs/types";
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IColor4Like {
  1512. r: float;
  1513. g: float;
  1514. b: float;
  1515. a: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IColor3Like {
  1521. r: float;
  1522. g: float;
  1523. b: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IVector4Like {
  1529. x: float;
  1530. y: float;
  1531. z: float;
  1532. w: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IVector3Like {
  1538. x: float;
  1539. y: float;
  1540. z: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IVector2Like {
  1546. x: float;
  1547. y: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IMatrixLike {
  1553. toArray(): DeepImmutable<Float32Array>;
  1554. updateFlag: int;
  1555. }
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IViewportLike {
  1560. x: float;
  1561. y: float;
  1562. width: float;
  1563. height: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IPlaneLike {
  1569. normal: IVector3Like;
  1570. d: float;
  1571. normalize(): void;
  1572. }
  1573. }
  1574. declare module "babylonjs/Materials/iEffectFallbacks" {
  1575. import { Effect } from "babylonjs/Materials/effect";
  1576. /**
  1577. * Interface used to define common properties for effect fallbacks
  1578. */
  1579. export interface IEffectFallbacks {
  1580. /**
  1581. * Removes the defines that should be removed when falling back.
  1582. * @param currentDefines defines the current define statements for the shader.
  1583. * @param effect defines the current effect we try to compile
  1584. * @returns The resulting defines with defines of the current rank removed.
  1585. */
  1586. reduce(currentDefines: string, effect: Effect): string;
  1587. /**
  1588. * Removes the fallback from the bound mesh.
  1589. */
  1590. unBindMesh(): void;
  1591. /**
  1592. * Checks to see if more fallbacks are still availible.
  1593. */
  1594. hasMoreFallbacks: boolean;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1598. /**
  1599. * Class used to evalaute queries containing `and` and `or` operators
  1600. */
  1601. export class AndOrNotEvaluator {
  1602. /**
  1603. * Evaluate a query
  1604. * @param query defines the query to evaluate
  1605. * @param evaluateCallback defines the callback used to filter result
  1606. * @returns true if the query matches
  1607. */
  1608. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1609. private static _HandleParenthesisContent;
  1610. private static _SimplifyNegation;
  1611. }
  1612. }
  1613. declare module "babylonjs/Misc/tags" {
  1614. /**
  1615. * Class used to store custom tags
  1616. */
  1617. export class Tags {
  1618. /**
  1619. * Adds support for tags on the given object
  1620. * @param obj defines the object to use
  1621. */
  1622. static EnableFor(obj: any): void;
  1623. /**
  1624. * Removes tags support
  1625. * @param obj defines the object to use
  1626. */
  1627. static DisableFor(obj: any): void;
  1628. /**
  1629. * Gets a boolean indicating if the given object has tags
  1630. * @param obj defines the object to use
  1631. * @returns a boolean
  1632. */
  1633. static HasTags(obj: any): boolean;
  1634. /**
  1635. * Gets the tags available on a given object
  1636. * @param obj defines the object to use
  1637. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1638. * @returns the tags
  1639. */
  1640. static GetTags(obj: any, asString?: boolean): any;
  1641. /**
  1642. * Adds tags to an object
  1643. * @param obj defines the object to use
  1644. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1645. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1646. */
  1647. static AddTagsTo(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _AddTagTo(obj: any, tag: string): void;
  1652. /**
  1653. * Removes specific tags from a specific object
  1654. * @param obj defines the object to use
  1655. * @param tagsString defines the tags to remove
  1656. */
  1657. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1658. /**
  1659. * @hidden
  1660. */
  1661. static _RemoveTagFrom(obj: any, tag: string): void;
  1662. /**
  1663. * Defines if tags hosted on an object match a given query
  1664. * @param obj defines the object to use
  1665. * @param tagsQuery defines the tag query
  1666. * @returns a boolean
  1667. */
  1668. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1669. }
  1670. }
  1671. declare module "babylonjs/Maths/math.scalar" {
  1672. /**
  1673. * Scalar computation library
  1674. */
  1675. export class Scalar {
  1676. /**
  1677. * Two pi constants convenient for computation.
  1678. */
  1679. static TwoPi: number;
  1680. /**
  1681. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1682. * @param a number
  1683. * @param b number
  1684. * @param epsilon (default = 1.401298E-45)
  1685. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1686. */
  1687. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1688. /**
  1689. * Returns a string : the upper case translation of the number i to hexadecimal.
  1690. * @param i number
  1691. * @returns the upper case translation of the number i to hexadecimal.
  1692. */
  1693. static ToHex(i: number): string;
  1694. /**
  1695. * Returns -1 if value is negative and +1 is value is positive.
  1696. * @param value the value
  1697. * @returns the value itself if it's equal to zero.
  1698. */
  1699. static Sign(value: number): number;
  1700. /**
  1701. * Returns the value itself if it's between min and max.
  1702. * Returns min if the value is lower than min.
  1703. * Returns max if the value is greater than max.
  1704. * @param value the value to clmap
  1705. * @param min the min value to clamp to (default: 0)
  1706. * @param max the max value to clamp to (default: 1)
  1707. * @returns the clamped value
  1708. */
  1709. static Clamp(value: number, min?: number, max?: number): number;
  1710. /**
  1711. * the log2 of value.
  1712. * @param value the value to compute log2 of
  1713. * @returns the log2 of value.
  1714. */
  1715. static Log2(value: number): number;
  1716. /**
  1717. * Loops the value, so that it is never larger than length and never smaller than 0.
  1718. *
  1719. * This is similar to the modulo operator but it works with floating point numbers.
  1720. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1721. * With t = 5 and length = 2.5, the result would be 0.0.
  1722. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1723. * @param value the value
  1724. * @param length the length
  1725. * @returns the looped value
  1726. */
  1727. static Repeat(value: number, length: number): number;
  1728. /**
  1729. * Normalize the value between 0.0 and 1.0 using min and max values
  1730. * @param value value to normalize
  1731. * @param min max to normalize between
  1732. * @param max min to normalize between
  1733. * @returns the normalized value
  1734. */
  1735. static Normalize(value: number, min: number, max: number): number;
  1736. /**
  1737. * Denormalize the value from 0.0 and 1.0 using min and max values
  1738. * @param normalized value to denormalize
  1739. * @param min max to denormalize between
  1740. * @param max min to denormalize between
  1741. * @returns the denormalized value
  1742. */
  1743. static Denormalize(normalized: number, min: number, max: number): number;
  1744. /**
  1745. * Calculates the shortest difference between two given angles given in degrees.
  1746. * @param current current angle in degrees
  1747. * @param target target angle in degrees
  1748. * @returns the delta
  1749. */
  1750. static DeltaAngle(current: number, target: number): number;
  1751. /**
  1752. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1753. * @param tx value
  1754. * @param length length
  1755. * @returns The returned value will move back and forth between 0 and length
  1756. */
  1757. static PingPong(tx: number, length: number): number;
  1758. /**
  1759. * Interpolates between min and max with smoothing at the limits.
  1760. *
  1761. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1762. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1763. * @param from from
  1764. * @param to to
  1765. * @param tx value
  1766. * @returns the smooth stepped value
  1767. */
  1768. static SmoothStep(from: number, to: number, tx: number): number;
  1769. /**
  1770. * Moves a value current towards target.
  1771. *
  1772. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1773. * Negative values of maxDelta pushes the value away from target.
  1774. * @param current current value
  1775. * @param target target value
  1776. * @param maxDelta max distance to move
  1777. * @returns resulting value
  1778. */
  1779. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1780. /**
  1781. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. *
  1783. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1784. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1785. * @param current current value
  1786. * @param target target value
  1787. * @param maxDelta max distance to move
  1788. * @returns resulting angle
  1789. */
  1790. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1791. /**
  1792. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1793. * @param start start value
  1794. * @param end target value
  1795. * @param amount amount to lerp between
  1796. * @returns the lerped value
  1797. */
  1798. static Lerp(start: number, end: number, amount: number): number;
  1799. /**
  1800. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1801. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static LerpAngle(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1810. * @param a start value
  1811. * @param b target value
  1812. * @param value value between a and b
  1813. * @returns the inverseLerp value
  1814. */
  1815. static InverseLerp(a: number, b: number, value: number): number;
  1816. /**
  1817. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1818. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1819. * @param value1 spline value
  1820. * @param tangent1 spline value
  1821. * @param value2 spline value
  1822. * @param tangent2 spline value
  1823. * @param amount input value
  1824. * @returns hermite result
  1825. */
  1826. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1827. /**
  1828. * Returns a random float number between and min and max values
  1829. * @param min min value of random
  1830. * @param max max value of random
  1831. * @returns random value
  1832. */
  1833. static RandomRange(min: number, max: number): number;
  1834. /**
  1835. * This function returns percentage of a number in a given range.
  1836. *
  1837. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1838. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1839. * @param number to convert to percentage
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the percentage
  1843. */
  1844. static RangeToPercent(number: number, min: number, max: number): number;
  1845. /**
  1846. * This function returns number that corresponds to the percentage in a given range.
  1847. *
  1848. * PercentToRange(0.34,0,100) will return 34.
  1849. * @param percent to convert to number
  1850. * @param min min range
  1851. * @param max max range
  1852. * @returns the number
  1853. */
  1854. static PercentToRange(percent: number, min: number, max: number): number;
  1855. /**
  1856. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1857. * @param angle The angle to normalize in radian.
  1858. * @return The converted angle.
  1859. */
  1860. static NormalizeRadians(angle: number): number;
  1861. }
  1862. }
  1863. declare module "babylonjs/Maths/math.constants" {
  1864. /**
  1865. * Constant used to convert a value to gamma space
  1866. * @ignorenaming
  1867. */
  1868. export const ToGammaSpace: number;
  1869. /**
  1870. * Constant used to convert a value to linear space
  1871. * @ignorenaming
  1872. */
  1873. export const ToLinearSpace = 2.2;
  1874. /**
  1875. * Constant used to define the minimal number value in Babylon.js
  1876. * @ignorenaming
  1877. */
  1878. let Epsilon: number;
  1879. export { Epsilon };
  1880. }
  1881. declare module "babylonjs/Maths/math.viewport" {
  1882. /**
  1883. * Class used to represent a viewport on screen
  1884. */
  1885. export class Viewport {
  1886. /** viewport left coordinate */
  1887. x: number;
  1888. /** viewport top coordinate */
  1889. y: number;
  1890. /**viewport width */
  1891. width: number;
  1892. /** viewport height */
  1893. height: number;
  1894. /**
  1895. * Creates a Viewport object located at (x, y) and sized (width, height)
  1896. * @param x defines viewport left coordinate
  1897. * @param y defines viewport top coordinate
  1898. * @param width defines the viewport width
  1899. * @param height defines the viewport height
  1900. */
  1901. constructor(
  1902. /** viewport left coordinate */
  1903. x: number,
  1904. /** viewport top coordinate */
  1905. y: number,
  1906. /**viewport width */
  1907. width: number,
  1908. /** viewport height */
  1909. height: number);
  1910. /**
  1911. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1912. * @param renderWidth defines the rendering width
  1913. * @param renderHeight defines the rendering height
  1914. * @returns a new Viewport
  1915. */
  1916. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1917. /**
  1918. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1919. * @param renderWidth defines the rendering width
  1920. * @param renderHeight defines the rendering height
  1921. * @param ref defines the target viewport
  1922. * @returns the current viewport
  1923. */
  1924. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1925. /**
  1926. * Returns a new Viewport copied from the current one
  1927. * @returns a new Viewport
  1928. */
  1929. clone(): Viewport;
  1930. }
  1931. }
  1932. declare module "babylonjs/Misc/arrayTools" {
  1933. /**
  1934. * Class containing a set of static utilities functions for arrays.
  1935. */
  1936. export class ArrayTools {
  1937. /**
  1938. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1939. * @param size the number of element to construct and put in the array
  1940. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1941. * @returns a new array filled with new objects
  1942. */
  1943. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1944. }
  1945. }
  1946. declare module "babylonjs/Maths/math.vector" {
  1947. import { Viewport } from "babylonjs/Maths/math.viewport";
  1948. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1949. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1950. /**
  1951. * Class representing a vector containing 2 coordinates
  1952. */
  1953. export class Vector2 {
  1954. /** defines the first coordinate */
  1955. x: number;
  1956. /** defines the second coordinate */
  1957. y: number;
  1958. /**
  1959. * Creates a new Vector2 from the given x and y coordinates
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. */
  1963. constructor(
  1964. /** defines the first coordinate */
  1965. x?: number,
  1966. /** defines the second coordinate */
  1967. y?: number);
  1968. /**
  1969. * Gets a string with the Vector2 coordinates
  1970. * @returns a string with the Vector2 coordinates
  1971. */
  1972. toString(): string;
  1973. /**
  1974. * Gets class name
  1975. * @returns the string "Vector2"
  1976. */
  1977. getClassName(): string;
  1978. /**
  1979. * Gets current vector hash code
  1980. * @returns the Vector2 hash code as a number
  1981. */
  1982. getHashCode(): number;
  1983. /**
  1984. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1985. * @param array defines the source array
  1986. * @param index defines the offset in source array
  1987. * @returns the current Vector2
  1988. */
  1989. toArray(array: FloatArray, index?: number): Vector2;
  1990. /**
  1991. * Copy the current vector to an array
  1992. * @returns a new array with 2 elements: the Vector2 coordinates.
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1997. * @param source defines the source Vector2
  1998. * @returns the current updated Vector2
  1999. */
  2000. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2001. /**
  2002. * Sets the Vector2 coordinates with the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns the current updated Vector2
  2006. */
  2007. copyFromFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Sets the Vector2 coordinates with the given floats
  2010. * @param x defines the first coordinate
  2011. * @param y defines the second coordinate
  2012. * @returns the current updated Vector2
  2013. */
  2014. set(x: number, y: number): Vector2;
  2015. /**
  2016. * Add another vector with the current one
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2019. */
  2020. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2021. /**
  2022. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2023. * @param otherVector defines the other vector
  2024. * @param result defines the target vector
  2025. * @returns the unmodified current Vector2
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2028. /**
  2029. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2030. * @param otherVector defines the other vector
  2031. * @returns the current updated Vector2
  2032. */
  2033. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2034. /**
  2035. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns a new Vector2
  2038. */
  2039. addVector3(otherVector: Vector3): Vector2;
  2040. /**
  2041. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. subtract(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Multiplies in place the current Vector2 coordinates by the given ones
  2061. * @param otherVector defines the other vector
  2062. * @returns the current updated Vector2
  2063. */
  2064. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2065. /**
  2066. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @returns a new Vector2
  2069. */
  2070. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2071. /**
  2072. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2073. * @param otherVector defines the other vector
  2074. * @param result defines the target vector
  2075. * @returns the unmodified current Vector2
  2076. */
  2077. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2078. /**
  2079. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2080. * @param x defines the first coordinate
  2081. * @param y defines the second coordinate
  2082. * @returns a new Vector2
  2083. */
  2084. multiplyByFloats(x: number, y: number): Vector2;
  2085. /**
  2086. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2087. * @param otherVector defines the other vector
  2088. * @returns a new Vector2
  2089. */
  2090. divide(otherVector: Vector2): Vector2;
  2091. /**
  2092. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2093. * @param otherVector defines the other vector
  2094. * @param result defines the target vector
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2098. /**
  2099. * Divides the current Vector2 coordinates by the given ones
  2100. * @param otherVector defines the other vector
  2101. * @returns the current updated Vector2
  2102. */
  2103. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2104. /**
  2105. * Gets a new Vector2 with current Vector2 negated coordinates
  2106. * @returns a new Vector2
  2107. */
  2108. negate(): Vector2;
  2109. /**
  2110. * Multiply the Vector2 coordinates by scale
  2111. * @param scale defines the scaling factor
  2112. * @returns the current updated Vector2
  2113. */
  2114. scaleInPlace(scale: number): Vector2;
  2115. /**
  2116. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2117. * @param scale defines the scaling factor
  2118. * @returns a new Vector2
  2119. */
  2120. scale(scale: number): Vector2;
  2121. /**
  2122. * Scale the current Vector2 values by a factor to a given Vector2
  2123. * @param scale defines the scale factor
  2124. * @param result defines the Vector2 object where to store the result
  2125. * @returns the unmodified current Vector2
  2126. */
  2127. scaleToRef(scale: number, result: Vector2): Vector2;
  2128. /**
  2129. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2130. * @param scale defines the scale factor
  2131. * @param result defines the Vector2 object where to store the result
  2132. * @returns the unmodified current Vector2
  2133. */
  2134. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2135. /**
  2136. * Gets a boolean if two vectors are equals
  2137. * @param otherVector defines the other vector
  2138. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2139. */
  2140. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2141. /**
  2142. * Gets a boolean if two vectors are equals (using an epsilon value)
  2143. * @param otherVector defines the other vector
  2144. * @param epsilon defines the minimal distance to consider equality
  2145. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2146. */
  2147. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2148. /**
  2149. * Gets a new Vector2 from current Vector2 floored values
  2150. * @returns a new Vector2
  2151. */
  2152. floor(): Vector2;
  2153. /**
  2154. * Gets a new Vector2 from current Vector2 floored values
  2155. * @returns a new Vector2
  2156. */
  2157. fract(): Vector2;
  2158. /**
  2159. * Gets the length of the vector
  2160. * @returns the vector length (float)
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Gets the vector squared length
  2165. * @returns the vector squared length (float)
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalize the vector
  2170. * @returns the current updated Vector2
  2171. */
  2172. normalize(): Vector2;
  2173. /**
  2174. * Gets a new Vector2 copied from the Vector2
  2175. * @returns a new Vector2
  2176. */
  2177. clone(): Vector2;
  2178. /**
  2179. * Gets a new Vector2(0, 0)
  2180. * @returns a new Vector2
  2181. */
  2182. static Zero(): Vector2;
  2183. /**
  2184. * Gets a new Vector2(1, 1)
  2185. * @returns a new Vector2
  2186. */
  2187. static One(): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set from the given index element of the given array
  2190. * @param array defines the data source
  2191. * @param offset defines the offset in the data source
  2192. * @returns a new Vector2
  2193. */
  2194. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2195. /**
  2196. * Sets "result" from the given index element of the given array
  2197. * @param array defines the data source
  2198. * @param offset defines the offset in the data source
  2199. * @param result defines the target vector
  2200. */
  2201. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2202. /**
  2203. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2204. * @param value1 defines 1st point of control
  2205. * @param value2 defines 2nd point of control
  2206. * @param value3 defines 3rd point of control
  2207. * @param value4 defines 4th point of control
  2208. * @param amount defines the interpolation factor
  2209. * @returns a new Vector2
  2210. */
  2211. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2212. /**
  2213. * 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".
  2214. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2215. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2216. * @param value defines the value to clamp
  2217. * @param min defines the lower limit
  2218. * @param max defines the upper limit
  2219. * @returns a new Vector2
  2220. */
  2221. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2222. /**
  2223. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2224. * @param value1 defines the 1st control point
  2225. * @param tangent1 defines the outgoing tangent
  2226. * @param value2 defines the 2nd control point
  2227. * @param tangent2 defines the incoming tangent
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2234. * @param start defines the start vector
  2235. * @param end defines the end vector
  2236. * @param amount defines the interpolation factor
  2237. * @returns a new Vector2
  2238. */
  2239. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2240. /**
  2241. * Gets the dot product of the vector "left" and the vector "right"
  2242. * @param left defines first vector
  2243. * @param right defines second vector
  2244. * @returns the dot product (float)
  2245. */
  2246. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2247. /**
  2248. * Returns a new Vector2 equal to the normalized given vector
  2249. * @param vector defines the vector to normalize
  2250. * @returns a new Vector2
  2251. */
  2252. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2253. /**
  2254. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2255. * @param left defines 1st vector
  2256. * @param right defines 2nd vector
  2257. * @returns a new Vector2
  2258. */
  2259. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2260. /**
  2261. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2262. * @param left defines 1st vector
  2263. * @param right defines 2nd vector
  2264. * @returns a new Vector2
  2265. */
  2266. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2267. /**
  2268. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2269. * @param vector defines the vector to transform
  2270. * @param transformation defines the matrix to apply
  2271. * @returns a new Vector2
  2272. */
  2273. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2274. /**
  2275. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2276. * @param vector defines the vector to transform
  2277. * @param transformation defines the matrix to apply
  2278. * @param result defines the target vector
  2279. */
  2280. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2281. /**
  2282. * Determines if a given vector is included in a triangle
  2283. * @param p defines the vector to test
  2284. * @param p0 defines 1st triangle point
  2285. * @param p1 defines 2nd triangle point
  2286. * @param p2 defines 3rd triangle point
  2287. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2288. */
  2289. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2290. /**
  2291. * Gets the distance between the vectors "value1" and "value2"
  2292. * @param value1 defines first vector
  2293. * @param value2 defines second vector
  2294. * @returns the distance between vectors
  2295. */
  2296. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2297. /**
  2298. * Returns the squared distance between the vectors "value1" and "value2"
  2299. * @param value1 defines first vector
  2300. * @param value2 defines second vector
  2301. * @returns the squared distance between vectors
  2302. */
  2303. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2304. /**
  2305. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2306. * @param value1 defines first vector
  2307. * @param value2 defines second vector
  2308. * @returns a new Vector2
  2309. */
  2310. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2311. /**
  2312. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2313. * @param p defines the middle point
  2314. * @param segA defines one point of the segment
  2315. * @param segB defines the other point of the segment
  2316. * @returns the shortest distance
  2317. */
  2318. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2319. }
  2320. /**
  2321. * Class used to store (x,y,z) vector representation
  2322. * A Vector3 is the main object used in 3D geometry
  2323. * It can represent etiher the coordinates of a point the space, either a direction
  2324. * Reminder: js uses a left handed forward facing system
  2325. */
  2326. export class Vector3 {
  2327. /**
  2328. * Defines the first coordinates (on X axis)
  2329. */
  2330. x: number;
  2331. /**
  2332. * Defines the second coordinates (on Y axis)
  2333. */
  2334. y: number;
  2335. /**
  2336. * Defines the third coordinates (on Z axis)
  2337. */
  2338. z: number;
  2339. private static _UpReadOnly;
  2340. private static _ZeroReadOnly;
  2341. /**
  2342. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2343. * @param x defines the first coordinates (on X axis)
  2344. * @param y defines the second coordinates (on Y axis)
  2345. * @param z defines the third coordinates (on Z axis)
  2346. */
  2347. constructor(
  2348. /**
  2349. * Defines the first coordinates (on X axis)
  2350. */
  2351. x?: number,
  2352. /**
  2353. * Defines the second coordinates (on Y axis)
  2354. */
  2355. y?: number,
  2356. /**
  2357. * Defines the third coordinates (on Z axis)
  2358. */
  2359. z?: number);
  2360. /**
  2361. * Creates a string representation of the Vector3
  2362. * @returns a string with the Vector3 coordinates.
  2363. */
  2364. toString(): string;
  2365. /**
  2366. * Gets the class name
  2367. * @returns the string "Vector3"
  2368. */
  2369. getClassName(): string;
  2370. /**
  2371. * Creates the Vector3 hash code
  2372. * @returns a number which tends to be unique between Vector3 instances
  2373. */
  2374. getHashCode(): number;
  2375. /**
  2376. * Creates an array containing three elements : the coordinates of the Vector3
  2377. * @returns a new array of numbers
  2378. */
  2379. asArray(): number[];
  2380. /**
  2381. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2382. * @param array defines the destination array
  2383. * @param index defines the offset in the destination array
  2384. * @returns the current Vector3
  2385. */
  2386. toArray(array: FloatArray, index?: number): Vector3;
  2387. /**
  2388. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2389. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2390. */
  2391. toQuaternion(): Quaternion;
  2392. /**
  2393. * Adds the given vector to the current Vector3
  2394. * @param otherVector defines the second operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2398. /**
  2399. * Adds the given coordinates to the current Vector3
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2406. /**
  2407. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Subtract the given vector from the current Vector3
  2421. * @param otherVector defines the second operand
  2422. * @returns the current updated Vector3
  2423. */
  2424. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2425. /**
  2426. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2427. * @param otherVector defines the second operand
  2428. * @returns the resulting Vector3
  2429. */
  2430. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2433. * @param otherVector defines the second operand
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2438. /**
  2439. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @returns the resulting Vector3
  2444. */
  2445. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2446. /**
  2447. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @param result defines the Vector3 object where to store the result
  2452. * @returns the current Vector3
  2453. */
  2454. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2455. /**
  2456. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2457. * @returns a new Vector3
  2458. */
  2459. negate(): Vector3;
  2460. /**
  2461. * Negate this vector in place
  2462. * @returns this
  2463. */
  2464. negateInPlace(): Vector3;
  2465. /**
  2466. * Multiplies the Vector3 coordinates by the float "scale"
  2467. * @param scale defines the multiplier factor
  2468. * @returns the current updated Vector3
  2469. */
  2470. scaleInPlace(scale: number): Vector3;
  2471. /**
  2472. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2473. * @param scale defines the multiplier factor
  2474. * @returns a new Vector3
  2475. */
  2476. scale(scale: number): Vector3;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2479. * @param scale defines the multiplier factor
  2480. * @param result defines the Vector3 object where to store the result
  2481. * @returns the current Vector3
  2482. */
  2483. scaleToRef(scale: number, result: Vector3): Vector3;
  2484. /**
  2485. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2486. * @param scale defines the scale factor
  2487. * @param result defines the Vector3 object where to store the result
  2488. * @returns the unmodified current Vector3
  2489. */
  2490. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2491. /**
  2492. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2493. * @param otherVector defines the second operand
  2494. * @returns true if both vectors are equals
  2495. */
  2496. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2497. /**
  2498. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2499. * @param otherVector defines the second operand
  2500. * @param epsilon defines the minimal distance to define values as equals
  2501. * @returns true if both vectors are distant less than epsilon
  2502. */
  2503. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2504. /**
  2505. * Returns true if the current Vector3 coordinates equals the given floats
  2506. * @param x defines the x coordinate of the operand
  2507. * @param y defines the y coordinate of the operand
  2508. * @param z defines the z coordinate of the operand
  2509. * @returns true if both vectors are equals
  2510. */
  2511. equalsToFloats(x: number, y: number, z: number): boolean;
  2512. /**
  2513. * Multiplies the current Vector3 coordinates by the given ones
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the new Vector3
  2522. */
  2523. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2533. * @param x defines the x coordinate of the operand
  2534. * @param y defines the y coordinate of the operand
  2535. * @param z defines the z coordinate of the operand
  2536. * @returns the new Vector3
  2537. */
  2538. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2539. /**
  2540. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2541. * @param otherVector defines the second operand
  2542. * @returns the new Vector3
  2543. */
  2544. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Divides the current Vector3 coordinates by the given ones.
  2554. * @param otherVector defines the second operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. divideInPlace(otherVector: Vector3): Vector3;
  2558. /**
  2559. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2560. * @param other defines the second operand
  2561. * @returns the current updated Vector3
  2562. */
  2563. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2566. * @param other defines the second operand
  2567. * @returns the current updated Vector3
  2568. */
  2569. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2570. /**
  2571. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2572. * @param x defines the x coordinate of the operand
  2573. * @param y defines the y coordinate of the operand
  2574. * @param z defines the z coordinate of the operand
  2575. * @returns the current updated Vector3
  2576. */
  2577. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2578. /**
  2579. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2580. * @param x defines the x coordinate of the operand
  2581. * @param y defines the y coordinate of the operand
  2582. * @param z defines the z coordinate of the operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2586. /**
  2587. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2588. * Check if is non uniform within a certain amount of decimal places to account for this
  2589. * @param epsilon the amount the values can differ
  2590. * @returns if the the vector is non uniform to a certain number of decimal places
  2591. */
  2592. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2593. /**
  2594. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2595. */
  2596. get isNonUniform(): boolean;
  2597. /**
  2598. * Gets a new Vector3 from current Vector3 floored values
  2599. * @returns a new Vector3
  2600. */
  2601. floor(): Vector3;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. fract(): Vector3;
  2607. /**
  2608. * Gets the length of the Vector3
  2609. * @returns the length of the Vector3
  2610. */
  2611. length(): number;
  2612. /**
  2613. * Gets the squared length of the Vector3
  2614. * @returns squared length of the Vector3
  2615. */
  2616. lengthSquared(): number;
  2617. /**
  2618. * Normalize the current Vector3.
  2619. * Please note that this is an in place operation.
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalize(): Vector3;
  2623. /**
  2624. * Reorders the x y z properties of the vector in place
  2625. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2626. * @returns the current updated vector
  2627. */
  2628. reorderInPlace(order: string): this;
  2629. /**
  2630. * Rotates the vector around 0,0,0 by a quaternion
  2631. * @param quaternion the rotation quaternion
  2632. * @param result vector to store the result
  2633. * @returns the resulting vector
  2634. */
  2635. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2636. /**
  2637. * Rotates a vector around a given point
  2638. * @param quaternion the rotation quaternion
  2639. * @param point the point to rotate around
  2640. * @param result vector to store the result
  2641. * @returns the resulting vector
  2642. */
  2643. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2644. /**
  2645. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2646. * The cross product is then orthogonal to both current and "other"
  2647. * @param other defines the right operand
  2648. * @returns the cross product
  2649. */
  2650. cross(other: Vector3): Vector3;
  2651. /**
  2652. * Normalize the current Vector3 with the given input length.
  2653. * Please note that this is an in place operation.
  2654. * @param len the length of the vector
  2655. * @returns the current updated Vector3
  2656. */
  2657. normalizeFromLength(len: number): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 to a new vector
  2660. * @returns the new Vector3
  2661. */
  2662. normalizeToNew(): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to the reference
  2665. * @param reference define the Vector3 to update
  2666. * @returns the updated Vector3
  2667. */
  2668. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2669. /**
  2670. * Creates a new Vector3 copied from the current Vector3
  2671. * @returns the new Vector3
  2672. */
  2673. clone(): Vector3;
  2674. /**
  2675. * Copies the given vector coordinates to the current Vector3 ones
  2676. * @param source defines the source Vector3
  2677. * @returns the current updated Vector3
  2678. */
  2679. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2680. /**
  2681. * Copies the given floats to the current Vector3 coordinates
  2682. * @param x defines the x coordinate of the operand
  2683. * @param y defines the y coordinate of the operand
  2684. * @param z defines the z coordinate of the operand
  2685. * @returns the current updated Vector3
  2686. */
  2687. copyFromFloats(x: number, y: number, z: number): Vector3;
  2688. /**
  2689. * Copies the given floats to the current Vector3 coordinates
  2690. * @param x defines the x coordinate of the operand
  2691. * @param y defines the y coordinate of the operand
  2692. * @param z defines the z coordinate of the operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. set(x: number, y: number, z: number): Vector3;
  2696. /**
  2697. * Copies the given float to the current Vector3 coordinates
  2698. * @param v defines the x, y and z coordinates of the operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. setAll(v: number): Vector3;
  2702. /**
  2703. * Get the clip factor between two vectors
  2704. * @param vector0 defines the first operand
  2705. * @param vector1 defines the second operand
  2706. * @param axis defines the axis to use
  2707. * @param size defines the size along the axis
  2708. * @returns the clip factor
  2709. */
  2710. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2711. /**
  2712. * Get angle between two vectors
  2713. * @param vector0 angle between vector0 and vector1
  2714. * @param vector1 angle between vector0 and vector1
  2715. * @param normal direction of the normal
  2716. * @return the angle between vector0 and vector1
  2717. */
  2718. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2719. /**
  2720. * Returns a new Vector3 set from the index "offset" of the given array
  2721. * @param array defines the source array
  2722. * @param offset defines the offset in the source array
  2723. * @returns the new Vector3
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2726. /**
  2727. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2728. * @param array defines the source array
  2729. * @param offset defines the offset in the source array
  2730. * @returns the new Vector3
  2731. * @deprecated Please use FromArray instead.
  2732. */
  2733. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2734. /**
  2735. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2736. * @param array defines the source array
  2737. * @param offset defines the offset in the source array
  2738. * @param result defines the Vector3 where to store the result
  2739. */
  2740. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2741. /**
  2742. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2743. * @param array defines the source array
  2744. * @param offset defines the offset in the source array
  2745. * @param result defines the Vector3 where to store the result
  2746. * @deprecated Please use FromArrayToRef instead.
  2747. */
  2748. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2749. /**
  2750. * Sets the given vector "result" with the given floats.
  2751. * @param x defines the x coordinate of the source
  2752. * @param y defines the y coordinate of the source
  2753. * @param z defines the z coordinate of the source
  2754. * @param result defines the Vector3 where to store the result
  2755. */
  2756. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2759. * @returns a new empty Vector3
  2760. */
  2761. static Zero(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2764. * @returns a new unit Vector3
  2765. */
  2766. static One(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2769. * @returns a new up Vector3
  2770. */
  2771. static Up(): Vector3;
  2772. /**
  2773. * Gets a up Vector3 that must not be updated
  2774. */
  2775. static get UpReadOnly(): DeepImmutable<Vector3>;
  2776. /**
  2777. * Gets a zero Vector3 that must not be updated
  2778. */
  2779. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2780. /**
  2781. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2782. * @returns a new down Vector3
  2783. */
  2784. static Down(): Vector3;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2787. * @returns a new forward Vector3
  2788. */
  2789. static Forward(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Backward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2797. * @returns a new right Vector3
  2798. */
  2799. static Right(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2802. * @returns a new left Vector3
  2803. */
  2804. static Left(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2807. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the transformed Vector3
  2811. */
  2812. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2815. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2823. * This method computes tranformed coordinates only, not transformed direction vectors
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2833. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2834. * @param vector defines the Vector3 to transform
  2835. * @param transformation defines the transformation matrix
  2836. * @returns the new Vector3
  2837. */
  2838. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2839. /**
  2840. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2841. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2842. * @param vector defines the Vector3 to transform
  2843. * @param transformation defines the transformation matrix
  2844. * @param result defines the Vector3 where to store the result
  2845. */
  2846. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2847. /**
  2848. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2849. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2850. * @param x define the x coordinate of the source vector
  2851. * @param y define the y coordinate of the source vector
  2852. * @param z define the z coordinate of the source vector
  2853. * @param transformation defines the transformation matrix
  2854. * @param result defines the Vector3 where to store the result
  2855. */
  2856. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2857. /**
  2858. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2859. * @param value1 defines the first control point
  2860. * @param value2 defines the second control point
  2861. * @param value3 defines the third control point
  2862. * @param value4 defines the fourth control point
  2863. * @param amount defines the amount on the spline to use
  2864. * @returns the new Vector3
  2865. */
  2866. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2867. /**
  2868. * 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"
  2869. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2870. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2871. * @param value defines the current value
  2872. * @param min defines the lower range value
  2873. * @param max defines the upper range value
  2874. * @returns the new Vector3
  2875. */
  2876. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * 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"
  2879. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2880. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2881. * @param value defines the current value
  2882. * @param min defines the lower range value
  2883. * @param max defines the upper range value
  2884. * @param result defines the Vector3 where to store the result
  2885. */
  2886. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2887. /**
  2888. * Checks if a given vector is inside a specific range
  2889. * @param v defines the vector to test
  2890. * @param min defines the minimum range
  2891. * @param max defines the maximum range
  2892. */
  2893. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2894. /**
  2895. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2896. * @param value1 defines the first control point
  2897. * @param tangent1 defines the first tangent vector
  2898. * @param value2 defines the second control point
  2899. * @param tangent2 defines the second tangent vector
  2900. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2901. * @returns the new Vector3
  2902. */
  2903. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2904. /**
  2905. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2906. * @param start defines the start value
  2907. * @param end defines the end value
  2908. * @param amount max defines amount between both (between 0 and 1)
  2909. * @returns the new Vector3
  2910. */
  2911. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2912. /**
  2913. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2914. * @param start defines the start value
  2915. * @param end defines the end value
  2916. * @param amount max defines amount between both (between 0 and 1)
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2920. /**
  2921. * Returns the dot product (float) between the vectors "left" and "right"
  2922. * @param left defines the left operand
  2923. * @param right defines the right operand
  2924. * @returns the dot product
  2925. */
  2926. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2929. * The cross product is then orthogonal to both "left" and "right"
  2930. * @param left defines the left operand
  2931. * @param right defines the right operand
  2932. * @returns the cross product
  2933. */
  2934. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2935. /**
  2936. * Sets the given vector "result" with the cross product of "left" and "right"
  2937. * The cross product is then orthogonal to both "left" and "right"
  2938. * @param left defines the left operand
  2939. * @param right defines the right operand
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2943. /**
  2944. * Returns a new Vector3 as the normalization of the given vector
  2945. * @param vector defines the Vector3 to normalize
  2946. * @returns the new Vector3
  2947. */
  2948. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" with the normalization of the given first vector
  2951. * @param vector defines the Vector3 to normalize
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2955. /**
  2956. * Project a Vector3 onto screen space
  2957. * @param vector defines the Vector3 to project
  2958. * @param world defines the world matrix to use
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @param viewport defines the screen viewport to use
  2961. * @returns the new Vector3
  2962. */
  2963. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2964. /** @hidden */
  2965. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Unproject from screen space to object space
  2968. * @param source defines the screen space Vector3 to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param transform defines the transform (view x projection) matrix to use
  2973. * @returns the new Vector3
  2974. */
  2975. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2976. /**
  2977. * Unproject from screen space to object space
  2978. * @param source defines the screen space Vector3 to use
  2979. * @param viewportWidth defines the current width of the viewport
  2980. * @param viewportHeight defines the current height of the viewport
  2981. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2982. * @param view defines the view matrix to use
  2983. * @param projection defines the projection matrix to use
  2984. * @returns the new Vector3
  2985. */
  2986. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Unproject from screen space to object space
  2989. * @param source defines the screen space Vector3 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 UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Unproject from screen space to object space
  3000. * @param sourceX defines the screen space x coordinate to use
  3001. * @param sourceY defines the screen space y coordinate to use
  3002. * @param sourceZ defines the screen space z coordinate to use
  3003. * @param viewportWidth defines the current width of the viewport
  3004. * @param viewportHeight defines the current height of the viewport
  3005. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3006. * @param view defines the view matrix to use
  3007. * @param projection defines the projection matrix to use
  3008. * @param result defines the Vector3 where to store the result
  3009. */
  3010. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3011. /**
  3012. * Gets the minimal coordinate values between two Vector3
  3013. * @param left defines the first operand
  3014. * @param right defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Gets the maximal coordinate values between two Vector3
  3020. * @param left defines the first operand
  3021. * @param right defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Returns the distance between the vectors "value1" and "value2"
  3027. * @param value1 defines the first operand
  3028. * @param value2 defines the second operand
  3029. * @returns the distance
  3030. */
  3031. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3032. /**
  3033. * Returns the squared distance between the vectors "value1" and "value2"
  3034. * @param value1 defines the first operand
  3035. * @param value2 defines the second operand
  3036. * @returns the squared distance
  3037. */
  3038. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3039. /**
  3040. * Returns a new Vector3 located at the center between "value1" and "value2"
  3041. * @param value1 defines the first operand
  3042. * @param value2 defines the second operand
  3043. * @returns the new Vector3
  3044. */
  3045. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3046. /**
  3047. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3048. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3049. * to something in order to rotate it from its local system to the given target system
  3050. * Note: axis1, axis2 and axis3 are normalized during this operation
  3051. * @param axis1 defines the first axis
  3052. * @param axis2 defines the second axis
  3053. * @param axis3 defines the third axis
  3054. * @returns a new Vector3
  3055. */
  3056. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3057. /**
  3058. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3059. * @param axis1 defines the first axis
  3060. * @param axis2 defines the second axis
  3061. * @param axis3 defines the third axis
  3062. * @param ref defines the Vector3 where to store the result
  3063. */
  3064. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3065. }
  3066. /**
  3067. * Vector4 class created for EulerAngle class conversion to Quaternion
  3068. */
  3069. export class Vector4 {
  3070. /** x value of the vector */
  3071. x: number;
  3072. /** y value of the vector */
  3073. y: number;
  3074. /** z value of the vector */
  3075. z: number;
  3076. /** w value of the vector */
  3077. w: number;
  3078. /**
  3079. * Creates a Vector4 object from the given floats.
  3080. * @param x x value of the vector
  3081. * @param y y value of the vector
  3082. * @param z z value of the vector
  3083. * @param w w value of the vector
  3084. */
  3085. constructor(
  3086. /** x value of the vector */
  3087. x: number,
  3088. /** y value of the vector */
  3089. y: number,
  3090. /** z value of the vector */
  3091. z: number,
  3092. /** w value of the vector */
  3093. w: number);
  3094. /**
  3095. * Returns the string with the Vector4 coordinates.
  3096. * @returns a string containing all the vector values
  3097. */
  3098. toString(): string;
  3099. /**
  3100. * Returns the string "Vector4".
  3101. * @returns "Vector4"
  3102. */
  3103. getClassName(): string;
  3104. /**
  3105. * Returns the Vector4 hash code.
  3106. * @returns a unique hash code
  3107. */
  3108. getHashCode(): number;
  3109. /**
  3110. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3111. * @returns the resulting array
  3112. */
  3113. asArray(): number[];
  3114. /**
  3115. * Populates the given array from the given index with the Vector4 coordinates.
  3116. * @param array array to populate
  3117. * @param index index of the array to start at (default: 0)
  3118. * @returns the Vector4.
  3119. */
  3120. toArray(array: FloatArray, index?: number): Vector4;
  3121. /**
  3122. * Adds the given vector to the current Vector4.
  3123. * @param otherVector the vector to add
  3124. * @returns the updated Vector4.
  3125. */
  3126. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3127. /**
  3128. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3129. * @param otherVector the vector to add
  3130. * @returns the resulting vector
  3131. */
  3132. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3135. * @param otherVector the vector to add
  3136. * @param result the vector to store the result
  3137. * @returns the current Vector4.
  3138. */
  3139. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3140. /**
  3141. * Subtract in place the given vector from the current Vector4.
  3142. * @param otherVector the vector to subtract
  3143. * @returns the updated Vector4.
  3144. */
  3145. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3146. /**
  3147. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3148. * @param otherVector the vector to add
  3149. * @returns the new vector with the result
  3150. */
  3151. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3152. /**
  3153. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3154. * @param otherVector the vector to subtract
  3155. * @param result the vector to store the result
  3156. * @returns the current Vector4.
  3157. */
  3158. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3159. /**
  3160. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3161. */
  3162. /**
  3163. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3164. * @param x value to subtract
  3165. * @param y value to subtract
  3166. * @param z value to subtract
  3167. * @param w value to subtract
  3168. * @returns new vector containing the result
  3169. */
  3170. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3171. /**
  3172. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3173. * @param x value to subtract
  3174. * @param y value to subtract
  3175. * @param z value to subtract
  3176. * @param w value to subtract
  3177. * @param result the vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3181. /**
  3182. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3183. * @returns a new vector with the negated values
  3184. */
  3185. negate(): Vector4;
  3186. /**
  3187. * Multiplies the current Vector4 coordinates by scale (float).
  3188. * @param scale the number to scale with
  3189. * @returns the updated Vector4.
  3190. */
  3191. scaleInPlace(scale: number): Vector4;
  3192. /**
  3193. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3194. * @param scale the number to scale with
  3195. * @returns a new vector with the result
  3196. */
  3197. scale(scale: number): Vector4;
  3198. /**
  3199. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3200. * @param scale the number to scale with
  3201. * @param result a vector to store the result in
  3202. * @returns the current Vector4.
  3203. */
  3204. scaleToRef(scale: number, result: Vector4): Vector4;
  3205. /**
  3206. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3207. * @param scale defines the scale factor
  3208. * @param result defines the Vector4 object where to store the result
  3209. * @returns the unmodified current Vector4
  3210. */
  3211. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3212. /**
  3213. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3214. * @param otherVector the vector to compare against
  3215. * @returns true if they are equal
  3216. */
  3217. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3218. /**
  3219. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3220. * @param otherVector vector to compare against
  3221. * @param epsilon (Default: very small number)
  3222. * @returns true if they are equal
  3223. */
  3224. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3225. /**
  3226. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3227. * @param x x value to compare against
  3228. * @param y y value to compare against
  3229. * @param z z value to compare against
  3230. * @param w w value to compare against
  3231. * @returns true if equal
  3232. */
  3233. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3234. /**
  3235. * Multiplies in place the current Vector4 by the given one.
  3236. * @param otherVector vector to multiple with
  3237. * @returns the updated Vector4.
  3238. */
  3239. multiplyInPlace(otherVector: Vector4): Vector4;
  3240. /**
  3241. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3242. * @param otherVector vector to multiple with
  3243. * @returns resulting new vector
  3244. */
  3245. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3248. * @param otherVector vector to multiple with
  3249. * @param result vector to store the result
  3250. * @returns the current Vector4.
  3251. */
  3252. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3253. /**
  3254. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3255. * @param x x value multiply with
  3256. * @param y y value multiply with
  3257. * @param z z value multiply with
  3258. * @param w w value multiply with
  3259. * @returns resulting new vector
  3260. */
  3261. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3264. * @param otherVector vector to devide with
  3265. * @returns resulting new vector
  3266. */
  3267. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3270. * @param otherVector vector to devide with
  3271. * @param result vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Divides the current Vector3 coordinates by the given ones.
  3277. * @param otherVector vector to devide with
  3278. * @returns the updated Vector3.
  3279. */
  3280. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3283. * @param other defines the second operand
  3284. * @returns the current updated Vector4
  3285. */
  3286. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3289. * @param other defines the second operand
  3290. * @returns the current updated Vector4
  3291. */
  3292. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3293. /**
  3294. * Gets a new Vector4 from current Vector4 floored values
  3295. * @returns a new Vector4
  3296. */
  3297. floor(): Vector4;
  3298. /**
  3299. * Gets a new Vector4 from current Vector3 floored values
  3300. * @returns a new Vector4
  3301. */
  3302. fract(): Vector4;
  3303. /**
  3304. * Returns the Vector4 length (float).
  3305. * @returns the length
  3306. */
  3307. length(): number;
  3308. /**
  3309. * Returns the Vector4 squared length (float).
  3310. * @returns the length squared
  3311. */
  3312. lengthSquared(): number;
  3313. /**
  3314. * Normalizes in place the Vector4.
  3315. * @returns the updated Vector4.
  3316. */
  3317. normalize(): Vector4;
  3318. /**
  3319. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3320. * @returns this converted to a new vector3
  3321. */
  3322. toVector3(): Vector3;
  3323. /**
  3324. * Returns a new Vector4 copied from the current one.
  3325. * @returns the new cloned vector
  3326. */
  3327. clone(): Vector4;
  3328. /**
  3329. * Updates the current Vector4 with the given one coordinates.
  3330. * @param source the source vector to copy from
  3331. * @returns the updated Vector4.
  3332. */
  3333. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Updates the current Vector4 coordinates with the given floats.
  3336. * @param x float to copy from
  3337. * @param y float to copy from
  3338. * @param z float to copy from
  3339. * @param w float to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to set from
  3346. * @param y float to set from
  3347. * @param z float to set from
  3348. * @param w float to set from
  3349. * @returns the updated Vector4.
  3350. */
  3351. set(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Copies the given float to the current Vector3 coordinates
  3354. * @param v defines the x, y, z and w coordinates of the operand
  3355. * @returns the current updated Vector3
  3356. */
  3357. setAll(v: number): Vector4;
  3358. /**
  3359. * Returns a new Vector4 set from the starting index of the given array.
  3360. * @param array the array to pull values from
  3361. * @param offset the offset into the array to start at
  3362. * @returns the new vector
  3363. */
  3364. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3365. /**
  3366. * Updates the given vector "result" from the starting index of the given array.
  3367. * @param array the array to pull values from
  3368. * @param offset the offset into the array to start at
  3369. * @param result the vector to store the result in
  3370. */
  3371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3372. /**
  3373. * Updates the given vector "result" from the starting index of the given Float32Array.
  3374. * @param array the array to pull values from
  3375. * @param offset the offset into the array to start at
  3376. * @param result the vector to store the result in
  3377. */
  3378. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3379. /**
  3380. * Updates the given vector "result" coordinates from the given floats.
  3381. * @param x float to set from
  3382. * @param y float to set from
  3383. * @param z float to set from
  3384. * @param w float to set from
  3385. * @param result the vector to the floats in
  3386. */
  3387. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3388. /**
  3389. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3390. * @returns the new vector
  3391. */
  3392. static Zero(): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3395. * @returns the new vector
  3396. */
  3397. static One(): Vector4;
  3398. /**
  3399. * Returns a new normalized Vector4 from the given one.
  3400. * @param vector the vector to normalize
  3401. * @returns the vector
  3402. */
  3403. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the given vector "result" from the normalization of the given one.
  3406. * @param vector the vector to normalize
  3407. * @param result the vector to store the result in
  3408. */
  3409. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3410. /**
  3411. * Returns a vector with the minimum values from the left and right vectors
  3412. * @param left left vector to minimize
  3413. * @param right right vector to minimize
  3414. * @returns a new vector with the minimum of the left and right vector values
  3415. */
  3416. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a vector with the maximum values from the left and right vectors
  3419. * @param left left vector to maximize
  3420. * @param right right vector to maximize
  3421. * @returns a new vector with the maximum of the left and right vector values
  3422. */
  3423. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Returns the distance (float) between the vectors "value1" and "value2".
  3426. * @param value1 value to calulate the distance between
  3427. * @param value2 value to calulate the distance between
  3428. * @return the distance between the two vectors
  3429. */
  3430. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3431. /**
  3432. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3433. * @param value1 value to calulate the distance between
  3434. * @param value2 value to calulate the distance between
  3435. * @return the distance between the two vectors squared
  3436. */
  3437. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3438. /**
  3439. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3440. * @param value1 value to calulate the center between
  3441. * @param value2 value to calulate the center between
  3442. * @return the center between the two vectors
  3443. */
  3444. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3447. * This methods computes transformed normalized direction vectors only.
  3448. * @param vector the vector to transform
  3449. * @param transformation the transformation matrix to apply
  3450. * @returns the new vector
  3451. */
  3452. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3453. /**
  3454. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3455. * This methods computes transformed normalized direction vectors only.
  3456. * @param vector the vector to transform
  3457. * @param transformation the transformation matrix to apply
  3458. * @param result the vector to store the result in
  3459. */
  3460. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3461. /**
  3462. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param x value to transform
  3465. * @param y value to transform
  3466. * @param z value to transform
  3467. * @param w value to transform
  3468. * @param transformation the transformation matrix to apply
  3469. * @param result the vector to store the results in
  3470. */
  3471. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3472. /**
  3473. * Creates a new Vector4 from a Vector3
  3474. * @param source defines the source data
  3475. * @param w defines the 4th component (default is 0)
  3476. * @returns a new Vector4
  3477. */
  3478. static FromVector3(source: Vector3, w?: number): Vector4;
  3479. }
  3480. /**
  3481. * Class used to store quaternion data
  3482. * @see https://en.wikipedia.org/wiki/Quaternion
  3483. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3484. */
  3485. export class Quaternion {
  3486. /** defines the first component (0 by default) */
  3487. x: number;
  3488. /** defines the second component (0 by default) */
  3489. y: number;
  3490. /** defines the third component (0 by default) */
  3491. z: number;
  3492. /** defines the fourth component (1.0 by default) */
  3493. w: number;
  3494. /**
  3495. * Creates a new Quaternion from the given floats
  3496. * @param x defines the first component (0 by default)
  3497. * @param y defines the second component (0 by default)
  3498. * @param z defines the third component (0 by default)
  3499. * @param w defines the fourth component (1.0 by default)
  3500. */
  3501. constructor(
  3502. /** defines the first component (0 by default) */
  3503. x?: number,
  3504. /** defines the second component (0 by default) */
  3505. y?: number,
  3506. /** defines the third component (0 by default) */
  3507. z?: number,
  3508. /** defines the fourth component (1.0 by default) */
  3509. w?: number);
  3510. /**
  3511. * Gets a string representation for the current quaternion
  3512. * @returns a string with the Quaternion coordinates
  3513. */
  3514. toString(): string;
  3515. /**
  3516. * Gets the class name of the quaternion
  3517. * @returns the string "Quaternion"
  3518. */
  3519. getClassName(): string;
  3520. /**
  3521. * Gets a hash code for this quaternion
  3522. * @returns the quaternion hash code
  3523. */
  3524. getHashCode(): number;
  3525. /**
  3526. * Copy the quaternion to an array
  3527. * @returns a new array populated with 4 elements from the quaternion coordinates
  3528. */
  3529. asArray(): number[];
  3530. /**
  3531. * Check if two quaternions are equals
  3532. * @param otherQuaternion defines the second operand
  3533. * @return true if the current quaternion and the given one coordinates are strictly equals
  3534. */
  3535. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3536. /**
  3537. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3538. * @param otherQuaternion defines the other quaternion
  3539. * @param epsilon defines the minimal distance to consider equality
  3540. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3541. */
  3542. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3543. /**
  3544. * Clone the current quaternion
  3545. * @returns a new quaternion copied from the current one
  3546. */
  3547. clone(): Quaternion;
  3548. /**
  3549. * Copy a quaternion to the current one
  3550. * @param other defines the other quaternion
  3551. * @returns the updated current quaternion
  3552. */
  3553. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Updates the current quaternion with the given float coordinates
  3556. * @param x defines the x coordinate
  3557. * @param y defines the y coordinate
  3558. * @param z defines the z coordinate
  3559. * @param w defines the w coordinate
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3563. /**
  3564. * Updates the current quaternion from the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. set(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Adds two quaternions
  3574. * @param other defines the second operand
  3575. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3576. */
  3577. add(other: DeepImmutable<Quaternion>): Quaternion;
  3578. /**
  3579. * Add a quaternion to the current one
  3580. * @param other defines the quaternion to add
  3581. * @returns the current quaternion
  3582. */
  3583. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3584. /**
  3585. * Subtract two quaternions
  3586. * @param other defines the second operand
  3587. * @returns a new quaternion as the subtraction result of the given one from the current one
  3588. */
  3589. subtract(other: Quaternion): Quaternion;
  3590. /**
  3591. * Multiplies the current quaternion by a scale factor
  3592. * @param value defines the scale factor
  3593. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3594. */
  3595. scale(value: number): Quaternion;
  3596. /**
  3597. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3598. * @param scale defines the scale factor
  3599. * @param result defines the Quaternion object where to store the result
  3600. * @returns the unmodified current quaternion
  3601. */
  3602. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies in place the current quaternion by a scale factor
  3605. * @param value defines the scale factor
  3606. * @returns the current modified quaternion
  3607. */
  3608. scaleInPlace(value: number): Quaternion;
  3609. /**
  3610. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3611. * @param scale defines the scale factor
  3612. * @param result defines the Quaternion object where to store the result
  3613. * @returns the unmodified current quaternion
  3614. */
  3615. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3616. /**
  3617. * Multiplies two quaternions
  3618. * @param q1 defines the second operand
  3619. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3620. */
  3621. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3622. /**
  3623. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3624. * @param q1 defines the second operand
  3625. * @param result defines the target quaternion
  3626. * @returns the current quaternion
  3627. */
  3628. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3629. /**
  3630. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3631. * @param q1 defines the second operand
  3632. * @returns the currentupdated quaternion
  3633. */
  3634. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3635. /**
  3636. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3637. * @param ref defines the target quaternion
  3638. * @returns the current quaternion
  3639. */
  3640. conjugateToRef(ref: Quaternion): Quaternion;
  3641. /**
  3642. * Conjugates in place (1-q) the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. conjugateInPlace(): Quaternion;
  3646. /**
  3647. * Conjugates in place (1-q) the current quaternion
  3648. * @returns a new quaternion
  3649. */
  3650. conjugate(): Quaternion;
  3651. /**
  3652. * Gets length of current quaternion
  3653. * @returns the quaternion length (float)
  3654. */
  3655. length(): number;
  3656. /**
  3657. * Normalize in place the current quaternion
  3658. * @returns the current updated quaternion
  3659. */
  3660. normalize(): Quaternion;
  3661. /**
  3662. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3663. * @param order is a reserved parameter and is ignore for now
  3664. * @returns a new Vector3 containing the Euler angles
  3665. */
  3666. toEulerAngles(order?: string): Vector3;
  3667. /**
  3668. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3669. * @param result defines the vector which will be filled with the Euler angles
  3670. * @param order is a reserved parameter and is ignore for now
  3671. * @returns the current unchanged quaternion
  3672. */
  3673. toEulerAnglesToRef(result: Vector3): Quaternion;
  3674. /**
  3675. * Updates the given rotation matrix with the current quaternion values
  3676. * @param result defines the target matrix
  3677. * @returns the current unchanged quaternion
  3678. */
  3679. toRotationMatrix(result: Matrix): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given rotation matrix values
  3682. * @param matrix defines the source matrix
  3683. * @returns the current updated quaternion
  3684. */
  3685. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3686. /**
  3687. * Creates a new quaternion from a rotation matrix
  3688. * @param matrix defines the source matrix
  3689. * @returns a new quaternion created from the given rotation matrix values
  3690. */
  3691. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3692. /**
  3693. * Updates the given quaternion with the given rotation matrix values
  3694. * @param matrix defines the source matrix
  3695. * @param result defines the target quaternion
  3696. */
  3697. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3698. /**
  3699. * Returns the dot product (float) between the quaternions "left" and "right"
  3700. * @param left defines the left operand
  3701. * @param right defines the right operand
  3702. * @returns the dot product
  3703. */
  3704. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3705. /**
  3706. * Checks if the two quaternions are close to each other
  3707. * @param quat0 defines the first quaternion to check
  3708. * @param quat1 defines the second quaternion to check
  3709. * @returns true if the two quaternions are close to each other
  3710. */
  3711. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3712. /**
  3713. * Creates an empty quaternion
  3714. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3715. */
  3716. static Zero(): Quaternion;
  3717. /**
  3718. * Inverse a given quaternion
  3719. * @param q defines the source quaternion
  3720. * @returns a new quaternion as the inverted current quaternion
  3721. */
  3722. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Inverse a given quaternion
  3725. * @param q defines the source quaternion
  3726. * @param result the quaternion the result will be stored in
  3727. * @returns the result quaternion
  3728. */
  3729. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3730. /**
  3731. * Creates an identity quaternion
  3732. * @returns the identity quaternion
  3733. */
  3734. static Identity(): Quaternion;
  3735. /**
  3736. * Gets a boolean indicating if the given quaternion is identity
  3737. * @param quaternion defines the quaternion to check
  3738. * @returns true if the quaternion is identity
  3739. */
  3740. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Creates a quaternion from a rotation around an axis
  3743. * @param axis defines the axis to use
  3744. * @param angle defines the angle to use
  3745. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3746. */
  3747. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3748. /**
  3749. * Creates a rotation around an axis and stores it into the given quaternion
  3750. * @param axis defines the axis to use
  3751. * @param angle defines the angle to use
  3752. * @param result defines the target quaternion
  3753. * @returns the target quaternion
  3754. */
  3755. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Creates a new quaternion from data stored into an array
  3758. * @param array defines the data source
  3759. * @param offset defines the offset in the source array where the data starts
  3760. * @returns a new quaternion
  3761. */
  3762. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @returns the new Quaternion
  3769. */
  3770. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3771. /**
  3772. * Updates a quaternion from Euler rotation angles
  3773. * @param x Pitch
  3774. * @param y Yaw
  3775. * @param z Roll
  3776. * @param result the quaternion to store the result
  3777. * @returns the updated quaternion
  3778. */
  3779. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3780. /**
  3781. * Create a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @returns the new Quaternion
  3784. */
  3785. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3786. /**
  3787. * Updates a quaternion from Euler rotation vector
  3788. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3789. * @param result the quaternion to store the result
  3790. * @returns the updated quaternion
  3791. */
  3792. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3793. /**
  3794. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @returns the new quaternion
  3799. */
  3800. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3801. /**
  3802. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3803. * @param yaw defines the rotation around Y axis
  3804. * @param pitch defines the rotation around X axis
  3805. * @param roll defines the rotation around Z axis
  3806. * @param result defines the target quaternion
  3807. */
  3808. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3817. /**
  3818. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3819. * @param alpha defines the rotation around first axis
  3820. * @param beta defines the rotation around second axis
  3821. * @param gamma defines the rotation around third axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3825. /**
  3826. * 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)
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3833. /**
  3834. * 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
  3835. * @param axis1 defines the first axis
  3836. * @param axis2 defines the second axis
  3837. * @param axis3 defines the third axis
  3838. * @param ref defines the target quaternion
  3839. */
  3840. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3841. /**
  3842. * Interpolates between two quaternions
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @returns the new interpolated quaternion
  3847. */
  3848. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3849. /**
  3850. * Interpolates between two quaternions and stores it into a target quaternion
  3851. * @param left defines first quaternion
  3852. * @param right defines second quaternion
  3853. * @param amount defines the gradient to use
  3854. * @param result defines the target quaternion
  3855. */
  3856. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3857. /**
  3858. * Interpolate between two quaternions using Hermite interpolation
  3859. * @param value1 defines first quaternion
  3860. * @param tangent1 defines the incoming tangent
  3861. * @param value2 defines second quaternion
  3862. * @param tangent2 defines the outgoing tangent
  3863. * @param amount defines the target quaternion
  3864. * @returns the new interpolated quaternion
  3865. */
  3866. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3867. }
  3868. /**
  3869. * Class used to store matrix data (4x4)
  3870. */
  3871. export class Matrix {
  3872. private static _updateFlagSeed;
  3873. private static _identityReadOnly;
  3874. private _isIdentity;
  3875. private _isIdentityDirty;
  3876. private _isIdentity3x2;
  3877. private _isIdentity3x2Dirty;
  3878. /**
  3879. * Gets the update flag of the matrix which is an unique number for the matrix.
  3880. * It will be incremented every time the matrix data change.
  3881. * You can use it to speed the comparison between two versions of the same matrix.
  3882. */
  3883. updateFlag: number;
  3884. private readonly _m;
  3885. /**
  3886. * Gets the internal data of the matrix
  3887. */
  3888. get m(): DeepImmutable<Float32Array>;
  3889. /** @hidden */
  3890. _markAsUpdated(): void;
  3891. /** @hidden */
  3892. private _updateIdentityStatus;
  3893. /**
  3894. * Creates an empty matrix (filled with zeros)
  3895. */
  3896. constructor();
  3897. /**
  3898. * Check if the current matrix is identity
  3899. * @returns true is the matrix is the identity matrix
  3900. */
  3901. isIdentity(): boolean;
  3902. /**
  3903. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3904. * @returns true is the matrix is the identity matrix
  3905. */
  3906. isIdentityAs3x2(): boolean;
  3907. /**
  3908. * Gets the determinant of the matrix
  3909. * @returns the matrix determinant
  3910. */
  3911. determinant(): number;
  3912. /**
  3913. * Returns the matrix as a Float32Array
  3914. * @returns the matrix underlying array
  3915. */
  3916. toArray(): DeepImmutable<Float32Array>;
  3917. /**
  3918. * Returns the matrix as a Float32Array
  3919. * @returns the matrix underlying array.
  3920. */
  3921. asArray(): DeepImmutable<Float32Array>;
  3922. /**
  3923. * Inverts the current matrix in place
  3924. * @returns the current inverted matrix
  3925. */
  3926. invert(): Matrix;
  3927. /**
  3928. * Sets all the matrix elements to zero
  3929. * @returns the current matrix
  3930. */
  3931. reset(): Matrix;
  3932. /**
  3933. * Adds the current matrix with a second one
  3934. * @param other defines the matrix to add
  3935. * @returns a new matrix as the addition of the current matrix and the given one
  3936. */
  3937. add(other: DeepImmutable<Matrix>): Matrix;
  3938. /**
  3939. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3940. * @param other defines the matrix to add
  3941. * @param result defines the target matrix
  3942. * @returns the current matrix
  3943. */
  3944. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3945. /**
  3946. * Adds in place the given matrix to the current matrix
  3947. * @param other defines the second operand
  3948. * @returns the current updated matrix
  3949. */
  3950. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3951. /**
  3952. * Sets the given matrix to the current inverted Matrix
  3953. * @param other defines the target matrix
  3954. * @returns the unmodified current matrix
  3955. */
  3956. invertToRef(other: Matrix): Matrix;
  3957. /**
  3958. * add a value at the specified position in the current Matrix
  3959. * @param index the index of the value within the matrix. between 0 and 15.
  3960. * @param value the value to be added
  3961. * @returns the current updated matrix
  3962. */
  3963. addAtIndex(index: number, value: number): Matrix;
  3964. /**
  3965. * mutiply the specified position in the current Matrix by a value
  3966. * @param index the index of the value within the matrix. between 0 and 15.
  3967. * @param value the value to be added
  3968. * @returns the current updated matrix
  3969. */
  3970. multiplyAtIndex(index: number, value: number): Matrix;
  3971. /**
  3972. * Inserts the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Adds the translation vector (using 3 floats) in the current matrix
  3981. * @param x defines the 1st component of the translation
  3982. * @param y defines the 2nd component of the translation
  3983. * @param z defines the 3rd component of the translation
  3984. * @returns the current updated matrix
  3985. */
  3986. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector in the current matrix
  3989. * @param vector3 defines the translation to insert
  3990. * @returns the current updated matrix
  3991. */
  3992. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3993. /**
  3994. * Gets the translation value of the current matrix
  3995. * @returns a new Vector3 as the extracted translation from the matrix
  3996. */
  3997. getTranslation(): Vector3;
  3998. /**
  3999. * Fill a Vector3 with the extracted translation from the matrix
  4000. * @param result defines the Vector3 where to store the translation
  4001. * @returns the current matrix
  4002. */
  4003. getTranslationToRef(result: Vector3): Matrix;
  4004. /**
  4005. * Remove rotation and scaling part from the matrix
  4006. * @returns the updated matrix
  4007. */
  4008. removeRotationAndScaling(): Matrix;
  4009. /**
  4010. * Multiply two matrices
  4011. * @param other defines the second operand
  4012. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4013. */
  4014. multiply(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Copy the current matrix from the given one
  4017. * @param other defines the source matrix
  4018. * @returns the current updated matrix
  4019. */
  4020. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4021. /**
  4022. * Populates the given array from the starting index with the current matrix values
  4023. * @param array defines the target array
  4024. * @param offset defines the offset in the target array where to start storing values
  4025. * @returns the current matrix
  4026. */
  4027. copyToArray(array: Float32Array, offset?: number): Matrix;
  4028. /**
  4029. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4030. * @param other defines the second operand
  4031. * @param result defines the matrix where to store the multiplication
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4035. /**
  4036. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4037. * @param other defines the second operand
  4038. * @param result defines the array where to store the multiplication
  4039. * @param offset defines the offset in the target array where to start storing values
  4040. * @returns the current matrix
  4041. */
  4042. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4043. /**
  4044. * Check equality between this matrix and a second one
  4045. * @param value defines the second matrix to compare
  4046. * @returns true is the current matrix and the given one values are strictly equal
  4047. */
  4048. equals(value: DeepImmutable<Matrix>): boolean;
  4049. /**
  4050. * Clone the current matrix
  4051. * @returns a new matrix from the current matrix
  4052. */
  4053. clone(): Matrix;
  4054. /**
  4055. * Returns the name of the current matrix class
  4056. * @returns the string "Matrix"
  4057. */
  4058. getClassName(): string;
  4059. /**
  4060. * Gets the hash code of the current matrix
  4061. * @returns the hash code
  4062. */
  4063. getHashCode(): number;
  4064. /**
  4065. * Decomposes the current Matrix into a translation, rotation and scaling components
  4066. * @param scale defines the scale vector3 given as a reference to update
  4067. * @param rotation defines the rotation quaternion given as a reference to update
  4068. * @param translation defines the translation vector3 given as a reference to update
  4069. * @returns true if operation was successful
  4070. */
  4071. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4072. /**
  4073. * Gets specific row of the matrix
  4074. * @param index defines the number of the row to get
  4075. * @returns the index-th row of the current matrix as a new Vector4
  4076. */
  4077. getRow(index: number): Nullable<Vector4>;
  4078. /**
  4079. * Sets the index-th row of the current matrix to the vector4 values
  4080. * @param index defines the number of the row to set
  4081. * @param row defines the target vector4
  4082. * @returns the updated current matrix
  4083. */
  4084. setRow(index: number, row: Vector4): Matrix;
  4085. /**
  4086. * Compute the transpose of the matrix
  4087. * @returns the new transposed matrix
  4088. */
  4089. transpose(): Matrix;
  4090. /**
  4091. * Compute the transpose of the matrix and store it in a given matrix
  4092. * @param result defines the target matrix
  4093. * @returns the current matrix
  4094. */
  4095. transposeToRef(result: Matrix): Matrix;
  4096. /**
  4097. * Sets the index-th row of the current matrix with the given 4 x float values
  4098. * @param index defines the row index
  4099. * @param x defines the x component to set
  4100. * @param y defines the y component to set
  4101. * @param z defines the z component to set
  4102. * @param w defines the w component to set
  4103. * @returns the updated current matrix
  4104. */
  4105. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4106. /**
  4107. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4108. * @param scale defines the scale factor
  4109. * @returns a new matrix
  4110. */
  4111. scale(scale: number): Matrix;
  4112. /**
  4113. * Scale the current matrix values by a factor to a given result matrix
  4114. * @param scale defines the scale factor
  4115. * @param result defines the matrix to store the result
  4116. * @returns the current matrix
  4117. */
  4118. scaleToRef(scale: number, result: Matrix): Matrix;
  4119. /**
  4120. * Scale the current matrix values by a factor and add the result to a given matrix
  4121. * @param scale defines the scale factor
  4122. * @param result defines the Matrix to store the result
  4123. * @returns the current matrix
  4124. */
  4125. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4126. /**
  4127. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4128. * @param ref matrix to store the result
  4129. */
  4130. toNormalMatrix(ref: Matrix): void;
  4131. /**
  4132. * Gets only rotation part of the current matrix
  4133. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4134. */
  4135. getRotationMatrix(): Matrix;
  4136. /**
  4137. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4138. * @param result defines the target matrix to store data to
  4139. * @returns the current matrix
  4140. */
  4141. getRotationMatrixToRef(result: Matrix): Matrix;
  4142. /**
  4143. * Toggles model matrix from being right handed to left handed in place and vice versa
  4144. */
  4145. toggleModelMatrixHandInPlace(): void;
  4146. /**
  4147. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4148. */
  4149. toggleProjectionMatrixHandInPlace(): void;
  4150. /**
  4151. * Creates a matrix from an array
  4152. * @param array defines the source array
  4153. * @param offset defines an offset in the source array
  4154. * @returns a new Matrix set from the starting index of the given array
  4155. */
  4156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4157. /**
  4158. * Copy the content of an array into a given matrix
  4159. * @param array defines the source array
  4160. * @param offset defines an offset in the source array
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4164. /**
  4165. * Stores an array into a matrix after having multiplied each component by a given factor
  4166. * @param array defines the source array
  4167. * @param offset defines the offset in the source array
  4168. * @param scale defines the scaling factor
  4169. * @param result defines the target matrix
  4170. */
  4171. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4172. /**
  4173. * Gets an identity matrix that must not be updated
  4174. */
  4175. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4176. /**
  4177. * Stores a list of values (16) inside a given matrix
  4178. * @param initialM11 defines 1st value of 1st row
  4179. * @param initialM12 defines 2nd value of 1st row
  4180. * @param initialM13 defines 3rd value of 1st row
  4181. * @param initialM14 defines 4th value of 1st row
  4182. * @param initialM21 defines 1st value of 2nd row
  4183. * @param initialM22 defines 2nd value of 2nd row
  4184. * @param initialM23 defines 3rd value of 2nd row
  4185. * @param initialM24 defines 4th value of 2nd row
  4186. * @param initialM31 defines 1st value of 3rd row
  4187. * @param initialM32 defines 2nd value of 3rd row
  4188. * @param initialM33 defines 3rd value of 3rd row
  4189. * @param initialM34 defines 4th value of 3rd row
  4190. * @param initialM41 defines 1st value of 4th row
  4191. * @param initialM42 defines 2nd value of 4th row
  4192. * @param initialM43 defines 3rd value of 4th row
  4193. * @param initialM44 defines 4th value of 4th row
  4194. * @param result defines the target matrix
  4195. */
  4196. 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;
  4197. /**
  4198. * Creates new matrix from a list of values (16)
  4199. * @param initialM11 defines 1st value of 1st row
  4200. * @param initialM12 defines 2nd value of 1st row
  4201. * @param initialM13 defines 3rd value of 1st row
  4202. * @param initialM14 defines 4th value of 1st row
  4203. * @param initialM21 defines 1st value of 2nd row
  4204. * @param initialM22 defines 2nd value of 2nd row
  4205. * @param initialM23 defines 3rd value of 2nd row
  4206. * @param initialM24 defines 4th value of 2nd row
  4207. * @param initialM31 defines 1st value of 3rd row
  4208. * @param initialM32 defines 2nd value of 3rd row
  4209. * @param initialM33 defines 3rd value of 3rd row
  4210. * @param initialM34 defines 4th value of 3rd row
  4211. * @param initialM41 defines 1st value of 4th row
  4212. * @param initialM42 defines 2nd value of 4th row
  4213. * @param initialM43 defines 3rd value of 4th row
  4214. * @param initialM44 defines 4th value of 4th row
  4215. * @returns the new matrix
  4216. */
  4217. 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;
  4218. /**
  4219. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @returns a new matrix
  4224. */
  4225. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4226. /**
  4227. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4228. * @param scale defines the scale vector3
  4229. * @param rotation defines the rotation quaternion
  4230. * @param translation defines the translation vector3
  4231. * @param result defines the target matrix
  4232. */
  4233. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4234. /**
  4235. * Creates a new identity matrix
  4236. * @returns a new identity matrix
  4237. */
  4238. static Identity(): Matrix;
  4239. /**
  4240. * Creates a new identity matrix and stores the result in a given matrix
  4241. * @param result defines the target matrix
  4242. */
  4243. static IdentityToRef(result: Matrix): void;
  4244. /**
  4245. * Creates a new zero matrix
  4246. * @returns a new zero matrix
  4247. */
  4248. static Zero(): Matrix;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the X axis
  4251. * @param angle defines the angle (in radians) to use
  4252. * @return the new matrix
  4253. */
  4254. static RotationX(angle: number): Matrix;
  4255. /**
  4256. * Creates a new matrix as the invert of a given matrix
  4257. * @param source defines the source matrix
  4258. * @returns the new matrix
  4259. */
  4260. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4263. * @param angle defines the angle (in radians) to use
  4264. * @param result defines the target matrix
  4265. */
  4266. static RotationXToRef(angle: number, result: Matrix): void;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis
  4269. * @param angle defines the angle (in radians) to use
  4270. * @return the new matrix
  4271. */
  4272. static RotationY(angle: number): Matrix;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4275. * @param angle defines the angle (in radians) to use
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationYToRef(angle: number, result: Matrix): void;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis
  4281. * @param angle defines the angle (in radians) to use
  4282. * @return the new matrix
  4283. */
  4284. static RotationZ(angle: number): Matrix;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4287. * @param angle defines the angle (in radians) to use
  4288. * @param result defines the target matrix
  4289. */
  4290. static RotationZToRef(angle: number, result: Matrix): void;
  4291. /**
  4292. * Creates a new rotation matrix for "angle" radians around the given axis
  4293. * @param axis defines the axis to use
  4294. * @param angle defines the angle (in radians) to use
  4295. * @return the new matrix
  4296. */
  4297. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4298. /**
  4299. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4300. * @param axis defines the axis to use
  4301. * @param angle defines the angle (in radians) to use
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4305. /**
  4306. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4307. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4308. * @param from defines the vector to align
  4309. * @param to defines the vector to align to
  4310. * @param result defines the target matrix
  4311. */
  4312. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4313. /**
  4314. * Creates a rotation matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @returns the new rotation matrix
  4319. */
  4320. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4321. /**
  4322. * Creates a rotation matrix and stores it in a given matrix
  4323. * @param yaw defines the yaw angle in radians (Y axis)
  4324. * @param pitch defines the pitch angle in radians (X axis)
  4325. * @param roll defines the roll angle in radians (X axis)
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4329. /**
  4330. * Creates a scaling matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @returns the new matrix
  4335. */
  4336. static Scaling(x: number, y: number, z: number): Matrix;
  4337. /**
  4338. * Creates a scaling matrix and stores it in a given matrix
  4339. * @param x defines the scale factor on X axis
  4340. * @param y defines the scale factor on Y axis
  4341. * @param z defines the scale factor on Z axis
  4342. * @param result defines the target matrix
  4343. */
  4344. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4345. /**
  4346. * Creates a translation matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Translation(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a translation matrix and stores it in a given matrix
  4355. * @param x defines the translation on X axis
  4356. * @param y defines the translation on Y axis
  4357. * @param z defines the translationon Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @returns the new matrix
  4367. */
  4368. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4369. /**
  4370. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4371. * @param startValue defines the start value
  4372. * @param endValue defines the end value
  4373. * @param gradient defines the gradient factor
  4374. * @param result defines the Matrix object where to store data
  4375. */
  4376. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4377. /**
  4378. * Builds a new matrix whose values are computed by:
  4379. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4380. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4381. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4382. * @param startValue defines the first matrix
  4383. * @param endValue defines the second matrix
  4384. * @param gradient defines the gradient between the two matrices
  4385. * @returns the new matrix
  4386. */
  4387. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4388. /**
  4389. * Update a matrix to values which are computed by:
  4390. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4391. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4392. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4393. * @param startValue defines the first matrix
  4394. * @param endValue defines the second matrix
  4395. * @param gradient defines the gradient between the two matrices
  4396. * @param result defines the target matrix
  4397. */
  4398. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4399. /**
  4400. * 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"
  4401. * This function works in left handed mode
  4402. * @param eye defines the final position of the entity
  4403. * @param target defines where the entity should look at
  4404. * @param up defines the up vector for the entity
  4405. * @returns the new matrix
  4406. */
  4407. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4408. /**
  4409. * 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".
  4410. * This function works in left handed mode
  4411. * @param eye defines the final position of the entity
  4412. * @param target defines where the entity should look at
  4413. * @param up defines the up vector for the entity
  4414. * @param result defines the target matrix
  4415. */
  4416. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4417. /**
  4418. * 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"
  4419. * This function works in right handed mode
  4420. * @param eye defines the final position of the entity
  4421. * @param target defines where the entity should look at
  4422. * @param up defines the up vector for the entity
  4423. * @returns the new matrix
  4424. */
  4425. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4426. /**
  4427. * 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".
  4428. * This function works in right handed mode
  4429. * @param eye defines the final position of the entity
  4430. * @param target defines where the entity should look at
  4431. * @param up defines the up vector for the entity
  4432. * @param result defines the target matrix
  4433. */
  4434. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4435. /**
  4436. * Create a left-handed orthographic projection matrix
  4437. * @param width defines the viewport width
  4438. * @param height defines the viewport height
  4439. * @param znear defines the near clip plane
  4440. * @param zfar defines the far clip plane
  4441. * @returns a new matrix as a left-handed orthographic projection matrix
  4442. */
  4443. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4444. /**
  4445. * Store a left-handed orthographic projection to a given matrix
  4446. * @param width defines the viewport width
  4447. * @param height defines the viewport height
  4448. * @param znear defines the near clip plane
  4449. * @param zfar defines the far clip plane
  4450. * @param result defines the target matrix
  4451. */
  4452. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4453. /**
  4454. * Create a left-handed orthographic projection matrix
  4455. * @param left defines the viewport left coordinate
  4456. * @param right defines the viewport right coordinate
  4457. * @param bottom defines the viewport bottom coordinate
  4458. * @param top defines the viewport top coordinate
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @returns a new matrix as a left-handed orthographic projection matrix
  4462. */
  4463. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4464. /**
  4465. * Stores a left-handed orthographic projection into a given matrix
  4466. * @param left defines the viewport left coordinate
  4467. * @param right defines the viewport right coordinate
  4468. * @param bottom defines the viewport bottom coordinate
  4469. * @param top defines the viewport top coordinate
  4470. * @param znear defines the near clip plane
  4471. * @param zfar defines the far clip plane
  4472. * @param result defines the target matrix
  4473. */
  4474. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4475. /**
  4476. * Creates a right-handed orthographic projection matrix
  4477. * @param left defines the viewport left coordinate
  4478. * @param right defines the viewport right coordinate
  4479. * @param bottom defines the viewport bottom coordinate
  4480. * @param top defines the viewport top coordinate
  4481. * @param znear defines the near clip plane
  4482. * @param zfar defines the far clip plane
  4483. * @returns a new matrix as a right-handed orthographic projection matrix
  4484. */
  4485. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4486. /**
  4487. * Stores a right-handed orthographic projection into a given matrix
  4488. * @param left defines the viewport left coordinate
  4489. * @param right defines the viewport right coordinate
  4490. * @param bottom defines the viewport bottom coordinate
  4491. * @param top defines the viewport top coordinate
  4492. * @param znear defines the near clip plane
  4493. * @param zfar defines the far clip plane
  4494. * @param result defines the target matrix
  4495. */
  4496. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4497. /**
  4498. * Creates a left-handed perspective projection matrix
  4499. * @param width defines the viewport width
  4500. * @param height defines the viewport height
  4501. * @param znear defines the near clip plane
  4502. * @param zfar defines the far clip plane
  4503. * @returns a new matrix as a left-handed perspective projection matrix
  4504. */
  4505. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4506. /**
  4507. * Creates a left-handed perspective projection matrix
  4508. * @param fov defines the horizontal field of view
  4509. * @param aspect defines the aspect ratio
  4510. * @param znear defines the near clip plane
  4511. * @param zfar defines the far clip plane
  4512. * @returns a new matrix as a left-handed perspective projection matrix
  4513. */
  4514. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4515. /**
  4516. * Stores a left-handed perspective projection into a given matrix
  4517. * @param fov defines the horizontal field of view
  4518. * @param aspect defines the aspect ratio
  4519. * @param znear defines the near clip plane
  4520. * @param zfar defines the far clip plane
  4521. * @param result defines the target matrix
  4522. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4523. */
  4524. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4525. /**
  4526. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4527. * @param fov defines the horizontal field of view
  4528. * @param aspect defines the aspect ratio
  4529. * @param znear defines the near clip plane
  4530. * @param zfar not used as infinity is used as far clip
  4531. * @param result defines the target matrix
  4532. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4533. */
  4534. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4535. /**
  4536. * Creates a right-handed perspective projection matrix
  4537. * @param fov defines the horizontal field of view
  4538. * @param aspect defines the aspect ratio
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @returns a new matrix as a right-handed perspective projection matrix
  4542. */
  4543. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4544. /**
  4545. * Stores a right-handed perspective projection into a given matrix
  4546. * @param fov defines the horizontal field of view
  4547. * @param aspect defines the aspect ratio
  4548. * @param znear defines the near clip plane
  4549. * @param zfar defines the far clip plane
  4550. * @param result defines the target matrix
  4551. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4552. */
  4553. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4554. /**
  4555. * Stores a right-handed perspective projection into a given matrix
  4556. * @param fov defines the horizontal field of view
  4557. * @param aspect defines the aspect ratio
  4558. * @param znear defines the near clip plane
  4559. * @param zfar not used as infinity is used as far clip
  4560. * @param result defines the target matrix
  4561. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4562. */
  4563. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4564. /**
  4565. * Stores a perspective projection for WebVR info a given matrix
  4566. * @param fov defines the field of view
  4567. * @param znear defines the near clip plane
  4568. * @param zfar defines the far clip plane
  4569. * @param result defines the target matrix
  4570. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4571. */
  4572. static PerspectiveFovWebVRToRef(fov: {
  4573. upDegrees: number;
  4574. downDegrees: number;
  4575. leftDegrees: number;
  4576. rightDegrees: number;
  4577. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4578. /**
  4579. * Computes a complete transformation matrix
  4580. * @param viewport defines the viewport to use
  4581. * @param world defines the world matrix
  4582. * @param view defines the view matrix
  4583. * @param projection defines the projection matrix
  4584. * @param zmin defines the near clip plane
  4585. * @param zmax defines the far clip plane
  4586. * @returns the transformation matrix
  4587. */
  4588. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4589. /**
  4590. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4597. * @param matrix defines the matrix to use
  4598. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4599. */
  4600. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4601. /**
  4602. * Compute the transpose of a given matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @returns the new matrix
  4605. */
  4606. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4607. /**
  4608. * Compute the transpose of a matrix and store it in a target matrix
  4609. * @param matrix defines the matrix to transpose
  4610. * @param result defines the target matrix
  4611. */
  4612. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @returns a new matrix
  4617. */
  4618. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4619. /**
  4620. * Computes a reflection matrix from a plane
  4621. * @param plane defines the reflection plane
  4622. * @param result defines the target matrix
  4623. */
  4624. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4625. /**
  4626. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4627. * @param xaxis defines the value of the 1st axis
  4628. * @param yaxis defines the value of the 2nd axis
  4629. * @param zaxis defines the value of the 3rd axis
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4635. * @param quat defines the quaternion to use
  4636. * @param result defines the target matrix
  4637. */
  4638. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4639. }
  4640. /**
  4641. * @hidden
  4642. */
  4643. export class TmpVectors {
  4644. static Vector2: Vector2[];
  4645. static Vector3: Vector3[];
  4646. static Vector4: Vector4[];
  4647. static Quaternion: Quaternion[];
  4648. static Matrix: Matrix[];
  4649. }
  4650. }
  4651. declare module "babylonjs/Maths/math.path" {
  4652. import { DeepImmutable, Nullable } from "babylonjs/types";
  4653. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4654. /**
  4655. * Defines potential orientation for back face culling
  4656. */
  4657. export enum Orientation {
  4658. /**
  4659. * Clockwise
  4660. */
  4661. CW = 0,
  4662. /** Counter clockwise */
  4663. CCW = 1
  4664. }
  4665. /** Class used to represent a Bezier curve */
  4666. export class BezierCurve {
  4667. /**
  4668. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4669. * @param t defines the time
  4670. * @param x1 defines the left coordinate on X axis
  4671. * @param y1 defines the left coordinate on Y axis
  4672. * @param x2 defines the right coordinate on X axis
  4673. * @param y2 defines the right coordinate on Y axis
  4674. * @returns the interpolated value
  4675. */
  4676. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4677. }
  4678. /**
  4679. * Defines angle representation
  4680. */
  4681. export class Angle {
  4682. private _radians;
  4683. /**
  4684. * Creates an Angle object of "radians" radians (float).
  4685. * @param radians the angle in radians
  4686. */
  4687. constructor(radians: number);
  4688. /**
  4689. * Get value in degrees
  4690. * @returns the Angle value in degrees (float)
  4691. */
  4692. degrees(): number;
  4693. /**
  4694. * Get value in radians
  4695. * @returns the Angle value in radians (float)
  4696. */
  4697. radians(): number;
  4698. /**
  4699. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4700. * @param a defines first vector
  4701. * @param b defines second vector
  4702. * @returns a new Angle
  4703. */
  4704. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4705. /**
  4706. * Gets a new Angle object from the given float in radians
  4707. * @param radians defines the angle value in radians
  4708. * @returns a new Angle
  4709. */
  4710. static FromRadians(radians: number): Angle;
  4711. /**
  4712. * Gets a new Angle object from the given float in degrees
  4713. * @param degrees defines the angle value in degrees
  4714. * @returns a new Angle
  4715. */
  4716. static FromDegrees(degrees: number): Angle;
  4717. }
  4718. /**
  4719. * This represents an arc in a 2d space.
  4720. */
  4721. export class Arc2 {
  4722. /** Defines the start point of the arc */
  4723. startPoint: Vector2;
  4724. /** Defines the mid point of the arc */
  4725. midPoint: Vector2;
  4726. /** Defines the end point of the arc */
  4727. endPoint: Vector2;
  4728. /**
  4729. * Defines the center point of the arc.
  4730. */
  4731. centerPoint: Vector2;
  4732. /**
  4733. * Defines the radius of the arc.
  4734. */
  4735. radius: number;
  4736. /**
  4737. * Defines the angle of the arc (from mid point to end point).
  4738. */
  4739. angle: Angle;
  4740. /**
  4741. * Defines the start angle of the arc (from start point to middle point).
  4742. */
  4743. startAngle: Angle;
  4744. /**
  4745. * Defines the orientation of the arc (clock wise/counter clock wise).
  4746. */
  4747. orientation: Orientation;
  4748. /**
  4749. * Creates an Arc object from the three given points : start, middle and end.
  4750. * @param startPoint Defines the start point of the arc
  4751. * @param midPoint Defines the midlle point of the arc
  4752. * @param endPoint Defines the end point of the arc
  4753. */
  4754. constructor(
  4755. /** Defines the start point of the arc */
  4756. startPoint: Vector2,
  4757. /** Defines the mid point of the arc */
  4758. midPoint: Vector2,
  4759. /** Defines the end point of the arc */
  4760. endPoint: Vector2);
  4761. }
  4762. /**
  4763. * Represents a 2D path made up of multiple 2D points
  4764. */
  4765. export class Path2 {
  4766. private _points;
  4767. private _length;
  4768. /**
  4769. * If the path start and end point are the same
  4770. */
  4771. closed: boolean;
  4772. /**
  4773. * Creates a Path2 object from the starting 2D coordinates x and y.
  4774. * @param x the starting points x value
  4775. * @param y the starting points y value
  4776. */
  4777. constructor(x: number, y: number);
  4778. /**
  4779. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4780. * @param x the added points x value
  4781. * @param y the added points y value
  4782. * @returns the updated Path2.
  4783. */
  4784. addLineTo(x: number, y: number): Path2;
  4785. /**
  4786. * 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.
  4787. * @param midX middle point x value
  4788. * @param midY middle point y value
  4789. * @param endX end point x value
  4790. * @param endY end point y value
  4791. * @param numberOfSegments (default: 36)
  4792. * @returns the updated Path2.
  4793. */
  4794. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4795. /**
  4796. * Closes the Path2.
  4797. * @returns the Path2.
  4798. */
  4799. close(): Path2;
  4800. /**
  4801. * Gets the sum of the distance between each sequential point in the path
  4802. * @returns the Path2 total length (float).
  4803. */
  4804. length(): number;
  4805. /**
  4806. * Gets the points which construct the path
  4807. * @returns the Path2 internal array of points.
  4808. */
  4809. getPoints(): Vector2[];
  4810. /**
  4811. * Retreives the point at the distance aways from the starting point
  4812. * @param normalizedLengthPosition the length along the path to retreive the point from
  4813. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4814. */
  4815. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4816. /**
  4817. * Creates a new path starting from an x and y position
  4818. * @param x starting x value
  4819. * @param y starting y value
  4820. * @returns a new Path2 starting at the coordinates (x, y).
  4821. */
  4822. static StartingAt(x: number, y: number): Path2;
  4823. }
  4824. /**
  4825. * Represents a 3D path made up of multiple 3D points
  4826. */
  4827. export class Path3D {
  4828. /**
  4829. * an array of Vector3, the curve axis of the Path3D
  4830. */
  4831. path: Vector3[];
  4832. private _curve;
  4833. private _distances;
  4834. private _tangents;
  4835. private _normals;
  4836. private _binormals;
  4837. private _raw;
  4838. private _alignTangentsWithPath;
  4839. private readonly _pointAtData;
  4840. /**
  4841. * new Path3D(path, normal, raw)
  4842. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4843. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4844. * @param path an array of Vector3, the curve axis of the Path3D
  4845. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4846. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4847. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4848. */
  4849. constructor(
  4850. /**
  4851. * an array of Vector3, the curve axis of the Path3D
  4852. */
  4853. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4854. /**
  4855. * Returns the Path3D array of successive Vector3 designing its curve.
  4856. * @returns the Path3D array of successive Vector3 designing its curve.
  4857. */
  4858. getCurve(): Vector3[];
  4859. /**
  4860. * Returns the Path3D array of successive Vector3 designing its curve.
  4861. * @returns the Path3D array of successive Vector3 designing its curve.
  4862. */
  4863. getPoints(): Vector3[];
  4864. /**
  4865. * @returns the computed length (float) of the path.
  4866. */
  4867. length(): number;
  4868. /**
  4869. * Returns an array populated with tangent vectors on each Path3D curve point.
  4870. * @returns an array populated with tangent vectors on each Path3D curve point.
  4871. */
  4872. getTangents(): Vector3[];
  4873. /**
  4874. * Returns an array populated with normal vectors on each Path3D curve point.
  4875. * @returns an array populated with normal vectors on each Path3D curve point.
  4876. */
  4877. getNormals(): Vector3[];
  4878. /**
  4879. * Returns an array populated with binormal vectors on each Path3D curve point.
  4880. * @returns an array populated with binormal vectors on each Path3D curve point.
  4881. */
  4882. getBinormals(): Vector3[];
  4883. /**
  4884. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4885. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4886. */
  4887. getDistances(): number[];
  4888. /**
  4889. * Returns an interpolated point along this path
  4890. * @param position the position of the point along this path, from 0.0 to 1.0
  4891. * @returns a new Vector3 as the point
  4892. */
  4893. getPointAt(position: number): Vector3;
  4894. /**
  4895. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4896. * @param position the position of the point along this path, from 0.0 to 1.0
  4897. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4898. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4899. */
  4900. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4901. /**
  4902. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4903. * @param position the position of the point along this path, from 0.0 to 1.0
  4904. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4905. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4906. */
  4907. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4908. /**
  4909. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4910. * @param position the position of the point along this path, from 0.0 to 1.0
  4911. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4912. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4913. */
  4914. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4915. /**
  4916. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4917. * @param position the position of the point along this path, from 0.0 to 1.0
  4918. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4919. */
  4920. getDistanceAt(position: number): number;
  4921. /**
  4922. * Returns the array index of the previous point of an interpolated point along this path
  4923. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4924. * @returns the array index
  4925. */
  4926. getPreviousPointIndexAt(position: number): number;
  4927. /**
  4928. * 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)
  4929. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4930. * @returns the sub position
  4931. */
  4932. getSubPositionAt(position: number): number;
  4933. /**
  4934. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4935. * @param target the vector of which to get the closest position to
  4936. * @returns the position of the closest virtual point on this path to the target vector
  4937. */
  4938. getClosestPositionTo(target: Vector3): number;
  4939. /**
  4940. * Returns a sub path (slice) of this path
  4941. * @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
  4942. * @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
  4943. * @returns a sub path (slice) of this path
  4944. */
  4945. slice(start?: number, end?: number): Path3D;
  4946. /**
  4947. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4948. * @param path path which all values are copied into the curves points
  4949. * @param firstNormal which should be projected onto the curve
  4950. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4951. * @returns the same object updated.
  4952. */
  4953. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4954. private _compute;
  4955. private _getFirstNonNullVector;
  4956. private _getLastNonNullVector;
  4957. private _normalVector;
  4958. /**
  4959. * Updates the point at data for an interpolated point along this curve
  4960. * @param position the position of the point along this curve, from 0.0 to 1.0
  4961. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4962. * @returns the (updated) point at data
  4963. */
  4964. private _updatePointAtData;
  4965. /**
  4966. * Updates the point at data from the specified parameters
  4967. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4968. * @param point the interpolated point
  4969. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4970. */
  4971. private _setPointAtData;
  4972. /**
  4973. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4974. */
  4975. private _updateInterpolationMatrix;
  4976. }
  4977. /**
  4978. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4979. * A Curve3 is designed from a series of successive Vector3.
  4980. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4981. */
  4982. export class Curve3 {
  4983. private _points;
  4984. private _length;
  4985. /**
  4986. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4987. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4988. * @param v1 (Vector3) the control point
  4989. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4996. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4997. * @param v1 (Vector3) the first control point
  4998. * @param v2 (Vector3) the second control point
  4999. * @param v3 (Vector3) the end point of the Cubic Bezier
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5006. * @param p1 (Vector3) the origin point of the Hermite Spline
  5007. * @param t1 (Vector3) the tangent vector at the origin point
  5008. * @param p2 (Vector3) the end point of the Hermite Spline
  5009. * @param t2 (Vector3) the tangent vector at the end point
  5010. * @param nbPoints (integer) the wanted number of points in the curve
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5014. /**
  5015. * Returns a Curve3 object along a CatmullRom Spline curve :
  5016. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5017. * @param nbPoints (integer) the wanted number of points between each curve control points
  5018. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5019. * @returns the created Curve3
  5020. */
  5021. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5022. /**
  5023. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5024. * A Curve3 is designed from a series of successive Vector3.
  5025. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5026. * @param points points which make up the curve
  5027. */
  5028. constructor(points: Vector3[]);
  5029. /**
  5030. * @returns the Curve3 stored array of successive Vector3
  5031. */
  5032. getPoints(): Vector3[];
  5033. /**
  5034. * @returns the computed length (float) of the curve.
  5035. */
  5036. length(): number;
  5037. /**
  5038. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5039. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5040. * curveA and curveB keep unchanged.
  5041. * @param curve the curve to continue from this curve
  5042. * @returns the newly constructed curve
  5043. */
  5044. continue(curve: DeepImmutable<Curve3>): Curve3;
  5045. private _computeLength;
  5046. }
  5047. }
  5048. declare module "babylonjs/Animations/easing" {
  5049. /**
  5050. * This represents the main contract an easing function should follow.
  5051. * Easing functions are used throughout the animation system.
  5052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5053. */
  5054. export interface IEasingFunction {
  5055. /**
  5056. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5057. * of the easing function.
  5058. * The link below provides some of the most common examples of easing functions.
  5059. * @see https://easings.net/
  5060. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5061. * @returns the corresponding value on the curve defined by the easing function
  5062. */
  5063. ease(gradient: number): number;
  5064. }
  5065. /**
  5066. * Base class used for every default easing function.
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class EasingFunction implements IEasingFunction {
  5070. /**
  5071. * Interpolation follows the mathematical formula associated with the easing function.
  5072. */
  5073. static readonly EASINGMODE_EASEIN: number;
  5074. /**
  5075. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5076. */
  5077. static readonly EASINGMODE_EASEOUT: number;
  5078. /**
  5079. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5080. */
  5081. static readonly EASINGMODE_EASEINOUT: number;
  5082. private _easingMode;
  5083. /**
  5084. * Sets the easing mode of the current function.
  5085. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5086. */
  5087. setEasingMode(easingMode: number): void;
  5088. /**
  5089. * Gets the current easing mode.
  5090. * @returns the easing mode
  5091. */
  5092. getEasingMode(): number;
  5093. /**
  5094. * @hidden
  5095. */
  5096. easeInCore(gradient: number): number;
  5097. /**
  5098. * Given an input gradient between 0 and 1, this returns the corresponding value
  5099. * of the easing function.
  5100. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5101. * @returns the corresponding value on the curve defined by the easing function
  5102. */
  5103. ease(gradient: number): number;
  5104. }
  5105. /**
  5106. * Easing function with a circle shape (see link below).
  5107. * @see https://easings.net/#easeInCirc
  5108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5109. */
  5110. export class CircleEase extends EasingFunction implements IEasingFunction {
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a ease back shape (see link below).
  5116. * @see https://easings.net/#easeInBack
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BackEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the amplitude of the function */
  5121. amplitude: number;
  5122. /**
  5123. * Instantiates a back ease easing
  5124. * @see https://easings.net/#easeInBack
  5125. * @param amplitude Defines the amplitude of the function
  5126. */
  5127. constructor(
  5128. /** Defines the amplitude of the function */
  5129. amplitude?: number);
  5130. /** @hidden */
  5131. easeInCore(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with a bouncing shape (see link below).
  5135. * @see https://easings.net/#easeInBounce
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class BounceEase extends EasingFunction implements IEasingFunction {
  5139. /** Defines the number of bounces */
  5140. bounces: number;
  5141. /** Defines the amplitude of the bounce */
  5142. bounciness: number;
  5143. /**
  5144. * Instantiates a bounce easing
  5145. * @see https://easings.net/#easeInBounce
  5146. * @param bounces Defines the number of bounces
  5147. * @param bounciness Defines the amplitude of the bounce
  5148. */
  5149. constructor(
  5150. /** Defines the number of bounces */
  5151. bounces?: number,
  5152. /** Defines the amplitude of the bounce */
  5153. bounciness?: number);
  5154. /** @hidden */
  5155. easeInCore(gradient: number): number;
  5156. }
  5157. /**
  5158. * Easing function with a power of 3 shape (see link below).
  5159. * @see https://easings.net/#easeInCubic
  5160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5161. */
  5162. export class CubicEase extends EasingFunction implements IEasingFunction {
  5163. /** @hidden */
  5164. easeInCore(gradient: number): number;
  5165. }
  5166. /**
  5167. * Easing function with an elastic shape (see link below).
  5168. * @see https://easings.net/#easeInElastic
  5169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5170. */
  5171. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5172. /** Defines the number of oscillations*/
  5173. oscillations: number;
  5174. /** Defines the amplitude of the oscillations*/
  5175. springiness: number;
  5176. /**
  5177. * Instantiates an elastic easing function
  5178. * @see https://easings.net/#easeInElastic
  5179. * @param oscillations Defines the number of oscillations
  5180. * @param springiness Defines the amplitude of the oscillations
  5181. */
  5182. constructor(
  5183. /** Defines the number of oscillations*/
  5184. oscillations?: number,
  5185. /** Defines the amplitude of the oscillations*/
  5186. springiness?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with an exponential shape (see link below).
  5192. * @see https://easings.net/#easeInExpo
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the exponent of the function */
  5197. exponent: number;
  5198. /**
  5199. * Instantiates an exponential easing function
  5200. * @see https://easings.net/#easeInExpo
  5201. * @param exponent Defines the exponent of the function
  5202. */
  5203. constructor(
  5204. /** Defines the exponent of the function */
  5205. exponent?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class PowerEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the power of the function */
  5216. power: number;
  5217. /**
  5218. * Instantiates an power base easing function
  5219. * @see https://easings.net/#easeInQuad
  5220. * @param power Defines the power of the function
  5221. */
  5222. constructor(
  5223. /** Defines the power of the function */
  5224. power?: number);
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a power of 2 shape (see link below).
  5230. * @see https://easings.net/#easeInQuad
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5234. /** @hidden */
  5235. easeInCore(gradient: number): number;
  5236. }
  5237. /**
  5238. * Easing function with a power of 4 shape (see link below).
  5239. * @see https://easings.net/#easeInQuart
  5240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5241. */
  5242. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5243. /** @hidden */
  5244. easeInCore(gradient: number): number;
  5245. }
  5246. /**
  5247. * Easing function with a power of 5 shape (see link below).
  5248. * @see https://easings.net/#easeInQuint
  5249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5250. */
  5251. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a sin shape (see link below).
  5257. * @see https://easings.net/#easeInSine
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class SineEase extends EasingFunction implements IEasingFunction {
  5261. /** @hidden */
  5262. easeInCore(gradient: number): number;
  5263. }
  5264. /**
  5265. * Easing function with a bezier shape (see link below).
  5266. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5270. /** Defines the x component of the start tangent in the bezier curve */
  5271. x1: number;
  5272. /** Defines the y component of the start tangent in the bezier curve */
  5273. y1: number;
  5274. /** Defines the x component of the end tangent in the bezier curve */
  5275. x2: number;
  5276. /** Defines the y component of the end tangent in the bezier curve */
  5277. y2: number;
  5278. /**
  5279. * Instantiates a bezier function
  5280. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5281. * @param x1 Defines the x component of the start tangent in the bezier curve
  5282. * @param y1 Defines the y component of the start tangent in the bezier curve
  5283. * @param x2 Defines the x component of the end tangent in the bezier curve
  5284. * @param y2 Defines the y component of the end tangent in the bezier curve
  5285. */
  5286. constructor(
  5287. /** Defines the x component of the start tangent in the bezier curve */
  5288. x1?: number,
  5289. /** Defines the y component of the start tangent in the bezier curve */
  5290. y1?: number,
  5291. /** Defines the x component of the end tangent in the bezier curve */
  5292. x2?: number,
  5293. /** Defines the y component of the end tangent in the bezier curve */
  5294. y2?: number);
  5295. /** @hidden */
  5296. easeInCore(gradient: number): number;
  5297. }
  5298. }
  5299. declare module "babylonjs/Maths/math.color" {
  5300. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5301. /**
  5302. * Class used to hold a RBG color
  5303. */
  5304. export class Color3 {
  5305. /**
  5306. * Defines the red component (between 0 and 1, default is 0)
  5307. */
  5308. r: number;
  5309. /**
  5310. * Defines the green component (between 0 and 1, default is 0)
  5311. */
  5312. g: number;
  5313. /**
  5314. * Defines the blue component (between 0 and 1, default is 0)
  5315. */
  5316. b: number;
  5317. /**
  5318. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5319. * @param r defines the red component (between 0 and 1, default is 0)
  5320. * @param g defines the green component (between 0 and 1, default is 0)
  5321. * @param b defines the blue component (between 0 and 1, default is 0)
  5322. */
  5323. constructor(
  5324. /**
  5325. * Defines the red component (between 0 and 1, default is 0)
  5326. */
  5327. r?: number,
  5328. /**
  5329. * Defines the green component (between 0 and 1, default is 0)
  5330. */
  5331. g?: number,
  5332. /**
  5333. * Defines the blue component (between 0 and 1, default is 0)
  5334. */
  5335. b?: number);
  5336. /**
  5337. * Creates a string with the Color3 current values
  5338. * @returns the string representation of the Color3 object
  5339. */
  5340. toString(): string;
  5341. /**
  5342. * Returns the string "Color3"
  5343. * @returns "Color3"
  5344. */
  5345. getClassName(): string;
  5346. /**
  5347. * Compute the Color3 hash code
  5348. * @returns an unique number that can be used to hash Color3 objects
  5349. */
  5350. getHashCode(): number;
  5351. /**
  5352. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5353. * @param array defines the array where to store the r,g,b components
  5354. * @param index defines an optional index in the target array to define where to start storing values
  5355. * @returns the current Color3 object
  5356. */
  5357. toArray(array: FloatArray, index?: number): Color3;
  5358. /**
  5359. * Returns a new Color4 object from the current Color3 and the given alpha
  5360. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5361. * @returns a new Color4 object
  5362. */
  5363. toColor4(alpha?: number): Color4;
  5364. /**
  5365. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5366. * @returns the new array
  5367. */
  5368. asArray(): number[];
  5369. /**
  5370. * Returns the luminance value
  5371. * @returns a float value
  5372. */
  5373. toLuminance(): number;
  5374. /**
  5375. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3 object
  5378. */
  5379. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines the Color3 object where to store the result
  5384. * @returns the current Color3
  5385. */
  5386. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Determines equality between Color3 objects
  5389. * @param otherColor defines the second operand
  5390. * @returns true if the rgb values are equal to the given ones
  5391. */
  5392. equals(otherColor: DeepImmutable<Color3>): boolean;
  5393. /**
  5394. * Determines equality between the current Color3 object and a set of r,b,g values
  5395. * @param r defines the red component to check
  5396. * @param g defines the green component to check
  5397. * @param b defines the blue component to check
  5398. * @returns true if the rgb values are equal to the given ones
  5399. */
  5400. equalsFloats(r: number, g: number, b: number): boolean;
  5401. /**
  5402. * Multiplies in place each rgb value by scale
  5403. * @param scale defines the scaling factor
  5404. * @returns the updated Color3
  5405. */
  5406. scale(scale: number): Color3;
  5407. /**
  5408. * Multiplies the rgb values by scale and stores the result into "result"
  5409. * @param scale defines the scaling factor
  5410. * @param result defines the Color3 object where to store the result
  5411. * @returns the unmodified current Color3
  5412. */
  5413. scaleToRef(scale: number, result: Color3): Color3;
  5414. /**
  5415. * Scale the current Color3 values by a factor and add the result to a given Color3
  5416. * @param scale defines the scale factor
  5417. * @param result defines color to store the result into
  5418. * @returns the unmodified current Color3
  5419. */
  5420. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5421. /**
  5422. * Clamps the rgb values by the min and max values and stores the result into "result"
  5423. * @param min defines minimum clamping value (default is 0)
  5424. * @param max defines maximum clamping value (default is 1)
  5425. * @param result defines color to store the result into
  5426. * @returns the original Color3
  5427. */
  5428. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5429. /**
  5430. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5431. * @param otherColor defines the second operand
  5432. * @returns the new Color3
  5433. */
  5434. add(otherColor: DeepImmutable<Color3>): Color3;
  5435. /**
  5436. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5437. * @param otherColor defines the second operand
  5438. * @param result defines Color3 object to store the result into
  5439. * @returns the unmodified current Color3
  5440. */
  5441. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5442. /**
  5443. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5444. * @param otherColor defines the second operand
  5445. * @returns the new Color3
  5446. */
  5447. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5448. /**
  5449. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5450. * @param otherColor defines the second operand
  5451. * @param result defines Color3 object to store the result into
  5452. * @returns the unmodified current Color3
  5453. */
  5454. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5455. /**
  5456. * Copy the current object
  5457. * @returns a new Color3 copied the current one
  5458. */
  5459. clone(): Color3;
  5460. /**
  5461. * Copies the rgb values from the source in the current Color3
  5462. * @param source defines the source Color3 object
  5463. * @returns the updated Color3 object
  5464. */
  5465. copyFrom(source: DeepImmutable<Color3>): Color3;
  5466. /**
  5467. * Updates the Color3 rgb values from the given floats
  5468. * @param r defines the red component to read from
  5469. * @param g defines the green component to read from
  5470. * @param b defines the blue component to read from
  5471. * @returns the current Color3 object
  5472. */
  5473. copyFromFloats(r: number, g: number, b: number): Color3;
  5474. /**
  5475. * Updates the Color3 rgb values from the given floats
  5476. * @param r defines the red component to read from
  5477. * @param g defines the green component to read from
  5478. * @param b defines the blue component to read from
  5479. * @returns the current Color3 object
  5480. */
  5481. set(r: number, g: number, b: number): Color3;
  5482. /**
  5483. * Compute the Color3 hexadecimal code as a string
  5484. * @returns a string containing the hexadecimal representation of the Color3 object
  5485. */
  5486. toHexString(): string;
  5487. /**
  5488. * Computes a new Color3 converted from the current one to linear space
  5489. * @returns a new Color3 object
  5490. */
  5491. toLinearSpace(): Color3;
  5492. /**
  5493. * Converts current color in rgb space to HSV values
  5494. * @returns a new color3 representing the HSV values
  5495. */
  5496. toHSV(): Color3;
  5497. /**
  5498. * Converts current color in rgb space to HSV values
  5499. * @param result defines the Color3 where to store the HSV values
  5500. */
  5501. toHSVToRef(result: Color3): void;
  5502. /**
  5503. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the linear space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5508. /**
  5509. * Computes a new Color3 converted from the current one to gamma space
  5510. * @returns a new Color3 object
  5511. */
  5512. toGammaSpace(): Color3;
  5513. /**
  5514. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5515. * @param convertedColor defines the Color3 object where to store the gamma space version
  5516. * @returns the unmodified Color3
  5517. */
  5518. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5519. private static _BlackReadOnly;
  5520. /**
  5521. * Convert Hue, saturation and value to a Color3 (RGB)
  5522. * @param hue defines the hue
  5523. * @param saturation defines the saturation
  5524. * @param value defines the value
  5525. * @param result defines the Color3 where to store the RGB values
  5526. */
  5527. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5528. /**
  5529. * Creates a new Color3 from the string containing valid hexadecimal values
  5530. * @param hex defines a string containing valid hexadecimal values
  5531. * @returns a new Color3 object
  5532. */
  5533. static FromHexString(hex: string): Color3;
  5534. /**
  5535. * Creates a new Color3 from the starting index of the given array
  5536. * @param array defines the source array
  5537. * @param offset defines an offset in the source array
  5538. * @returns a new Color3 object
  5539. */
  5540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5541. /**
  5542. * Creates a new Color3 from integer values (< 256)
  5543. * @param r defines the red component to read from (value between 0 and 255)
  5544. * @param g defines the green component to read from (value between 0 and 255)
  5545. * @param b defines the blue component to read from (value between 0 and 255)
  5546. * @returns a new Color3 object
  5547. */
  5548. static FromInts(r: number, g: number, b: number): Color3;
  5549. /**
  5550. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5551. * @param start defines the start Color3 value
  5552. * @param end defines the end Color3 value
  5553. * @param amount defines the gradient value between start and end
  5554. * @returns a new Color3 object
  5555. */
  5556. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5557. /**
  5558. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5559. * @param left defines the start value
  5560. * @param right defines the end value
  5561. * @param amount defines the gradient factor
  5562. * @param result defines the Color3 object where to store the result
  5563. */
  5564. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5565. /**
  5566. * Returns a Color3 value containing a red color
  5567. * @returns a new Color3 object
  5568. */
  5569. static Red(): Color3;
  5570. /**
  5571. * Returns a Color3 value containing a green color
  5572. * @returns a new Color3 object
  5573. */
  5574. static Green(): Color3;
  5575. /**
  5576. * Returns a Color3 value containing a blue color
  5577. * @returns a new Color3 object
  5578. */
  5579. static Blue(): Color3;
  5580. /**
  5581. * Returns a Color3 value containing a black color
  5582. * @returns a new Color3 object
  5583. */
  5584. static Black(): Color3;
  5585. /**
  5586. * Gets a Color3 value containing a black color that must not be updated
  5587. */
  5588. static get BlackReadOnly(): DeepImmutable<Color3>;
  5589. /**
  5590. * Returns a Color3 value containing a white color
  5591. * @returns a new Color3 object
  5592. */
  5593. static White(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a purple color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Purple(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a magenta color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Magenta(): Color3;
  5604. /**
  5605. * Returns a Color3 value containing a yellow color
  5606. * @returns a new Color3 object
  5607. */
  5608. static Yellow(): Color3;
  5609. /**
  5610. * Returns a Color3 value containing a gray color
  5611. * @returns a new Color3 object
  5612. */
  5613. static Gray(): Color3;
  5614. /**
  5615. * Returns a Color3 value containing a teal color
  5616. * @returns a new Color3 object
  5617. */
  5618. static Teal(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a random color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Random(): Color3;
  5624. }
  5625. /**
  5626. * Class used to hold a RBGA color
  5627. */
  5628. export class Color4 {
  5629. /**
  5630. * Defines the red component (between 0 and 1, default is 0)
  5631. */
  5632. r: number;
  5633. /**
  5634. * Defines the green component (between 0 and 1, default is 0)
  5635. */
  5636. g: number;
  5637. /**
  5638. * Defines the blue component (between 0 and 1, default is 0)
  5639. */
  5640. b: number;
  5641. /**
  5642. * Defines the alpha component (between 0 and 1, default is 1)
  5643. */
  5644. a: number;
  5645. /**
  5646. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5647. * @param r defines the red component (between 0 and 1, default is 0)
  5648. * @param g defines the green component (between 0 and 1, default is 0)
  5649. * @param b defines the blue component (between 0 and 1, default is 0)
  5650. * @param a defines the alpha component (between 0 and 1, default is 1)
  5651. */
  5652. constructor(
  5653. /**
  5654. * Defines the red component (between 0 and 1, default is 0)
  5655. */
  5656. r?: number,
  5657. /**
  5658. * Defines the green component (between 0 and 1, default is 0)
  5659. */
  5660. g?: number,
  5661. /**
  5662. * Defines the blue component (between 0 and 1, default is 0)
  5663. */
  5664. b?: number,
  5665. /**
  5666. * Defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. a?: number);
  5669. /**
  5670. * Adds in place the given Color4 values to the current Color4 object
  5671. * @param right defines the second operand
  5672. * @returns the current updated Color4 object
  5673. */
  5674. addInPlace(right: DeepImmutable<Color4>): Color4;
  5675. /**
  5676. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5677. * @returns the new array
  5678. */
  5679. asArray(): number[];
  5680. /**
  5681. * Stores from the starting index in the given array the Color4 successive values
  5682. * @param array defines the array where to store the r,g,b components
  5683. * @param index defines an optional index in the target array to define where to start storing values
  5684. * @returns the current Color4 object
  5685. */
  5686. toArray(array: number[], index?: number): Color4;
  5687. /**
  5688. * Determines equality between Color4 objects
  5689. * @param otherColor defines the second operand
  5690. * @returns true if the rgba values are equal to the given ones
  5691. */
  5692. equals(otherColor: DeepImmutable<Color4>): boolean;
  5693. /**
  5694. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5695. * @param right defines the second operand
  5696. * @returns a new Color4 object
  5697. */
  5698. add(right: DeepImmutable<Color4>): Color4;
  5699. /**
  5700. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5701. * @param right defines the second operand
  5702. * @returns a new Color4 object
  5703. */
  5704. subtract(right: DeepImmutable<Color4>): Color4;
  5705. /**
  5706. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5707. * @param right defines the second operand
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the current Color4 object
  5710. */
  5711. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5712. /**
  5713. * Creates a new Color4 with the current Color4 values multiplied by scale
  5714. * @param scale defines the scaling factor to apply
  5715. * @returns a new Color4 object
  5716. */
  5717. scale(scale: number): Color4;
  5718. /**
  5719. * Multiplies the current Color4 values by scale and stores the result in "result"
  5720. * @param scale defines the scaling factor to apply
  5721. * @param result defines the Color4 object where to store the result
  5722. * @returns the current unmodified Color4
  5723. */
  5724. scaleToRef(scale: number, result: Color4): Color4;
  5725. /**
  5726. * Scale the current Color4 values by a factor and add the result to a given Color4
  5727. * @param scale defines the scale factor
  5728. * @param result defines the Color4 object where to store the result
  5729. * @returns the unmodified current Color4
  5730. */
  5731. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5732. /**
  5733. * Clamps the rgb values by the min and max values and stores the result into "result"
  5734. * @param min defines minimum clamping value (default is 0)
  5735. * @param max defines maximum clamping value (default is 1)
  5736. * @param result defines color to store the result into.
  5737. * @returns the cuurent Color4
  5738. */
  5739. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5740. /**
  5741. * Multipy an Color4 value by another and return a new Color4 object
  5742. * @param color defines the Color4 value to multiply by
  5743. * @returns a new Color4 object
  5744. */
  5745. multiply(color: Color4): Color4;
  5746. /**
  5747. * Multipy a Color4 value by another and push the result in a reference value
  5748. * @param color defines the Color4 value to multiply by
  5749. * @param result defines the Color4 to fill the result in
  5750. * @returns the result Color4
  5751. */
  5752. multiplyToRef(color: Color4, result: Color4): Color4;
  5753. /**
  5754. * Creates a string with the Color4 current values
  5755. * @returns the string representation of the Color4 object
  5756. */
  5757. toString(): string;
  5758. /**
  5759. * Returns the string "Color4"
  5760. * @returns "Color4"
  5761. */
  5762. getClassName(): string;
  5763. /**
  5764. * Compute the Color4 hash code
  5765. * @returns an unique number that can be used to hash Color4 objects
  5766. */
  5767. getHashCode(): number;
  5768. /**
  5769. * Creates a new Color4 copied from the current one
  5770. * @returns a new Color4 object
  5771. */
  5772. clone(): Color4;
  5773. /**
  5774. * Copies the given Color4 values into the current one
  5775. * @param source defines the source Color4 object
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFrom(source: Color4): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Copies the given float values into the current one
  5790. * @param r defines the red component to read from
  5791. * @param g defines the green component to read from
  5792. * @param b defines the blue component to read from
  5793. * @param a defines the alpha component to read from
  5794. * @returns the current updated Color4 object
  5795. */
  5796. set(r: number, g: number, b: number, a: number): Color4;
  5797. /**
  5798. * Compute the Color4 hexadecimal code as a string
  5799. * @returns a string containing the hexadecimal representation of the Color4 object
  5800. */
  5801. toHexString(): string;
  5802. /**
  5803. * Computes a new Color4 converted from the current one to linear space
  5804. * @returns a new Color4 object
  5805. */
  5806. toLinearSpace(): Color4;
  5807. /**
  5808. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5809. * @param convertedColor defines the Color4 object where to store the linear space version
  5810. * @returns the unmodified Color4
  5811. */
  5812. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5813. /**
  5814. * Computes a new Color4 converted from the current one to gamma space
  5815. * @returns a new Color4 object
  5816. */
  5817. toGammaSpace(): Color4;
  5818. /**
  5819. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5820. * @param convertedColor defines the Color4 object where to store the gamma space version
  5821. * @returns the unmodified Color4
  5822. */
  5823. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5824. /**
  5825. * Creates a new Color4 from the string containing valid hexadecimal values
  5826. * @param hex defines a string containing valid hexadecimal values
  5827. * @returns a new Color4 object
  5828. */
  5829. static FromHexString(hex: string): Color4;
  5830. /**
  5831. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5832. * @param left defines the start value
  5833. * @param right defines the end value
  5834. * @param amount defines the gradient factor
  5835. * @returns a new Color4 object
  5836. */
  5837. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5838. /**
  5839. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5840. * @param left defines the start value
  5841. * @param right defines the end value
  5842. * @param amount defines the gradient factor
  5843. * @param result defines the Color4 object where to store data
  5844. */
  5845. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5846. /**
  5847. * Creates a new Color4 from a Color3 and an alpha value
  5848. * @param color3 defines the source Color3 to read from
  5849. * @param alpha defines the alpha component (1.0 by default)
  5850. * @returns a new Color4 object
  5851. */
  5852. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5853. /**
  5854. * Creates a new Color4 from the starting index element of the given array
  5855. * @param array defines the source array to read from
  5856. * @param offset defines the offset in the source array
  5857. * @returns a new Color4 object
  5858. */
  5859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5860. /**
  5861. * Creates a new Color3 from integer values (< 256)
  5862. * @param r defines the red component to read from (value between 0 and 255)
  5863. * @param g defines the green component to read from (value between 0 and 255)
  5864. * @param b defines the blue component to read from (value between 0 and 255)
  5865. * @param a defines the alpha component to read from (value between 0 and 255)
  5866. * @returns a new Color3 object
  5867. */
  5868. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5869. /**
  5870. * Check the content of a given array and convert it to an array containing RGBA data
  5871. * If the original array was already containing count * 4 values then it is returned directly
  5872. * @param colors defines the array to check
  5873. * @param count defines the number of RGBA data to expect
  5874. * @returns an array containing count * 4 values (RGBA)
  5875. */
  5876. static CheckColors4(colors: number[], count: number): number[];
  5877. }
  5878. /**
  5879. * @hidden
  5880. */
  5881. export class TmpColors {
  5882. static Color3: Color3[];
  5883. static Color4: Color4[];
  5884. }
  5885. }
  5886. declare module "babylonjs/Animations/animationKey" {
  5887. /**
  5888. * Defines an interface which represents an animation key frame
  5889. */
  5890. export interface IAnimationKey {
  5891. /**
  5892. * Frame of the key frame
  5893. */
  5894. frame: number;
  5895. /**
  5896. * Value at the specifies key frame
  5897. */
  5898. value: any;
  5899. /**
  5900. * The input tangent for the cubic hermite spline
  5901. */
  5902. inTangent?: any;
  5903. /**
  5904. * The output tangent for the cubic hermite spline
  5905. */
  5906. outTangent?: any;
  5907. /**
  5908. * The animation interpolation type
  5909. */
  5910. interpolation?: AnimationKeyInterpolation;
  5911. }
  5912. /**
  5913. * Enum for the animation key frame interpolation type
  5914. */
  5915. export enum AnimationKeyInterpolation {
  5916. /**
  5917. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5918. */
  5919. STEP = 1
  5920. }
  5921. }
  5922. declare module "babylonjs/Animations/animationRange" {
  5923. /**
  5924. * Represents the range of an animation
  5925. */
  5926. export class AnimationRange {
  5927. /**The name of the animation range**/
  5928. name: string;
  5929. /**The starting frame of the animation */
  5930. from: number;
  5931. /**The ending frame of the animation*/
  5932. to: number;
  5933. /**
  5934. * Initializes the range of an animation
  5935. * @param name The name of the animation range
  5936. * @param from The starting frame of the animation
  5937. * @param to The ending frame of the animation
  5938. */
  5939. constructor(
  5940. /**The name of the animation range**/
  5941. name: string,
  5942. /**The starting frame of the animation */
  5943. from: number,
  5944. /**The ending frame of the animation*/
  5945. to: number);
  5946. /**
  5947. * Makes a copy of the animation range
  5948. * @returns A copy of the animation range
  5949. */
  5950. clone(): AnimationRange;
  5951. }
  5952. }
  5953. declare module "babylonjs/Animations/animationEvent" {
  5954. /**
  5955. * Composed of a frame, and an action function
  5956. */
  5957. export class AnimationEvent {
  5958. /** The frame for which the event is triggered **/
  5959. frame: number;
  5960. /** The event to perform when triggered **/
  5961. action: (currentFrame: number) => void;
  5962. /** Specifies if the event should be triggered only once**/
  5963. onlyOnce?: boolean | undefined;
  5964. /**
  5965. * Specifies if the animation event is done
  5966. */
  5967. isDone: boolean;
  5968. /**
  5969. * Initializes the animation event
  5970. * @param frame The frame for which the event is triggered
  5971. * @param action The event to perform when triggered
  5972. * @param onlyOnce Specifies if the event should be triggered only once
  5973. */
  5974. constructor(
  5975. /** The frame for which the event is triggered **/
  5976. frame: number,
  5977. /** The event to perform when triggered **/
  5978. action: (currentFrame: number) => void,
  5979. /** Specifies if the event should be triggered only once**/
  5980. onlyOnce?: boolean | undefined);
  5981. /** @hidden */
  5982. _clone(): AnimationEvent;
  5983. }
  5984. }
  5985. declare module "babylonjs/Behaviors/behavior" {
  5986. import { Nullable } from "babylonjs/types";
  5987. /**
  5988. * Interface used to define a behavior
  5989. */
  5990. export interface Behavior<T> {
  5991. /** gets or sets behavior's name */
  5992. name: string;
  5993. /**
  5994. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5995. */
  5996. init(): void;
  5997. /**
  5998. * Called when the behavior is attached to a target
  5999. * @param target defines the target where the behavior is attached to
  6000. */
  6001. attach(target: T): void;
  6002. /**
  6003. * Called when the behavior is detached from its target
  6004. */
  6005. detach(): void;
  6006. }
  6007. /**
  6008. * Interface implemented by classes supporting behaviors
  6009. */
  6010. export interface IBehaviorAware<T> {
  6011. /**
  6012. * Attach a behavior
  6013. * @param behavior defines the behavior to attach
  6014. * @returns the current host
  6015. */
  6016. addBehavior(behavior: Behavior<T>): T;
  6017. /**
  6018. * Remove a behavior from the current object
  6019. * @param behavior defines the behavior to detach
  6020. * @returns the current host
  6021. */
  6022. removeBehavior(behavior: Behavior<T>): T;
  6023. /**
  6024. * Gets a behavior using its name to search
  6025. * @param name defines the name to search
  6026. * @returns the behavior or null if not found
  6027. */
  6028. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Misc/smartArray" {
  6032. /**
  6033. * Defines an array and its length.
  6034. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6035. */
  6036. export interface ISmartArrayLike<T> {
  6037. /**
  6038. * The data of the array.
  6039. */
  6040. data: Array<T>;
  6041. /**
  6042. * The active length of the array.
  6043. */
  6044. length: number;
  6045. }
  6046. /**
  6047. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6048. */
  6049. export class SmartArray<T> implements ISmartArrayLike<T> {
  6050. /**
  6051. * The full set of data from the array.
  6052. */
  6053. data: Array<T>;
  6054. /**
  6055. * The active length of the array.
  6056. */
  6057. length: number;
  6058. protected _id: number;
  6059. /**
  6060. * Instantiates a Smart Array.
  6061. * @param capacity defines the default capacity of the array.
  6062. */
  6063. constructor(capacity: number);
  6064. /**
  6065. * Pushes a value at the end of the active data.
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Iterates over the active data and apply the lambda to them.
  6071. * @param func defines the action to apply on each value.
  6072. */
  6073. forEach(func: (content: T) => void): void;
  6074. /**
  6075. * Sorts the full sets of data.
  6076. * @param compareFn defines the comparison function to apply.
  6077. */
  6078. sort(compareFn: (a: T, b: T) => number): void;
  6079. /**
  6080. * Resets the active data to an empty array.
  6081. */
  6082. reset(): void;
  6083. /**
  6084. * Releases all the data from the array as well as the array.
  6085. */
  6086. dispose(): void;
  6087. /**
  6088. * Concats the active data with a given array.
  6089. * @param array defines the data to concatenate with.
  6090. */
  6091. concat(array: any): void;
  6092. /**
  6093. * Returns the position of a value in the active data.
  6094. * @param value defines the value to find the index for
  6095. * @returns the index if found in the active data otherwise -1
  6096. */
  6097. indexOf(value: T): number;
  6098. /**
  6099. * Returns whether an element is part of the active data.
  6100. * @param value defines the value to look for
  6101. * @returns true if found in the active data otherwise false
  6102. */
  6103. contains(value: T): boolean;
  6104. private static _GlobalId;
  6105. }
  6106. /**
  6107. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6108. * The data in this array can only be present once
  6109. */
  6110. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6111. private _duplicateId;
  6112. /**
  6113. * Pushes a value at the end of the active data.
  6114. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6115. * @param value defines the object to push in the array.
  6116. */
  6117. push(value: T): void;
  6118. /**
  6119. * Pushes a value at the end of the active data.
  6120. * If the data is already present, it won t be added again
  6121. * @param value defines the object to push in the array.
  6122. * @returns true if added false if it was already present
  6123. */
  6124. pushNoDuplicate(value: T): boolean;
  6125. /**
  6126. * Resets the active data to an empty array.
  6127. */
  6128. reset(): void;
  6129. /**
  6130. * Concats the active data with a given array.
  6131. * This ensures no dupplicate will be present in the result.
  6132. * @param array defines the data to concatenate with.
  6133. */
  6134. concatWithNoDuplicate(array: any): void;
  6135. }
  6136. }
  6137. declare module "babylonjs/Cameras/cameraInputsManager" {
  6138. import { Nullable } from "babylonjs/types";
  6139. import { Camera } from "babylonjs/Cameras/camera";
  6140. /**
  6141. * @ignore
  6142. * This is a list of all the different input types that are available in the application.
  6143. * Fo instance: ArcRotateCameraGamepadInput...
  6144. */
  6145. export var CameraInputTypes: {};
  6146. /**
  6147. * This is the contract to implement in order to create a new input class.
  6148. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6149. */
  6150. export interface ICameraInput<TCamera extends Camera> {
  6151. /**
  6152. * Defines the camera the input is attached to.
  6153. */
  6154. camera: Nullable<TCamera>;
  6155. /**
  6156. * Gets the class name of the current intput.
  6157. * @returns the class name
  6158. */
  6159. getClassName(): string;
  6160. /**
  6161. * Get the friendly name associated with the input class.
  6162. * @returns the input friendly name
  6163. */
  6164. getSimpleName(): string;
  6165. /**
  6166. * Attach the input controls to a specific dom element to get the input from.
  6167. * @param element Defines the element the controls should be listened from
  6168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6169. */
  6170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6171. /**
  6172. * Detach the current controls from the specified dom element.
  6173. * @param element Defines the element to stop listening the inputs from
  6174. */
  6175. detachControl(element: Nullable<HTMLElement>): void;
  6176. /**
  6177. * Update the current camera state depending on the inputs that have been used this frame.
  6178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6179. */
  6180. checkInputs?: () => void;
  6181. }
  6182. /**
  6183. * Represents a map of input types to input instance or input index to input instance.
  6184. */
  6185. export interface CameraInputsMap<TCamera extends Camera> {
  6186. /**
  6187. * Accessor to the input by input type.
  6188. */
  6189. [name: string]: ICameraInput<TCamera>;
  6190. /**
  6191. * Accessor to the input by input index.
  6192. */
  6193. [idx: number]: ICameraInput<TCamera>;
  6194. }
  6195. /**
  6196. * This represents the input manager used within a camera.
  6197. * It helps dealing with all the different kind of input attached to a camera.
  6198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6199. */
  6200. export class CameraInputsManager<TCamera extends Camera> {
  6201. /**
  6202. * Defines the list of inputs attahed to the camera.
  6203. */
  6204. attached: CameraInputsMap<TCamera>;
  6205. /**
  6206. * Defines the dom element the camera is collecting inputs from.
  6207. * This is null if the controls have not been attached.
  6208. */
  6209. attachedElement: Nullable<HTMLElement>;
  6210. /**
  6211. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6212. */
  6213. noPreventDefault: boolean;
  6214. /**
  6215. * Defined the camera the input manager belongs to.
  6216. */
  6217. camera: TCamera;
  6218. /**
  6219. * Update the current camera state depending on the inputs that have been used this frame.
  6220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6221. */
  6222. checkInputs: () => void;
  6223. /**
  6224. * Instantiate a new Camera Input Manager.
  6225. * @param camera Defines the camera the input manager blongs to
  6226. */
  6227. constructor(camera: TCamera);
  6228. /**
  6229. * Add an input method to a camera
  6230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6231. * @param input camera input method
  6232. */
  6233. add(input: ICameraInput<TCamera>): void;
  6234. /**
  6235. * Remove a specific input method from a camera
  6236. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6237. * @param inputToRemove camera input method
  6238. */
  6239. remove(inputToRemove: ICameraInput<TCamera>): void;
  6240. /**
  6241. * Remove a specific input type from a camera
  6242. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6243. * @param inputType the type of the input to remove
  6244. */
  6245. removeByType(inputType: string): void;
  6246. private _addCheckInputs;
  6247. /**
  6248. * Attach the input controls to the currently attached dom element to listen the events from.
  6249. * @param input Defines the input to attach
  6250. */
  6251. attachInput(input: ICameraInput<TCamera>): void;
  6252. /**
  6253. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6254. * @param element Defines the dom element to collect the events from
  6255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6256. */
  6257. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6258. /**
  6259. * Detach the current manager inputs controls from a specific dom element.
  6260. * @param element Defines the dom element to collect the events from
  6261. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6262. */
  6263. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6264. /**
  6265. * Rebuild the dynamic inputCheck function from the current list of
  6266. * defined inputs in the manager.
  6267. */
  6268. rebuildInputCheck(): void;
  6269. /**
  6270. * Remove all attached input methods from a camera
  6271. */
  6272. clear(): void;
  6273. /**
  6274. * Serialize the current input manager attached to a camera.
  6275. * This ensures than once parsed,
  6276. * the input associated to the camera will be identical to the current ones
  6277. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6278. */
  6279. serialize(serializedCamera: any): void;
  6280. /**
  6281. * Parses an input manager serialized JSON to restore the previous list of inputs
  6282. * and states associated to a camera.
  6283. * @param parsedCamera Defines the JSON to parse
  6284. */
  6285. parse(parsedCamera: any): void;
  6286. }
  6287. }
  6288. declare module "babylonjs/Meshes/buffer" {
  6289. import { Nullable, DataArray } from "babylonjs/types";
  6290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6291. /**
  6292. * Class used to store data that will be store in GPU memory
  6293. */
  6294. export class Buffer {
  6295. private _engine;
  6296. private _buffer;
  6297. /** @hidden */
  6298. _data: Nullable<DataArray>;
  6299. private _updatable;
  6300. private _instanced;
  6301. private _divisor;
  6302. /**
  6303. * Gets the byte stride.
  6304. */
  6305. readonly byteStride: number;
  6306. /**
  6307. * Constructor
  6308. * @param engine the engine
  6309. * @param data the data to use for this buffer
  6310. * @param updatable whether the data is updatable
  6311. * @param stride the stride (optional)
  6312. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6313. * @param instanced whether the buffer is instanced (optional)
  6314. * @param useBytes set to true if the stride in in bytes (optional)
  6315. * @param divisor sets an optional divisor for instances (1 by default)
  6316. */
  6317. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6318. /**
  6319. * Create a new VertexBuffer based on the current buffer
  6320. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6321. * @param offset defines offset in the buffer (0 by default)
  6322. * @param size defines the size in floats of attributes (position is 3 for instance)
  6323. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6324. * @param instanced defines if the vertex buffer contains indexed data
  6325. * @param useBytes defines if the offset and stride are in bytes *
  6326. * @param divisor sets an optional divisor for instances (1 by default)
  6327. * @returns the new vertex buffer
  6328. */
  6329. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6330. /**
  6331. * Gets a boolean indicating if the Buffer is updatable?
  6332. * @returns true if the buffer is updatable
  6333. */
  6334. isUpdatable(): boolean;
  6335. /**
  6336. * Gets current buffer's data
  6337. * @returns a DataArray or null
  6338. */
  6339. getData(): Nullable<DataArray>;
  6340. /**
  6341. * Gets underlying native buffer
  6342. * @returns underlying native buffer
  6343. */
  6344. getBuffer(): Nullable<DataBuffer>;
  6345. /**
  6346. * Gets the stride in float32 units (i.e. byte stride / 4).
  6347. * May not be an integer if the byte stride is not divisible by 4.
  6348. * @returns the stride in float32 units
  6349. * @deprecated Please use byteStride instead.
  6350. */
  6351. getStrideSize(): number;
  6352. /**
  6353. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6354. * @param data defines the data to store
  6355. */
  6356. create(data?: Nullable<DataArray>): void;
  6357. /** @hidden */
  6358. _rebuild(): void;
  6359. /**
  6360. * Update current buffer data
  6361. * @param data defines the data to store
  6362. */
  6363. update(data: DataArray): void;
  6364. /**
  6365. * Updates the data directly.
  6366. * @param data the new data
  6367. * @param offset the new offset
  6368. * @param vertexCount the vertex count (optional)
  6369. * @param useBytes set to true if the offset is in bytes
  6370. */
  6371. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6372. /**
  6373. * Release all resources
  6374. */
  6375. dispose(): void;
  6376. }
  6377. /**
  6378. * Specialized buffer used to store vertex data
  6379. */
  6380. export class VertexBuffer {
  6381. /** @hidden */
  6382. _buffer: Buffer;
  6383. private _kind;
  6384. private _size;
  6385. private _ownsBuffer;
  6386. private _instanced;
  6387. private _instanceDivisor;
  6388. /**
  6389. * The byte type.
  6390. */
  6391. static readonly BYTE: number;
  6392. /**
  6393. * The unsigned byte type.
  6394. */
  6395. static readonly UNSIGNED_BYTE: number;
  6396. /**
  6397. * The short type.
  6398. */
  6399. static readonly SHORT: number;
  6400. /**
  6401. * The unsigned short type.
  6402. */
  6403. static readonly UNSIGNED_SHORT: number;
  6404. /**
  6405. * The integer type.
  6406. */
  6407. static readonly INT: number;
  6408. /**
  6409. * The unsigned integer type.
  6410. */
  6411. static readonly UNSIGNED_INT: number;
  6412. /**
  6413. * The float type.
  6414. */
  6415. static readonly FLOAT: number;
  6416. /**
  6417. * Gets or sets the instance divisor when in instanced mode
  6418. */
  6419. get instanceDivisor(): number;
  6420. set instanceDivisor(value: number);
  6421. /**
  6422. * Gets the byte stride.
  6423. */
  6424. readonly byteStride: number;
  6425. /**
  6426. * Gets the byte offset.
  6427. */
  6428. readonly byteOffset: number;
  6429. /**
  6430. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6431. */
  6432. readonly normalized: boolean;
  6433. /**
  6434. * Gets the data type of each component in the array.
  6435. */
  6436. readonly type: number;
  6437. /**
  6438. * Constructor
  6439. * @param engine the engine
  6440. * @param data the data to use for this vertex buffer
  6441. * @param kind the vertex buffer kind
  6442. * @param updatable whether the data is updatable
  6443. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6444. * @param stride the stride (optional)
  6445. * @param instanced whether the buffer is instanced (optional)
  6446. * @param offset the offset of the data (optional)
  6447. * @param size the number of components (optional)
  6448. * @param type the type of the component (optional)
  6449. * @param normalized whether the data contains normalized data (optional)
  6450. * @param useBytes set to true if stride and offset are in bytes (optional)
  6451. * @param divisor defines the instance divisor to use (1 by default)
  6452. */
  6453. 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);
  6454. /** @hidden */
  6455. _rebuild(): void;
  6456. /**
  6457. * Returns the kind of the VertexBuffer (string)
  6458. * @returns a string
  6459. */
  6460. getKind(): string;
  6461. /**
  6462. * Gets a boolean indicating if the VertexBuffer is updatable?
  6463. * @returns true if the buffer is updatable
  6464. */
  6465. isUpdatable(): boolean;
  6466. /**
  6467. * Gets current buffer's data
  6468. * @returns a DataArray or null
  6469. */
  6470. getData(): Nullable<DataArray>;
  6471. /**
  6472. * Gets underlying native buffer
  6473. * @returns underlying native buffer
  6474. */
  6475. getBuffer(): Nullable<DataBuffer>;
  6476. /**
  6477. * Gets the stride in float32 units (i.e. byte stride / 4).
  6478. * May not be an integer if the byte stride is not divisible by 4.
  6479. * @returns the stride in float32 units
  6480. * @deprecated Please use byteStride instead.
  6481. */
  6482. getStrideSize(): number;
  6483. /**
  6484. * Returns the offset as a multiple of the type byte length.
  6485. * @returns the offset in bytes
  6486. * @deprecated Please use byteOffset instead.
  6487. */
  6488. getOffset(): number;
  6489. /**
  6490. * Returns the number of components per vertex attribute (integer)
  6491. * @returns the size in float
  6492. */
  6493. getSize(): number;
  6494. /**
  6495. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6496. * @returns true if this buffer is instanced
  6497. */
  6498. getIsInstanced(): boolean;
  6499. /**
  6500. * Returns the instancing divisor, zero for non-instanced (integer).
  6501. * @returns a number
  6502. */
  6503. getInstanceDivisor(): number;
  6504. /**
  6505. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6506. * @param data defines the data to store
  6507. */
  6508. create(data?: DataArray): void;
  6509. /**
  6510. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6511. * This function will create a new buffer if the current one is not updatable
  6512. * @param data defines the data to store
  6513. */
  6514. update(data: DataArray): void;
  6515. /**
  6516. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6517. * Returns the directly updated WebGLBuffer.
  6518. * @param data the new data
  6519. * @param offset the new offset
  6520. * @param useBytes set to true if the offset is in bytes
  6521. */
  6522. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6523. /**
  6524. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6525. */
  6526. dispose(): void;
  6527. /**
  6528. * Enumerates each value of this vertex buffer as numbers.
  6529. * @param count the number of values to enumerate
  6530. * @param callback the callback function called for each value
  6531. */
  6532. forEach(count: number, callback: (value: number, index: number) => void): void;
  6533. /**
  6534. * Positions
  6535. */
  6536. static readonly PositionKind: string;
  6537. /**
  6538. * Normals
  6539. */
  6540. static readonly NormalKind: string;
  6541. /**
  6542. * Tangents
  6543. */
  6544. static readonly TangentKind: string;
  6545. /**
  6546. * Texture coordinates
  6547. */
  6548. static readonly UVKind: string;
  6549. /**
  6550. * Texture coordinates 2
  6551. */
  6552. static readonly UV2Kind: string;
  6553. /**
  6554. * Texture coordinates 3
  6555. */
  6556. static readonly UV3Kind: string;
  6557. /**
  6558. * Texture coordinates 4
  6559. */
  6560. static readonly UV4Kind: string;
  6561. /**
  6562. * Texture coordinates 5
  6563. */
  6564. static readonly UV5Kind: string;
  6565. /**
  6566. * Texture coordinates 6
  6567. */
  6568. static readonly UV6Kind: string;
  6569. /**
  6570. * Colors
  6571. */
  6572. static readonly ColorKind: string;
  6573. /**
  6574. * Matrix indices (for bones)
  6575. */
  6576. static readonly MatricesIndicesKind: string;
  6577. /**
  6578. * Matrix weights (for bones)
  6579. */
  6580. static readonly MatricesWeightsKind: string;
  6581. /**
  6582. * Additional matrix indices (for bones)
  6583. */
  6584. static readonly MatricesIndicesExtraKind: string;
  6585. /**
  6586. * Additional matrix weights (for bones)
  6587. */
  6588. static readonly MatricesWeightsExtraKind: string;
  6589. /**
  6590. * Deduces the stride given a kind.
  6591. * @param kind The kind string to deduce
  6592. * @returns The deduced stride
  6593. */
  6594. static DeduceStride(kind: string): number;
  6595. /**
  6596. * Gets the byte length of the given type.
  6597. * @param type the type
  6598. * @returns the number of bytes
  6599. */
  6600. static GetTypeByteLength(type: number): number;
  6601. /**
  6602. * Enumerates each value of the given parameters as numbers.
  6603. * @param data the data to enumerate
  6604. * @param byteOffset the byte offset of the data
  6605. * @param byteStride the byte stride of the data
  6606. * @param componentCount the number of components per element
  6607. * @param componentType the type of the component
  6608. * @param count the number of values to enumerate
  6609. * @param normalized whether the data is normalized
  6610. * @param callback the callback function called for each value
  6611. */
  6612. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6613. private static _GetFloatValue;
  6614. }
  6615. }
  6616. declare module "babylonjs/Collisions/intersectionInfo" {
  6617. import { Nullable } from "babylonjs/types";
  6618. /**
  6619. * @hidden
  6620. */
  6621. export class IntersectionInfo {
  6622. bu: Nullable<number>;
  6623. bv: Nullable<number>;
  6624. distance: number;
  6625. faceId: number;
  6626. subMeshId: number;
  6627. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6628. }
  6629. }
  6630. declare module "babylonjs/Maths/math.plane" {
  6631. import { DeepImmutable } from "babylonjs/types";
  6632. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6633. /**
  6634. * Represens a plane by the equation ax + by + cz + d = 0
  6635. */
  6636. export class Plane {
  6637. private static _TmpMatrix;
  6638. /**
  6639. * Normal of the plane (a,b,c)
  6640. */
  6641. normal: Vector3;
  6642. /**
  6643. * d component of the plane
  6644. */
  6645. d: number;
  6646. /**
  6647. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6648. * @param a a component of the plane
  6649. * @param b b component of the plane
  6650. * @param c c component of the plane
  6651. * @param d d component of the plane
  6652. */
  6653. constructor(a: number, b: number, c: number, d: number);
  6654. /**
  6655. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6656. */
  6657. asArray(): number[];
  6658. /**
  6659. * @returns a new plane copied from the current Plane.
  6660. */
  6661. clone(): Plane;
  6662. /**
  6663. * @returns the string "Plane".
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * @returns the Plane hash code.
  6668. */
  6669. getHashCode(): number;
  6670. /**
  6671. * Normalize the current Plane in place.
  6672. * @returns the updated Plane.
  6673. */
  6674. normalize(): Plane;
  6675. /**
  6676. * Applies a transformation the plane and returns the result
  6677. * @param transformation the transformation matrix to be applied to the plane
  6678. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6679. */
  6680. transform(transformation: DeepImmutable<Matrix>): Plane;
  6681. /**
  6682. * Calcualtte the dot product between the point and the plane normal
  6683. * @param point point to calculate the dot product with
  6684. * @returns the dot product (float) of the point coordinates and the plane normal.
  6685. */
  6686. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6687. /**
  6688. * Updates the current Plane from the plane defined by the three given points.
  6689. * @param point1 one of the points used to contruct the plane
  6690. * @param point2 one of the points used to contruct the plane
  6691. * @param point3 one of the points used to contruct the plane
  6692. * @returns the updated Plane.
  6693. */
  6694. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Checks if the plane is facing a given direction
  6697. * @param direction the direction to check if the plane is facing
  6698. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6699. * @returns True is the vector "direction" is the same side than the plane normal.
  6700. */
  6701. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6702. /**
  6703. * Calculates the distance to a point
  6704. * @param point point to calculate distance to
  6705. * @returns the signed distance (float) from the given point to the Plane.
  6706. */
  6707. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6708. /**
  6709. * Creates a plane from an array
  6710. * @param array the array to create a plane from
  6711. * @returns a new Plane from the given array.
  6712. */
  6713. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6714. /**
  6715. * Creates a plane from three points
  6716. * @param point1 point used to create the plane
  6717. * @param point2 point used to create the plane
  6718. * @param point3 point used to create the plane
  6719. * @returns a new Plane defined by the three given points.
  6720. */
  6721. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6722. /**
  6723. * Creates a plane from an origin point and a normal
  6724. * @param origin origin of the plane to be constructed
  6725. * @param normal normal of the plane to be constructed
  6726. * @returns a new Plane the normal vector to this plane at the given origin point.
  6727. * Note : the vector "normal" is updated because normalized.
  6728. */
  6729. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6730. /**
  6731. * Calculates the distance from a plane and a point
  6732. * @param origin origin of the plane to be constructed
  6733. * @param normal normal of the plane to be constructed
  6734. * @param point point to calculate distance to
  6735. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6736. */
  6737. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6738. }
  6739. }
  6740. declare module "babylonjs/Culling/boundingSphere" {
  6741. import { DeepImmutable } from "babylonjs/types";
  6742. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6743. import { Plane } from "babylonjs/Maths/math.plane";
  6744. /**
  6745. * Class used to store bounding sphere information
  6746. */
  6747. export class BoundingSphere {
  6748. /**
  6749. * Gets the center of the bounding sphere in local space
  6750. */
  6751. readonly center: Vector3;
  6752. /**
  6753. * Radius of the bounding sphere in local space
  6754. */
  6755. radius: number;
  6756. /**
  6757. * Gets the center of the bounding sphere in world space
  6758. */
  6759. readonly centerWorld: Vector3;
  6760. /**
  6761. * Radius of the bounding sphere in world space
  6762. */
  6763. radiusWorld: number;
  6764. /**
  6765. * Gets the minimum vector in local space
  6766. */
  6767. readonly minimum: Vector3;
  6768. /**
  6769. * Gets the maximum vector in local space
  6770. */
  6771. readonly maximum: Vector3;
  6772. private _worldMatrix;
  6773. private static readonly TmpVector3;
  6774. /**
  6775. * Creates a new bounding sphere
  6776. * @param min defines the minimum vector (in local space)
  6777. * @param max defines the maximum vector (in local space)
  6778. * @param worldMatrix defines the new world matrix
  6779. */
  6780. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6781. /**
  6782. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6783. * @param min defines the new minimum vector (in local space)
  6784. * @param max defines the new maximum vector (in local space)
  6785. * @param worldMatrix defines the new world matrix
  6786. */
  6787. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6788. /**
  6789. * Scale the current bounding sphere by applying a scale factor
  6790. * @param factor defines the scale factor to apply
  6791. * @returns the current bounding box
  6792. */
  6793. scale(factor: number): BoundingSphere;
  6794. /**
  6795. * Gets the world matrix of the bounding box
  6796. * @returns a matrix
  6797. */
  6798. getWorldMatrix(): DeepImmutable<Matrix>;
  6799. /** @hidden */
  6800. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6801. /**
  6802. * Tests if the bounding sphere is intersecting the frustum planes
  6803. * @param frustumPlanes defines the frustum planes to test
  6804. * @returns true if there is an intersection
  6805. */
  6806. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6807. /**
  6808. * Tests if the bounding sphere center is in between the frustum planes.
  6809. * Used for optimistic fast inclusion.
  6810. * @param frustumPlanes defines the frustum planes to test
  6811. * @returns true if the sphere center is in between the frustum planes
  6812. */
  6813. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6814. /**
  6815. * Tests if a point is inside the bounding sphere
  6816. * @param point defines the point to test
  6817. * @returns true if the point is inside the bounding sphere
  6818. */
  6819. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6820. /**
  6821. * Checks if two sphere intersct
  6822. * @param sphere0 sphere 0
  6823. * @param sphere1 sphere 1
  6824. * @returns true if the speres intersect
  6825. */
  6826. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6827. }
  6828. }
  6829. declare module "babylonjs/Culling/boundingBox" {
  6830. import { DeepImmutable } from "babylonjs/types";
  6831. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6832. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6833. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6834. import { Plane } from "babylonjs/Maths/math.plane";
  6835. /**
  6836. * Class used to store bounding box information
  6837. */
  6838. export class BoundingBox implements ICullable {
  6839. /**
  6840. * Gets the 8 vectors representing the bounding box in local space
  6841. */
  6842. readonly vectors: Vector3[];
  6843. /**
  6844. * Gets the center of the bounding box in local space
  6845. */
  6846. readonly center: Vector3;
  6847. /**
  6848. * Gets the center of the bounding box in world space
  6849. */
  6850. readonly centerWorld: Vector3;
  6851. /**
  6852. * Gets the extend size in local space
  6853. */
  6854. readonly extendSize: Vector3;
  6855. /**
  6856. * Gets the extend size in world space
  6857. */
  6858. readonly extendSizeWorld: Vector3;
  6859. /**
  6860. * Gets the OBB (object bounding box) directions
  6861. */
  6862. readonly directions: Vector3[];
  6863. /**
  6864. * Gets the 8 vectors representing the bounding box in world space
  6865. */
  6866. readonly vectorsWorld: Vector3[];
  6867. /**
  6868. * Gets the minimum vector in world space
  6869. */
  6870. readonly minimumWorld: Vector3;
  6871. /**
  6872. * Gets the maximum vector in world space
  6873. */
  6874. readonly maximumWorld: Vector3;
  6875. /**
  6876. * Gets the minimum vector in local space
  6877. */
  6878. readonly minimum: Vector3;
  6879. /**
  6880. * Gets the maximum vector in local space
  6881. */
  6882. readonly maximum: Vector3;
  6883. private _worldMatrix;
  6884. private static readonly TmpVector3;
  6885. /**
  6886. * @hidden
  6887. */
  6888. _tag: number;
  6889. /**
  6890. * Creates a new bounding box
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding box by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingBox;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(world: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding box is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding box is entirely inside the frustum planes
  6924. * @param frustumPlanes defines the frustum planes to test
  6925. * @returns true if there is an inclusion
  6926. */
  6927. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6928. /**
  6929. * Tests if a point is inside the bounding box
  6930. * @param point defines the point to test
  6931. * @returns true if the point is inside the bounding box
  6932. */
  6933. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6934. /**
  6935. * Tests if the bounding box intersects with a bounding sphere
  6936. * @param sphere defines the sphere to test
  6937. * @returns true if there is an intersection
  6938. */
  6939. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6940. /**
  6941. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6942. * @param min defines the min vector to use
  6943. * @param max defines the max vector to use
  6944. * @returns true if there is an intersection
  6945. */
  6946. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Tests if two bounding boxes are intersections
  6949. * @param box0 defines the first box to test
  6950. * @param box1 defines the second box to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6954. /**
  6955. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6956. * @param minPoint defines the minimum vector of the bounding box
  6957. * @param maxPoint defines the maximum vector of the bounding box
  6958. * @param sphereCenter defines the sphere center
  6959. * @param sphereRadius defines the sphere radius
  6960. * @returns true if there is an intersection
  6961. */
  6962. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6963. /**
  6964. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6965. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @return true if there is an inclusion
  6968. */
  6969. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6972. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6973. * @param frustumPlanes defines the frustum planes to test
  6974. * @return true if there is an intersection
  6975. */
  6976. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6977. }
  6978. }
  6979. declare module "babylonjs/Collisions/collider" {
  6980. import { Nullable, IndicesArray } from "babylonjs/types";
  6981. import { Vector3 } from "babylonjs/Maths/math.vector";
  6982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6983. import { Plane } from "babylonjs/Maths/math.plane";
  6984. /** @hidden */
  6985. export class Collider {
  6986. /** Define if a collision was found */
  6987. collisionFound: boolean;
  6988. /**
  6989. * Define last intersection point in local space
  6990. */
  6991. intersectionPoint: Vector3;
  6992. /**
  6993. * Define last collided mesh
  6994. */
  6995. collidedMesh: Nullable<AbstractMesh>;
  6996. private _collisionPoint;
  6997. private _planeIntersectionPoint;
  6998. private _tempVector;
  6999. private _tempVector2;
  7000. private _tempVector3;
  7001. private _tempVector4;
  7002. private _edge;
  7003. private _baseToVertex;
  7004. private _destinationPoint;
  7005. private _slidePlaneNormal;
  7006. private _displacementVector;
  7007. /** @hidden */
  7008. _radius: Vector3;
  7009. /** @hidden */
  7010. _retry: number;
  7011. private _velocity;
  7012. private _basePoint;
  7013. private _epsilon;
  7014. /** @hidden */
  7015. _velocityWorldLength: number;
  7016. /** @hidden */
  7017. _basePointWorld: Vector3;
  7018. private _velocityWorld;
  7019. private _normalizedVelocity;
  7020. /** @hidden */
  7021. _initialVelocity: Vector3;
  7022. /** @hidden */
  7023. _initialPosition: Vector3;
  7024. private _nearestDistance;
  7025. private _collisionMask;
  7026. get collisionMask(): number;
  7027. set collisionMask(mask: number);
  7028. /**
  7029. * Gets the plane normal used to compute the sliding response (in local space)
  7030. */
  7031. get slidePlaneNormal(): Vector3;
  7032. /** @hidden */
  7033. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7034. /** @hidden */
  7035. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7036. /** @hidden */
  7037. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7038. /** @hidden */
  7039. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7042. /** @hidden */
  7043. _getResponse(pos: Vector3, vel: Vector3): void;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingInfo" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7050. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. import { Collider } from "babylonjs/Collisions/collider";
  7053. /**
  7054. * Interface for cullable objects
  7055. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7056. */
  7057. export interface ICullable {
  7058. /**
  7059. * Checks if the object or part of the object is in the frustum
  7060. * @param frustumPlanes Camera near/planes
  7061. * @returns true if the object is in frustum otherwise false
  7062. */
  7063. isInFrustum(frustumPlanes: Plane[]): boolean;
  7064. /**
  7065. * Checks if a cullable object (mesh...) is in the camera frustum
  7066. * Unlike isInFrustum this cheks the full bounding box
  7067. * @param frustumPlanes Camera near/planes
  7068. * @returns true if the object is in frustum otherwise false
  7069. */
  7070. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7071. }
  7072. /**
  7073. * Info for a bounding data of a mesh
  7074. */
  7075. export class BoundingInfo implements ICullable {
  7076. /**
  7077. * Bounding box for the mesh
  7078. */
  7079. readonly boundingBox: BoundingBox;
  7080. /**
  7081. * Bounding sphere for the mesh
  7082. */
  7083. readonly boundingSphere: BoundingSphere;
  7084. private _isLocked;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Constructs bounding info
  7088. * @param minimum min vector of the bounding box/sphere
  7089. * @param maximum max vector of the bounding box/sphere
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * min vector of the bounding box/sphere
  7102. */
  7103. get minimum(): Vector3;
  7104. /**
  7105. * max vector of the bounding box/sphere
  7106. */
  7107. get maximum(): Vector3;
  7108. /**
  7109. * If the info is locked and won't be updated to avoid perf overhead
  7110. */
  7111. get isLocked(): boolean;
  7112. set isLocked(value: boolean);
  7113. /**
  7114. * Updates the bounding sphere and box
  7115. * @param world world matrix to be used to update
  7116. */
  7117. update(world: DeepImmutable<Matrix>): void;
  7118. /**
  7119. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7120. * @param center New center of the bounding info
  7121. * @param extend New extend of the bounding info
  7122. * @returns the current bounding info
  7123. */
  7124. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7125. /**
  7126. * Scale the current bounding info by applying a scale factor
  7127. * @param factor defines the scale factor to apply
  7128. * @returns the current bounding info
  7129. */
  7130. scale(factor: number): BoundingInfo;
  7131. /**
  7132. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7133. * @param frustumPlanes defines the frustum to test
  7134. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7135. * @returns true if the bounding info is in the frustum planes
  7136. */
  7137. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7138. /**
  7139. * Gets the world distance between the min and max points of the bounding box
  7140. */
  7141. get diagonalLength(): number;
  7142. /**
  7143. * Checks if a cullable object (mesh...) is in the camera frustum
  7144. * Unlike isInFrustum this cheks the full bounding box
  7145. * @param frustumPlanes Camera near/planes
  7146. * @returns true if the object is in frustum otherwise false
  7147. */
  7148. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7149. /** @hidden */
  7150. _checkCollision(collider: Collider): boolean;
  7151. /**
  7152. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7153. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7154. * @param point the point to check intersection with
  7155. * @returns if the point intersects
  7156. */
  7157. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7158. /**
  7159. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7160. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7161. * @param boundingInfo the bounding info to check intersection with
  7162. * @param precise if the intersection should be done using OBB
  7163. * @returns if the bounding info intersects
  7164. */
  7165. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7166. }
  7167. }
  7168. declare module "babylonjs/Maths/math.functions" {
  7169. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7170. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7171. /**
  7172. * Extracts minimum and maximum values from a list of indexed positions
  7173. * @param positions defines the positions to use
  7174. * @param indices defines the indices to the positions
  7175. * @param indexStart defines the start index
  7176. * @param indexCount defines the end index
  7177. * @param bias defines bias value to add to the result
  7178. * @return minimum and maximum values
  7179. */
  7180. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7181. minimum: Vector3;
  7182. maximum: Vector3;
  7183. };
  7184. /**
  7185. * Extracts minimum and maximum values from a list of positions
  7186. * @param positions defines the positions to use
  7187. * @param start defines the start index in the positions array
  7188. * @param count defines the number of positions to handle
  7189. * @param bias defines bias value to add to the result
  7190. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7191. * @return minimum and maximum values
  7192. */
  7193. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7194. minimum: Vector3;
  7195. maximum: Vector3;
  7196. };
  7197. }
  7198. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7200. /** @hidden */
  7201. export class WebGLDataBuffer extends DataBuffer {
  7202. private _buffer;
  7203. constructor(resource: WebGLBuffer);
  7204. get underlyingResource(): any;
  7205. }
  7206. }
  7207. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7208. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7209. import { Nullable } from "babylonjs/types";
  7210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7211. /** @hidden */
  7212. export class WebGLPipelineContext implements IPipelineContext {
  7213. engine: ThinEngine;
  7214. program: Nullable<WebGLProgram>;
  7215. context?: WebGLRenderingContext;
  7216. vertexShader?: WebGLShader;
  7217. fragmentShader?: WebGLShader;
  7218. isParallelCompiled: boolean;
  7219. onCompiled?: () => void;
  7220. transformFeedback?: WebGLTransformFeedback | null;
  7221. vertexCompilationError: Nullable<string>;
  7222. fragmentCompilationError: Nullable<string>;
  7223. programLinkError: Nullable<string>;
  7224. programValidationError: Nullable<string>;
  7225. get isAsync(): boolean;
  7226. get isReady(): boolean;
  7227. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7228. }
  7229. }
  7230. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7231. import { FloatArray, Nullable } from "babylonjs/types";
  7232. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7233. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7234. module "babylonjs/Engines/thinEngine" {
  7235. interface ThinEngine {
  7236. /**
  7237. * Create an uniform buffer
  7238. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7239. * @param elements defines the content of the uniform buffer
  7240. * @returns the webGL uniform buffer
  7241. */
  7242. createUniformBuffer(elements: FloatArray): DataBuffer;
  7243. /**
  7244. * Create a dynamic uniform buffer
  7245. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7246. * @param elements defines the content of the uniform buffer
  7247. * @returns the webGL uniform buffer
  7248. */
  7249. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7250. /**
  7251. * Update an existing uniform buffer
  7252. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7253. * @param uniformBuffer defines the target uniform buffer
  7254. * @param elements defines the content to update
  7255. * @param offset defines the offset in the uniform buffer where update should start
  7256. * @param count defines the size of the data to update
  7257. */
  7258. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7259. /**
  7260. * Bind an uniform buffer to the current webGL context
  7261. * @param buffer defines the buffer to bind
  7262. */
  7263. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7264. /**
  7265. * Bind a buffer to the current webGL context at a given location
  7266. * @param buffer defines the buffer to bind
  7267. * @param location defines the index where to bind the buffer
  7268. */
  7269. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7270. /**
  7271. * Bind a specific block at a given index in a specific shader program
  7272. * @param pipelineContext defines the pipeline context to use
  7273. * @param blockName defines the block name
  7274. * @param index defines the index where to bind the block
  7275. */
  7276. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7277. }
  7278. }
  7279. }
  7280. declare module "babylonjs/Materials/uniformBuffer" {
  7281. import { Nullable, FloatArray } from "babylonjs/types";
  7282. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7283. import { Engine } from "babylonjs/Engines/engine";
  7284. import { Effect } from "babylonjs/Materials/effect";
  7285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7287. import { Color3 } from "babylonjs/Maths/math.color";
  7288. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7289. /**
  7290. * Uniform buffer objects.
  7291. *
  7292. * Handles blocks of uniform on the GPU.
  7293. *
  7294. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7295. *
  7296. * For more information, please refer to :
  7297. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7298. */
  7299. export class UniformBuffer {
  7300. private _engine;
  7301. private _buffer;
  7302. private _data;
  7303. private _bufferData;
  7304. private _dynamic?;
  7305. private _uniformLocations;
  7306. private _uniformSizes;
  7307. private _uniformLocationPointer;
  7308. private _needSync;
  7309. private _noUBO;
  7310. private _currentEffect;
  7311. /** @hidden */
  7312. _alreadyBound: boolean;
  7313. private static _MAX_UNIFORM_SIZE;
  7314. private static _tempBuffer;
  7315. /**
  7316. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7321. /**
  7322. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7327. /**
  7328. * Lambda to Update a single float in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateFloat: (name: string, x: number) => void;
  7333. /**
  7334. * Lambda to Update a vec2 of float in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7339. /**
  7340. * Lambda to Update a vec3 of float in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update a vec4 of float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7351. /**
  7352. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateMatrix: (name: string, mat: Matrix) => void;
  7357. /**
  7358. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateVector3: (name: string, vector: Vector3) => void;
  7363. /**
  7364. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateVector4: (name: string, vector: Vector4) => void;
  7369. /**
  7370. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7375. /**
  7376. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7381. /**
  7382. * Instantiates a new Uniform buffer objects.
  7383. *
  7384. * Handles blocks of uniform on the GPU.
  7385. *
  7386. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7387. *
  7388. * For more information, please refer to :
  7389. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7390. * @param engine Define the engine the buffer is associated with
  7391. * @param data Define the data contained in the buffer
  7392. * @param dynamic Define if the buffer is updatable
  7393. */
  7394. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7395. /**
  7396. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7397. * or just falling back on setUniformXXX calls.
  7398. */
  7399. get useUbo(): boolean;
  7400. /**
  7401. * Indicates if the WebGL underlying uniform buffer is in sync
  7402. * with the javascript cache data.
  7403. */
  7404. get isSync(): boolean;
  7405. /**
  7406. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7407. * Also, a dynamic UniformBuffer will disable cache verification and always
  7408. * update the underlying WebGL uniform buffer to the GPU.
  7409. * @returns if Dynamic, otherwise false
  7410. */
  7411. isDynamic(): boolean;
  7412. /**
  7413. * The data cache on JS side.
  7414. * @returns the underlying data as a float array
  7415. */
  7416. getData(): Float32Array;
  7417. /**
  7418. * The underlying WebGL Uniform buffer.
  7419. * @returns the webgl buffer
  7420. */
  7421. getBuffer(): Nullable<DataBuffer>;
  7422. /**
  7423. * std140 layout specifies how to align data within an UBO structure.
  7424. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7425. * for specs.
  7426. */
  7427. private _fillAlignment;
  7428. /**
  7429. * Adds an uniform in the buffer.
  7430. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7431. * for the layout to be correct !
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. * @param size Data size, or data directly.
  7434. */
  7435. addUniform(name: string, size: number | number[]): void;
  7436. /**
  7437. * Adds a Matrix 4x4 to the uniform buffer.
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param mat A 4x4 matrix.
  7440. */
  7441. addMatrix(name: string, mat: Matrix): void;
  7442. /**
  7443. * Adds a vec2 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param x Define the x component value of the vec2
  7446. * @param y Define the y component value of the vec2
  7447. */
  7448. addFloat2(name: string, x: number, y: number): void;
  7449. /**
  7450. * Adds a vec3 to the uniform buffer.
  7451. * @param name Name of the uniform, as used in the uniform block in the shader.
  7452. * @param x Define the x component value of the vec3
  7453. * @param y Define the y component value of the vec3
  7454. * @param z Define the z component value of the vec3
  7455. */
  7456. addFloat3(name: string, x: number, y: number, z: number): void;
  7457. /**
  7458. * Adds a vec3 to the uniform buffer.
  7459. * @param name Name of the uniform, as used in the uniform block in the shader.
  7460. * @param color Define the vec3 from a Color
  7461. */
  7462. addColor3(name: string, color: Color3): void;
  7463. /**
  7464. * Adds a vec4 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. * @param color Define the rgb components from a Color
  7467. * @param alpha Define the a component of the vec4
  7468. */
  7469. addColor4(name: string, color: Color3, alpha: number): void;
  7470. /**
  7471. * Adds a vec3 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param vector Define the vec3 components from a Vector
  7474. */
  7475. addVector3(name: string, vector: Vector3): void;
  7476. /**
  7477. * Adds a Matrix 3x3 to the uniform buffer.
  7478. * @param name Name of the uniform, as used in the uniform block in the shader.
  7479. */
  7480. addMatrix3x3(name: string): void;
  7481. /**
  7482. * Adds a Matrix 2x2 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. */
  7485. addMatrix2x2(name: string): void;
  7486. /**
  7487. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7488. */
  7489. create(): void;
  7490. /** @hidden */
  7491. _rebuild(): void;
  7492. /**
  7493. * Updates the WebGL Uniform Buffer on the GPU.
  7494. * If the `dynamic` flag is set to true, no cache comparison is done.
  7495. * Otherwise, the buffer will be updated only if the cache differs.
  7496. */
  7497. update(): void;
  7498. /**
  7499. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. * @param size Define the size of the data.
  7503. */
  7504. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7505. private _valueCache;
  7506. private _cacheMatrix;
  7507. private _updateMatrix3x3ForUniform;
  7508. private _updateMatrix3x3ForEffect;
  7509. private _updateMatrix2x2ForEffect;
  7510. private _updateMatrix2x2ForUniform;
  7511. private _updateFloatForEffect;
  7512. private _updateFloatForUniform;
  7513. private _updateFloat2ForEffect;
  7514. private _updateFloat2ForUniform;
  7515. private _updateFloat3ForEffect;
  7516. private _updateFloat3ForUniform;
  7517. private _updateFloat4ForEffect;
  7518. private _updateFloat4ForUniform;
  7519. private _updateMatrixForEffect;
  7520. private _updateMatrixForUniform;
  7521. private _updateVector3ForEffect;
  7522. private _updateVector3ForUniform;
  7523. private _updateVector4ForEffect;
  7524. private _updateVector4ForUniform;
  7525. private _updateColor3ForEffect;
  7526. private _updateColor3ForUniform;
  7527. private _updateColor4ForEffect;
  7528. private _updateColor4ForUniform;
  7529. /**
  7530. * Sets a sampler uniform on the effect.
  7531. * @param name Define the name of the sampler.
  7532. * @param texture Define the texture to set in the sampler
  7533. */
  7534. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7535. /**
  7536. * Directly updates the value of the uniform in the cache AND on the GPU.
  7537. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7538. * @param data Define the flattened data
  7539. */
  7540. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7541. /**
  7542. * Binds this uniform buffer to an effect.
  7543. * @param effect Define the effect to bind the buffer to
  7544. * @param name Name of the uniform block in the shader.
  7545. */
  7546. bindToEffect(effect: Effect, name: string): void;
  7547. /**
  7548. * Disposes the uniform buffer.
  7549. */
  7550. dispose(): void;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/iInspectable" {
  7554. /**
  7555. * Enum that determines the text-wrapping mode to use.
  7556. */
  7557. export enum InspectableType {
  7558. /**
  7559. * Checkbox for booleans
  7560. */
  7561. Checkbox = 0,
  7562. /**
  7563. * Sliders for numbers
  7564. */
  7565. Slider = 1,
  7566. /**
  7567. * Vector3
  7568. */
  7569. Vector3 = 2,
  7570. /**
  7571. * Quaternions
  7572. */
  7573. Quaternion = 3,
  7574. /**
  7575. * Color3
  7576. */
  7577. Color3 = 4,
  7578. /**
  7579. * String
  7580. */
  7581. String = 5
  7582. }
  7583. /**
  7584. * Interface used to define custom inspectable properties.
  7585. * This interface is used by the inspector to display custom property grids
  7586. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7587. */
  7588. export interface IInspectable {
  7589. /**
  7590. * Gets the label to display
  7591. */
  7592. label: string;
  7593. /**
  7594. * Gets the name of the property to edit
  7595. */
  7596. propertyName: string;
  7597. /**
  7598. * Gets the type of the editor to use
  7599. */
  7600. type: InspectableType;
  7601. /**
  7602. * Gets the minimum value of the property when using in "slider" mode
  7603. */
  7604. min?: number;
  7605. /**
  7606. * Gets the maximum value of the property when using in "slider" mode
  7607. */
  7608. max?: number;
  7609. /**
  7610. * Gets the setp to use when using in "slider" mode
  7611. */
  7612. step?: number;
  7613. }
  7614. }
  7615. declare module "babylonjs/Misc/timingTools" {
  7616. /**
  7617. * Class used to provide helper for timing
  7618. */
  7619. export class TimingTools {
  7620. /**
  7621. * Polyfill for setImmediate
  7622. * @param action defines the action to execute after the current execution block
  7623. */
  7624. static SetImmediate(action: () => void): void;
  7625. }
  7626. }
  7627. declare module "babylonjs/Misc/instantiationTools" {
  7628. /**
  7629. * Class used to enable instatition of objects by class name
  7630. */
  7631. export class InstantiationTools {
  7632. /**
  7633. * Use this object to register external classes like custom textures or material
  7634. * to allow the laoders to instantiate them
  7635. */
  7636. static RegisteredExternalClasses: {
  7637. [key: string]: Object;
  7638. };
  7639. /**
  7640. * Tries to instantiate a new object from a given class name
  7641. * @param className defines the class name to instantiate
  7642. * @returns the new object or null if the system was not able to do the instantiation
  7643. */
  7644. static Instantiate(className: string): any;
  7645. }
  7646. }
  7647. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7648. /**
  7649. * Define options used to create a depth texture
  7650. */
  7651. export class DepthTextureCreationOptions {
  7652. /** Specifies whether or not a stencil should be allocated in the texture */
  7653. generateStencil?: boolean;
  7654. /** Specifies whether or not bilinear filtering is enable on the texture */
  7655. bilinearFiltering?: boolean;
  7656. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7657. comparisonFunction?: number;
  7658. /** Specifies if the created texture is a cube texture */
  7659. isCube?: boolean;
  7660. }
  7661. }
  7662. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7664. import { Nullable } from "babylonjs/types";
  7665. import { Scene } from "babylonjs/scene";
  7666. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7667. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7668. module "babylonjs/Engines/thinEngine" {
  7669. interface ThinEngine {
  7670. /**
  7671. * Creates a depth stencil cube texture.
  7672. * This is only available in WebGL 2.
  7673. * @param size The size of face edge in the cube texture.
  7674. * @param options The options defining the cube texture.
  7675. * @returns The cube texture
  7676. */
  7677. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7678. /**
  7679. * Creates a cube texture
  7680. * @param rootUrl defines the url where the files to load is located
  7681. * @param scene defines the current scene
  7682. * @param files defines the list of files to load (1 per face)
  7683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7684. * @param onLoad defines an optional callback raised when the texture is loaded
  7685. * @param onError defines an optional callback raised if there is an issue to load the texture
  7686. * @param format defines the format of the data
  7687. * @param forcedExtension defines the extension to use to pick the right loader
  7688. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7691. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7692. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7693. * @returns the cube texture as an InternalTexture
  7694. */
  7695. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7696. /**
  7697. * Creates a cube texture
  7698. * @param rootUrl defines the url where the files to load is located
  7699. * @param scene defines the current scene
  7700. * @param files defines the list of files to load (1 per face)
  7701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7702. * @param onLoad defines an optional callback raised when the texture is loaded
  7703. * @param onError defines an optional callback raised if there is an issue to load the texture
  7704. * @param format defines the format of the data
  7705. * @param forcedExtension defines the extension to use to pick the right loader
  7706. * @returns the cube texture as an InternalTexture
  7707. */
  7708. 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;
  7709. /**
  7710. * Creates a cube texture
  7711. * @param rootUrl defines the url where the files to load is located
  7712. * @param scene defines the current scene
  7713. * @param files defines the list of files to load (1 per face)
  7714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7715. * @param onLoad defines an optional callback raised when the texture is loaded
  7716. * @param onError defines an optional callback raised if there is an issue to load the texture
  7717. * @param format defines the format of the data
  7718. * @param forcedExtension defines the extension to use to pick the right loader
  7719. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7725. /** @hidden */
  7726. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7727. /** @hidden */
  7728. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7729. /** @hidden */
  7730. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7731. /** @hidden */
  7732. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7733. /**
  7734. * @hidden
  7735. */
  7736. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7737. }
  7738. }
  7739. }
  7740. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7741. import { Nullable } from "babylonjs/types";
  7742. import { Scene } from "babylonjs/scene";
  7743. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7745. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. set boundingBoxSize(value: Vector3);
  7769. /**
  7770. * Returns the bounding box size
  7771. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7772. */
  7773. get boundingBoxSize(): Vector3;
  7774. protected _rotationY: number;
  7775. /**
  7776. * Sets texture matrix rotation angle around Y axis in radians.
  7777. */
  7778. set rotationY(value: number);
  7779. /**
  7780. * Gets texture matrix rotation angle around Y axis radians.
  7781. */
  7782. get rotationY(): number;
  7783. /**
  7784. * Are mip maps generated for this texture or not.
  7785. */
  7786. get noMipmap(): boolean;
  7787. private _noMipmap;
  7788. private _files;
  7789. protected _forcedExtension: Nullable<string>;
  7790. private _extensions;
  7791. private _textureMatrix;
  7792. private _format;
  7793. private _createPolynomials;
  7794. /** @hidden */
  7795. _prefiltered: boolean;
  7796. /**
  7797. * Creates a cube texture from an array of image urls
  7798. * @param files defines an array of image urls
  7799. * @param scene defines the hosting scene
  7800. * @param noMipmap specifies if mip maps are not used
  7801. * @returns a cube texture
  7802. */
  7803. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7804. /**
  7805. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7806. * @param url defines the url of the prefiltered texture
  7807. * @param scene defines the scene the texture is attached to
  7808. * @param forcedExtension defines the extension of the file if different from the url
  7809. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7810. * @return the prefiltered texture
  7811. */
  7812. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7813. /**
  7814. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7815. * as prefiltered data.
  7816. * @param rootUrl defines the url of the texture or the root name of the six images
  7817. * @param scene defines the scene the texture is attached to
  7818. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7819. * @param noMipmap defines if mipmaps should be created or not
  7820. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7821. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7822. * @param onError defines a callback triggered in case of error during load
  7823. * @param format defines the internal format to use for the texture once loaded
  7824. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7825. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7826. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7827. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7828. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7829. * @return the cube texture
  7830. */
  7831. 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);
  7832. /**
  7833. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7834. */
  7835. get isPrefiltered(): boolean;
  7836. /**
  7837. * Get the current class name of the texture useful for serialization or dynamic coding.
  7838. * @returns "CubeTexture"
  7839. */
  7840. getClassName(): string;
  7841. /**
  7842. * Update the url (and optional buffer) of this texture if url was null during construction.
  7843. * @param url the url of the texture
  7844. * @param forcedExtension defines the extension to use
  7845. * @param onLoad callback called when the texture is loaded (defaults to null)
  7846. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7847. */
  7848. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7849. /**
  7850. * Delays loading of the cube texture
  7851. * @param forcedExtension defines the extension to use
  7852. */
  7853. delayLoad(forcedExtension?: string): void;
  7854. /**
  7855. * Returns the reflection texture matrix
  7856. * @returns the reflection texture matrix
  7857. */
  7858. getReflectionTextureMatrix(): Matrix;
  7859. /**
  7860. * Sets the reflection texture matrix
  7861. * @param value Reflection texture matrix
  7862. */
  7863. setReflectionTextureMatrix(value: Matrix): void;
  7864. /**
  7865. * Parses text to create a cube texture
  7866. * @param parsedTexture define the serialized text to read from
  7867. * @param scene defines the hosting scene
  7868. * @param rootUrl defines the root url of the cube texture
  7869. * @returns a cube texture
  7870. */
  7871. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7872. /**
  7873. * Makes a clone, or deep copy, of the cube texture
  7874. * @returns a new cube texture
  7875. */
  7876. clone(): CubeTexture;
  7877. }
  7878. }
  7879. declare module "babylonjs/Materials/materialDefines" {
  7880. /**
  7881. * Manages the defines for the Material
  7882. */
  7883. export class MaterialDefines {
  7884. /** @hidden */
  7885. protected _keys: string[];
  7886. private _isDirty;
  7887. /** @hidden */
  7888. _renderId: number;
  7889. /** @hidden */
  7890. _areLightsDirty: boolean;
  7891. /** @hidden */
  7892. _areLightsDisposed: boolean;
  7893. /** @hidden */
  7894. _areAttributesDirty: boolean;
  7895. /** @hidden */
  7896. _areTexturesDirty: boolean;
  7897. /** @hidden */
  7898. _areFresnelDirty: boolean;
  7899. /** @hidden */
  7900. _areMiscDirty: boolean;
  7901. /** @hidden */
  7902. _areImageProcessingDirty: boolean;
  7903. /** @hidden */
  7904. _normals: boolean;
  7905. /** @hidden */
  7906. _uvs: boolean;
  7907. /** @hidden */
  7908. _needNormals: boolean;
  7909. /** @hidden */
  7910. _needUVs: boolean;
  7911. [id: string]: any;
  7912. /**
  7913. * Specifies if the material needs to be re-calculated
  7914. */
  7915. get isDirty(): boolean;
  7916. /**
  7917. * Marks the material to indicate that it has been re-calculated
  7918. */
  7919. markAsProcessed(): void;
  7920. /**
  7921. * Marks the material to indicate that it needs to be re-calculated
  7922. */
  7923. markAsUnprocessed(): void;
  7924. /**
  7925. * Marks the material to indicate all of its defines need to be re-calculated
  7926. */
  7927. markAllAsDirty(): void;
  7928. /**
  7929. * Marks the material to indicate that image processing needs to be re-calculated
  7930. */
  7931. markAsImageProcessingDirty(): void;
  7932. /**
  7933. * Marks the material to indicate the lights need to be re-calculated
  7934. * @param disposed Defines whether the light is dirty due to dispose or not
  7935. */
  7936. markAsLightDirty(disposed?: boolean): void;
  7937. /**
  7938. * Marks the attribute state as changed
  7939. */
  7940. markAsAttributesDirty(): void;
  7941. /**
  7942. * Marks the texture state as changed
  7943. */
  7944. markAsTexturesDirty(): void;
  7945. /**
  7946. * Marks the fresnel state as changed
  7947. */
  7948. markAsFresnelDirty(): void;
  7949. /**
  7950. * Marks the misc state as changed
  7951. */
  7952. markAsMiscDirty(): void;
  7953. /**
  7954. * Rebuilds the material defines
  7955. */
  7956. rebuild(): void;
  7957. /**
  7958. * Specifies if two material defines are equal
  7959. * @param other - A material define instance to compare to
  7960. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7961. */
  7962. isEqual(other: MaterialDefines): boolean;
  7963. /**
  7964. * Clones this instance's defines to another instance
  7965. * @param other - material defines to clone values to
  7966. */
  7967. cloneTo(other: MaterialDefines): void;
  7968. /**
  7969. * Resets the material define values
  7970. */
  7971. reset(): void;
  7972. /**
  7973. * Converts the material define values to a string
  7974. * @returns - String of material define information
  7975. */
  7976. toString(): string;
  7977. }
  7978. }
  7979. declare module "babylonjs/Materials/colorCurves" {
  7980. import { Effect } from "babylonjs/Materials/effect";
  7981. /**
  7982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7984. * 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;
  7985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7986. */
  7987. export class ColorCurves {
  7988. private _dirty;
  7989. private _tempColor;
  7990. private _globalCurve;
  7991. private _highlightsCurve;
  7992. private _midtonesCurve;
  7993. private _shadowsCurve;
  7994. private _positiveCurve;
  7995. private _negativeCurve;
  7996. private _globalHue;
  7997. private _globalDensity;
  7998. private _globalSaturation;
  7999. private _globalExposure;
  8000. /**
  8001. * Gets the global Hue value.
  8002. * 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).
  8003. */
  8004. get globalHue(): number;
  8005. /**
  8006. * Sets the global Hue value.
  8007. * 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).
  8008. */
  8009. set globalHue(value: number);
  8010. /**
  8011. * Gets the global Density value.
  8012. * 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.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get globalDensity(): number;
  8016. /**
  8017. * Sets the global Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set globalDensity(value: number);
  8022. /**
  8023. * Gets the global Saturation value.
  8024. * 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.
  8025. */
  8026. get globalSaturation(): number;
  8027. /**
  8028. * Sets the global Saturation value.
  8029. * 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.
  8030. */
  8031. set globalSaturation(value: number);
  8032. /**
  8033. * Gets the global Exposure value.
  8034. * 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.
  8035. */
  8036. get globalExposure(): number;
  8037. /**
  8038. * Sets the global Exposure value.
  8039. * 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.
  8040. */
  8041. set globalExposure(value: number);
  8042. private _highlightsHue;
  8043. private _highlightsDensity;
  8044. private _highlightsSaturation;
  8045. private _highlightsExposure;
  8046. /**
  8047. * Gets the highlights Hue value.
  8048. * 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).
  8049. */
  8050. get highlightsHue(): number;
  8051. /**
  8052. * Sets the highlights Hue value.
  8053. * 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).
  8054. */
  8055. set highlightsHue(value: number);
  8056. /**
  8057. * Gets the highlights Density value.
  8058. * 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.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get highlightsDensity(): number;
  8062. /**
  8063. * Sets the highlights Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set highlightsDensity(value: number);
  8068. /**
  8069. * Gets the highlights Saturation value.
  8070. * 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.
  8071. */
  8072. get highlightsSaturation(): number;
  8073. /**
  8074. * Sets the highlights Saturation value.
  8075. * 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.
  8076. */
  8077. set highlightsSaturation(value: number);
  8078. /**
  8079. * Gets the highlights Exposure value.
  8080. * 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.
  8081. */
  8082. get highlightsExposure(): number;
  8083. /**
  8084. * Sets the highlights Exposure value.
  8085. * 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.
  8086. */
  8087. set highlightsExposure(value: number);
  8088. private _midtonesHue;
  8089. private _midtonesDensity;
  8090. private _midtonesSaturation;
  8091. private _midtonesExposure;
  8092. /**
  8093. * Gets the midtones Hue value.
  8094. * 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).
  8095. */
  8096. get midtonesHue(): number;
  8097. /**
  8098. * Sets the midtones Hue value.
  8099. * 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).
  8100. */
  8101. set midtonesHue(value: number);
  8102. /**
  8103. * Gets the midtones Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get midtonesDensity(): number;
  8108. /**
  8109. * Sets the midtones Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set midtonesDensity(value: number);
  8114. /**
  8115. * Gets the midtones Saturation value.
  8116. * 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.
  8117. */
  8118. get midtonesSaturation(): number;
  8119. /**
  8120. * Sets the midtones Saturation value.
  8121. * 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.
  8122. */
  8123. set midtonesSaturation(value: number);
  8124. /**
  8125. * Gets the midtones Exposure value.
  8126. * 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.
  8127. */
  8128. get midtonesExposure(): number;
  8129. /**
  8130. * Sets the midtones Exposure value.
  8131. * 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.
  8132. */
  8133. set midtonesExposure(value: number);
  8134. private _shadowsHue;
  8135. private _shadowsDensity;
  8136. private _shadowsSaturation;
  8137. private _shadowsExposure;
  8138. /**
  8139. * Gets the shadows Hue value.
  8140. * 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).
  8141. */
  8142. get shadowsHue(): number;
  8143. /**
  8144. * Sets the shadows Hue value.
  8145. * 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).
  8146. */
  8147. set shadowsHue(value: number);
  8148. /**
  8149. * Gets the shadows Density value.
  8150. * 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.
  8151. * Values less than zero provide a filter of opposite hue.
  8152. */
  8153. get shadowsDensity(): number;
  8154. /**
  8155. * Sets the shadows Density value.
  8156. * 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.
  8157. * Values less than zero provide a filter of opposite hue.
  8158. */
  8159. set shadowsDensity(value: number);
  8160. /**
  8161. * Gets the shadows Saturation value.
  8162. * 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.
  8163. */
  8164. get shadowsSaturation(): number;
  8165. /**
  8166. * Sets the shadows Saturation value.
  8167. * 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.
  8168. */
  8169. set shadowsSaturation(value: number);
  8170. /**
  8171. * Gets the shadows Exposure value.
  8172. * 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.
  8173. */
  8174. get shadowsExposure(): number;
  8175. /**
  8176. * Sets the shadows Exposure value.
  8177. * 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.
  8178. */
  8179. set shadowsExposure(value: number);
  8180. /**
  8181. * Returns the class name
  8182. * @returns The class name
  8183. */
  8184. getClassName(): string;
  8185. /**
  8186. * Binds the color curves to the shader.
  8187. * @param colorCurves The color curve to bind
  8188. * @param effect The effect to bind to
  8189. * @param positiveUniform The positive uniform shader parameter
  8190. * @param neutralUniform The neutral uniform shader parameter
  8191. * @param negativeUniform The negative uniform shader parameter
  8192. */
  8193. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8194. /**
  8195. * Prepare the list of uniforms associated with the ColorCurves effects.
  8196. * @param uniformsList The list of uniforms used in the effect
  8197. */
  8198. static PrepareUniforms(uniformsList: string[]): void;
  8199. /**
  8200. * Returns color grading data based on a hue, density, saturation and exposure value.
  8201. * @param filterHue The hue of the color filter.
  8202. * @param filterDensity The density of the color filter.
  8203. * @param saturation The saturation.
  8204. * @param exposure The exposure.
  8205. * @param result The result data container.
  8206. */
  8207. private getColorGradingDataToRef;
  8208. /**
  8209. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8210. * @param value The input slider value in range [-100,100].
  8211. * @returns Adjusted value.
  8212. */
  8213. private static applyColorGradingSliderNonlinear;
  8214. /**
  8215. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8216. * @param hue The hue (H) input.
  8217. * @param saturation The saturation (S) input.
  8218. * @param brightness The brightness (B) input.
  8219. * @result An RGBA color represented as Vector4.
  8220. */
  8221. private static fromHSBToRef;
  8222. /**
  8223. * Returns a value clamped between min and max
  8224. * @param value The value to clamp
  8225. * @param min The minimum of value
  8226. * @param max The maximum of value
  8227. * @returns The clamped value.
  8228. */
  8229. private static clamp;
  8230. /**
  8231. * Clones the current color curve instance.
  8232. * @return The cloned curves
  8233. */
  8234. clone(): ColorCurves;
  8235. /**
  8236. * Serializes the current color curve instance to a json representation.
  8237. * @return a JSON representation
  8238. */
  8239. serialize(): any;
  8240. /**
  8241. * Parses the color curve from a json representation.
  8242. * @param source the JSON source to parse
  8243. * @return The parsed curves
  8244. */
  8245. static Parse(source: any): ColorCurves;
  8246. }
  8247. }
  8248. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8249. import { Observable } from "babylonjs/Misc/observable";
  8250. import { Nullable } from "babylonjs/types";
  8251. import { Color4 } from "babylonjs/Maths/math.color";
  8252. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8253. import { Effect } from "babylonjs/Materials/effect";
  8254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8255. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8256. /**
  8257. * Interface to follow in your material defines to integrate easily the
  8258. * Image proccessing functions.
  8259. * @hidden
  8260. */
  8261. export interface IImageProcessingConfigurationDefines {
  8262. IMAGEPROCESSING: boolean;
  8263. VIGNETTE: boolean;
  8264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8265. VIGNETTEBLENDMODEOPAQUE: boolean;
  8266. TONEMAPPING: boolean;
  8267. TONEMAPPING_ACES: boolean;
  8268. CONTRAST: boolean;
  8269. EXPOSURE: boolean;
  8270. COLORCURVES: boolean;
  8271. COLORGRADING: boolean;
  8272. COLORGRADING3D: boolean;
  8273. SAMPLER3DGREENDEPTH: boolean;
  8274. SAMPLER3DBGRMAP: boolean;
  8275. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8276. }
  8277. /**
  8278. * @hidden
  8279. */
  8280. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8281. IMAGEPROCESSING: boolean;
  8282. VIGNETTE: boolean;
  8283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8284. VIGNETTEBLENDMODEOPAQUE: boolean;
  8285. TONEMAPPING: boolean;
  8286. TONEMAPPING_ACES: boolean;
  8287. CONTRAST: boolean;
  8288. COLORCURVES: boolean;
  8289. COLORGRADING: boolean;
  8290. COLORGRADING3D: boolean;
  8291. SAMPLER3DGREENDEPTH: boolean;
  8292. SAMPLER3DBGRMAP: boolean;
  8293. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8294. EXPOSURE: boolean;
  8295. constructor();
  8296. }
  8297. /**
  8298. * This groups together the common properties used for image processing either in direct forward pass
  8299. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8300. * or not.
  8301. */
  8302. export class ImageProcessingConfiguration {
  8303. /**
  8304. * Default tone mapping applied in BabylonJS.
  8305. */
  8306. static readonly TONEMAPPING_STANDARD: number;
  8307. /**
  8308. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8309. * to other engines rendering to increase portability.
  8310. */
  8311. static readonly TONEMAPPING_ACES: number;
  8312. /**
  8313. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8314. */
  8315. colorCurves: Nullable<ColorCurves>;
  8316. private _colorCurvesEnabled;
  8317. /**
  8318. * Gets wether the color curves effect is enabled.
  8319. */
  8320. get colorCurvesEnabled(): boolean;
  8321. /**
  8322. * Sets wether the color curves effect is enabled.
  8323. */
  8324. set colorCurvesEnabled(value: boolean);
  8325. private _colorGradingTexture;
  8326. /**
  8327. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8328. */
  8329. get colorGradingTexture(): Nullable<BaseTexture>;
  8330. /**
  8331. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8332. */
  8333. set colorGradingTexture(value: Nullable<BaseTexture>);
  8334. private _colorGradingEnabled;
  8335. /**
  8336. * Gets wether the color grading effect is enabled.
  8337. */
  8338. get colorGradingEnabled(): boolean;
  8339. /**
  8340. * Sets wether the color grading effect is enabled.
  8341. */
  8342. set colorGradingEnabled(value: boolean);
  8343. private _colorGradingWithGreenDepth;
  8344. /**
  8345. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8346. */
  8347. get colorGradingWithGreenDepth(): boolean;
  8348. /**
  8349. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8350. */
  8351. set colorGradingWithGreenDepth(value: boolean);
  8352. private _colorGradingBGR;
  8353. /**
  8354. * Gets wether the color grading texture contains BGR values.
  8355. */
  8356. get colorGradingBGR(): boolean;
  8357. /**
  8358. * Sets wether the color grading texture contains BGR values.
  8359. */
  8360. set colorGradingBGR(value: boolean);
  8361. /** @hidden */
  8362. _exposure: number;
  8363. /**
  8364. * Gets the Exposure used in the effect.
  8365. */
  8366. get exposure(): number;
  8367. /**
  8368. * Sets the Exposure used in the effect.
  8369. */
  8370. set exposure(value: number);
  8371. private _toneMappingEnabled;
  8372. /**
  8373. * Gets wether the tone mapping effect is enabled.
  8374. */
  8375. get toneMappingEnabled(): boolean;
  8376. /**
  8377. * Sets wether the tone mapping effect is enabled.
  8378. */
  8379. set toneMappingEnabled(value: boolean);
  8380. private _toneMappingType;
  8381. /**
  8382. * Gets the type of tone mapping effect.
  8383. */
  8384. get toneMappingType(): number;
  8385. /**
  8386. * Sets the type of tone mapping effect used in BabylonJS.
  8387. */
  8388. set toneMappingType(value: number);
  8389. protected _contrast: number;
  8390. /**
  8391. * Gets the contrast used in the effect.
  8392. */
  8393. get contrast(): number;
  8394. /**
  8395. * Sets the contrast used in the effect.
  8396. */
  8397. set contrast(value: number);
  8398. /**
  8399. * Vignette stretch size.
  8400. */
  8401. vignetteStretch: number;
  8402. /**
  8403. * Vignette centre X Offset.
  8404. */
  8405. vignetteCentreX: number;
  8406. /**
  8407. * Vignette centre Y Offset.
  8408. */
  8409. vignetteCentreY: number;
  8410. /**
  8411. * Vignette weight or intensity of the vignette effect.
  8412. */
  8413. vignetteWeight: number;
  8414. /**
  8415. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8416. * if vignetteEnabled is set to true.
  8417. */
  8418. vignetteColor: Color4;
  8419. /**
  8420. * Camera field of view used by the Vignette effect.
  8421. */
  8422. vignetteCameraFov: number;
  8423. private _vignetteBlendMode;
  8424. /**
  8425. * Gets the vignette blend mode allowing different kind of effect.
  8426. */
  8427. get vignetteBlendMode(): number;
  8428. /**
  8429. * Sets the vignette blend mode allowing different kind of effect.
  8430. */
  8431. set vignetteBlendMode(value: number);
  8432. private _vignetteEnabled;
  8433. /**
  8434. * Gets wether the vignette effect is enabled.
  8435. */
  8436. get vignetteEnabled(): boolean;
  8437. /**
  8438. * Sets wether the vignette effect is enabled.
  8439. */
  8440. set vignetteEnabled(value: boolean);
  8441. private _applyByPostProcess;
  8442. /**
  8443. * Gets wether the image processing is applied through a post process or not.
  8444. */
  8445. get applyByPostProcess(): boolean;
  8446. /**
  8447. * Sets wether the image processing is applied through a post process or not.
  8448. */
  8449. set applyByPostProcess(value: boolean);
  8450. private _isEnabled;
  8451. /**
  8452. * Gets wether the image processing is enabled or not.
  8453. */
  8454. get isEnabled(): boolean;
  8455. /**
  8456. * Sets wether the image processing is enabled or not.
  8457. */
  8458. set isEnabled(value: boolean);
  8459. /**
  8460. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8461. */
  8462. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8463. /**
  8464. * Method called each time the image processing information changes requires to recompile the effect.
  8465. */
  8466. protected _updateParameters(): void;
  8467. /**
  8468. * Gets the current class name.
  8469. * @return "ImageProcessingConfiguration"
  8470. */
  8471. getClassName(): string;
  8472. /**
  8473. * Prepare the list of uniforms associated with the Image Processing effects.
  8474. * @param uniforms The list of uniforms used in the effect
  8475. * @param defines the list of defines currently in use
  8476. */
  8477. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8478. /**
  8479. * Prepare the list of samplers associated with the Image Processing effects.
  8480. * @param samplersList The list of uniforms used in the effect
  8481. * @param defines the list of defines currently in use
  8482. */
  8483. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8484. /**
  8485. * Prepare the list of defines associated to the shader.
  8486. * @param defines the list of defines to complete
  8487. * @param forPostProcess Define if we are currently in post process mode or not
  8488. */
  8489. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8490. /**
  8491. * Returns true if all the image processing information are ready.
  8492. * @returns True if ready, otherwise, false
  8493. */
  8494. isReady(): boolean;
  8495. /**
  8496. * Binds the image processing to the shader.
  8497. * @param effect The effect to bind to
  8498. * @param overrideAspectRatio Override the aspect ratio of the effect
  8499. */
  8500. bind(effect: Effect, overrideAspectRatio?: number): void;
  8501. /**
  8502. * Clones the current image processing instance.
  8503. * @return The cloned image processing
  8504. */
  8505. clone(): ImageProcessingConfiguration;
  8506. /**
  8507. * Serializes the current image processing instance to a json representation.
  8508. * @return a JSON representation
  8509. */
  8510. serialize(): any;
  8511. /**
  8512. * Parses the image processing from a json representation.
  8513. * @param source the JSON source to parse
  8514. * @return The parsed image processing
  8515. */
  8516. static Parse(source: any): ImageProcessingConfiguration;
  8517. private static _VIGNETTEMODE_MULTIPLY;
  8518. private static _VIGNETTEMODE_OPAQUE;
  8519. /**
  8520. * Used to apply the vignette as a mix with the pixel color.
  8521. */
  8522. static get VIGNETTEMODE_MULTIPLY(): number;
  8523. /**
  8524. * Used to apply the vignette as a replacement of the pixel color.
  8525. */
  8526. static get VIGNETTEMODE_OPAQUE(): number;
  8527. }
  8528. }
  8529. declare module "babylonjs/Shaders/postprocess.vertex" {
  8530. /** @hidden */
  8531. export var postprocessVertexShader: {
  8532. name: string;
  8533. shader: string;
  8534. };
  8535. }
  8536. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8538. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8539. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8540. module "babylonjs/Engines/thinEngine" {
  8541. interface ThinEngine {
  8542. /**
  8543. * Creates a new render target texture
  8544. * @param size defines the size of the texture
  8545. * @param options defines the options used to create the texture
  8546. * @returns a new render target texture stored in an InternalTexture
  8547. */
  8548. createRenderTargetTexture(size: number | {
  8549. width: number;
  8550. height: number;
  8551. layers?: number;
  8552. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8553. /**
  8554. * Creates a depth stencil texture.
  8555. * This is only available in WebGL 2 or with the depth texture extension available.
  8556. * @param size The size of face edge in the texture.
  8557. * @param options The options defining the texture.
  8558. * @returns The texture
  8559. */
  8560. createDepthStencilTexture(size: number | {
  8561. width: number;
  8562. height: number;
  8563. layers?: number;
  8564. }, options: DepthTextureCreationOptions): InternalTexture;
  8565. /** @hidden */
  8566. _createDepthStencilTexture(size: number | {
  8567. width: number;
  8568. height: number;
  8569. layers?: number;
  8570. }, options: DepthTextureCreationOptions): InternalTexture;
  8571. }
  8572. }
  8573. }
  8574. declare module "babylonjs/Maths/math.axis" {
  8575. import { Vector3 } from "babylonjs/Maths/math.vector";
  8576. /** Defines supported spaces */
  8577. export enum Space {
  8578. /** Local (object) space */
  8579. LOCAL = 0,
  8580. /** World space */
  8581. WORLD = 1,
  8582. /** Bone space */
  8583. BONE = 2
  8584. }
  8585. /** Defines the 3 main axes */
  8586. export class Axis {
  8587. /** X axis */
  8588. static X: Vector3;
  8589. /** Y axis */
  8590. static Y: Vector3;
  8591. /** Z axis */
  8592. static Z: Vector3;
  8593. }
  8594. }
  8595. declare module "babylonjs/Cameras/targetCamera" {
  8596. import { Nullable } from "babylonjs/types";
  8597. import { Camera } from "babylonjs/Cameras/camera";
  8598. import { Scene } from "babylonjs/scene";
  8599. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8600. /**
  8601. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8602. * This is the base of the follow, arc rotate cameras and Free camera
  8603. * @see http://doc.babylonjs.com/features/cameras
  8604. */
  8605. export class TargetCamera extends Camera {
  8606. private static _RigCamTransformMatrix;
  8607. private static _TargetTransformMatrix;
  8608. private static _TargetFocalPoint;
  8609. /**
  8610. * Define the current direction the camera is moving to
  8611. */
  8612. cameraDirection: Vector3;
  8613. /**
  8614. * Define the current rotation the camera is rotating to
  8615. */
  8616. cameraRotation: Vector2;
  8617. /**
  8618. * When set, the up vector of the camera will be updated by the rotation of the camera
  8619. */
  8620. updateUpVectorFromRotation: boolean;
  8621. private _tmpQuaternion;
  8622. /**
  8623. * Define the current rotation of the camera
  8624. */
  8625. rotation: Vector3;
  8626. /**
  8627. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8628. */
  8629. rotationQuaternion: Quaternion;
  8630. /**
  8631. * Define the current speed of the camera
  8632. */
  8633. speed: number;
  8634. /**
  8635. * Add constraint to the camera to prevent it to move freely in all directions and
  8636. * around all axis.
  8637. */
  8638. noRotationConstraint: boolean;
  8639. /**
  8640. * Define the current target of the camera as an object or a position.
  8641. */
  8642. lockedTarget: any;
  8643. /** @hidden */
  8644. _currentTarget: Vector3;
  8645. /** @hidden */
  8646. _initialFocalDistance: number;
  8647. /** @hidden */
  8648. _viewMatrix: Matrix;
  8649. /** @hidden */
  8650. _camMatrix: Matrix;
  8651. /** @hidden */
  8652. _cameraTransformMatrix: Matrix;
  8653. /** @hidden */
  8654. _cameraRotationMatrix: Matrix;
  8655. /** @hidden */
  8656. _referencePoint: Vector3;
  8657. /** @hidden */
  8658. _transformedReferencePoint: Vector3;
  8659. protected _globalCurrentTarget: Vector3;
  8660. protected _globalCurrentUpVector: Vector3;
  8661. /** @hidden */
  8662. _reset: () => void;
  8663. private _defaultUp;
  8664. /**
  8665. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8666. * This is the base of the follow, arc rotate cameras and Free camera
  8667. * @see http://doc.babylonjs.com/features/cameras
  8668. * @param name Defines the name of the camera in the scene
  8669. * @param position Defines the start position of the camera in the scene
  8670. * @param scene Defines the scene the camera belongs to
  8671. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8672. */
  8673. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8674. /**
  8675. * Gets the position in front of the camera at a given distance.
  8676. * @param distance The distance from the camera we want the position to be
  8677. * @returns the position
  8678. */
  8679. getFrontPosition(distance: number): Vector3;
  8680. /** @hidden */
  8681. _getLockedTargetPosition(): Nullable<Vector3>;
  8682. private _storedPosition;
  8683. private _storedRotation;
  8684. private _storedRotationQuaternion;
  8685. /**
  8686. * Store current camera state of the camera (fov, position, rotation, etc..)
  8687. * @returns the camera
  8688. */
  8689. storeState(): Camera;
  8690. /**
  8691. * Restored camera state. You must call storeState() first
  8692. * @returns whether it was successful or not
  8693. * @hidden
  8694. */
  8695. _restoreStateValues(): boolean;
  8696. /** @hidden */
  8697. _initCache(): void;
  8698. /** @hidden */
  8699. _updateCache(ignoreParentClass?: boolean): void;
  8700. /** @hidden */
  8701. _isSynchronizedViewMatrix(): boolean;
  8702. /** @hidden */
  8703. _computeLocalCameraSpeed(): number;
  8704. /**
  8705. * Defines the target the camera should look at.
  8706. * @param target Defines the new target as a Vector or a mesh
  8707. */
  8708. setTarget(target: Vector3): void;
  8709. /**
  8710. * Return the current target position of the camera. This value is expressed in local space.
  8711. * @returns the target position
  8712. */
  8713. getTarget(): Vector3;
  8714. /** @hidden */
  8715. _decideIfNeedsToMove(): boolean;
  8716. /** @hidden */
  8717. _updatePosition(): void;
  8718. /** @hidden */
  8719. _checkInputs(): void;
  8720. protected _updateCameraRotationMatrix(): void;
  8721. /**
  8722. * 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)
  8723. * @returns the current camera
  8724. */
  8725. private _rotateUpVectorWithCameraRotationMatrix;
  8726. private _cachedRotationZ;
  8727. private _cachedQuaternionRotationZ;
  8728. /** @hidden */
  8729. _getViewMatrix(): Matrix;
  8730. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8731. /**
  8732. * @hidden
  8733. */
  8734. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8735. /**
  8736. * @hidden
  8737. */
  8738. _updateRigCameras(): void;
  8739. private _getRigCamPositionAndTarget;
  8740. /**
  8741. * Gets the current object class name.
  8742. * @return the class name
  8743. */
  8744. getClassName(): string;
  8745. }
  8746. }
  8747. declare module "babylonjs/Events/keyboardEvents" {
  8748. /**
  8749. * Gather the list of keyboard event types as constants.
  8750. */
  8751. export class KeyboardEventTypes {
  8752. /**
  8753. * The keydown event is fired when a key becomes active (pressed).
  8754. */
  8755. static readonly KEYDOWN: number;
  8756. /**
  8757. * The keyup event is fired when a key has been released.
  8758. */
  8759. static readonly KEYUP: number;
  8760. }
  8761. /**
  8762. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8763. */
  8764. export class KeyboardInfo {
  8765. /**
  8766. * Defines the type of event (KeyboardEventTypes)
  8767. */
  8768. type: number;
  8769. /**
  8770. * Defines the related dom event
  8771. */
  8772. event: KeyboardEvent;
  8773. /**
  8774. * Instantiates a new keyboard info.
  8775. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8776. * @param type Defines the type of event (KeyboardEventTypes)
  8777. * @param event Defines the related dom event
  8778. */
  8779. constructor(
  8780. /**
  8781. * Defines the type of event (KeyboardEventTypes)
  8782. */
  8783. type: number,
  8784. /**
  8785. * Defines the related dom event
  8786. */
  8787. event: KeyboardEvent);
  8788. }
  8789. /**
  8790. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8791. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8792. */
  8793. export class KeyboardInfoPre extends KeyboardInfo {
  8794. /**
  8795. * Defines the type of event (KeyboardEventTypes)
  8796. */
  8797. type: number;
  8798. /**
  8799. * Defines the related dom event
  8800. */
  8801. event: KeyboardEvent;
  8802. /**
  8803. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8804. */
  8805. skipOnPointerObservable: boolean;
  8806. /**
  8807. * Instantiates a new keyboard pre info.
  8808. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8809. * @param type Defines the type of event (KeyboardEventTypes)
  8810. * @param event Defines the related dom event
  8811. */
  8812. constructor(
  8813. /**
  8814. * Defines the type of event (KeyboardEventTypes)
  8815. */
  8816. type: number,
  8817. /**
  8818. * Defines the related dom event
  8819. */
  8820. event: KeyboardEvent);
  8821. }
  8822. }
  8823. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8824. import { Nullable } from "babylonjs/types";
  8825. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8826. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8827. /**
  8828. * Manage the keyboard inputs to control the movement of a free camera.
  8829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8830. */
  8831. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8832. /**
  8833. * Defines the camera the input is attached to.
  8834. */
  8835. camera: FreeCamera;
  8836. /**
  8837. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8838. */
  8839. keysUp: number[];
  8840. /**
  8841. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8842. */
  8843. keysDown: number[];
  8844. /**
  8845. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8846. */
  8847. keysLeft: number[];
  8848. /**
  8849. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8850. */
  8851. keysRight: number[];
  8852. private _keys;
  8853. private _onCanvasBlurObserver;
  8854. private _onKeyboardObserver;
  8855. private _engine;
  8856. private _scene;
  8857. /**
  8858. * Attach the input controls to a specific dom element to get the input from.
  8859. * @param element Defines the element the controls should be listened from
  8860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8861. */
  8862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8863. /**
  8864. * Detach the current controls from the specified dom element.
  8865. * @param element Defines the element to stop listening the inputs from
  8866. */
  8867. detachControl(element: Nullable<HTMLElement>): void;
  8868. /**
  8869. * Update the current camera state depending on the inputs that have been used this frame.
  8870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8871. */
  8872. checkInputs(): void;
  8873. /**
  8874. * Gets the class name of the current intput.
  8875. * @returns the class name
  8876. */
  8877. getClassName(): string;
  8878. /** @hidden */
  8879. _onLostFocus(): void;
  8880. /**
  8881. * Get the friendly name associated with the input class.
  8882. * @returns the input friendly name
  8883. */
  8884. getSimpleName(): string;
  8885. }
  8886. }
  8887. declare module "babylonjs/Lights/shadowLight" {
  8888. import { Camera } from "babylonjs/Cameras/camera";
  8889. import { Scene } from "babylonjs/scene";
  8890. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8892. import { Light } from "babylonjs/Lights/light";
  8893. /**
  8894. * Interface describing all the common properties and methods a shadow light needs to implement.
  8895. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8896. * as well as binding the different shadow properties to the effects.
  8897. */
  8898. export interface IShadowLight extends Light {
  8899. /**
  8900. * The light id in the scene (used in scene.findLighById for instance)
  8901. */
  8902. id: string;
  8903. /**
  8904. * The position the shdow will be casted from.
  8905. */
  8906. position: Vector3;
  8907. /**
  8908. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8909. */
  8910. direction: Vector3;
  8911. /**
  8912. * The transformed position. Position of the light in world space taking parenting in account.
  8913. */
  8914. transformedPosition: Vector3;
  8915. /**
  8916. * The transformed direction. Direction of the light in world space taking parenting in account.
  8917. */
  8918. transformedDirection: Vector3;
  8919. /**
  8920. * The friendly name of the light in the scene.
  8921. */
  8922. name: string;
  8923. /**
  8924. * Defines the shadow projection clipping minimum z value.
  8925. */
  8926. shadowMinZ: number;
  8927. /**
  8928. * Defines the shadow projection clipping maximum z value.
  8929. */
  8930. shadowMaxZ: number;
  8931. /**
  8932. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8933. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8934. */
  8935. computeTransformedInformation(): boolean;
  8936. /**
  8937. * Gets the scene the light belongs to.
  8938. * @returns The scene
  8939. */
  8940. getScene(): Scene;
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8948. * @param matrix The materix to updated with the projection information
  8949. * @param viewMatrix The transform matrix of the light
  8950. * @param renderList The list of mesh to render in the map
  8951. * @returns The current light
  8952. */
  8953. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8954. /**
  8955. * Gets the current depth scale used in ESM.
  8956. * @returns The scale
  8957. */
  8958. getDepthScale(): number;
  8959. /**
  8960. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8961. * @returns true if a cube texture needs to be use
  8962. */
  8963. needCube(): boolean;
  8964. /**
  8965. * Detects if the projection matrix requires to be recomputed this frame.
  8966. * @returns true if it requires to be recomputed otherwise, false.
  8967. */
  8968. needProjectionMatrixCompute(): boolean;
  8969. /**
  8970. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8971. */
  8972. forceProjectionMatrixCompute(): void;
  8973. /**
  8974. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8975. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8976. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8977. */
  8978. getShadowDirection(faceIndex?: number): Vector3;
  8979. /**
  8980. * Gets the minZ used for shadow according to both the scene and the light.
  8981. * @param activeCamera The camera we are returning the min for
  8982. * @returns the depth min z
  8983. */
  8984. getDepthMinZ(activeCamera: Camera): number;
  8985. /**
  8986. * Gets the maxZ used for shadow according to both the scene and the light.
  8987. * @param activeCamera The camera we are returning the max for
  8988. * @returns the depth max z
  8989. */
  8990. getDepthMaxZ(activeCamera: Camera): number;
  8991. }
  8992. /**
  8993. * Base implementation IShadowLight
  8994. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8995. */
  8996. export abstract class ShadowLight extends Light implements IShadowLight {
  8997. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8998. protected _position: Vector3;
  8999. protected _setPosition(value: Vector3): void;
  9000. /**
  9001. * Sets the position the shadow will be casted from. Also use as the light position for both
  9002. * point and spot lights.
  9003. */
  9004. get position(): Vector3;
  9005. /**
  9006. * Sets the position the shadow will be casted from. Also use as the light position for both
  9007. * point and spot lights.
  9008. */
  9009. set position(value: Vector3);
  9010. protected _direction: Vector3;
  9011. protected _setDirection(value: Vector3): void;
  9012. /**
  9013. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9014. * Also use as the light direction on spot and directional lights.
  9015. */
  9016. get direction(): Vector3;
  9017. /**
  9018. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9019. * Also use as the light direction on spot and directional lights.
  9020. */
  9021. set direction(value: Vector3);
  9022. protected _shadowMinZ: number;
  9023. /**
  9024. * Gets the shadow projection clipping minimum z value.
  9025. */
  9026. get shadowMinZ(): number;
  9027. /**
  9028. * Sets the shadow projection clipping minimum z value.
  9029. */
  9030. set shadowMinZ(value: number);
  9031. protected _shadowMaxZ: number;
  9032. /**
  9033. * Sets the shadow projection clipping maximum z value.
  9034. */
  9035. get shadowMaxZ(): number;
  9036. /**
  9037. * Gets the shadow projection clipping maximum z value.
  9038. */
  9039. set shadowMaxZ(value: number);
  9040. /**
  9041. * Callback defining a custom Projection Matrix Builder.
  9042. * This can be used to override the default projection matrix computation.
  9043. */
  9044. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9045. /**
  9046. * The transformed position. Position of the light in world space taking parenting in account.
  9047. */
  9048. transformedPosition: Vector3;
  9049. /**
  9050. * The transformed direction. Direction of the light in world space taking parenting in account.
  9051. */
  9052. transformedDirection: Vector3;
  9053. private _needProjectionMatrixCompute;
  9054. /**
  9055. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9056. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9057. */
  9058. computeTransformedInformation(): boolean;
  9059. /**
  9060. * Return the depth scale used for the shadow map.
  9061. * @returns the depth scale.
  9062. */
  9063. getDepthScale(): number;
  9064. /**
  9065. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9066. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9067. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9068. */
  9069. getShadowDirection(faceIndex?: number): Vector3;
  9070. /**
  9071. * Returns the ShadowLight absolute position in the World.
  9072. * @returns the position vector in world space
  9073. */
  9074. getAbsolutePosition(): Vector3;
  9075. /**
  9076. * Sets the ShadowLight direction toward the passed target.
  9077. * @param target The point to target in local space
  9078. * @returns the updated ShadowLight direction
  9079. */
  9080. setDirectionToTarget(target: Vector3): Vector3;
  9081. /**
  9082. * Returns the light rotation in euler definition.
  9083. * @returns the x y z rotation in local space.
  9084. */
  9085. getRotation(): Vector3;
  9086. /**
  9087. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9088. * @returns true if a cube texture needs to be use
  9089. */
  9090. needCube(): boolean;
  9091. /**
  9092. * Detects if the projection matrix requires to be recomputed this frame.
  9093. * @returns true if it requires to be recomputed otherwise, false.
  9094. */
  9095. needProjectionMatrixCompute(): boolean;
  9096. /**
  9097. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9098. */
  9099. forceProjectionMatrixCompute(): void;
  9100. /** @hidden */
  9101. _initCache(): void;
  9102. /** @hidden */
  9103. _isSynchronized(): boolean;
  9104. /**
  9105. * Computes the world matrix of the node
  9106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9107. * @returns the world matrix
  9108. */
  9109. computeWorldMatrix(force?: boolean): Matrix;
  9110. /**
  9111. * Gets the minZ used for shadow according to both the scene and the light.
  9112. * @param activeCamera The camera we are returning the min for
  9113. * @returns the depth min z
  9114. */
  9115. getDepthMinZ(activeCamera: Camera): number;
  9116. /**
  9117. * Gets the maxZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the max for
  9119. * @returns the depth max z
  9120. */
  9121. getDepthMaxZ(activeCamera: Camera): number;
  9122. /**
  9123. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9124. * @param matrix The materix to updated with the projection information
  9125. * @param viewMatrix The transform matrix of the light
  9126. * @param renderList The list of mesh to render in the map
  9127. * @returns The current light
  9128. */
  9129. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9130. }
  9131. }
  9132. declare module "babylonjs/Materials/effectFallbacks" {
  9133. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9134. import { Effect } from "babylonjs/Materials/effect";
  9135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9136. /**
  9137. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9138. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9139. */
  9140. export class EffectFallbacks implements IEffectFallbacks {
  9141. private _defines;
  9142. private _currentRank;
  9143. private _maxRank;
  9144. private _mesh;
  9145. /**
  9146. * Removes the fallback from the bound mesh.
  9147. */
  9148. unBindMesh(): void;
  9149. /**
  9150. * Adds a fallback on the specified property.
  9151. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9152. * @param define The name of the define in the shader
  9153. */
  9154. addFallback(rank: number, define: string): void;
  9155. /**
  9156. * Sets the mesh to use CPU skinning when needing to fallback.
  9157. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9158. * @param mesh The mesh to use the fallbacks.
  9159. */
  9160. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9161. /**
  9162. * Checks to see if more fallbacks are still availible.
  9163. */
  9164. get hasMoreFallbacks(): boolean;
  9165. /**
  9166. * Removes the defines that should be removed when falling back.
  9167. * @param currentDefines defines the current define statements for the shader.
  9168. * @param effect defines the current effect we try to compile
  9169. * @returns The resulting defines with defines of the current rank removed.
  9170. */
  9171. reduce(currentDefines: string, effect: Effect): string;
  9172. }
  9173. }
  9174. declare module "babylonjs/Materials/materialHelper" {
  9175. import { Nullable } from "babylonjs/types";
  9176. import { Scene } from "babylonjs/scene";
  9177. import { Engine } from "babylonjs/Engines/engine";
  9178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9179. import { Light } from "babylonjs/Lights/light";
  9180. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9181. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9183. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9184. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9185. /**
  9186. * "Static Class" containing the most commonly used helper while dealing with material for
  9187. * rendering purpose.
  9188. *
  9189. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9190. *
  9191. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9192. */
  9193. export class MaterialHelper {
  9194. /**
  9195. * Bind the current view position to an effect.
  9196. * @param effect The effect to be bound
  9197. * @param scene The scene the eyes position is used from
  9198. */
  9199. static BindEyePosition(effect: Effect, scene: Scene): void;
  9200. /**
  9201. * Helps preparing the defines values about the UVs in used in the effect.
  9202. * UVs are shared as much as we can accross channels in the shaders.
  9203. * @param texture The texture we are preparing the UVs for
  9204. * @param defines The defines to update
  9205. * @param key The channel key "diffuse", "specular"... used in the shader
  9206. */
  9207. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9208. /**
  9209. * Binds a texture matrix value to its corrsponding uniform
  9210. * @param texture The texture to bind the matrix for
  9211. * @param uniformBuffer The uniform buffer receivin the data
  9212. * @param key The channel key "diffuse", "specular"... used in the shader
  9213. */
  9214. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9215. /**
  9216. * Gets the current status of the fog (should it be enabled?)
  9217. * @param mesh defines the mesh to evaluate for fog support
  9218. * @param scene defines the hosting scene
  9219. * @returns true if fog must be enabled
  9220. */
  9221. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9222. /**
  9223. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9224. * @param mesh defines the current mesh
  9225. * @param scene defines the current scene
  9226. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9227. * @param pointsCloud defines if point cloud rendering has to be turned on
  9228. * @param fogEnabled defines if fog has to be turned on
  9229. * @param alphaTest defines if alpha testing has to be turned on
  9230. * @param defines defines the current list of defines
  9231. */
  9232. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9233. /**
  9234. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9235. * @param scene defines the current scene
  9236. * @param engine defines the current engine
  9237. * @param defines specifies the list of active defines
  9238. * @param useInstances defines if instances have to be turned on
  9239. * @param useClipPlane defines if clip plane have to be turned on
  9240. */
  9241. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9242. /**
  9243. * Prepares the defines for bones
  9244. * @param mesh The mesh containing the geometry data we will draw
  9245. * @param defines The defines to update
  9246. */
  9247. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9248. /**
  9249. * Prepares the defines for morph targets
  9250. * @param mesh The mesh containing the geometry data we will draw
  9251. * @param defines The defines to update
  9252. */
  9253. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9254. /**
  9255. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9256. * @param mesh The mesh containing the geometry data we will draw
  9257. * @param defines The defines to update
  9258. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9259. * @param useBones Precise whether bones should be used or not (override mesh info)
  9260. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9261. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9262. * @returns false if defines are considered not dirty and have not been checked
  9263. */
  9264. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9265. /**
  9266. * Prepares the defines related to multiview
  9267. * @param scene The scene we are intending to draw
  9268. * @param defines The defines to update
  9269. */
  9270. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9271. /**
  9272. * Prepares the defines related to the light information passed in parameter
  9273. * @param scene The scene we are intending to draw
  9274. * @param mesh The mesh the effect is compiling for
  9275. * @param light The light the effect is compiling for
  9276. * @param lightIndex The index of the light
  9277. * @param defines The defines to update
  9278. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9279. * @param state Defines the current state regarding what is needed (normals, etc...)
  9280. */
  9281. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9282. needNormals: boolean;
  9283. needRebuild: boolean;
  9284. shadowEnabled: boolean;
  9285. specularEnabled: boolean;
  9286. lightmapMode: boolean;
  9287. }): void;
  9288. /**
  9289. * Prepares the defines related to the light information passed in parameter
  9290. * @param scene The scene we are intending to draw
  9291. * @param mesh The mesh the effect is compiling for
  9292. * @param defines The defines to update
  9293. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9294. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9295. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9296. * @returns true if normals will be required for the rest of the effect
  9297. */
  9298. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9299. /**
  9300. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9301. * @param lightIndex defines the light index
  9302. * @param uniformsList The uniform list
  9303. * @param samplersList The sampler list
  9304. * @param projectedLightTexture defines if projected texture must be used
  9305. * @param uniformBuffersList defines an optional list of uniform buffers
  9306. */
  9307. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9308. /**
  9309. * Prepares the uniforms and samplers list to be used in the effect
  9310. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9311. * @param samplersList The sampler list
  9312. * @param defines The defines helping in the list generation
  9313. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9314. */
  9315. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9316. /**
  9317. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9318. * @param defines The defines to update while falling back
  9319. * @param fallbacks The authorized effect fallbacks
  9320. * @param maxSimultaneousLights The maximum number of lights allowed
  9321. * @param rank the current rank of the Effect
  9322. * @returns The newly affected rank
  9323. */
  9324. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9325. private static _TmpMorphInfluencers;
  9326. /**
  9327. * Prepares the list of attributes required for morph targets according to the effect defines.
  9328. * @param attribs The current list of supported attribs
  9329. * @param mesh The mesh to prepare the morph targets attributes for
  9330. * @param influencers The number of influencers
  9331. */
  9332. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9333. /**
  9334. * Prepares the list of attributes required for morph targets according to the effect defines.
  9335. * @param attribs The current list of supported attribs
  9336. * @param mesh The mesh to prepare the morph targets attributes for
  9337. * @param defines The current Defines of the effect
  9338. */
  9339. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9340. /**
  9341. * Prepares the list of attributes required for bones according to the effect defines.
  9342. * @param attribs The current list of supported attribs
  9343. * @param mesh The mesh to prepare the bones attributes for
  9344. * @param defines The current Defines of the effect
  9345. * @param fallbacks The current efffect fallback strategy
  9346. */
  9347. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9348. /**
  9349. * Check and prepare the list of attributes required for instances according to the effect defines.
  9350. * @param attribs The current list of supported attribs
  9351. * @param defines The current MaterialDefines of the effect
  9352. */
  9353. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9354. /**
  9355. * Add the list of attributes required for instances to the attribs array.
  9356. * @param attribs The current list of supported attribs
  9357. */
  9358. static PushAttributesForInstances(attribs: string[]): void;
  9359. /**
  9360. * Binds the light information to the effect.
  9361. * @param light The light containing the generator
  9362. * @param effect The effect we are binding the data to
  9363. * @param lightIndex The light index in the effect used to render
  9364. */
  9365. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9366. /**
  9367. * Binds the lights information from the scene to the effect for the given mesh.
  9368. * @param light Light to bind
  9369. * @param lightIndex Light index
  9370. * @param scene The scene where the light belongs to
  9371. * @param effect The effect we are binding the data to
  9372. * @param useSpecular Defines if specular is supported
  9373. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9374. */
  9375. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9376. /**
  9377. * Binds the lights information from the scene to the effect for the given mesh.
  9378. * @param scene The scene the lights belongs to
  9379. * @param mesh The mesh we are binding the information to render
  9380. * @param effect The effect we are binding the data to
  9381. * @param defines The generated defines for the effect
  9382. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9383. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9384. */
  9385. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9386. private static _tempFogColor;
  9387. /**
  9388. * Binds the fog information from the scene to the effect for the given mesh.
  9389. * @param scene The scene the lights belongs to
  9390. * @param mesh The mesh we are binding the information to render
  9391. * @param effect The effect we are binding the data to
  9392. * @param linearSpace Defines if the fog effect is applied in linear space
  9393. */
  9394. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9395. /**
  9396. * Binds the bones information from the mesh to the effect.
  9397. * @param mesh The mesh we are binding the information to render
  9398. * @param effect The effect we are binding the data to
  9399. */
  9400. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9401. /**
  9402. * Binds the morph targets information from the mesh to the effect.
  9403. * @param abstractMesh The mesh we are binding the information to render
  9404. * @param effect The effect we are binding the data to
  9405. */
  9406. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9407. /**
  9408. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9409. * @param defines The generated defines used in the effect
  9410. * @param effect The effect we are binding the data to
  9411. * @param scene The scene we are willing to render with logarithmic scale for
  9412. */
  9413. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9414. /**
  9415. * Binds the clip plane information from the scene to the effect.
  9416. * @param scene The scene the clip plane information are extracted from
  9417. * @param effect The effect we are binding the data to
  9418. */
  9419. static BindClipPlane(effect: Effect, scene: Scene): void;
  9420. }
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9423. /** @hidden */
  9424. export var packingFunctions: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9430. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9431. /** @hidden */
  9432. export var shadowMapPixelShader: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9438. /** @hidden */
  9439. export var bonesDeclaration: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9445. /** @hidden */
  9446. export var morphTargetsVertexGlobalDeclaration: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9452. /** @hidden */
  9453. export var morphTargetsVertexDeclaration: {
  9454. name: string;
  9455. shader: string;
  9456. };
  9457. }
  9458. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9459. /** @hidden */
  9460. export var instancesDeclaration: {
  9461. name: string;
  9462. shader: string;
  9463. };
  9464. }
  9465. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9466. /** @hidden */
  9467. export var helperFunctions: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9473. /** @hidden */
  9474. export var morphTargetsVertex: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9480. /** @hidden */
  9481. export var instancesVertex: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9487. /** @hidden */
  9488. export var bonesVertex: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9494. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9495. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9496. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9497. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9498. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9499. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9500. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9501. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9502. /** @hidden */
  9503. export var shadowMapVertexShader: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9509. /** @hidden */
  9510. export var depthBoxBlurPixelShader: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9516. import { Nullable } from "babylonjs/types";
  9517. import { Scene } from "babylonjs/scene";
  9518. import { Matrix } from "babylonjs/Maths/math.vector";
  9519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9521. import { Mesh } from "babylonjs/Meshes/mesh";
  9522. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9523. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9524. import { Effect } from "babylonjs/Materials/effect";
  9525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9526. import "babylonjs/Shaders/shadowMap.fragment";
  9527. import "babylonjs/Shaders/shadowMap.vertex";
  9528. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9529. import { Observable } from "babylonjs/Misc/observable";
  9530. /**
  9531. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9532. */
  9533. export interface ICustomShaderOptions {
  9534. /**
  9535. * Gets or sets the custom shader name to use
  9536. */
  9537. shaderName: string;
  9538. /**
  9539. * The list of attribute names used in the shader
  9540. */
  9541. attributes?: string[];
  9542. /**
  9543. * The list of unifrom names used in the shader
  9544. */
  9545. uniforms?: string[];
  9546. /**
  9547. * The list of sampler names used in the shader
  9548. */
  9549. samplers?: string[];
  9550. /**
  9551. * The list of defines used in the shader
  9552. */
  9553. defines?: string[];
  9554. }
  9555. /**
  9556. * Interface to implement to create a shadow generator compatible with BJS.
  9557. */
  9558. export interface IShadowGenerator {
  9559. /**
  9560. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9561. * @returns The render target texture if present otherwise, null
  9562. */
  9563. getShadowMap(): Nullable<RenderTargetTexture>;
  9564. /**
  9565. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9566. * @param subMesh The submesh we want to render in the shadow map
  9567. * @param useInstances Defines wether will draw in the map using instances
  9568. * @returns true if ready otherwise, false
  9569. */
  9570. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9571. /**
  9572. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9573. * @param defines Defines of the material we want to update
  9574. * @param lightIndex Index of the light in the enabled light list of the material
  9575. */
  9576. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9577. /**
  9578. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9579. * defined in the generator but impacting the effect).
  9580. * It implies the unifroms available on the materials are the standard BJS ones.
  9581. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9582. * @param effect The effect we are binfing the information for
  9583. */
  9584. bindShadowLight(lightIndex: string, effect: Effect): void;
  9585. /**
  9586. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9587. * (eq to shadow prjection matrix * light transform matrix)
  9588. * @returns The transform matrix used to create the shadow map
  9589. */
  9590. getTransformMatrix(): Matrix;
  9591. /**
  9592. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9593. * Cube and 2D textures for instance.
  9594. */
  9595. recreateShadowMap(): void;
  9596. /**
  9597. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9598. * @param onCompiled Callback triggered at the and of the effects compilation
  9599. * @param options Sets of optional options forcing the compilation with different modes
  9600. */
  9601. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9602. useInstances: boolean;
  9603. }>): void;
  9604. /**
  9605. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9606. * @param options Sets of optional options forcing the compilation with different modes
  9607. * @returns A promise that resolves when the compilation completes
  9608. */
  9609. forceCompilationAsync(options?: Partial<{
  9610. useInstances: boolean;
  9611. }>): Promise<void>;
  9612. /**
  9613. * Serializes the shadow generator setup to a json object.
  9614. * @returns The serialized JSON object
  9615. */
  9616. serialize(): any;
  9617. /**
  9618. * Disposes the Shadow map and related Textures and effects.
  9619. */
  9620. dispose(): void;
  9621. }
  9622. /**
  9623. * Default implementation IShadowGenerator.
  9624. * This is the main object responsible of generating shadows in the framework.
  9625. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9626. */
  9627. export class ShadowGenerator implements IShadowGenerator {
  9628. /**
  9629. * Shadow generator mode None: no filtering applied.
  9630. */
  9631. static readonly FILTER_NONE: number;
  9632. /**
  9633. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9634. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9635. */
  9636. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9637. /**
  9638. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9639. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9640. */
  9641. static readonly FILTER_POISSONSAMPLING: number;
  9642. /**
  9643. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9644. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9645. */
  9646. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9647. /**
  9648. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9649. * edge artifacts on steep falloff.
  9650. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9651. */
  9652. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9653. /**
  9654. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9655. * edge artifacts on steep falloff.
  9656. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9657. */
  9658. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9659. /**
  9660. * Shadow generator mode PCF: Percentage Closer Filtering
  9661. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9662. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9663. */
  9664. static readonly FILTER_PCF: number;
  9665. /**
  9666. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9667. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9668. * Contact Hardening
  9669. */
  9670. static readonly FILTER_PCSS: number;
  9671. /**
  9672. * Reserved for PCF and PCSS
  9673. * Highest Quality.
  9674. *
  9675. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9676. *
  9677. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9678. */
  9679. static readonly QUALITY_HIGH: number;
  9680. /**
  9681. * Reserved for PCF and PCSS
  9682. * Good tradeoff for quality/perf cross devices
  9683. *
  9684. * Execute PCF on a 3*3 kernel.
  9685. *
  9686. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9687. */
  9688. static readonly QUALITY_MEDIUM: number;
  9689. /**
  9690. * Reserved for PCF and PCSS
  9691. * The lowest quality but the fastest.
  9692. *
  9693. * Execute PCF on a 1*1 kernel.
  9694. *
  9695. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9696. */
  9697. static readonly QUALITY_LOW: number;
  9698. /** Gets or sets the custom shader name to use */
  9699. customShaderOptions: ICustomShaderOptions;
  9700. /**
  9701. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9702. */
  9703. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9704. /**
  9705. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9706. */
  9707. onAfterShadowMapRenderObservable: Observable<Effect>;
  9708. /**
  9709. * Observable triggered before a mesh is rendered in the shadow map.
  9710. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9711. */
  9712. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9713. /**
  9714. * Observable triggered after a mesh is rendered in the shadow map.
  9715. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9716. */
  9717. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9718. private _bias;
  9719. /**
  9720. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9721. */
  9722. get bias(): number;
  9723. /**
  9724. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9725. */
  9726. set bias(bias: number);
  9727. private _normalBias;
  9728. /**
  9729. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9730. */
  9731. get normalBias(): number;
  9732. /**
  9733. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9734. */
  9735. set normalBias(normalBias: number);
  9736. private _blurBoxOffset;
  9737. /**
  9738. * Gets the blur box offset: offset applied during the blur pass.
  9739. * Only useful if useKernelBlur = false
  9740. */
  9741. get blurBoxOffset(): number;
  9742. /**
  9743. * Sets the blur box offset: offset applied during the blur pass.
  9744. * Only useful if useKernelBlur = false
  9745. */
  9746. set blurBoxOffset(value: number);
  9747. private _blurScale;
  9748. /**
  9749. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9750. * 2 means half of the size.
  9751. */
  9752. get blurScale(): number;
  9753. /**
  9754. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9755. * 2 means half of the size.
  9756. */
  9757. set blurScale(value: number);
  9758. private _blurKernel;
  9759. /**
  9760. * Gets the blur kernel: kernel size of the blur pass.
  9761. * Only useful if useKernelBlur = true
  9762. */
  9763. get blurKernel(): number;
  9764. /**
  9765. * Sets the blur kernel: kernel size of the blur pass.
  9766. * Only useful if useKernelBlur = true
  9767. */
  9768. set blurKernel(value: number);
  9769. private _useKernelBlur;
  9770. /**
  9771. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9772. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9773. */
  9774. get useKernelBlur(): boolean;
  9775. /**
  9776. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9777. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9778. */
  9779. set useKernelBlur(value: boolean);
  9780. private _depthScale;
  9781. /**
  9782. * Gets the depth scale used in ESM mode.
  9783. */
  9784. get depthScale(): number;
  9785. /**
  9786. * Sets the depth scale used in ESM mode.
  9787. * This can override the scale stored on the light.
  9788. */
  9789. set depthScale(value: number);
  9790. private _filter;
  9791. /**
  9792. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9793. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9794. */
  9795. get filter(): number;
  9796. /**
  9797. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9798. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9799. */
  9800. set filter(value: number);
  9801. /**
  9802. * Gets if the current filter is set to Poisson Sampling.
  9803. */
  9804. get usePoissonSampling(): boolean;
  9805. /**
  9806. * Sets the current filter to Poisson Sampling.
  9807. */
  9808. set usePoissonSampling(value: boolean);
  9809. /**
  9810. * Gets if the current filter is set to ESM.
  9811. */
  9812. get useExponentialShadowMap(): boolean;
  9813. /**
  9814. * Sets the current filter is to ESM.
  9815. */
  9816. set useExponentialShadowMap(value: boolean);
  9817. /**
  9818. * Gets if the current filter is set to filtered ESM.
  9819. */
  9820. get useBlurExponentialShadowMap(): boolean;
  9821. /**
  9822. * Gets if the current filter is set to filtered ESM.
  9823. */
  9824. set useBlurExponentialShadowMap(value: boolean);
  9825. /**
  9826. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9827. * exponential to prevent steep falloff artifacts).
  9828. */
  9829. get useCloseExponentialShadowMap(): boolean;
  9830. /**
  9831. * Sets the current filter to "close ESM" (using the inverse of the
  9832. * exponential to prevent steep falloff artifacts).
  9833. */
  9834. set useCloseExponentialShadowMap(value: boolean);
  9835. /**
  9836. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9837. * exponential to prevent steep falloff artifacts).
  9838. */
  9839. get useBlurCloseExponentialShadowMap(): boolean;
  9840. /**
  9841. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9842. * exponential to prevent steep falloff artifacts).
  9843. */
  9844. set useBlurCloseExponentialShadowMap(value: boolean);
  9845. /**
  9846. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9847. */
  9848. get usePercentageCloserFiltering(): boolean;
  9849. /**
  9850. * Sets the current filter to "PCF" (percentage closer filtering).
  9851. */
  9852. set usePercentageCloserFiltering(value: boolean);
  9853. private _filteringQuality;
  9854. /**
  9855. * Gets the PCF or PCSS Quality.
  9856. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9857. */
  9858. get filteringQuality(): number;
  9859. /**
  9860. * Sets the PCF or PCSS Quality.
  9861. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9862. */
  9863. set filteringQuality(filteringQuality: number);
  9864. /**
  9865. * Gets if the current filter is set to "PCSS" (contact hardening).
  9866. */
  9867. get useContactHardeningShadow(): boolean;
  9868. /**
  9869. * Sets the current filter to "PCSS" (contact hardening).
  9870. */
  9871. set useContactHardeningShadow(value: boolean);
  9872. private _contactHardeningLightSizeUVRatio;
  9873. /**
  9874. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9875. * Using a ratio helps keeping shape stability independently of the map size.
  9876. *
  9877. * It does not account for the light projection as it was having too much
  9878. * instability during the light setup or during light position changes.
  9879. *
  9880. * Only valid if useContactHardeningShadow is true.
  9881. */
  9882. get contactHardeningLightSizeUVRatio(): number;
  9883. /**
  9884. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9885. * Using a ratio helps keeping shape stability independently of the map size.
  9886. *
  9887. * It does not account for the light projection as it was having too much
  9888. * instability during the light setup or during light position changes.
  9889. *
  9890. * Only valid if useContactHardeningShadow is true.
  9891. */
  9892. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9893. private _darkness;
  9894. /** Gets or sets the actual darkness of a shadow */
  9895. get darkness(): number;
  9896. set darkness(value: number);
  9897. /**
  9898. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9899. * 0 means strongest and 1 would means no shadow.
  9900. * @returns the darkness.
  9901. */
  9902. getDarkness(): number;
  9903. /**
  9904. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9905. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9906. * @returns the shadow generator allowing fluent coding.
  9907. */
  9908. setDarkness(darkness: number): ShadowGenerator;
  9909. private _transparencyShadow;
  9910. /** Gets or sets the ability to have transparent shadow */
  9911. get transparencyShadow(): boolean;
  9912. set transparencyShadow(value: boolean);
  9913. /**
  9914. * Sets the ability to have transparent shadow (boolean).
  9915. * @param transparent True if transparent else False
  9916. * @returns the shadow generator allowing fluent coding
  9917. */
  9918. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9919. private _shadowMap;
  9920. private _shadowMap2;
  9921. /**
  9922. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9923. * @returns The render target texture if present otherwise, null
  9924. */
  9925. getShadowMap(): Nullable<RenderTargetTexture>;
  9926. /**
  9927. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9928. * @returns The render target texture if the shadow map is present otherwise, null
  9929. */
  9930. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9931. /**
  9932. * Gets the class name of that object
  9933. * @returns "ShadowGenerator"
  9934. */
  9935. getClassName(): string;
  9936. /**
  9937. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9938. * @param mesh Mesh to add
  9939. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9940. * @returns the Shadow Generator itself
  9941. */
  9942. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9943. /**
  9944. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9945. * @param mesh Mesh to remove
  9946. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9947. * @returns the Shadow Generator itself
  9948. */
  9949. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9950. /**
  9951. * Controls the extent to which the shadows fade out at the edge of the frustum
  9952. * Used only by directionals and spots
  9953. */
  9954. frustumEdgeFalloff: number;
  9955. private _light;
  9956. /**
  9957. * Returns the associated light object.
  9958. * @returns the light generating the shadow
  9959. */
  9960. getLight(): IShadowLight;
  9961. /**
  9962. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9963. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9964. * It might on the other hand introduce peter panning.
  9965. */
  9966. forceBackFacesOnly: boolean;
  9967. private _scene;
  9968. private _lightDirection;
  9969. private _effect;
  9970. private _viewMatrix;
  9971. private _projectionMatrix;
  9972. private _transformMatrix;
  9973. private _cachedPosition;
  9974. private _cachedDirection;
  9975. private _cachedDefines;
  9976. private _currentRenderID;
  9977. private _boxBlurPostprocess;
  9978. private _kernelBlurXPostprocess;
  9979. private _kernelBlurYPostprocess;
  9980. private _blurPostProcesses;
  9981. private _mapSize;
  9982. private _currentFaceIndex;
  9983. private _currentFaceIndexCache;
  9984. private _textureType;
  9985. private _defaultTextureMatrix;
  9986. private _storedUniqueId;
  9987. /** @hidden */
  9988. static _SceneComponentInitialization: (scene: Scene) => void;
  9989. /**
  9990. * Creates a ShadowGenerator object.
  9991. * A ShadowGenerator is the required tool to use the shadows.
  9992. * Each light casting shadows needs to use its own ShadowGenerator.
  9993. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9994. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9995. * @param light The light object generating the shadows.
  9996. * @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.
  9997. */
  9998. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9999. private _initializeGenerator;
  10000. private _initializeShadowMap;
  10001. private _initializeBlurRTTAndPostProcesses;
  10002. private _renderForShadowMap;
  10003. private _renderSubMeshForShadowMap;
  10004. private _applyFilterValues;
  10005. /**
  10006. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10007. * @param onCompiled Callback triggered at the and of the effects compilation
  10008. * @param options Sets of optional options forcing the compilation with different modes
  10009. */
  10010. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  10011. useInstances: boolean;
  10012. }>): void;
  10013. /**
  10014. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10015. * @param options Sets of optional options forcing the compilation with different modes
  10016. * @returns A promise that resolves when the compilation completes
  10017. */
  10018. forceCompilationAsync(options?: Partial<{
  10019. useInstances: boolean;
  10020. }>): Promise<void>;
  10021. /**
  10022. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10023. * @param subMesh The submesh we want to render in the shadow map
  10024. * @param useInstances Defines wether will draw in the map using instances
  10025. * @returns true if ready otherwise, false
  10026. */
  10027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10028. /**
  10029. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10030. * @param defines Defines of the material we want to update
  10031. * @param lightIndex Index of the light in the enabled light list of the material
  10032. */
  10033. prepareDefines(defines: any, lightIndex: number): void;
  10034. /**
  10035. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10036. * defined in the generator but impacting the effect).
  10037. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10038. * @param effect The effect we are binfing the information for
  10039. */
  10040. bindShadowLight(lightIndex: string, effect: Effect): void;
  10041. /**
  10042. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10043. * (eq to shadow prjection matrix * light transform matrix)
  10044. * @returns The transform matrix used to create the shadow map
  10045. */
  10046. getTransformMatrix(): Matrix;
  10047. /**
  10048. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10049. * Cube and 2D textures for instance.
  10050. */
  10051. recreateShadowMap(): void;
  10052. private _disposeBlurPostProcesses;
  10053. private _disposeRTTandPostProcesses;
  10054. /**
  10055. * Disposes the ShadowGenerator.
  10056. * Returns nothing.
  10057. */
  10058. dispose(): void;
  10059. /**
  10060. * Serializes the shadow generator setup to a json object.
  10061. * @returns The serialized JSON object
  10062. */
  10063. serialize(): any;
  10064. /**
  10065. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10066. * @param parsedShadowGenerator The JSON object to parse
  10067. * @param scene The scene to create the shadow map for
  10068. * @returns The parsed shadow generator
  10069. */
  10070. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10071. }
  10072. }
  10073. declare module "babylonjs/Lights/light" {
  10074. import { Nullable } from "babylonjs/types";
  10075. import { Scene } from "babylonjs/scene";
  10076. import { Vector3 } from "babylonjs/Maths/math.vector";
  10077. import { Color3 } from "babylonjs/Maths/math.color";
  10078. import { Node } from "babylonjs/node";
  10079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10080. import { Effect } from "babylonjs/Materials/effect";
  10081. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10082. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10083. /**
  10084. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10085. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10086. * 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.
  10087. */
  10088. export abstract class Light extends Node {
  10089. /**
  10090. * Falloff Default: light is falling off following the material specification:
  10091. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10092. */
  10093. static readonly FALLOFF_DEFAULT: number;
  10094. /**
  10095. * Falloff Physical: light is falling off following the inverse squared distance law.
  10096. */
  10097. static readonly FALLOFF_PHYSICAL: number;
  10098. /**
  10099. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10100. * to enhance interoperability with other engines.
  10101. */
  10102. static readonly FALLOFF_GLTF: number;
  10103. /**
  10104. * Falloff Standard: light is falling off like in the standard material
  10105. * to enhance interoperability with other materials.
  10106. */
  10107. static readonly FALLOFF_STANDARD: number;
  10108. /**
  10109. * If every light affecting the material is in this lightmapMode,
  10110. * material.lightmapTexture adds or multiplies
  10111. * (depends on material.useLightmapAsShadowmap)
  10112. * after every other light calculations.
  10113. */
  10114. static readonly LIGHTMAP_DEFAULT: number;
  10115. /**
  10116. * material.lightmapTexture as only diffuse lighting from this light
  10117. * adds only specular lighting from this light
  10118. * adds dynamic shadows
  10119. */
  10120. static readonly LIGHTMAP_SPECULAR: number;
  10121. /**
  10122. * material.lightmapTexture as only lighting
  10123. * no light calculation from this light
  10124. * only adds dynamic shadows from this light
  10125. */
  10126. static readonly LIGHTMAP_SHADOWSONLY: number;
  10127. /**
  10128. * Each light type uses the default quantity according to its type:
  10129. * point/spot lights use luminous intensity
  10130. * directional lights use illuminance
  10131. */
  10132. static readonly INTENSITYMODE_AUTOMATIC: number;
  10133. /**
  10134. * lumen (lm)
  10135. */
  10136. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10137. /**
  10138. * candela (lm/sr)
  10139. */
  10140. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10141. /**
  10142. * lux (lm/m^2)
  10143. */
  10144. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10145. /**
  10146. * nit (cd/m^2)
  10147. */
  10148. static readonly INTENSITYMODE_LUMINANCE: number;
  10149. /**
  10150. * Light type const id of the point light.
  10151. */
  10152. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10153. /**
  10154. * Light type const id of the directional light.
  10155. */
  10156. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10157. /**
  10158. * Light type const id of the spot light.
  10159. */
  10160. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10161. /**
  10162. * Light type const id of the hemispheric light.
  10163. */
  10164. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10165. /**
  10166. * Diffuse gives the basic color to an object.
  10167. */
  10168. diffuse: Color3;
  10169. /**
  10170. * Specular produces a highlight color on an object.
  10171. * Note: This is note affecting PBR materials.
  10172. */
  10173. specular: Color3;
  10174. /**
  10175. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10176. * falling off base on range or angle.
  10177. * This can be set to any values in Light.FALLOFF_x.
  10178. *
  10179. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10180. * other types of materials.
  10181. */
  10182. falloffType: number;
  10183. /**
  10184. * Strength of the light.
  10185. * Note: By default it is define in the framework own unit.
  10186. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10187. */
  10188. intensity: number;
  10189. private _range;
  10190. protected _inverseSquaredRange: number;
  10191. /**
  10192. * Defines how far from the source the light is impacting in scene units.
  10193. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10194. */
  10195. get range(): number;
  10196. /**
  10197. * Defines how far from the source the light is impacting in scene units.
  10198. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10199. */
  10200. set range(value: number);
  10201. /**
  10202. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10203. * of light.
  10204. */
  10205. private _photometricScale;
  10206. private _intensityMode;
  10207. /**
  10208. * Gets the photometric scale used to interpret the intensity.
  10209. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10210. */
  10211. get intensityMode(): number;
  10212. /**
  10213. * Sets the photometric scale used to interpret the intensity.
  10214. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10215. */
  10216. set intensityMode(value: number);
  10217. private _radius;
  10218. /**
  10219. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10220. */
  10221. get radius(): number;
  10222. /**
  10223. * sets the light radius used by PBR Materials to simulate soft area lights.
  10224. */
  10225. set radius(value: number);
  10226. private _renderPriority;
  10227. /**
  10228. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10229. * exceeding the number allowed of the materials.
  10230. */
  10231. renderPriority: number;
  10232. private _shadowEnabled;
  10233. /**
  10234. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10235. * the current shadow generator.
  10236. */
  10237. get shadowEnabled(): boolean;
  10238. /**
  10239. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10240. * the current shadow generator.
  10241. */
  10242. set shadowEnabled(value: boolean);
  10243. private _includedOnlyMeshes;
  10244. /**
  10245. * Gets the only meshes impacted by this light.
  10246. */
  10247. get includedOnlyMeshes(): AbstractMesh[];
  10248. /**
  10249. * Sets the only meshes impacted by this light.
  10250. */
  10251. set includedOnlyMeshes(value: AbstractMesh[]);
  10252. private _excludedMeshes;
  10253. /**
  10254. * Gets the meshes not impacted by this light.
  10255. */
  10256. get excludedMeshes(): AbstractMesh[];
  10257. /**
  10258. * Sets the meshes not impacted by this light.
  10259. */
  10260. set excludedMeshes(value: AbstractMesh[]);
  10261. private _excludeWithLayerMask;
  10262. /**
  10263. * Gets the layer id use to find what meshes are not impacted by the light.
  10264. * Inactive if 0
  10265. */
  10266. get excludeWithLayerMask(): number;
  10267. /**
  10268. * Sets the layer id use to find what meshes are not impacted by the light.
  10269. * Inactive if 0
  10270. */
  10271. set excludeWithLayerMask(value: number);
  10272. private _includeOnlyWithLayerMask;
  10273. /**
  10274. * Gets the layer id use to find what meshes are impacted by the light.
  10275. * Inactive if 0
  10276. */
  10277. get includeOnlyWithLayerMask(): number;
  10278. /**
  10279. * Sets the layer id use to find what meshes are impacted by the light.
  10280. * Inactive if 0
  10281. */
  10282. set includeOnlyWithLayerMask(value: number);
  10283. private _lightmapMode;
  10284. /**
  10285. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10286. */
  10287. get lightmapMode(): number;
  10288. /**
  10289. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10290. */
  10291. set lightmapMode(value: number);
  10292. /**
  10293. * Shadow generator associted to the light.
  10294. * @hidden Internal use only.
  10295. */
  10296. _shadowGenerator: Nullable<IShadowGenerator>;
  10297. /**
  10298. * @hidden Internal use only.
  10299. */
  10300. _excludedMeshesIds: string[];
  10301. /**
  10302. * @hidden Internal use only.
  10303. */
  10304. _includedOnlyMeshesIds: string[];
  10305. /**
  10306. * The current light unifom buffer.
  10307. * @hidden Internal use only.
  10308. */
  10309. _uniformBuffer: UniformBuffer;
  10310. /** @hidden */
  10311. _renderId: number;
  10312. /**
  10313. * Creates a Light object in the scene.
  10314. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10315. * @param name The firendly name of the light
  10316. * @param scene The scene the light belongs too
  10317. */
  10318. constructor(name: string, scene: Scene);
  10319. protected abstract _buildUniformLayout(): void;
  10320. /**
  10321. * Sets the passed Effect "effect" with the Light information.
  10322. * @param effect The effect to update
  10323. * @param lightIndex The index of the light in the effect to update
  10324. * @returns The light
  10325. */
  10326. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10327. /**
  10328. * Sets the passed Effect "effect" with the Light textures.
  10329. * @param effect The effect to update
  10330. * @param lightIndex The index of the light in the effect to update
  10331. * @returns The light
  10332. */
  10333. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10334. /**
  10335. * Binds the lights information from the scene to the effect for the given mesh.
  10336. * @param lightIndex Light index
  10337. * @param scene The scene where the light belongs to
  10338. * @param effect The effect we are binding the data to
  10339. * @param useSpecular Defines if specular is supported
  10340. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10341. */
  10342. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10343. /**
  10344. * Sets the passed Effect "effect" with the Light information.
  10345. * @param effect The effect to update
  10346. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10347. * @returns The light
  10348. */
  10349. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10350. /**
  10351. * Returns the string "Light".
  10352. * @returns the class name
  10353. */
  10354. getClassName(): string;
  10355. /** @hidden */
  10356. readonly _isLight: boolean;
  10357. /**
  10358. * Converts the light information to a readable string for debug purpose.
  10359. * @param fullDetails Supports for multiple levels of logging within scene loading
  10360. * @returns the human readable light info
  10361. */
  10362. toString(fullDetails?: boolean): string;
  10363. /** @hidden */
  10364. protected _syncParentEnabledState(): void;
  10365. /**
  10366. * Set the enabled state of this node.
  10367. * @param value - the new enabled state
  10368. */
  10369. setEnabled(value: boolean): void;
  10370. /**
  10371. * Returns the Light associated shadow generator if any.
  10372. * @return the associated shadow generator.
  10373. */
  10374. getShadowGenerator(): Nullable<IShadowGenerator>;
  10375. /**
  10376. * Returns a Vector3, the absolute light position in the World.
  10377. * @returns the world space position of the light
  10378. */
  10379. getAbsolutePosition(): Vector3;
  10380. /**
  10381. * Specifies if the light will affect the passed mesh.
  10382. * @param mesh The mesh to test against the light
  10383. * @return true the mesh is affected otherwise, false.
  10384. */
  10385. canAffectMesh(mesh: AbstractMesh): boolean;
  10386. /**
  10387. * Sort function to order lights for rendering.
  10388. * @param a First Light object to compare to second.
  10389. * @param b Second Light object to compare first.
  10390. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10391. */
  10392. static CompareLightsPriority(a: Light, b: Light): number;
  10393. /**
  10394. * Releases resources associated with this node.
  10395. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10396. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10397. */
  10398. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10399. /**
  10400. * Returns the light type ID (integer).
  10401. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10402. */
  10403. getTypeID(): number;
  10404. /**
  10405. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10406. * @returns the scaled intensity in intensity mode unit
  10407. */
  10408. getScaledIntensity(): number;
  10409. /**
  10410. * Returns a new Light object, named "name", from the current one.
  10411. * @param name The name of the cloned light
  10412. * @returns the new created light
  10413. */
  10414. clone(name: string): Nullable<Light>;
  10415. /**
  10416. * Serializes the current light into a Serialization object.
  10417. * @returns the serialized object.
  10418. */
  10419. serialize(): any;
  10420. /**
  10421. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10422. * This new light is named "name" and added to the passed scene.
  10423. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10424. * @param name The friendly name of the light
  10425. * @param scene The scene the new light will belong to
  10426. * @returns the constructor function
  10427. */
  10428. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10429. /**
  10430. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10431. * @param parsedLight The JSON representation of the light
  10432. * @param scene The scene to create the parsed light in
  10433. * @returns the created light after parsing
  10434. */
  10435. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10436. private _hookArrayForExcluded;
  10437. private _hookArrayForIncludedOnly;
  10438. private _resyncMeshes;
  10439. /**
  10440. * Forces the meshes to update their light related information in their rendering used effects
  10441. * @hidden Internal Use Only
  10442. */
  10443. _markMeshesAsLightDirty(): void;
  10444. /**
  10445. * Recomputes the cached photometric scale if needed.
  10446. */
  10447. private _computePhotometricScale;
  10448. /**
  10449. * Returns the Photometric Scale according to the light type and intensity mode.
  10450. */
  10451. private _getPhotometricScale;
  10452. /**
  10453. * Reorder the light in the scene according to their defined priority.
  10454. * @hidden Internal Use Only
  10455. */
  10456. _reorderLightsInScene(): void;
  10457. /**
  10458. * Prepares the list of defines specific to the light type.
  10459. * @param defines the list of defines
  10460. * @param lightIndex defines the index of the light for the effect
  10461. */
  10462. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10463. }
  10464. }
  10465. declare module "babylonjs/Actions/action" {
  10466. import { Observable } from "babylonjs/Misc/observable";
  10467. import { Condition } from "babylonjs/Actions/condition";
  10468. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10469. import { ActionManager } from "babylonjs/Actions/actionManager";
  10470. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10471. /**
  10472. * Interface used to define Action
  10473. */
  10474. export interface IAction {
  10475. /**
  10476. * Trigger for the action
  10477. */
  10478. trigger: number;
  10479. /** Options of the trigger */
  10480. triggerOptions: any;
  10481. /**
  10482. * Gets the trigger parameters
  10483. * @returns the trigger parameters
  10484. */
  10485. getTriggerParameter(): any;
  10486. /**
  10487. * Internal only - executes current action event
  10488. * @hidden
  10489. */
  10490. _executeCurrent(evt?: ActionEvent): void;
  10491. /**
  10492. * Serialize placeholder for child classes
  10493. * @param parent of child
  10494. * @returns the serialized object
  10495. */
  10496. serialize(parent: any): any;
  10497. /**
  10498. * Internal only
  10499. * @hidden
  10500. */
  10501. _prepare(): void;
  10502. /**
  10503. * Internal only - manager for action
  10504. * @hidden
  10505. */
  10506. _actionManager: AbstractActionManager;
  10507. /**
  10508. * Adds action to chain of actions, may be a DoNothingAction
  10509. * @param action defines the next action to execute
  10510. * @returns The action passed in
  10511. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10512. */
  10513. then(action: IAction): IAction;
  10514. }
  10515. /**
  10516. * The action to be carried out following a trigger
  10517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10518. */
  10519. export class Action implements IAction {
  10520. /** the trigger, with or without parameters, for the action */
  10521. triggerOptions: any;
  10522. /**
  10523. * Trigger for the action
  10524. */
  10525. trigger: number;
  10526. /**
  10527. * Internal only - manager for action
  10528. * @hidden
  10529. */
  10530. _actionManager: ActionManager;
  10531. private _nextActiveAction;
  10532. private _child;
  10533. private _condition?;
  10534. private _triggerParameter;
  10535. /**
  10536. * An event triggered prior to action being executed.
  10537. */
  10538. onBeforeExecuteObservable: Observable<Action>;
  10539. /**
  10540. * Creates a new Action
  10541. * @param triggerOptions the trigger, with or without parameters, for the action
  10542. * @param condition an optional determinant of action
  10543. */
  10544. constructor(
  10545. /** the trigger, with or without parameters, for the action */
  10546. triggerOptions: any, condition?: Condition);
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. _prepare(): void;
  10552. /**
  10553. * Gets the trigger parameters
  10554. * @returns the trigger parameters
  10555. */
  10556. getTriggerParameter(): any;
  10557. /**
  10558. * Internal only - executes current action event
  10559. * @hidden
  10560. */
  10561. _executeCurrent(evt?: ActionEvent): void;
  10562. /**
  10563. * Execute placeholder for child classes
  10564. * @param evt optional action event
  10565. */
  10566. execute(evt?: ActionEvent): void;
  10567. /**
  10568. * Skips to next active action
  10569. */
  10570. skipToNextActiveAction(): void;
  10571. /**
  10572. * Adds action to chain of actions, may be a DoNothingAction
  10573. * @param action defines the next action to execute
  10574. * @returns The action passed in
  10575. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10576. */
  10577. then(action: Action): Action;
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */
  10582. _getProperty(propertyPath: string): string;
  10583. /**
  10584. * Internal only
  10585. * @hidden
  10586. */
  10587. _getEffectiveTarget(target: any, propertyPath: string): any;
  10588. /**
  10589. * Serialize placeholder for child classes
  10590. * @param parent of child
  10591. * @returns the serialized object
  10592. */
  10593. serialize(parent: any): any;
  10594. /**
  10595. * Internal only called by serialize
  10596. * @hidden
  10597. */
  10598. protected _serialize(serializedAction: any, parent?: any): any;
  10599. /**
  10600. * Internal only
  10601. * @hidden
  10602. */
  10603. static _SerializeValueAsString: (value: any) => string;
  10604. /**
  10605. * Internal only
  10606. * @hidden
  10607. */
  10608. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10609. name: string;
  10610. targetType: string;
  10611. value: string;
  10612. };
  10613. }
  10614. }
  10615. declare module "babylonjs/Actions/condition" {
  10616. import { ActionManager } from "babylonjs/Actions/actionManager";
  10617. /**
  10618. * A Condition applied to an Action
  10619. */
  10620. export class Condition {
  10621. /**
  10622. * Internal only - manager for action
  10623. * @hidden
  10624. */
  10625. _actionManager: ActionManager;
  10626. /**
  10627. * Internal only
  10628. * @hidden
  10629. */
  10630. _evaluationId: number;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. _currentResult: boolean;
  10636. /**
  10637. * Creates a new Condition
  10638. * @param actionManager the manager of the action the condition is applied to
  10639. */
  10640. constructor(actionManager: ActionManager);
  10641. /**
  10642. * Check if the current condition is valid
  10643. * @returns a boolean
  10644. */
  10645. isValid(): boolean;
  10646. /**
  10647. * Internal only
  10648. * @hidden
  10649. */
  10650. _getProperty(propertyPath: string): string;
  10651. /**
  10652. * Internal only
  10653. * @hidden
  10654. */
  10655. _getEffectiveTarget(target: any, propertyPath: string): any;
  10656. /**
  10657. * Serialize placeholder for child classes
  10658. * @returns the serialized object
  10659. */
  10660. serialize(): any;
  10661. /**
  10662. * Internal only
  10663. * @hidden
  10664. */
  10665. protected _serialize(serializedCondition: any): any;
  10666. }
  10667. /**
  10668. * Defines specific conditional operators as extensions of Condition
  10669. */
  10670. export class ValueCondition extends Condition {
  10671. /** path to specify the property of the target the conditional operator uses */
  10672. propertyPath: string;
  10673. /** the value compared by the conditional operator against the current value of the property */
  10674. value: any;
  10675. /** the conditional operator, default ValueCondition.IsEqual */
  10676. operator: number;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private static _IsEqual;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private static _IsDifferent;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. private static _IsGreater;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. private static _IsLesser;
  10697. /**
  10698. * returns the number for IsEqual
  10699. */
  10700. static get IsEqual(): number;
  10701. /**
  10702. * Returns the number for IsDifferent
  10703. */
  10704. static get IsDifferent(): number;
  10705. /**
  10706. * Returns the number for IsGreater
  10707. */
  10708. static get IsGreater(): number;
  10709. /**
  10710. * Returns the number for IsLesser
  10711. */
  10712. static get IsLesser(): number;
  10713. /**
  10714. * Internal only The action manager for the condition
  10715. * @hidden
  10716. */
  10717. _actionManager: ActionManager;
  10718. /**
  10719. * Internal only
  10720. * @hidden
  10721. */
  10722. private _target;
  10723. /**
  10724. * Internal only
  10725. * @hidden
  10726. */
  10727. private _effectiveTarget;
  10728. /**
  10729. * Internal only
  10730. * @hidden
  10731. */
  10732. private _property;
  10733. /**
  10734. * Creates a new ValueCondition
  10735. * @param actionManager manager for the action the condition applies to
  10736. * @param target for the action
  10737. * @param propertyPath path to specify the property of the target the conditional operator uses
  10738. * @param value the value compared by the conditional operator against the current value of the property
  10739. * @param operator the conditional operator, default ValueCondition.IsEqual
  10740. */
  10741. constructor(actionManager: ActionManager, target: any,
  10742. /** path to specify the property of the target the conditional operator uses */
  10743. propertyPath: string,
  10744. /** the value compared by the conditional operator against the current value of the property */
  10745. value: any,
  10746. /** the conditional operator, default ValueCondition.IsEqual */
  10747. operator?: number);
  10748. /**
  10749. * Compares the given value with the property value for the specified conditional operator
  10750. * @returns the result of the comparison
  10751. */
  10752. isValid(): boolean;
  10753. /**
  10754. * Serialize the ValueCondition into a JSON compatible object
  10755. * @returns serialization object
  10756. */
  10757. serialize(): any;
  10758. /**
  10759. * Gets the name of the conditional operator for the ValueCondition
  10760. * @param operator the conditional operator
  10761. * @returns the name
  10762. */
  10763. static GetOperatorName(operator: number): string;
  10764. }
  10765. /**
  10766. * Defines a predicate condition as an extension of Condition
  10767. */
  10768. export class PredicateCondition extends Condition {
  10769. /** defines the predicate function used to validate the condition */
  10770. predicate: () => boolean;
  10771. /**
  10772. * Internal only - manager for action
  10773. * @hidden
  10774. */
  10775. _actionManager: ActionManager;
  10776. /**
  10777. * Creates a new PredicateCondition
  10778. * @param actionManager manager for the action the condition applies to
  10779. * @param predicate defines the predicate function used to validate the condition
  10780. */
  10781. constructor(actionManager: ActionManager,
  10782. /** defines the predicate function used to validate the condition */
  10783. predicate: () => boolean);
  10784. /**
  10785. * @returns the validity of the predicate condition
  10786. */
  10787. isValid(): boolean;
  10788. }
  10789. /**
  10790. * Defines a state condition as an extension of Condition
  10791. */
  10792. export class StateCondition extends Condition {
  10793. /** Value to compare with target state */
  10794. value: string;
  10795. /**
  10796. * Internal only - manager for action
  10797. * @hidden
  10798. */
  10799. _actionManager: ActionManager;
  10800. /**
  10801. * Internal only
  10802. * @hidden
  10803. */
  10804. private _target;
  10805. /**
  10806. * Creates a new StateCondition
  10807. * @param actionManager manager for the action the condition applies to
  10808. * @param target of the condition
  10809. * @param value to compare with target state
  10810. */
  10811. constructor(actionManager: ActionManager, target: any,
  10812. /** Value to compare with target state */
  10813. value: string);
  10814. /**
  10815. * Gets a boolean indicating if the current condition is met
  10816. * @returns the validity of the state
  10817. */
  10818. isValid(): boolean;
  10819. /**
  10820. * Serialize the StateCondition into a JSON compatible object
  10821. * @returns serialization object
  10822. */
  10823. serialize(): any;
  10824. }
  10825. }
  10826. declare module "babylonjs/Actions/directActions" {
  10827. import { Action } from "babylonjs/Actions/action";
  10828. import { Condition } from "babylonjs/Actions/condition";
  10829. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10830. /**
  10831. * This defines an action responsible to toggle a boolean once triggered.
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10833. */
  10834. export class SwitchBooleanAction extends Action {
  10835. /**
  10836. * The path to the boolean property in the target object
  10837. */
  10838. propertyPath: string;
  10839. private _target;
  10840. private _effectiveTarget;
  10841. private _property;
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param target defines the object containing the boolean
  10846. * @param propertyPath defines the path to the boolean property in the target object
  10847. * @param condition defines the trigger related conditions
  10848. */
  10849. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10850. /** @hidden */
  10851. _prepare(): void;
  10852. /**
  10853. * Execute the action toggle the boolean value.
  10854. */
  10855. execute(): void;
  10856. /**
  10857. * Serializes the actions and its related information.
  10858. * @param parent defines the object to serialize in
  10859. * @returns the serialized object
  10860. */
  10861. serialize(parent: any): any;
  10862. }
  10863. /**
  10864. * This defines an action responsible to set a the state field of the target
  10865. * to a desired value once triggered.
  10866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10867. */
  10868. export class SetStateAction extends Action {
  10869. /**
  10870. * The value to store in the state field.
  10871. */
  10872. value: string;
  10873. private _target;
  10874. /**
  10875. * Instantiate the action
  10876. * @param triggerOptions defines the trigger options
  10877. * @param target defines the object containing the state property
  10878. * @param value defines the value to store in the state field
  10879. * @param condition defines the trigger related conditions
  10880. */
  10881. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10882. /**
  10883. * Execute the action and store the value on the target state property.
  10884. */
  10885. execute(): void;
  10886. /**
  10887. * Serializes the actions and its related information.
  10888. * @param parent defines the object to serialize in
  10889. * @returns the serialized object
  10890. */
  10891. serialize(parent: any): any;
  10892. }
  10893. /**
  10894. * This defines an action responsible to set a property of the target
  10895. * to a desired value once triggered.
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10897. */
  10898. export class SetValueAction extends Action {
  10899. /**
  10900. * The path of the property to set in the target.
  10901. */
  10902. propertyPath: string;
  10903. /**
  10904. * The value to set in the property
  10905. */
  10906. value: any;
  10907. private _target;
  10908. private _effectiveTarget;
  10909. private _property;
  10910. /**
  10911. * Instantiate the action
  10912. * @param triggerOptions defines the trigger options
  10913. * @param target defines the object containing the property
  10914. * @param propertyPath defines the path of the property to set in the target
  10915. * @param value defines the value to set in the property
  10916. * @param condition defines the trigger related conditions
  10917. */
  10918. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10919. /** @hidden */
  10920. _prepare(): void;
  10921. /**
  10922. * Execute the action and set the targetted property to the desired value.
  10923. */
  10924. execute(): void;
  10925. /**
  10926. * Serializes the actions and its related information.
  10927. * @param parent defines the object to serialize in
  10928. * @returns the serialized object
  10929. */
  10930. serialize(parent: any): any;
  10931. }
  10932. /**
  10933. * This defines an action responsible to increment the target value
  10934. * to a desired value once triggered.
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10936. */
  10937. export class IncrementValueAction extends Action {
  10938. /**
  10939. * The path of the property to increment in the target.
  10940. */
  10941. propertyPath: string;
  10942. /**
  10943. * The value we should increment the property by.
  10944. */
  10945. value: any;
  10946. private _target;
  10947. private _effectiveTarget;
  10948. private _property;
  10949. /**
  10950. * Instantiate the action
  10951. * @param triggerOptions defines the trigger options
  10952. * @param target defines the object containing the property
  10953. * @param propertyPath defines the path of the property to increment in the target
  10954. * @param value defines the value value we should increment the property by
  10955. * @param condition defines the trigger related conditions
  10956. */
  10957. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10958. /** @hidden */
  10959. _prepare(): void;
  10960. /**
  10961. * Execute the action and increment the target of the value amount.
  10962. */
  10963. execute(): void;
  10964. /**
  10965. * Serializes the actions and its related information.
  10966. * @param parent defines the object to serialize in
  10967. * @returns the serialized object
  10968. */
  10969. serialize(parent: any): any;
  10970. }
  10971. /**
  10972. * This defines an action responsible to start an animation once triggered.
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10974. */
  10975. export class PlayAnimationAction extends Action {
  10976. /**
  10977. * Where the animation should start (animation frame)
  10978. */
  10979. from: number;
  10980. /**
  10981. * Where the animation should stop (animation frame)
  10982. */
  10983. to: number;
  10984. /**
  10985. * Define if the animation should loop or stop after the first play.
  10986. */
  10987. loop?: boolean;
  10988. private _target;
  10989. /**
  10990. * Instantiate the action
  10991. * @param triggerOptions defines the trigger options
  10992. * @param target defines the target animation or animation name
  10993. * @param from defines from where the animation should start (animation frame)
  10994. * @param end defines where the animation should stop (animation frame)
  10995. * @param loop defines if the animation should loop or stop after the first play
  10996. * @param condition defines the trigger related conditions
  10997. */
  10998. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10999. /** @hidden */
  11000. _prepare(): void;
  11001. /**
  11002. * Execute the action and play the animation.
  11003. */
  11004. execute(): void;
  11005. /**
  11006. * Serializes the actions and its related information.
  11007. * @param parent defines the object to serialize in
  11008. * @returns the serialized object
  11009. */
  11010. serialize(parent: any): any;
  11011. }
  11012. /**
  11013. * This defines an action responsible to stop an animation once triggered.
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11015. */
  11016. export class StopAnimationAction extends Action {
  11017. private _target;
  11018. /**
  11019. * Instantiate the action
  11020. * @param triggerOptions defines the trigger options
  11021. * @param target defines the target animation or animation name
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions: any, target: any, condition?: Condition);
  11025. /** @hidden */
  11026. _prepare(): void;
  11027. /**
  11028. * Execute the action and stop the animation.
  11029. */
  11030. execute(): void;
  11031. /**
  11032. * Serializes the actions and its related information.
  11033. * @param parent defines the object to serialize in
  11034. * @returns the serialized object
  11035. */
  11036. serialize(parent: any): any;
  11037. }
  11038. /**
  11039. * This defines an action responsible that does nothing once triggered.
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11041. */
  11042. export class DoNothingAction extends Action {
  11043. /**
  11044. * Instantiate the action
  11045. * @param triggerOptions defines the trigger options
  11046. * @param condition defines the trigger related conditions
  11047. */
  11048. constructor(triggerOptions?: any, condition?: Condition);
  11049. /**
  11050. * Execute the action and do nothing.
  11051. */
  11052. execute(): void;
  11053. /**
  11054. * Serializes the actions and its related information.
  11055. * @param parent defines the object to serialize in
  11056. * @returns the serialized object
  11057. */
  11058. serialize(parent: any): any;
  11059. }
  11060. /**
  11061. * This defines an action responsible to trigger several actions once triggered.
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11063. */
  11064. export class CombineAction extends Action {
  11065. /**
  11066. * The list of aggregated animations to run.
  11067. */
  11068. children: Action[];
  11069. /**
  11070. * Instantiate the action
  11071. * @param triggerOptions defines the trigger options
  11072. * @param children defines the list of aggregated animations to run
  11073. * @param condition defines the trigger related conditions
  11074. */
  11075. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11076. /** @hidden */
  11077. _prepare(): void;
  11078. /**
  11079. * Execute the action and executes all the aggregated actions.
  11080. */
  11081. execute(evt: ActionEvent): void;
  11082. /**
  11083. * Serializes the actions and its related information.
  11084. * @param parent defines the object to serialize in
  11085. * @returns the serialized object
  11086. */
  11087. serialize(parent: any): any;
  11088. }
  11089. /**
  11090. * This defines an action responsible to run code (external event) once triggered.
  11091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11092. */
  11093. export class ExecuteCodeAction extends Action {
  11094. /**
  11095. * The callback function to run.
  11096. */
  11097. func: (evt: ActionEvent) => void;
  11098. /**
  11099. * Instantiate the action
  11100. * @param triggerOptions defines the trigger options
  11101. * @param func defines the callback function to run
  11102. * @param condition defines the trigger related conditions
  11103. */
  11104. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11105. /**
  11106. * Execute the action and run the attached code.
  11107. */
  11108. execute(evt: ActionEvent): void;
  11109. }
  11110. /**
  11111. * This defines an action responsible to set the parent property of the target once triggered.
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11113. */
  11114. export class SetParentAction extends Action {
  11115. private _parent;
  11116. private _target;
  11117. /**
  11118. * Instantiate the action
  11119. * @param triggerOptions defines the trigger options
  11120. * @param target defines the target containing the parent property
  11121. * @param parent defines from where the animation should start (animation frame)
  11122. * @param condition defines the trigger related conditions
  11123. */
  11124. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11125. /** @hidden */
  11126. _prepare(): void;
  11127. /**
  11128. * Execute the action and set the parent property.
  11129. */
  11130. execute(): void;
  11131. /**
  11132. * Serializes the actions and its related information.
  11133. * @param parent defines the object to serialize in
  11134. * @returns the serialized object
  11135. */
  11136. serialize(parent: any): any;
  11137. }
  11138. }
  11139. declare module "babylonjs/Actions/actionManager" {
  11140. import { Nullable } from "babylonjs/types";
  11141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11142. import { Scene } from "babylonjs/scene";
  11143. import { IAction } from "babylonjs/Actions/action";
  11144. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11145. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11146. /**
  11147. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11148. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11150. */
  11151. export class ActionManager extends AbstractActionManager {
  11152. /**
  11153. * Nothing
  11154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11155. */
  11156. static readonly NothingTrigger: number;
  11157. /**
  11158. * On pick
  11159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11160. */
  11161. static readonly OnPickTrigger: number;
  11162. /**
  11163. * On left pick
  11164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11165. */
  11166. static readonly OnLeftPickTrigger: number;
  11167. /**
  11168. * On right pick
  11169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11170. */
  11171. static readonly OnRightPickTrigger: number;
  11172. /**
  11173. * On center pick
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11175. */
  11176. static readonly OnCenterPickTrigger: number;
  11177. /**
  11178. * On pick down
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11180. */
  11181. static readonly OnPickDownTrigger: number;
  11182. /**
  11183. * On double pick
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11185. */
  11186. static readonly OnDoublePickTrigger: number;
  11187. /**
  11188. * On pick up
  11189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11190. */
  11191. static readonly OnPickUpTrigger: number;
  11192. /**
  11193. * On pick out.
  11194. * This trigger will only be raised if you also declared a OnPickDown
  11195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11196. */
  11197. static readonly OnPickOutTrigger: number;
  11198. /**
  11199. * On long press
  11200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11201. */
  11202. static readonly OnLongPressTrigger: number;
  11203. /**
  11204. * On pointer over
  11205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11206. */
  11207. static readonly OnPointerOverTrigger: number;
  11208. /**
  11209. * On pointer out
  11210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11211. */
  11212. static readonly OnPointerOutTrigger: number;
  11213. /**
  11214. * On every frame
  11215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11216. */
  11217. static readonly OnEveryFrameTrigger: number;
  11218. /**
  11219. * On intersection enter
  11220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11221. */
  11222. static readonly OnIntersectionEnterTrigger: number;
  11223. /**
  11224. * On intersection exit
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11226. */
  11227. static readonly OnIntersectionExitTrigger: number;
  11228. /**
  11229. * On key down
  11230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11231. */
  11232. static readonly OnKeyDownTrigger: number;
  11233. /**
  11234. * On key up
  11235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11236. */
  11237. static readonly OnKeyUpTrigger: number;
  11238. private _scene;
  11239. /**
  11240. * Creates a new action manager
  11241. * @param scene defines the hosting scene
  11242. */
  11243. constructor(scene: Scene);
  11244. /**
  11245. * Releases all associated resources
  11246. */
  11247. dispose(): void;
  11248. /**
  11249. * Gets hosting scene
  11250. * @returns the hosting scene
  11251. */
  11252. getScene(): Scene;
  11253. /**
  11254. * Does this action manager handles actions of any of the given triggers
  11255. * @param triggers defines the triggers to be tested
  11256. * @return a boolean indicating whether one (or more) of the triggers is handled
  11257. */
  11258. hasSpecificTriggers(triggers: number[]): boolean;
  11259. /**
  11260. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11261. * speed.
  11262. * @param triggerA defines the trigger to be tested
  11263. * @param triggerB defines the trigger to be tested
  11264. * @return a boolean indicating whether one (or more) of the triggers is handled
  11265. */
  11266. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11267. /**
  11268. * Does this action manager handles actions of a given trigger
  11269. * @param trigger defines the trigger to be tested
  11270. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11271. * @return whether the trigger is handled
  11272. */
  11273. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11274. /**
  11275. * Does this action manager has pointer triggers
  11276. */
  11277. get hasPointerTriggers(): boolean;
  11278. /**
  11279. * Does this action manager has pick triggers
  11280. */
  11281. get hasPickTriggers(): boolean;
  11282. /**
  11283. * Registers an action to this action manager
  11284. * @param action defines the action to be registered
  11285. * @return the action amended (prepared) after registration
  11286. */
  11287. registerAction(action: IAction): Nullable<IAction>;
  11288. /**
  11289. * Unregisters an action to this action manager
  11290. * @param action defines the action to be unregistered
  11291. * @return a boolean indicating whether the action has been unregistered
  11292. */
  11293. unregisterAction(action: IAction): Boolean;
  11294. /**
  11295. * Process a specific trigger
  11296. * @param trigger defines the trigger to process
  11297. * @param evt defines the event details to be processed
  11298. */
  11299. processTrigger(trigger: number, evt?: IActionEvent): void;
  11300. /** @hidden */
  11301. _getEffectiveTarget(target: any, propertyPath: string): any;
  11302. /** @hidden */
  11303. _getProperty(propertyPath: string): string;
  11304. /**
  11305. * Serialize this manager to a JSON object
  11306. * @param name defines the property name to store this manager
  11307. * @returns a JSON representation of this manager
  11308. */
  11309. serialize(name: string): any;
  11310. /**
  11311. * Creates a new ActionManager from a JSON data
  11312. * @param parsedActions defines the JSON data to read from
  11313. * @param object defines the hosting mesh
  11314. * @param scene defines the hosting scene
  11315. */
  11316. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11317. /**
  11318. * Get a trigger name by index
  11319. * @param trigger defines the trigger index
  11320. * @returns a trigger name
  11321. */
  11322. static GetTriggerName(trigger: number): string;
  11323. }
  11324. }
  11325. declare module "babylonjs/Culling/ray" {
  11326. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11327. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11329. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11330. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11331. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11332. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11333. import { Plane } from "babylonjs/Maths/math.plane";
  11334. /**
  11335. * Class representing a ray with position and direction
  11336. */
  11337. export class Ray {
  11338. /** origin point */
  11339. origin: Vector3;
  11340. /** direction */
  11341. direction: Vector3;
  11342. /** length of the ray */
  11343. length: number;
  11344. private static readonly TmpVector3;
  11345. private _tmpRay;
  11346. /**
  11347. * Creates a new ray
  11348. * @param origin origin point
  11349. * @param direction direction
  11350. * @param length length of the ray
  11351. */
  11352. constructor(
  11353. /** origin point */
  11354. origin: Vector3,
  11355. /** direction */
  11356. direction: Vector3,
  11357. /** length of the ray */
  11358. length?: number);
  11359. /**
  11360. * Checks if the ray intersects a box
  11361. * @param minimum bound of the box
  11362. * @param maximum bound of the box
  11363. * @param intersectionTreshold extra extend to be added to the box in all direction
  11364. * @returns if the box was hit
  11365. */
  11366. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11367. /**
  11368. * Checks if the ray intersects a box
  11369. * @param box the bounding box to check
  11370. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11371. * @returns if the box was hit
  11372. */
  11373. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11374. /**
  11375. * If the ray hits a sphere
  11376. * @param sphere the bounding sphere to check
  11377. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11378. * @returns true if it hits the sphere
  11379. */
  11380. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11381. /**
  11382. * If the ray hits a triange
  11383. * @param vertex0 triangle vertex
  11384. * @param vertex1 triangle vertex
  11385. * @param vertex2 triangle vertex
  11386. * @returns intersection information if hit
  11387. */
  11388. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11389. /**
  11390. * Checks if ray intersects a plane
  11391. * @param plane the plane to check
  11392. * @returns the distance away it was hit
  11393. */
  11394. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11395. /**
  11396. * Calculate the intercept of a ray on a given axis
  11397. * @param axis to check 'x' | 'y' | 'z'
  11398. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11399. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11400. */
  11401. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11402. /**
  11403. * Checks if ray intersects a mesh
  11404. * @param mesh the mesh to check
  11405. * @param fastCheck if only the bounding box should checked
  11406. * @returns picking info of the intersecton
  11407. */
  11408. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11409. /**
  11410. * Checks if ray intersects a mesh
  11411. * @param meshes the meshes to check
  11412. * @param fastCheck if only the bounding box should checked
  11413. * @param results array to store result in
  11414. * @returns Array of picking infos
  11415. */
  11416. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11417. private _comparePickingInfo;
  11418. private static smallnum;
  11419. private static rayl;
  11420. /**
  11421. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11422. * @param sega the first point of the segment to test the intersection against
  11423. * @param segb the second point of the segment to test the intersection against
  11424. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11425. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11426. */
  11427. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11428. /**
  11429. * Update the ray from viewport position
  11430. * @param x position
  11431. * @param y y position
  11432. * @param viewportWidth viewport width
  11433. * @param viewportHeight viewport height
  11434. * @param world world matrix
  11435. * @param view view matrix
  11436. * @param projection projection matrix
  11437. * @returns this ray updated
  11438. */
  11439. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11440. /**
  11441. * Creates a ray with origin and direction of 0,0,0
  11442. * @returns the new ray
  11443. */
  11444. static Zero(): Ray;
  11445. /**
  11446. * Creates a new ray from screen space and viewport
  11447. * @param x position
  11448. * @param y y position
  11449. * @param viewportWidth viewport width
  11450. * @param viewportHeight viewport height
  11451. * @param world world matrix
  11452. * @param view view matrix
  11453. * @param projection projection matrix
  11454. * @returns new ray
  11455. */
  11456. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11457. /**
  11458. * 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
  11459. * transformed to the given world matrix.
  11460. * @param origin The origin point
  11461. * @param end The end point
  11462. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11463. * @returns the new ray
  11464. */
  11465. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11466. /**
  11467. * Transforms a ray by a matrix
  11468. * @param ray ray to transform
  11469. * @param matrix matrix to apply
  11470. * @returns the resulting new ray
  11471. */
  11472. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11473. /**
  11474. * Transforms a ray by a matrix
  11475. * @param ray ray to transform
  11476. * @param matrix matrix to apply
  11477. * @param result ray to store result in
  11478. */
  11479. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11480. /**
  11481. * Unproject a ray from screen space to object space
  11482. * @param sourceX defines the screen space x coordinate to use
  11483. * @param sourceY defines the screen space y coordinate to use
  11484. * @param viewportWidth defines the current width of the viewport
  11485. * @param viewportHeight defines the current height of the viewport
  11486. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11487. * @param view defines the view matrix to use
  11488. * @param projection defines the projection matrix to use
  11489. */
  11490. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11491. }
  11492. /**
  11493. * Type used to define predicate used to select faces when a mesh intersection is detected
  11494. */
  11495. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11496. module "babylonjs/scene" {
  11497. interface Scene {
  11498. /** @hidden */
  11499. _tempPickingRay: Nullable<Ray>;
  11500. /** @hidden */
  11501. _cachedRayForTransform: Ray;
  11502. /** @hidden */
  11503. _pickWithRayInverseMatrix: Matrix;
  11504. /** @hidden */
  11505. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11506. /** @hidden */
  11507. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11508. }
  11509. }
  11510. }
  11511. declare module "babylonjs/sceneComponent" {
  11512. import { Scene } from "babylonjs/scene";
  11513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11514. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11515. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11516. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11517. import { Nullable } from "babylonjs/types";
  11518. import { Camera } from "babylonjs/Cameras/camera";
  11519. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11520. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11521. import { AbstractScene } from "babylonjs/abstractScene";
  11522. import { Mesh } from "babylonjs/Meshes/mesh";
  11523. /**
  11524. * Groups all the scene component constants in one place to ease maintenance.
  11525. * @hidden
  11526. */
  11527. export class SceneComponentConstants {
  11528. static readonly NAME_EFFECTLAYER: string;
  11529. static readonly NAME_LAYER: string;
  11530. static readonly NAME_LENSFLARESYSTEM: string;
  11531. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11532. static readonly NAME_PARTICLESYSTEM: string;
  11533. static readonly NAME_GAMEPAD: string;
  11534. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11535. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11536. static readonly NAME_DEPTHRENDERER: string;
  11537. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11538. static readonly NAME_SPRITE: string;
  11539. static readonly NAME_OUTLINERENDERER: string;
  11540. static readonly NAME_PROCEDURALTEXTURE: string;
  11541. static readonly NAME_SHADOWGENERATOR: string;
  11542. static readonly NAME_OCTREE: string;
  11543. static readonly NAME_PHYSICSENGINE: string;
  11544. static readonly NAME_AUDIO: string;
  11545. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11546. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11547. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11548. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11549. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11550. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11551. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11552. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11553. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11554. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11555. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11556. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11557. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11558. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11559. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11560. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11561. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11562. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11563. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11564. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11565. static readonly STEP_AFTERRENDER_AUDIO: number;
  11566. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11567. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11568. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11569. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11570. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11571. static readonly STEP_POINTERMOVE_SPRITE: number;
  11572. static readonly STEP_POINTERDOWN_SPRITE: number;
  11573. static readonly STEP_POINTERUP_SPRITE: number;
  11574. }
  11575. /**
  11576. * This represents a scene component.
  11577. *
  11578. * This is used to decouple the dependency the scene is having on the different workloads like
  11579. * layers, post processes...
  11580. */
  11581. export interface ISceneComponent {
  11582. /**
  11583. * The name of the component. Each component must have a unique name.
  11584. */
  11585. name: string;
  11586. /**
  11587. * The scene the component belongs to.
  11588. */
  11589. scene: Scene;
  11590. /**
  11591. * Register the component to one instance of a scene.
  11592. */
  11593. register(): void;
  11594. /**
  11595. * Rebuilds the elements related to this component in case of
  11596. * context lost for instance.
  11597. */
  11598. rebuild(): void;
  11599. /**
  11600. * Disposes the component and the associated ressources.
  11601. */
  11602. dispose(): void;
  11603. }
  11604. /**
  11605. * This represents a SERIALIZABLE scene component.
  11606. *
  11607. * This extends Scene Component to add Serialization methods on top.
  11608. */
  11609. export interface ISceneSerializableComponent extends ISceneComponent {
  11610. /**
  11611. * Adds all the elements from the container to the scene
  11612. * @param container the container holding the elements
  11613. */
  11614. addFromContainer(container: AbstractScene): void;
  11615. /**
  11616. * Removes all the elements in the container from the scene
  11617. * @param container contains the elements to remove
  11618. * @param dispose if the removed element should be disposed (default: false)
  11619. */
  11620. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11621. /**
  11622. * Serializes the component data to the specified json object
  11623. * @param serializationObject The object to serialize to
  11624. */
  11625. serialize(serializationObject: any): void;
  11626. }
  11627. /**
  11628. * Strong typing of a Mesh related stage step action
  11629. */
  11630. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11631. /**
  11632. * Strong typing of a Evaluate Sub Mesh related stage step action
  11633. */
  11634. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11635. /**
  11636. * Strong typing of a Active Mesh related stage step action
  11637. */
  11638. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11639. /**
  11640. * Strong typing of a Camera related stage step action
  11641. */
  11642. export type CameraStageAction = (camera: Camera) => void;
  11643. /**
  11644. * Strong typing of a Camera Frame buffer related stage step action
  11645. */
  11646. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11647. /**
  11648. * Strong typing of a Render Target related stage step action
  11649. */
  11650. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11651. /**
  11652. * Strong typing of a RenderingGroup related stage step action
  11653. */
  11654. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11655. /**
  11656. * Strong typing of a Mesh Render related stage step action
  11657. */
  11658. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11659. /**
  11660. * Strong typing of a simple stage step action
  11661. */
  11662. export type SimpleStageAction = () => void;
  11663. /**
  11664. * Strong typing of a render target action.
  11665. */
  11666. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11667. /**
  11668. * Strong typing of a pointer move action.
  11669. */
  11670. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11671. /**
  11672. * Strong typing of a pointer up/down action.
  11673. */
  11674. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11675. /**
  11676. * Representation of a stage in the scene (Basically a list of ordered steps)
  11677. * @hidden
  11678. */
  11679. export class Stage<T extends Function> extends Array<{
  11680. index: number;
  11681. component: ISceneComponent;
  11682. action: T;
  11683. }> {
  11684. /**
  11685. * Hide ctor from the rest of the world.
  11686. * @param items The items to add.
  11687. */
  11688. private constructor();
  11689. /**
  11690. * Creates a new Stage.
  11691. * @returns A new instance of a Stage
  11692. */
  11693. static Create<T extends Function>(): Stage<T>;
  11694. /**
  11695. * Registers a step in an ordered way in the targeted stage.
  11696. * @param index Defines the position to register the step in
  11697. * @param component Defines the component attached to the step
  11698. * @param action Defines the action to launch during the step
  11699. */
  11700. registerStep(index: number, component: ISceneComponent, action: T): void;
  11701. /**
  11702. * Clears all the steps from the stage.
  11703. */
  11704. clear(): void;
  11705. }
  11706. }
  11707. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11708. import { Nullable } from "babylonjs/types";
  11709. import { Observable } from "babylonjs/Misc/observable";
  11710. import { Scene } from "babylonjs/scene";
  11711. import { Sprite } from "babylonjs/Sprites/sprite";
  11712. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11713. import { Ray } from "babylonjs/Culling/ray";
  11714. import { Camera } from "babylonjs/Cameras/camera";
  11715. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11716. import { ISceneComponent } from "babylonjs/sceneComponent";
  11717. module "babylonjs/scene" {
  11718. interface Scene {
  11719. /** @hidden */
  11720. _pointerOverSprite: Nullable<Sprite>;
  11721. /** @hidden */
  11722. _pickedDownSprite: Nullable<Sprite>;
  11723. /** @hidden */
  11724. _tempSpritePickingRay: Nullable<Ray>;
  11725. /**
  11726. * All of the sprite managers added to this scene
  11727. * @see http://doc.babylonjs.com/babylon101/sprites
  11728. */
  11729. spriteManagers: Array<ISpriteManager>;
  11730. /**
  11731. * An event triggered when sprites rendering is about to start
  11732. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11733. */
  11734. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11735. /**
  11736. * An event triggered when sprites rendering is done
  11737. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11738. */
  11739. onAfterSpritesRenderingObservable: Observable<Scene>;
  11740. /** @hidden */
  11741. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11742. /** Launch a ray to try to pick a sprite in the scene
  11743. * @param x position on screen
  11744. * @param y position on screen
  11745. * @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
  11746. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11747. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11748. * @returns a PickingInfo
  11749. */
  11750. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11751. /** Use the given ray to pick a sprite in the scene
  11752. * @param ray The ray (in world space) to use to pick meshes
  11753. * @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
  11754. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11755. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11756. * @returns a PickingInfo
  11757. */
  11758. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11759. /** @hidden */
  11760. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11761. /** Launch a ray to try to pick sprites in the scene
  11762. * @param x position on screen
  11763. * @param y position on screen
  11764. * @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
  11765. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11766. * @returns a PickingInfo array
  11767. */
  11768. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11769. /** Use the given ray to pick sprites in the scene
  11770. * @param ray The ray (in world space) to use to pick meshes
  11771. * @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
  11772. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11773. * @returns a PickingInfo array
  11774. */
  11775. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11776. /**
  11777. * Force the sprite under the pointer
  11778. * @param sprite defines the sprite to use
  11779. */
  11780. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11781. /**
  11782. * Gets the sprite under the pointer
  11783. * @returns a Sprite or null if no sprite is under the pointer
  11784. */
  11785. getPointerOverSprite(): Nullable<Sprite>;
  11786. }
  11787. }
  11788. /**
  11789. * Defines the sprite scene component responsible to manage sprites
  11790. * in a given scene.
  11791. */
  11792. export class SpriteSceneComponent implements ISceneComponent {
  11793. /**
  11794. * The component name helpfull to identify the component in the list of scene components.
  11795. */
  11796. readonly name: string;
  11797. /**
  11798. * The scene the component belongs to.
  11799. */
  11800. scene: Scene;
  11801. /** @hidden */
  11802. private _spritePredicate;
  11803. /**
  11804. * Creates a new instance of the component for the given scene
  11805. * @param scene Defines the scene to register the component in
  11806. */
  11807. constructor(scene: Scene);
  11808. /**
  11809. * Registers the component in a given scene
  11810. */
  11811. register(): void;
  11812. /**
  11813. * Rebuilds the elements related to this component in case of
  11814. * context lost for instance.
  11815. */
  11816. rebuild(): void;
  11817. /**
  11818. * Disposes the component and the associated ressources.
  11819. */
  11820. dispose(): void;
  11821. private _pickSpriteButKeepRay;
  11822. private _pointerMove;
  11823. private _pointerDown;
  11824. private _pointerUp;
  11825. }
  11826. }
  11827. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11828. /** @hidden */
  11829. export var fogFragmentDeclaration: {
  11830. name: string;
  11831. shader: string;
  11832. };
  11833. }
  11834. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11835. /** @hidden */
  11836. export var fogFragment: {
  11837. name: string;
  11838. shader: string;
  11839. };
  11840. }
  11841. declare module "babylonjs/Shaders/sprites.fragment" {
  11842. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11843. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11844. /** @hidden */
  11845. export var spritesPixelShader: {
  11846. name: string;
  11847. shader: string;
  11848. };
  11849. }
  11850. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11851. /** @hidden */
  11852. export var fogVertexDeclaration: {
  11853. name: string;
  11854. shader: string;
  11855. };
  11856. }
  11857. declare module "babylonjs/Shaders/sprites.vertex" {
  11858. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11859. /** @hidden */
  11860. export var spritesVertexShader: {
  11861. name: string;
  11862. shader: string;
  11863. };
  11864. }
  11865. declare module "babylonjs/Sprites/spriteManager" {
  11866. import { IDisposable, Scene } from "babylonjs/scene";
  11867. import { Nullable } from "babylonjs/types";
  11868. import { Observable } from "babylonjs/Misc/observable";
  11869. import { Sprite } from "babylonjs/Sprites/sprite";
  11870. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11871. import { Camera } from "babylonjs/Cameras/camera";
  11872. import { Texture } from "babylonjs/Materials/Textures/texture";
  11873. import "babylonjs/Shaders/sprites.fragment";
  11874. import "babylonjs/Shaders/sprites.vertex";
  11875. import { Ray } from "babylonjs/Culling/ray";
  11876. /**
  11877. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11878. */
  11879. export interface ISpriteManager extends IDisposable {
  11880. /**
  11881. * Restricts the camera to viewing objects with the same layerMask.
  11882. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11883. */
  11884. layerMask: number;
  11885. /**
  11886. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11887. */
  11888. isPickable: boolean;
  11889. /**
  11890. * Specifies the rendering group id for this mesh (0 by default)
  11891. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11892. */
  11893. renderingGroupId: number;
  11894. /**
  11895. * Defines the list of sprites managed by the manager.
  11896. */
  11897. sprites: Array<Sprite>;
  11898. /**
  11899. * Tests the intersection of a sprite with a specific ray.
  11900. * @param ray The ray we are sending to test the collision
  11901. * @param camera The camera space we are sending rays in
  11902. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11903. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11904. * @returns picking info or null.
  11905. */
  11906. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11907. /**
  11908. * Intersects the sprites with a ray
  11909. * @param ray defines the ray to intersect with
  11910. * @param camera defines the current active camera
  11911. * @param predicate defines a predicate used to select candidate sprites
  11912. * @returns null if no hit or a PickingInfo array
  11913. */
  11914. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11915. /**
  11916. * Renders the list of sprites on screen.
  11917. */
  11918. render(): void;
  11919. }
  11920. /**
  11921. * Class used to manage multiple sprites on the same spritesheet
  11922. * @see http://doc.babylonjs.com/babylon101/sprites
  11923. */
  11924. export class SpriteManager implements ISpriteManager {
  11925. /** defines the manager's name */
  11926. name: string;
  11927. /** Gets the list of sprites */
  11928. sprites: Sprite[];
  11929. /** Gets or sets the rendering group id (0 by default) */
  11930. renderingGroupId: number;
  11931. /** Gets or sets camera layer mask */
  11932. layerMask: number;
  11933. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11934. fogEnabled: boolean;
  11935. /** Gets or sets a boolean indicating if the sprites are pickable */
  11936. isPickable: boolean;
  11937. /** Defines the default width of a cell in the spritesheet */
  11938. cellWidth: number;
  11939. /** Defines the default height of a cell in the spritesheet */
  11940. cellHeight: number;
  11941. /** Associative array from JSON sprite data file */
  11942. private _cellData;
  11943. /** Array of sprite names from JSON sprite data file */
  11944. private _spriteMap;
  11945. /** True when packed cell data from JSON file is ready*/
  11946. private _packedAndReady;
  11947. /**
  11948. * An event triggered when the manager is disposed.
  11949. */
  11950. onDisposeObservable: Observable<SpriteManager>;
  11951. private _onDisposeObserver;
  11952. /**
  11953. * Callback called when the manager is disposed
  11954. */
  11955. set onDispose(callback: () => void);
  11956. private _capacity;
  11957. private _fromPacked;
  11958. private _spriteTexture;
  11959. private _epsilon;
  11960. private _scene;
  11961. private _vertexData;
  11962. private _buffer;
  11963. private _vertexBuffers;
  11964. private _indexBuffer;
  11965. private _effectBase;
  11966. private _effectFog;
  11967. /**
  11968. * Gets or sets the spritesheet texture
  11969. */
  11970. get texture(): Texture;
  11971. set texture(value: Texture);
  11972. /**
  11973. * Creates a new sprite manager
  11974. * @param name defines the manager's name
  11975. * @param imgUrl defines the sprite sheet url
  11976. * @param capacity defines the maximum allowed number of sprites
  11977. * @param cellSize defines the size of a sprite cell
  11978. * @param scene defines the hosting scene
  11979. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11980. * @param samplingMode defines the smapling mode to use with spritesheet
  11981. * @param fromPacked set to false; do not alter
  11982. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11983. */
  11984. constructor(
  11985. /** defines the manager's name */
  11986. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11987. private _makePacked;
  11988. private _appendSpriteVertex;
  11989. /**
  11990. * Intersects the sprites with a ray
  11991. * @param ray defines the ray to intersect with
  11992. * @param camera defines the current active camera
  11993. * @param predicate defines a predicate used to select candidate sprites
  11994. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11995. * @returns null if no hit or a PickingInfo
  11996. */
  11997. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11998. /**
  11999. * Intersects the sprites with a ray
  12000. * @param ray defines the ray to intersect with
  12001. * @param camera defines the current active camera
  12002. * @param predicate defines a predicate used to select candidate sprites
  12003. * @returns null if no hit or a PickingInfo array
  12004. */
  12005. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12006. /**
  12007. * Render all child sprites
  12008. */
  12009. render(): void;
  12010. /**
  12011. * Release associated resources
  12012. */
  12013. dispose(): void;
  12014. }
  12015. }
  12016. declare module "babylonjs/Sprites/sprite" {
  12017. import { Vector3 } from "babylonjs/Maths/math.vector";
  12018. import { Nullable } from "babylonjs/types";
  12019. import { ActionManager } from "babylonjs/Actions/actionManager";
  12020. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12021. import { Color4 } from "babylonjs/Maths/math.color";
  12022. /**
  12023. * Class used to represent a sprite
  12024. * @see http://doc.babylonjs.com/babylon101/sprites
  12025. */
  12026. export class Sprite {
  12027. /** defines the name */
  12028. name: string;
  12029. /** Gets or sets the current world position */
  12030. position: Vector3;
  12031. /** Gets or sets the main color */
  12032. color: Color4;
  12033. /** Gets or sets the width */
  12034. width: number;
  12035. /** Gets or sets the height */
  12036. height: number;
  12037. /** Gets or sets rotation angle */
  12038. angle: number;
  12039. /** Gets or sets the cell index in the sprite sheet */
  12040. cellIndex: number;
  12041. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12042. cellRef: string;
  12043. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12044. invertU: number;
  12045. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12046. invertV: number;
  12047. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12048. disposeWhenFinishedAnimating: boolean;
  12049. /** Gets the list of attached animations */
  12050. animations: Animation[];
  12051. /** Gets or sets a boolean indicating if the sprite can be picked */
  12052. isPickable: boolean;
  12053. /**
  12054. * Gets or sets the associated action manager
  12055. */
  12056. actionManager: Nullable<ActionManager>;
  12057. private _animationStarted;
  12058. private _loopAnimation;
  12059. private _fromIndex;
  12060. private _toIndex;
  12061. private _delay;
  12062. private _direction;
  12063. private _manager;
  12064. private _time;
  12065. private _onAnimationEnd;
  12066. /**
  12067. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12068. */
  12069. isVisible: boolean;
  12070. /**
  12071. * Gets or sets the sprite size
  12072. */
  12073. get size(): number;
  12074. set size(value: number);
  12075. /**
  12076. * Creates a new Sprite
  12077. * @param name defines the name
  12078. * @param manager defines the manager
  12079. */
  12080. constructor(
  12081. /** defines the name */
  12082. name: string, manager: ISpriteManager);
  12083. /**
  12084. * Starts an animation
  12085. * @param from defines the initial key
  12086. * @param to defines the end key
  12087. * @param loop defines if the animation must loop
  12088. * @param delay defines the start delay (in ms)
  12089. * @param onAnimationEnd defines a callback to call when animation ends
  12090. */
  12091. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12092. /** Stops current animation (if any) */
  12093. stopAnimation(): void;
  12094. /** @hidden */
  12095. _animate(deltaTime: number): void;
  12096. /** Release associated resources */
  12097. dispose(): void;
  12098. }
  12099. }
  12100. declare module "babylonjs/Collisions/pickingInfo" {
  12101. import { Nullable } from "babylonjs/types";
  12102. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12104. import { Sprite } from "babylonjs/Sprites/sprite";
  12105. import { Ray } from "babylonjs/Culling/ray";
  12106. /**
  12107. * Information about the result of picking within a scene
  12108. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12109. */
  12110. export class PickingInfo {
  12111. /** @hidden */
  12112. _pickingUnavailable: boolean;
  12113. /**
  12114. * If the pick collided with an object
  12115. */
  12116. hit: boolean;
  12117. /**
  12118. * Distance away where the pick collided
  12119. */
  12120. distance: number;
  12121. /**
  12122. * The location of pick collision
  12123. */
  12124. pickedPoint: Nullable<Vector3>;
  12125. /**
  12126. * The mesh corresponding the the pick collision
  12127. */
  12128. pickedMesh: Nullable<AbstractMesh>;
  12129. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12130. bu: number;
  12131. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12132. bv: number;
  12133. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12134. faceId: number;
  12135. /** Id of the the submesh that was picked */
  12136. subMeshId: number;
  12137. /** If a sprite was picked, this will be the sprite the pick collided with */
  12138. pickedSprite: Nullable<Sprite>;
  12139. /**
  12140. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12141. */
  12142. originMesh: Nullable<AbstractMesh>;
  12143. /**
  12144. * The ray that was used to perform the picking.
  12145. */
  12146. ray: Nullable<Ray>;
  12147. /**
  12148. * Gets the normal correspodning to the face the pick collided with
  12149. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12150. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12151. * @returns The normal correspodning to the face the pick collided with
  12152. */
  12153. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12154. /**
  12155. * Gets the texture coordinates of where the pick occured
  12156. * @returns the vector containing the coordnates of the texture
  12157. */
  12158. getTextureCoordinates(): Nullable<Vector2>;
  12159. }
  12160. }
  12161. declare module "babylonjs/Events/pointerEvents" {
  12162. import { Nullable } from "babylonjs/types";
  12163. import { Vector2 } from "babylonjs/Maths/math.vector";
  12164. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12165. import { Ray } from "babylonjs/Culling/ray";
  12166. /**
  12167. * Gather the list of pointer event types as constants.
  12168. */
  12169. export class PointerEventTypes {
  12170. /**
  12171. * 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.
  12172. */
  12173. static readonly POINTERDOWN: number;
  12174. /**
  12175. * The pointerup event is fired when a pointer is no longer active.
  12176. */
  12177. static readonly POINTERUP: number;
  12178. /**
  12179. * The pointermove event is fired when a pointer changes coordinates.
  12180. */
  12181. static readonly POINTERMOVE: number;
  12182. /**
  12183. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12184. */
  12185. static readonly POINTERWHEEL: number;
  12186. /**
  12187. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12188. */
  12189. static readonly POINTERPICK: number;
  12190. /**
  12191. * The pointertap event is fired when a the object has been touched and released without drag.
  12192. */
  12193. static readonly POINTERTAP: number;
  12194. /**
  12195. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12196. */
  12197. static readonly POINTERDOUBLETAP: number;
  12198. }
  12199. /**
  12200. * Base class of pointer info types.
  12201. */
  12202. export class PointerInfoBase {
  12203. /**
  12204. * Defines the type of event (PointerEventTypes)
  12205. */
  12206. type: number;
  12207. /**
  12208. * Defines the related dom event
  12209. */
  12210. event: PointerEvent | MouseWheelEvent;
  12211. /**
  12212. * Instantiates the base class of pointers info.
  12213. * @param type Defines the type of event (PointerEventTypes)
  12214. * @param event Defines the related dom event
  12215. */
  12216. constructor(
  12217. /**
  12218. * Defines the type of event (PointerEventTypes)
  12219. */
  12220. type: number,
  12221. /**
  12222. * Defines the related dom event
  12223. */
  12224. event: PointerEvent | MouseWheelEvent);
  12225. }
  12226. /**
  12227. * This class is used to store pointer related info for the onPrePointerObservable event.
  12228. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12229. */
  12230. export class PointerInfoPre extends PointerInfoBase {
  12231. /**
  12232. * Ray from a pointer if availible (eg. 6dof controller)
  12233. */
  12234. ray: Nullable<Ray>;
  12235. /**
  12236. * Defines the local position of the pointer on the canvas.
  12237. */
  12238. localPosition: Vector2;
  12239. /**
  12240. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12241. */
  12242. skipOnPointerObservable: boolean;
  12243. /**
  12244. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12245. * @param type Defines the type of event (PointerEventTypes)
  12246. * @param event Defines the related dom event
  12247. * @param localX Defines the local x coordinates of the pointer when the event occured
  12248. * @param localY Defines the local y coordinates of the pointer when the event occured
  12249. */
  12250. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12251. }
  12252. /**
  12253. * This type contains all the data related to a pointer event in Babylon.js.
  12254. * 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.
  12255. */
  12256. export class PointerInfo extends PointerInfoBase {
  12257. /**
  12258. * Defines the picking info associated to the info (if any)\
  12259. */
  12260. pickInfo: Nullable<PickingInfo>;
  12261. /**
  12262. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12263. * @param type Defines the type of event (PointerEventTypes)
  12264. * @param event Defines the related dom event
  12265. * @param pickInfo Defines the picking info associated to the info (if any)\
  12266. */
  12267. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12268. /**
  12269. * Defines the picking info associated to the info (if any)\
  12270. */
  12271. pickInfo: Nullable<PickingInfo>);
  12272. }
  12273. /**
  12274. * Data relating to a touch event on the screen.
  12275. */
  12276. export interface PointerTouch {
  12277. /**
  12278. * X coordinate of touch.
  12279. */
  12280. x: number;
  12281. /**
  12282. * Y coordinate of touch.
  12283. */
  12284. y: number;
  12285. /**
  12286. * Id of touch. Unique for each finger.
  12287. */
  12288. pointerId: number;
  12289. /**
  12290. * Event type passed from DOM.
  12291. */
  12292. type: any;
  12293. }
  12294. }
  12295. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12296. import { Observable } from "babylonjs/Misc/observable";
  12297. import { Nullable } from "babylonjs/types";
  12298. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12299. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12300. /**
  12301. * Manage the mouse inputs to control the movement of a free camera.
  12302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12303. */
  12304. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12305. /**
  12306. * Define if touch is enabled in the mouse input
  12307. */
  12308. touchEnabled: boolean;
  12309. /**
  12310. * Defines the camera the input is attached to.
  12311. */
  12312. camera: FreeCamera;
  12313. /**
  12314. * Defines the buttons associated with the input to handle camera move.
  12315. */
  12316. buttons: number[];
  12317. /**
  12318. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12319. */
  12320. angularSensibility: number;
  12321. private _pointerInput;
  12322. private _onMouseMove;
  12323. private _observer;
  12324. private previousPosition;
  12325. /**
  12326. * Observable for when a pointer move event occurs containing the move offset
  12327. */
  12328. onPointerMovedObservable: Observable<{
  12329. offsetX: number;
  12330. offsetY: number;
  12331. }>;
  12332. /**
  12333. * @hidden
  12334. * If the camera should be rotated automatically based on pointer movement
  12335. */
  12336. _allowCameraRotation: boolean;
  12337. /**
  12338. * Manage the mouse inputs to control the movement of a free camera.
  12339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12340. * @param touchEnabled Defines if touch is enabled or not
  12341. */
  12342. constructor(
  12343. /**
  12344. * Define if touch is enabled in the mouse input
  12345. */
  12346. touchEnabled?: boolean);
  12347. /**
  12348. * Attach the input controls to a specific dom element to get the input from.
  12349. * @param element Defines the element the controls should be listened from
  12350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12351. */
  12352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12353. /**
  12354. * Called on JS contextmenu event.
  12355. * Override this method to provide functionality.
  12356. */
  12357. protected onContextMenu(evt: PointerEvent): void;
  12358. /**
  12359. * Detach the current controls from the specified dom element.
  12360. * @param element Defines the element to stop listening the inputs from
  12361. */
  12362. detachControl(element: Nullable<HTMLElement>): void;
  12363. /**
  12364. * Gets the class name of the current intput.
  12365. * @returns the class name
  12366. */
  12367. getClassName(): string;
  12368. /**
  12369. * Get the friendly name associated with the input class.
  12370. * @returns the input friendly name
  12371. */
  12372. getSimpleName(): string;
  12373. }
  12374. }
  12375. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12376. import { Nullable } from "babylonjs/types";
  12377. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12378. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12379. /**
  12380. * Manage the touch inputs to control the movement of a free camera.
  12381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12382. */
  12383. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12384. /**
  12385. * Defines the camera the input is attached to.
  12386. */
  12387. camera: FreeCamera;
  12388. /**
  12389. * Defines the touch sensibility for rotation.
  12390. * The higher the faster.
  12391. */
  12392. touchAngularSensibility: number;
  12393. /**
  12394. * Defines the touch sensibility for move.
  12395. * The higher the faster.
  12396. */
  12397. touchMoveSensibility: number;
  12398. private _offsetX;
  12399. private _offsetY;
  12400. private _pointerPressed;
  12401. private _pointerInput;
  12402. private _observer;
  12403. private _onLostFocus;
  12404. /**
  12405. * Attach the input controls to a specific dom element to get the input from.
  12406. * @param element Defines the element the controls should be listened from
  12407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12408. */
  12409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12410. /**
  12411. * Detach the current controls from the specified dom element.
  12412. * @param element Defines the element to stop listening the inputs from
  12413. */
  12414. detachControl(element: Nullable<HTMLElement>): void;
  12415. /**
  12416. * Update the current camera state depending on the inputs that have been used this frame.
  12417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12418. */
  12419. checkInputs(): void;
  12420. /**
  12421. * Gets the class name of the current intput.
  12422. * @returns the class name
  12423. */
  12424. getClassName(): string;
  12425. /**
  12426. * Get the friendly name associated with the input class.
  12427. * @returns the input friendly name
  12428. */
  12429. getSimpleName(): string;
  12430. }
  12431. }
  12432. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12433. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12434. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12435. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12436. import { Nullable } from "babylonjs/types";
  12437. /**
  12438. * Default Inputs manager for the FreeCamera.
  12439. * It groups all the default supported inputs for ease of use.
  12440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12441. */
  12442. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12443. /**
  12444. * @hidden
  12445. */
  12446. _mouseInput: Nullable<FreeCameraMouseInput>;
  12447. /**
  12448. * Instantiates a new FreeCameraInputsManager.
  12449. * @param camera Defines the camera the inputs belong to
  12450. */
  12451. constructor(camera: FreeCamera);
  12452. /**
  12453. * Add keyboard input support to the input manager.
  12454. * @returns the current input manager
  12455. */
  12456. addKeyboard(): FreeCameraInputsManager;
  12457. /**
  12458. * Add mouse input support to the input manager.
  12459. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12460. * @returns the current input manager
  12461. */
  12462. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12463. /**
  12464. * Removes the mouse input support from the manager
  12465. * @returns the current input manager
  12466. */
  12467. removeMouse(): FreeCameraInputsManager;
  12468. /**
  12469. * Add touch input support to the input manager.
  12470. * @returns the current input manager
  12471. */
  12472. addTouch(): FreeCameraInputsManager;
  12473. /**
  12474. * Remove all attached input methods from a camera
  12475. */
  12476. clear(): void;
  12477. }
  12478. }
  12479. declare module "babylonjs/Cameras/freeCamera" {
  12480. import { Vector3 } from "babylonjs/Maths/math.vector";
  12481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12482. import { Scene } from "babylonjs/scene";
  12483. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12484. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12485. /**
  12486. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12487. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12488. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12489. */
  12490. export class FreeCamera extends TargetCamera {
  12491. /**
  12492. * Define the collision ellipsoid of the camera.
  12493. * This is helpful to simulate a camera body like the player body around the camera
  12494. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12495. */
  12496. ellipsoid: Vector3;
  12497. /**
  12498. * Define an offset for the position of the ellipsoid around the camera.
  12499. * This can be helpful to determine the center of the body near the gravity center of the body
  12500. * instead of its head.
  12501. */
  12502. ellipsoidOffset: Vector3;
  12503. /**
  12504. * Enable or disable collisions of the camera with the rest of the scene objects.
  12505. */
  12506. checkCollisions: boolean;
  12507. /**
  12508. * Enable or disable gravity on the camera.
  12509. */
  12510. applyGravity: boolean;
  12511. /**
  12512. * Define the input manager associated to the camera.
  12513. */
  12514. inputs: FreeCameraInputsManager;
  12515. /**
  12516. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12517. * Higher values reduce sensitivity.
  12518. */
  12519. get angularSensibility(): number;
  12520. /**
  12521. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12522. * Higher values reduce sensitivity.
  12523. */
  12524. set angularSensibility(value: number);
  12525. /**
  12526. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12527. */
  12528. get keysUp(): number[];
  12529. set keysUp(value: number[]);
  12530. /**
  12531. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12532. */
  12533. get keysDown(): number[];
  12534. set keysDown(value: number[]);
  12535. /**
  12536. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12537. */
  12538. get keysLeft(): number[];
  12539. set keysLeft(value: number[]);
  12540. /**
  12541. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12542. */
  12543. get keysRight(): number[];
  12544. set keysRight(value: number[]);
  12545. /**
  12546. * Event raised when the camera collide with a mesh in the scene.
  12547. */
  12548. onCollide: (collidedMesh: AbstractMesh) => void;
  12549. private _collider;
  12550. private _needMoveForGravity;
  12551. private _oldPosition;
  12552. private _diffPosition;
  12553. private _newPosition;
  12554. /** @hidden */
  12555. _localDirection: Vector3;
  12556. /** @hidden */
  12557. _transformedDirection: Vector3;
  12558. /**
  12559. * Instantiates a Free Camera.
  12560. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12561. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12562. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12563. * @param name Define the name of the camera in the scene
  12564. * @param position Define the start position of the camera in the scene
  12565. * @param scene Define the scene the camera belongs to
  12566. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12567. */
  12568. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12569. /**
  12570. * Attached controls to the current camera.
  12571. * @param element Defines the element the controls should be listened from
  12572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12573. */
  12574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12575. /**
  12576. * Detach the current controls from the camera.
  12577. * The camera will stop reacting to inputs.
  12578. * @param element Defines the element to stop listening the inputs from
  12579. */
  12580. detachControl(element: HTMLElement): void;
  12581. private _collisionMask;
  12582. /**
  12583. * Define a collision mask to limit the list of object the camera can collide with
  12584. */
  12585. get collisionMask(): number;
  12586. set collisionMask(mask: number);
  12587. /** @hidden */
  12588. _collideWithWorld(displacement: Vector3): void;
  12589. private _onCollisionPositionChange;
  12590. /** @hidden */
  12591. _checkInputs(): void;
  12592. /** @hidden */
  12593. _decideIfNeedsToMove(): boolean;
  12594. /** @hidden */
  12595. _updatePosition(): void;
  12596. /**
  12597. * Destroy the camera and release the current resources hold by it.
  12598. */
  12599. dispose(): void;
  12600. /**
  12601. * Gets the current object class name.
  12602. * @return the class name
  12603. */
  12604. getClassName(): string;
  12605. }
  12606. }
  12607. declare module "babylonjs/Gamepads/gamepad" {
  12608. import { Observable } from "babylonjs/Misc/observable";
  12609. /**
  12610. * Represents a gamepad control stick position
  12611. */
  12612. export class StickValues {
  12613. /**
  12614. * The x component of the control stick
  12615. */
  12616. x: number;
  12617. /**
  12618. * The y component of the control stick
  12619. */
  12620. y: number;
  12621. /**
  12622. * Initializes the gamepad x and y control stick values
  12623. * @param x The x component of the gamepad control stick value
  12624. * @param y The y component of the gamepad control stick value
  12625. */
  12626. constructor(
  12627. /**
  12628. * The x component of the control stick
  12629. */
  12630. x: number,
  12631. /**
  12632. * The y component of the control stick
  12633. */
  12634. y: number);
  12635. }
  12636. /**
  12637. * An interface which manages callbacks for gamepad button changes
  12638. */
  12639. export interface GamepadButtonChanges {
  12640. /**
  12641. * Called when a gamepad has been changed
  12642. */
  12643. changed: boolean;
  12644. /**
  12645. * Called when a gamepad press event has been triggered
  12646. */
  12647. pressChanged: boolean;
  12648. /**
  12649. * Called when a touch event has been triggered
  12650. */
  12651. touchChanged: boolean;
  12652. /**
  12653. * Called when a value has changed
  12654. */
  12655. valueChanged: boolean;
  12656. }
  12657. /**
  12658. * Represents a gamepad
  12659. */
  12660. export class Gamepad {
  12661. /**
  12662. * The id of the gamepad
  12663. */
  12664. id: string;
  12665. /**
  12666. * The index of the gamepad
  12667. */
  12668. index: number;
  12669. /**
  12670. * The browser gamepad
  12671. */
  12672. browserGamepad: any;
  12673. /**
  12674. * Specifies what type of gamepad this represents
  12675. */
  12676. type: number;
  12677. private _leftStick;
  12678. private _rightStick;
  12679. /** @hidden */
  12680. _isConnected: boolean;
  12681. private _leftStickAxisX;
  12682. private _leftStickAxisY;
  12683. private _rightStickAxisX;
  12684. private _rightStickAxisY;
  12685. /**
  12686. * Triggered when the left control stick has been changed
  12687. */
  12688. private _onleftstickchanged;
  12689. /**
  12690. * Triggered when the right control stick has been changed
  12691. */
  12692. private _onrightstickchanged;
  12693. /**
  12694. * Represents a gamepad controller
  12695. */
  12696. static GAMEPAD: number;
  12697. /**
  12698. * Represents a generic controller
  12699. */
  12700. static GENERIC: number;
  12701. /**
  12702. * Represents an XBox controller
  12703. */
  12704. static XBOX: number;
  12705. /**
  12706. * Represents a pose-enabled controller
  12707. */
  12708. static POSE_ENABLED: number;
  12709. /**
  12710. * Represents an Dual Shock controller
  12711. */
  12712. static DUALSHOCK: number;
  12713. /**
  12714. * Specifies whether the left control stick should be Y-inverted
  12715. */
  12716. protected _invertLeftStickY: boolean;
  12717. /**
  12718. * Specifies if the gamepad has been connected
  12719. */
  12720. get isConnected(): boolean;
  12721. /**
  12722. * Initializes the gamepad
  12723. * @param id The id of the gamepad
  12724. * @param index The index of the gamepad
  12725. * @param browserGamepad The browser gamepad
  12726. * @param leftStickX The x component of the left joystick
  12727. * @param leftStickY The y component of the left joystick
  12728. * @param rightStickX The x component of the right joystick
  12729. * @param rightStickY The y component of the right joystick
  12730. */
  12731. constructor(
  12732. /**
  12733. * The id of the gamepad
  12734. */
  12735. id: string,
  12736. /**
  12737. * The index of the gamepad
  12738. */
  12739. index: number,
  12740. /**
  12741. * The browser gamepad
  12742. */
  12743. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12744. /**
  12745. * Callback triggered when the left joystick has changed
  12746. * @param callback
  12747. */
  12748. onleftstickchanged(callback: (values: StickValues) => void): void;
  12749. /**
  12750. * Callback triggered when the right joystick has changed
  12751. * @param callback
  12752. */
  12753. onrightstickchanged(callback: (values: StickValues) => void): void;
  12754. /**
  12755. * Gets the left joystick
  12756. */
  12757. get leftStick(): StickValues;
  12758. /**
  12759. * Sets the left joystick values
  12760. */
  12761. set leftStick(newValues: StickValues);
  12762. /**
  12763. * Gets the right joystick
  12764. */
  12765. get rightStick(): StickValues;
  12766. /**
  12767. * Sets the right joystick value
  12768. */
  12769. set rightStick(newValues: StickValues);
  12770. /**
  12771. * Updates the gamepad joystick positions
  12772. */
  12773. update(): void;
  12774. /**
  12775. * Disposes the gamepad
  12776. */
  12777. dispose(): void;
  12778. }
  12779. /**
  12780. * Represents a generic gamepad
  12781. */
  12782. export class GenericPad extends Gamepad {
  12783. private _buttons;
  12784. private _onbuttondown;
  12785. private _onbuttonup;
  12786. /**
  12787. * Observable triggered when a button has been pressed
  12788. */
  12789. onButtonDownObservable: Observable<number>;
  12790. /**
  12791. * Observable triggered when a button has been released
  12792. */
  12793. onButtonUpObservable: Observable<number>;
  12794. /**
  12795. * Callback triggered when a button has been pressed
  12796. * @param callback Called when a button has been pressed
  12797. */
  12798. onbuttondown(callback: (buttonPressed: number) => void): void;
  12799. /**
  12800. * Callback triggered when a button has been released
  12801. * @param callback Called when a button has been released
  12802. */
  12803. onbuttonup(callback: (buttonReleased: number) => void): void;
  12804. /**
  12805. * Initializes the generic gamepad
  12806. * @param id The id of the generic gamepad
  12807. * @param index The index of the generic gamepad
  12808. * @param browserGamepad The browser gamepad
  12809. */
  12810. constructor(id: string, index: number, browserGamepad: any);
  12811. private _setButtonValue;
  12812. /**
  12813. * Updates the generic gamepad
  12814. */
  12815. update(): void;
  12816. /**
  12817. * Disposes the generic gamepad
  12818. */
  12819. dispose(): void;
  12820. }
  12821. }
  12822. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12823. import { Nullable } from "babylonjs/types";
  12824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12825. import { Scene } from "babylonjs/scene";
  12826. module "babylonjs/Engines/engine" {
  12827. interface Engine {
  12828. /**
  12829. * Creates a raw texture
  12830. * @param data defines the data to store in the texture
  12831. * @param width defines the width of the texture
  12832. * @param height defines the height of the texture
  12833. * @param format defines the format of the data
  12834. * @param generateMipMaps defines if the engine should generate the mip levels
  12835. * @param invertY defines if data must be stored with Y axis inverted
  12836. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12837. * @param compression defines the compression used (null by default)
  12838. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12839. * @returns the raw texture inside an InternalTexture
  12840. */
  12841. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12842. /**
  12843. * Update a raw texture
  12844. * @param texture defines the texture to update
  12845. * @param data defines the data to store in the texture
  12846. * @param format defines the format of the data
  12847. * @param invertY defines if data must be stored with Y axis inverted
  12848. */
  12849. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12850. /**
  12851. * Update a raw texture
  12852. * @param texture defines the texture to update
  12853. * @param data defines the data to store in the texture
  12854. * @param format defines the format of the data
  12855. * @param invertY defines if data must be stored with Y axis inverted
  12856. * @param compression defines the compression used (null by default)
  12857. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12858. */
  12859. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12860. /**
  12861. * Creates a new raw cube texture
  12862. * @param data defines the array of data to use to create each face
  12863. * @param size defines the size of the textures
  12864. * @param format defines the format of the data
  12865. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12866. * @param generateMipMaps defines if the engine should generate the mip levels
  12867. * @param invertY defines if data must be stored with Y axis inverted
  12868. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12869. * @param compression defines the compression used (null by default)
  12870. * @returns the cube texture as an InternalTexture
  12871. */
  12872. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12873. /**
  12874. * Update a raw cube texture
  12875. * @param texture defines the texture to udpdate
  12876. * @param data defines the data to store
  12877. * @param format defines the data format
  12878. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12879. * @param invertY defines if data must be stored with Y axis inverted
  12880. */
  12881. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12882. /**
  12883. * Update a raw cube texture
  12884. * @param texture defines the texture to udpdate
  12885. * @param data defines the data to store
  12886. * @param format defines the data format
  12887. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12888. * @param invertY defines if data must be stored with Y axis inverted
  12889. * @param compression defines the compression used (null by default)
  12890. */
  12891. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12892. /**
  12893. * Update a raw cube texture
  12894. * @param texture defines the texture to udpdate
  12895. * @param data defines the data to store
  12896. * @param format defines the data format
  12897. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12898. * @param invertY defines if data must be stored with Y axis inverted
  12899. * @param compression defines the compression used (null by default)
  12900. * @param level defines which level of the texture to update
  12901. */
  12902. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12903. /**
  12904. * Creates a new raw cube texture from a specified url
  12905. * @param url defines the url where the data is located
  12906. * @param scene defines the current scene
  12907. * @param size defines the size of the textures
  12908. * @param format defines the format of the data
  12909. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12910. * @param noMipmap defines if the engine should avoid generating the mip levels
  12911. * @param callback defines a callback used to extract texture data from loaded data
  12912. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12913. * @param onLoad defines a callback called when texture is loaded
  12914. * @param onError defines a callback called if there is an error
  12915. * @returns the cube texture as an InternalTexture
  12916. */
  12917. 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;
  12918. /**
  12919. * Creates a new raw cube texture from a specified url
  12920. * @param url defines the url where the data is located
  12921. * @param scene defines the current scene
  12922. * @param size defines the size of the textures
  12923. * @param format defines the format of the data
  12924. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12925. * @param noMipmap defines if the engine should avoid generating the mip levels
  12926. * @param callback defines a callback used to extract texture data from loaded data
  12927. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12928. * @param onLoad defines a callback called when texture is loaded
  12929. * @param onError defines a callback called if there is an error
  12930. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12931. * @param invertY defines if data must be stored with Y axis inverted
  12932. * @returns the cube texture as an InternalTexture
  12933. */
  12934. 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;
  12935. /**
  12936. * Creates a new raw 3D texture
  12937. * @param data defines the data used to create the texture
  12938. * @param width defines the width of the texture
  12939. * @param height defines the height of the texture
  12940. * @param depth defines the depth of the texture
  12941. * @param format defines the format of the texture
  12942. * @param generateMipMaps defines if the engine must generate mip levels
  12943. * @param invertY defines if data must be stored with Y axis inverted
  12944. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12945. * @param compression defines the compressed used (can be null)
  12946. * @param textureType defines the compressed used (can be null)
  12947. * @returns a new raw 3D texture (stored in an InternalTexture)
  12948. */
  12949. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12950. /**
  12951. * Update a raw 3D texture
  12952. * @param texture defines the texture to update
  12953. * @param data defines the data to store
  12954. * @param format defines the data format
  12955. * @param invertY defines if data must be stored with Y axis inverted
  12956. */
  12957. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12958. /**
  12959. * Update a raw 3D texture
  12960. * @param texture defines the texture to update
  12961. * @param data defines the data to store
  12962. * @param format defines the data format
  12963. * @param invertY defines if data must be stored with Y axis inverted
  12964. * @param compression defines the used compression (can be null)
  12965. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12966. */
  12967. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12968. /**
  12969. * Creates a new raw 2D array texture
  12970. * @param data defines the data used to create the texture
  12971. * @param width defines the width of the texture
  12972. * @param height defines the height of the texture
  12973. * @param depth defines the number of layers of the texture
  12974. * @param format defines the format of the texture
  12975. * @param generateMipMaps defines if the engine must generate mip levels
  12976. * @param invertY defines if data must be stored with Y axis inverted
  12977. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12978. * @param compression defines the compressed used (can be null)
  12979. * @param textureType defines the compressed used (can be null)
  12980. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12981. */
  12982. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12983. /**
  12984. * Update a raw 2D array texture
  12985. * @param texture defines the texture to update
  12986. * @param data defines the data to store
  12987. * @param format defines the data format
  12988. * @param invertY defines if data must be stored with Y axis inverted
  12989. */
  12990. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12991. /**
  12992. * Update a raw 2D array texture
  12993. * @param texture defines the texture to update
  12994. * @param data defines the data to store
  12995. * @param format defines the data format
  12996. * @param invertY defines if data must be stored with Y axis inverted
  12997. * @param compression defines the used compression (can be null)
  12998. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12999. */
  13000. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13001. }
  13002. }
  13003. }
  13004. declare module "babylonjs/Materials/Textures/rawTexture" {
  13005. import { Scene } from "babylonjs/scene";
  13006. import { Texture } from "babylonjs/Materials/Textures/texture";
  13007. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13008. /**
  13009. * Raw texture can help creating a texture directly from an array of data.
  13010. * This can be super useful if you either get the data from an uncompressed source or
  13011. * if you wish to create your texture pixel by pixel.
  13012. */
  13013. export class RawTexture extends Texture {
  13014. /**
  13015. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13016. */
  13017. format: number;
  13018. private _engine;
  13019. /**
  13020. * Instantiates a new RawTexture.
  13021. * Raw texture can help creating a texture directly from an array of data.
  13022. * This can be super useful if you either get the data from an uncompressed source or
  13023. * if you wish to create your texture pixel by pixel.
  13024. * @param data define the array of data to use to create the texture
  13025. * @param width define the width of the texture
  13026. * @param height define the height of the texture
  13027. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13028. * @param scene define the scene the texture belongs to
  13029. * @param generateMipMaps define whether mip maps should be generated or not
  13030. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13031. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13032. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13033. */
  13034. constructor(data: ArrayBufferView, width: number, height: number,
  13035. /**
  13036. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13037. */
  13038. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13039. /**
  13040. * Updates the texture underlying data.
  13041. * @param data Define the new data of the texture
  13042. */
  13043. update(data: ArrayBufferView): void;
  13044. /**
  13045. * Creates a luminance texture from some data.
  13046. * @param data Define the texture data
  13047. * @param width Define the width of the texture
  13048. * @param height Define the height of the texture
  13049. * @param scene Define the scene the texture belongs to
  13050. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13051. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13052. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13053. * @returns the luminance texture
  13054. */
  13055. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13056. /**
  13057. * Creates a luminance alpha texture from some data.
  13058. * @param data Define the texture data
  13059. * @param width Define the width of the texture
  13060. * @param height Define the height of the texture
  13061. * @param scene Define the scene the texture belongs to
  13062. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13063. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13064. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13065. * @returns the luminance alpha texture
  13066. */
  13067. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13068. /**
  13069. * Creates an alpha texture from some data.
  13070. * @param data Define the texture data
  13071. * @param width Define the width of the texture
  13072. * @param height Define the height of the texture
  13073. * @param scene Define the scene the texture belongs to
  13074. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13075. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13076. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13077. * @returns the alpha texture
  13078. */
  13079. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13080. /**
  13081. * Creates a RGB texture from some data.
  13082. * @param data Define the texture data
  13083. * @param width Define the width of the texture
  13084. * @param height Define the height of the texture
  13085. * @param scene Define the scene the texture belongs to
  13086. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13087. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13088. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13089. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13090. * @returns the RGB alpha texture
  13091. */
  13092. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13093. /**
  13094. * Creates a RGBA texture from some data.
  13095. * @param data Define the texture data
  13096. * @param width Define the width of the texture
  13097. * @param height Define the height of the texture
  13098. * @param scene Define the scene the texture belongs to
  13099. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13100. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13101. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13102. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13103. * @returns the RGBA texture
  13104. */
  13105. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13106. /**
  13107. * Creates a R texture from some data.
  13108. * @param data Define the texture data
  13109. * @param width Define the width of the texture
  13110. * @param height Define the height of the texture
  13111. * @param scene Define the scene the texture belongs to
  13112. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13113. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13114. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13115. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13116. * @returns the R texture
  13117. */
  13118. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13119. }
  13120. }
  13121. declare module "babylonjs/Maths/math.size" {
  13122. /**
  13123. * Interface for the size containing width and height
  13124. */
  13125. export interface ISize {
  13126. /**
  13127. * Width
  13128. */
  13129. width: number;
  13130. /**
  13131. * Heighht
  13132. */
  13133. height: number;
  13134. }
  13135. /**
  13136. * Size containing widht and height
  13137. */
  13138. export class Size implements ISize {
  13139. /**
  13140. * Width
  13141. */
  13142. width: number;
  13143. /**
  13144. * Height
  13145. */
  13146. height: number;
  13147. /**
  13148. * Creates a Size object from the given width and height (floats).
  13149. * @param width width of the new size
  13150. * @param height height of the new size
  13151. */
  13152. constructor(width: number, height: number);
  13153. /**
  13154. * Returns a string with the Size width and height
  13155. * @returns a string with the Size width and height
  13156. */
  13157. toString(): string;
  13158. /**
  13159. * "Size"
  13160. * @returns the string "Size"
  13161. */
  13162. getClassName(): string;
  13163. /**
  13164. * Returns the Size hash code.
  13165. * @returns a hash code for a unique width and height
  13166. */
  13167. getHashCode(): number;
  13168. /**
  13169. * Updates the current size from the given one.
  13170. * @param src the given size
  13171. */
  13172. copyFrom(src: Size): void;
  13173. /**
  13174. * Updates in place the current Size from the given floats.
  13175. * @param width width of the new size
  13176. * @param height height of the new size
  13177. * @returns the updated Size.
  13178. */
  13179. copyFromFloats(width: number, height: number): Size;
  13180. /**
  13181. * Updates in place the current Size from the given floats.
  13182. * @param width width to set
  13183. * @param height height to set
  13184. * @returns the updated Size.
  13185. */
  13186. set(width: number, height: number): Size;
  13187. /**
  13188. * Multiplies the width and height by numbers
  13189. * @param w factor to multiple the width by
  13190. * @param h factor to multiple the height by
  13191. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13192. */
  13193. multiplyByFloats(w: number, h: number): Size;
  13194. /**
  13195. * Clones the size
  13196. * @returns a new Size copied from the given one.
  13197. */
  13198. clone(): Size;
  13199. /**
  13200. * True if the current Size and the given one width and height are strictly equal.
  13201. * @param other the other size to compare against
  13202. * @returns True if the current Size and the given one width and height are strictly equal.
  13203. */
  13204. equals(other: Size): boolean;
  13205. /**
  13206. * The surface of the Size : width * height (float).
  13207. */
  13208. get surface(): number;
  13209. /**
  13210. * Create a new size of zero
  13211. * @returns a new Size set to (0.0, 0.0)
  13212. */
  13213. static Zero(): Size;
  13214. /**
  13215. * Sums the width and height of two sizes
  13216. * @param otherSize size to add to this size
  13217. * @returns a new Size set as the addition result of the current Size and the given one.
  13218. */
  13219. add(otherSize: Size): Size;
  13220. /**
  13221. * Subtracts the width and height of two
  13222. * @param otherSize size to subtract to this size
  13223. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13224. */
  13225. subtract(otherSize: Size): Size;
  13226. /**
  13227. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13228. * @param start starting size to lerp between
  13229. * @param end end size to lerp between
  13230. * @param amount amount to lerp between the start and end values
  13231. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13232. */
  13233. static Lerp(start: Size, end: Size, amount: number): Size;
  13234. }
  13235. }
  13236. declare module "babylonjs/Animations/runtimeAnimation" {
  13237. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13238. import { Animatable } from "babylonjs/Animations/animatable";
  13239. import { Scene } from "babylonjs/scene";
  13240. /**
  13241. * Defines a runtime animation
  13242. */
  13243. export class RuntimeAnimation {
  13244. private _events;
  13245. /**
  13246. * The current frame of the runtime animation
  13247. */
  13248. private _currentFrame;
  13249. /**
  13250. * The animation used by the runtime animation
  13251. */
  13252. private _animation;
  13253. /**
  13254. * The target of the runtime animation
  13255. */
  13256. private _target;
  13257. /**
  13258. * The initiating animatable
  13259. */
  13260. private _host;
  13261. /**
  13262. * The original value of the runtime animation
  13263. */
  13264. private _originalValue;
  13265. /**
  13266. * The original blend value of the runtime animation
  13267. */
  13268. private _originalBlendValue;
  13269. /**
  13270. * The offsets cache of the runtime animation
  13271. */
  13272. private _offsetsCache;
  13273. /**
  13274. * The high limits cache of the runtime animation
  13275. */
  13276. private _highLimitsCache;
  13277. /**
  13278. * Specifies if the runtime animation has been stopped
  13279. */
  13280. private _stopped;
  13281. /**
  13282. * The blending factor of the runtime animation
  13283. */
  13284. private _blendingFactor;
  13285. /**
  13286. * The BabylonJS scene
  13287. */
  13288. private _scene;
  13289. /**
  13290. * The current value of the runtime animation
  13291. */
  13292. private _currentValue;
  13293. /** @hidden */
  13294. _animationState: _IAnimationState;
  13295. /**
  13296. * The active target of the runtime animation
  13297. */
  13298. private _activeTargets;
  13299. private _currentActiveTarget;
  13300. private _directTarget;
  13301. /**
  13302. * The target path of the runtime animation
  13303. */
  13304. private _targetPath;
  13305. /**
  13306. * The weight of the runtime animation
  13307. */
  13308. private _weight;
  13309. /**
  13310. * The ratio offset of the runtime animation
  13311. */
  13312. private _ratioOffset;
  13313. /**
  13314. * The previous delay of the runtime animation
  13315. */
  13316. private _previousDelay;
  13317. /**
  13318. * The previous ratio of the runtime animation
  13319. */
  13320. private _previousRatio;
  13321. private _enableBlending;
  13322. private _keys;
  13323. private _minFrame;
  13324. private _maxFrame;
  13325. private _minValue;
  13326. private _maxValue;
  13327. private _targetIsArray;
  13328. /**
  13329. * Gets the current frame of the runtime animation
  13330. */
  13331. get currentFrame(): number;
  13332. /**
  13333. * Gets the weight of the runtime animation
  13334. */
  13335. get weight(): number;
  13336. /**
  13337. * Gets the current value of the runtime animation
  13338. */
  13339. get currentValue(): any;
  13340. /**
  13341. * Gets the target path of the runtime animation
  13342. */
  13343. get targetPath(): string;
  13344. /**
  13345. * Gets the actual target of the runtime animation
  13346. */
  13347. get target(): any;
  13348. /** @hidden */
  13349. _onLoop: () => void;
  13350. /**
  13351. * Create a new RuntimeAnimation object
  13352. * @param target defines the target of the animation
  13353. * @param animation defines the source animation object
  13354. * @param scene defines the hosting scene
  13355. * @param host defines the initiating Animatable
  13356. */
  13357. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13358. private _preparePath;
  13359. /**
  13360. * Gets the animation from the runtime animation
  13361. */
  13362. get animation(): Animation;
  13363. /**
  13364. * Resets the runtime animation to the beginning
  13365. * @param restoreOriginal defines whether to restore the target property to the original value
  13366. */
  13367. reset(restoreOriginal?: boolean): void;
  13368. /**
  13369. * Specifies if the runtime animation is stopped
  13370. * @returns Boolean specifying if the runtime animation is stopped
  13371. */
  13372. isStopped(): boolean;
  13373. /**
  13374. * Disposes of the runtime animation
  13375. */
  13376. dispose(): void;
  13377. /**
  13378. * Apply the interpolated value to the target
  13379. * @param currentValue defines the value computed by the animation
  13380. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13381. */
  13382. setValue(currentValue: any, weight: number): void;
  13383. private _getOriginalValues;
  13384. private _setValue;
  13385. /**
  13386. * Gets the loop pmode of the runtime animation
  13387. * @returns Loop Mode
  13388. */
  13389. private _getCorrectLoopMode;
  13390. /**
  13391. * Move the current animation to a given frame
  13392. * @param frame defines the frame to move to
  13393. */
  13394. goToFrame(frame: number): void;
  13395. /**
  13396. * @hidden Internal use only
  13397. */
  13398. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13399. /**
  13400. * Execute the current animation
  13401. * @param delay defines the delay to add to the current frame
  13402. * @param from defines the lower bound of the animation range
  13403. * @param to defines the upper bound of the animation range
  13404. * @param loop defines if the current animation must loop
  13405. * @param speedRatio defines the current speed ratio
  13406. * @param weight defines the weight of the animation (default is -1 so no weight)
  13407. * @param onLoop optional callback called when animation loops
  13408. * @returns a boolean indicating if the animation is running
  13409. */
  13410. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13411. }
  13412. }
  13413. declare module "babylonjs/Animations/animatable" {
  13414. import { Animation } from "babylonjs/Animations/animation";
  13415. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13416. import { Nullable } from "babylonjs/types";
  13417. import { Observable } from "babylonjs/Misc/observable";
  13418. import { Scene } from "babylonjs/scene";
  13419. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13420. import { Node } from "babylonjs/node";
  13421. /**
  13422. * Class used to store an actual running animation
  13423. */
  13424. export class Animatable {
  13425. /** defines the target object */
  13426. target: any;
  13427. /** defines the starting frame number (default is 0) */
  13428. fromFrame: number;
  13429. /** defines the ending frame number (default is 100) */
  13430. toFrame: number;
  13431. /** defines if the animation must loop (default is false) */
  13432. loopAnimation: boolean;
  13433. /** defines a callback to call when animation ends if it is not looping */
  13434. onAnimationEnd?: (() => void) | null | undefined;
  13435. /** defines a callback to call when animation loops */
  13436. onAnimationLoop?: (() => void) | null | undefined;
  13437. private _localDelayOffset;
  13438. private _pausedDelay;
  13439. private _runtimeAnimations;
  13440. private _paused;
  13441. private _scene;
  13442. private _speedRatio;
  13443. private _weight;
  13444. private _syncRoot;
  13445. /**
  13446. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13447. * This will only apply for non looping animation (default is true)
  13448. */
  13449. disposeOnEnd: boolean;
  13450. /**
  13451. * Gets a boolean indicating if the animation has started
  13452. */
  13453. animationStarted: boolean;
  13454. /**
  13455. * Observer raised when the animation ends
  13456. */
  13457. onAnimationEndObservable: Observable<Animatable>;
  13458. /**
  13459. * Observer raised when the animation loops
  13460. */
  13461. onAnimationLoopObservable: Observable<Animatable>;
  13462. /**
  13463. * Gets the root Animatable used to synchronize and normalize animations
  13464. */
  13465. get syncRoot(): Nullable<Animatable>;
  13466. /**
  13467. * Gets the current frame of the first RuntimeAnimation
  13468. * Used to synchronize Animatables
  13469. */
  13470. get masterFrame(): number;
  13471. /**
  13472. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13473. */
  13474. get weight(): number;
  13475. set weight(value: number);
  13476. /**
  13477. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13478. */
  13479. get speedRatio(): number;
  13480. set speedRatio(value: number);
  13481. /**
  13482. * Creates a new Animatable
  13483. * @param scene defines the hosting scene
  13484. * @param target defines the target object
  13485. * @param fromFrame defines the starting frame number (default is 0)
  13486. * @param toFrame defines the ending frame number (default is 100)
  13487. * @param loopAnimation defines if the animation must loop (default is false)
  13488. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13489. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13490. * @param animations defines a group of animation to add to the new Animatable
  13491. * @param onAnimationLoop defines a callback to call when animation loops
  13492. */
  13493. constructor(scene: Scene,
  13494. /** defines the target object */
  13495. target: any,
  13496. /** defines the starting frame number (default is 0) */
  13497. fromFrame?: number,
  13498. /** defines the ending frame number (default is 100) */
  13499. toFrame?: number,
  13500. /** defines if the animation must loop (default is false) */
  13501. loopAnimation?: boolean, speedRatio?: number,
  13502. /** defines a callback to call when animation ends if it is not looping */
  13503. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13504. /** defines a callback to call when animation loops */
  13505. onAnimationLoop?: (() => void) | null | undefined);
  13506. /**
  13507. * Synchronize and normalize current Animatable with a source Animatable
  13508. * This is useful when using animation weights and when animations are not of the same length
  13509. * @param root defines the root Animatable to synchronize with
  13510. * @returns the current Animatable
  13511. */
  13512. syncWith(root: Animatable): Animatable;
  13513. /**
  13514. * Gets the list of runtime animations
  13515. * @returns an array of RuntimeAnimation
  13516. */
  13517. getAnimations(): RuntimeAnimation[];
  13518. /**
  13519. * Adds more animations to the current animatable
  13520. * @param target defines the target of the animations
  13521. * @param animations defines the new animations to add
  13522. */
  13523. appendAnimations(target: any, animations: Animation[]): void;
  13524. /**
  13525. * Gets the source animation for a specific property
  13526. * @param property defines the propertyu to look for
  13527. * @returns null or the source animation for the given property
  13528. */
  13529. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13530. /**
  13531. * Gets the runtime animation for a specific property
  13532. * @param property defines the propertyu to look for
  13533. * @returns null or the runtime animation for the given property
  13534. */
  13535. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13536. /**
  13537. * Resets the animatable to its original state
  13538. */
  13539. reset(): void;
  13540. /**
  13541. * Allows the animatable to blend with current running animations
  13542. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13543. * @param blendingSpeed defines the blending speed to use
  13544. */
  13545. enableBlending(blendingSpeed: number): void;
  13546. /**
  13547. * Disable animation blending
  13548. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13549. */
  13550. disableBlending(): void;
  13551. /**
  13552. * Jump directly to a given frame
  13553. * @param frame defines the frame to jump to
  13554. */
  13555. goToFrame(frame: number): void;
  13556. /**
  13557. * Pause the animation
  13558. */
  13559. pause(): void;
  13560. /**
  13561. * Restart the animation
  13562. */
  13563. restart(): void;
  13564. private _raiseOnAnimationEnd;
  13565. /**
  13566. * Stop and delete the current animation
  13567. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13568. * @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)
  13569. */
  13570. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13571. /**
  13572. * Wait asynchronously for the animation to end
  13573. * @returns a promise which will be fullfilled when the animation ends
  13574. */
  13575. waitAsync(): Promise<Animatable>;
  13576. /** @hidden */
  13577. _animate(delay: number): boolean;
  13578. }
  13579. module "babylonjs/scene" {
  13580. interface Scene {
  13581. /** @hidden */
  13582. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13583. /** @hidden */
  13584. _processLateAnimationBindingsForMatrices(holder: {
  13585. totalWeight: number;
  13586. animations: RuntimeAnimation[];
  13587. originalValue: Matrix;
  13588. }): any;
  13589. /** @hidden */
  13590. _processLateAnimationBindingsForQuaternions(holder: {
  13591. totalWeight: number;
  13592. animations: RuntimeAnimation[];
  13593. originalValue: Quaternion;
  13594. }, refQuaternion: Quaternion): Quaternion;
  13595. /** @hidden */
  13596. _processLateAnimationBindings(): void;
  13597. /**
  13598. * Will start the animation sequence of a given target
  13599. * @param target defines the target
  13600. * @param from defines from which frame should animation start
  13601. * @param to defines until which frame should animation run.
  13602. * @param weight defines the weight to apply to the animation (1.0 by default)
  13603. * @param loop defines if the animation loops
  13604. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13605. * @param onAnimationEnd defines the function to be executed when the animation ends
  13606. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13607. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13608. * @param onAnimationLoop defines the callback to call when an animation loops
  13609. * @returns the animatable object created for this animation
  13610. */
  13611. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13612. /**
  13613. * Will start the animation sequence of a given target
  13614. * @param target defines the target
  13615. * @param from defines from which frame should animation start
  13616. * @param to defines until which frame should animation run.
  13617. * @param loop defines if the animation loops
  13618. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13619. * @param onAnimationEnd defines the function to be executed when the animation ends
  13620. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13621. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13622. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13623. * @param onAnimationLoop defines the callback to call when an animation loops
  13624. * @returns the animatable object created for this animation
  13625. */
  13626. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13627. /**
  13628. * Will start the animation sequence of a given target and its hierarchy
  13629. * @param target defines the target
  13630. * @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.
  13631. * @param from defines from which frame should animation start
  13632. * @param to defines until which frame should animation run.
  13633. * @param loop defines if the animation loops
  13634. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13635. * @param onAnimationEnd defines the function to be executed when the animation ends
  13636. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13637. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13638. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13639. * @param onAnimationLoop defines the callback to call when an animation loops
  13640. * @returns the list of created animatables
  13641. */
  13642. 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[];
  13643. /**
  13644. * Begin a new animation on a given node
  13645. * @param target defines the target where the animation will take place
  13646. * @param animations defines the list of animations to start
  13647. * @param from defines the initial value
  13648. * @param to defines the final value
  13649. * @param loop defines if you want animation to loop (off by default)
  13650. * @param speedRatio defines the speed ratio to apply to all animations
  13651. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13652. * @param onAnimationLoop defines the callback to call when an animation loops
  13653. * @returns the list of created animatables
  13654. */
  13655. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13656. /**
  13657. * Begin a new animation on a given node and its hierarchy
  13658. * @param target defines the root node where the animation will take place
  13659. * @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.
  13660. * @param animations defines the list of animations to start
  13661. * @param from defines the initial value
  13662. * @param to defines the final value
  13663. * @param loop defines if you want animation to loop (off by default)
  13664. * @param speedRatio defines the speed ratio to apply to all animations
  13665. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13666. * @param onAnimationLoop defines the callback to call when an animation loops
  13667. * @returns the list of animatables created for all nodes
  13668. */
  13669. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13670. /**
  13671. * Gets the animatable associated with a specific target
  13672. * @param target defines the target of the animatable
  13673. * @returns the required animatable if found
  13674. */
  13675. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13676. /**
  13677. * Gets all animatables associated with a given target
  13678. * @param target defines the target to look animatables for
  13679. * @returns an array of Animatables
  13680. */
  13681. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13682. /**
  13683. * Stops and removes all animations that have been applied to the scene
  13684. */
  13685. stopAllAnimations(): void;
  13686. /**
  13687. * Gets the current delta time used by animation engine
  13688. */
  13689. deltaTime: number;
  13690. }
  13691. }
  13692. module "babylonjs/Bones/bone" {
  13693. interface Bone {
  13694. /**
  13695. * Copy an animation range from another bone
  13696. * @param source defines the source bone
  13697. * @param rangeName defines the range name to copy
  13698. * @param frameOffset defines the frame offset
  13699. * @param rescaleAsRequired defines if rescaling must be applied if required
  13700. * @param skelDimensionsRatio defines the scaling ratio
  13701. * @returns true if operation was successful
  13702. */
  13703. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13704. }
  13705. }
  13706. }
  13707. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13708. /**
  13709. * Class used to override all child animations of a given target
  13710. */
  13711. export class AnimationPropertiesOverride {
  13712. /**
  13713. * Gets or sets a value indicating if animation blending must be used
  13714. */
  13715. enableBlending: boolean;
  13716. /**
  13717. * Gets or sets the blending speed to use when enableBlending is true
  13718. */
  13719. blendingSpeed: number;
  13720. /**
  13721. * Gets or sets the default loop mode to use
  13722. */
  13723. loopMode: number;
  13724. }
  13725. }
  13726. declare module "babylonjs/Bones/skeleton" {
  13727. import { Bone } from "babylonjs/Bones/bone";
  13728. import { Observable } from "babylonjs/Misc/observable";
  13729. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13730. import { Scene } from "babylonjs/scene";
  13731. import { Nullable } from "babylonjs/types";
  13732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13733. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13734. import { Animatable } from "babylonjs/Animations/animatable";
  13735. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13736. import { Animation } from "babylonjs/Animations/animation";
  13737. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13738. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13739. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13740. /**
  13741. * Class used to handle skinning animations
  13742. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13743. */
  13744. export class Skeleton implements IAnimatable {
  13745. /** defines the skeleton name */
  13746. name: string;
  13747. /** defines the skeleton Id */
  13748. id: string;
  13749. /**
  13750. * Defines the list of child bones
  13751. */
  13752. bones: Bone[];
  13753. /**
  13754. * Defines an estimate of the dimension of the skeleton at rest
  13755. */
  13756. dimensionsAtRest: Vector3;
  13757. /**
  13758. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13759. */
  13760. needInitialSkinMatrix: boolean;
  13761. /**
  13762. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13763. */
  13764. overrideMesh: Nullable<AbstractMesh>;
  13765. /**
  13766. * Gets the list of animations attached to this skeleton
  13767. */
  13768. animations: Array<Animation>;
  13769. private _scene;
  13770. private _isDirty;
  13771. private _transformMatrices;
  13772. private _transformMatrixTexture;
  13773. private _meshesWithPoseMatrix;
  13774. private _animatables;
  13775. private _identity;
  13776. private _synchronizedWithMesh;
  13777. private _ranges;
  13778. private _lastAbsoluteTransformsUpdateId;
  13779. private _canUseTextureForBones;
  13780. private _uniqueId;
  13781. /** @hidden */
  13782. _numBonesWithLinkedTransformNode: number;
  13783. /** @hidden */
  13784. _hasWaitingData: Nullable<boolean>;
  13785. /**
  13786. * Specifies if the skeleton should be serialized
  13787. */
  13788. doNotSerialize: boolean;
  13789. private _useTextureToStoreBoneMatrices;
  13790. /**
  13791. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13792. * Please note that this option is not available if the hardware does not support it
  13793. */
  13794. get useTextureToStoreBoneMatrices(): boolean;
  13795. set useTextureToStoreBoneMatrices(value: boolean);
  13796. private _animationPropertiesOverride;
  13797. /**
  13798. * Gets or sets the animation properties override
  13799. */
  13800. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13801. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13802. /**
  13803. * List of inspectable custom properties (used by the Inspector)
  13804. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13805. */
  13806. inspectableCustomProperties: IInspectable[];
  13807. /**
  13808. * An observable triggered before computing the skeleton's matrices
  13809. */
  13810. onBeforeComputeObservable: Observable<Skeleton>;
  13811. /**
  13812. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13813. */
  13814. get isUsingTextureForMatrices(): boolean;
  13815. /**
  13816. * Gets the unique ID of this skeleton
  13817. */
  13818. get uniqueId(): number;
  13819. /**
  13820. * Creates a new skeleton
  13821. * @param name defines the skeleton name
  13822. * @param id defines the skeleton Id
  13823. * @param scene defines the hosting scene
  13824. */
  13825. constructor(
  13826. /** defines the skeleton name */
  13827. name: string,
  13828. /** defines the skeleton Id */
  13829. id: string, scene: Scene);
  13830. /**
  13831. * Gets the current object class name.
  13832. * @return the class name
  13833. */
  13834. getClassName(): string;
  13835. /**
  13836. * Returns an array containing the root bones
  13837. * @returns an array containing the root bones
  13838. */
  13839. getChildren(): Array<Bone>;
  13840. /**
  13841. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13842. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13843. * @returns a Float32Array containing matrices data
  13844. */
  13845. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13846. /**
  13847. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13848. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13849. * @returns a raw texture containing the data
  13850. */
  13851. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13852. /**
  13853. * Gets the current hosting scene
  13854. * @returns a scene object
  13855. */
  13856. getScene(): Scene;
  13857. /**
  13858. * Gets a string representing the current skeleton data
  13859. * @param fullDetails defines a boolean indicating if we want a verbose version
  13860. * @returns a string representing the current skeleton data
  13861. */
  13862. toString(fullDetails?: boolean): string;
  13863. /**
  13864. * Get bone's index searching by name
  13865. * @param name defines bone's name to search for
  13866. * @return the indice of the bone. Returns -1 if not found
  13867. */
  13868. getBoneIndexByName(name: string): number;
  13869. /**
  13870. * Creater a new animation range
  13871. * @param name defines the name of the range
  13872. * @param from defines the start key
  13873. * @param to defines the end key
  13874. */
  13875. createAnimationRange(name: string, from: number, to: number): void;
  13876. /**
  13877. * Delete a specific animation range
  13878. * @param name defines the name of the range
  13879. * @param deleteFrames defines if frames must be removed as well
  13880. */
  13881. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13882. /**
  13883. * Gets a specific animation range
  13884. * @param name defines the name of the range to look for
  13885. * @returns the requested animation range or null if not found
  13886. */
  13887. getAnimationRange(name: string): Nullable<AnimationRange>;
  13888. /**
  13889. * Gets the list of all animation ranges defined on this skeleton
  13890. * @returns an array
  13891. */
  13892. getAnimationRanges(): Nullable<AnimationRange>[];
  13893. /**
  13894. * Copy animation range from a source skeleton.
  13895. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13896. * @param source defines the source skeleton
  13897. * @param name defines the name of the range to copy
  13898. * @param rescaleAsRequired defines if rescaling must be applied if required
  13899. * @returns true if operation was successful
  13900. */
  13901. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13902. /**
  13903. * Forces the skeleton to go to rest pose
  13904. */
  13905. returnToRest(): void;
  13906. private _getHighestAnimationFrame;
  13907. /**
  13908. * Begin a specific animation range
  13909. * @param name defines the name of the range to start
  13910. * @param loop defines if looping must be turned on (false by default)
  13911. * @param speedRatio defines the speed ratio to apply (1 by default)
  13912. * @param onAnimationEnd defines a callback which will be called when animation will end
  13913. * @returns a new animatable
  13914. */
  13915. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13916. /** @hidden */
  13917. _markAsDirty(): void;
  13918. /** @hidden */
  13919. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13920. /** @hidden */
  13921. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13922. private _computeTransformMatrices;
  13923. /**
  13924. * Build all resources required to render a skeleton
  13925. */
  13926. prepare(): void;
  13927. /**
  13928. * Gets the list of animatables currently running for this skeleton
  13929. * @returns an array of animatables
  13930. */
  13931. getAnimatables(): IAnimatable[];
  13932. /**
  13933. * Clone the current skeleton
  13934. * @param name defines the name of the new skeleton
  13935. * @param id defines the id of the new skeleton
  13936. * @returns the new skeleton
  13937. */
  13938. clone(name: string, id?: string): Skeleton;
  13939. /**
  13940. * Enable animation blending for this skeleton
  13941. * @param blendingSpeed defines the blending speed to apply
  13942. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13943. */
  13944. enableBlending(blendingSpeed?: number): void;
  13945. /**
  13946. * Releases all resources associated with the current skeleton
  13947. */
  13948. dispose(): void;
  13949. /**
  13950. * Serialize the skeleton in a JSON object
  13951. * @returns a JSON object
  13952. */
  13953. serialize(): any;
  13954. /**
  13955. * Creates a new skeleton from serialized data
  13956. * @param parsedSkeleton defines the serialized data
  13957. * @param scene defines the hosting scene
  13958. * @returns a new skeleton
  13959. */
  13960. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13961. /**
  13962. * Compute all node absolute transforms
  13963. * @param forceUpdate defines if computation must be done even if cache is up to date
  13964. */
  13965. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13966. /**
  13967. * Gets the root pose matrix
  13968. * @returns a matrix
  13969. */
  13970. getPoseMatrix(): Nullable<Matrix>;
  13971. /**
  13972. * Sorts bones per internal index
  13973. */
  13974. sortBones(): void;
  13975. private _sortBones;
  13976. }
  13977. }
  13978. declare module "babylonjs/Bones/bone" {
  13979. import { Skeleton } from "babylonjs/Bones/skeleton";
  13980. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13981. import { Nullable } from "babylonjs/types";
  13982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13983. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13984. import { Node } from "babylonjs/node";
  13985. import { Space } from "babylonjs/Maths/math.axis";
  13986. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13987. /**
  13988. * Class used to store bone information
  13989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13990. */
  13991. export class Bone extends Node {
  13992. /**
  13993. * defines the bone name
  13994. */
  13995. name: string;
  13996. private static _tmpVecs;
  13997. private static _tmpQuat;
  13998. private static _tmpMats;
  13999. /**
  14000. * Gets the list of child bones
  14001. */
  14002. children: Bone[];
  14003. /** Gets the animations associated with this bone */
  14004. animations: import("babylonjs/Animations/animation").Animation[];
  14005. /**
  14006. * Gets or sets bone length
  14007. */
  14008. length: number;
  14009. /**
  14010. * @hidden Internal only
  14011. * Set this value to map this bone to a different index in the transform matrices
  14012. * Set this value to -1 to exclude the bone from the transform matrices
  14013. */
  14014. _index: Nullable<number>;
  14015. private _skeleton;
  14016. private _localMatrix;
  14017. private _restPose;
  14018. private _baseMatrix;
  14019. private _absoluteTransform;
  14020. private _invertedAbsoluteTransform;
  14021. private _parent;
  14022. private _scalingDeterminant;
  14023. private _worldTransform;
  14024. private _localScaling;
  14025. private _localRotation;
  14026. private _localPosition;
  14027. private _needToDecompose;
  14028. private _needToCompose;
  14029. /** @hidden */
  14030. _linkedTransformNode: Nullable<TransformNode>;
  14031. /** @hidden */
  14032. _waitingTransformNodeId: Nullable<string>;
  14033. /** @hidden */
  14034. get _matrix(): Matrix;
  14035. /** @hidden */
  14036. set _matrix(value: Matrix);
  14037. /**
  14038. * Create a new bone
  14039. * @param name defines the bone name
  14040. * @param skeleton defines the parent skeleton
  14041. * @param parentBone defines the parent (can be null if the bone is the root)
  14042. * @param localMatrix defines the local matrix
  14043. * @param restPose defines the rest pose matrix
  14044. * @param baseMatrix defines the base matrix
  14045. * @param index defines index of the bone in the hiearchy
  14046. */
  14047. constructor(
  14048. /**
  14049. * defines the bone name
  14050. */
  14051. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14052. /**
  14053. * Gets the current object class name.
  14054. * @return the class name
  14055. */
  14056. getClassName(): string;
  14057. /**
  14058. * Gets the parent skeleton
  14059. * @returns a skeleton
  14060. */
  14061. getSkeleton(): Skeleton;
  14062. /**
  14063. * Gets parent bone
  14064. * @returns a bone or null if the bone is the root of the bone hierarchy
  14065. */
  14066. getParent(): Nullable<Bone>;
  14067. /**
  14068. * Returns an array containing the root bones
  14069. * @returns an array containing the root bones
  14070. */
  14071. getChildren(): Array<Bone>;
  14072. /**
  14073. * Gets the node index in matrix array generated for rendering
  14074. * @returns the node index
  14075. */
  14076. getIndex(): number;
  14077. /**
  14078. * Sets the parent bone
  14079. * @param parent defines the parent (can be null if the bone is the root)
  14080. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14081. */
  14082. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14083. /**
  14084. * Gets the local matrix
  14085. * @returns a matrix
  14086. */
  14087. getLocalMatrix(): Matrix;
  14088. /**
  14089. * Gets the base matrix (initial matrix which remains unchanged)
  14090. * @returns a matrix
  14091. */
  14092. getBaseMatrix(): Matrix;
  14093. /**
  14094. * Gets the rest pose matrix
  14095. * @returns a matrix
  14096. */
  14097. getRestPose(): Matrix;
  14098. /**
  14099. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14100. */
  14101. getWorldMatrix(): Matrix;
  14102. /**
  14103. * Sets the local matrix to rest pose matrix
  14104. */
  14105. returnToRest(): void;
  14106. /**
  14107. * Gets the inverse of the absolute transform matrix.
  14108. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14109. * @returns a matrix
  14110. */
  14111. getInvertedAbsoluteTransform(): Matrix;
  14112. /**
  14113. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14114. * @returns a matrix
  14115. */
  14116. getAbsoluteTransform(): Matrix;
  14117. /**
  14118. * Links with the given transform node.
  14119. * The local matrix of this bone is copied from the transform node every frame.
  14120. * @param transformNode defines the transform node to link to
  14121. */
  14122. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14123. /**
  14124. * Gets the node used to drive the bone's transformation
  14125. * @returns a transform node or null
  14126. */
  14127. getTransformNode(): Nullable<TransformNode>;
  14128. /** Gets or sets current position (in local space) */
  14129. get position(): Vector3;
  14130. set position(newPosition: Vector3);
  14131. /** Gets or sets current rotation (in local space) */
  14132. get rotation(): Vector3;
  14133. set rotation(newRotation: Vector3);
  14134. /** Gets or sets current rotation quaternion (in local space) */
  14135. get rotationQuaternion(): Quaternion;
  14136. set rotationQuaternion(newRotation: Quaternion);
  14137. /** Gets or sets current scaling (in local space) */
  14138. get scaling(): Vector3;
  14139. set scaling(newScaling: Vector3);
  14140. /**
  14141. * Gets the animation properties override
  14142. */
  14143. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14144. private _decompose;
  14145. private _compose;
  14146. /**
  14147. * Update the base and local matrices
  14148. * @param matrix defines the new base or local matrix
  14149. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14150. * @param updateLocalMatrix defines if the local matrix should be updated
  14151. */
  14152. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14153. /** @hidden */
  14154. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14155. /**
  14156. * Flag the bone as dirty (Forcing it to update everything)
  14157. */
  14158. markAsDirty(): void;
  14159. /** @hidden */
  14160. _markAsDirtyAndCompose(): void;
  14161. private _markAsDirtyAndDecompose;
  14162. /**
  14163. * Translate the bone in local or world space
  14164. * @param vec The amount to translate the bone
  14165. * @param space The space that the translation is in
  14166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14167. */
  14168. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14169. /**
  14170. * Set the postion of the bone in local or world space
  14171. * @param position The position to set the bone
  14172. * @param space The space that the position is in
  14173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14174. */
  14175. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14176. /**
  14177. * Set the absolute position of the bone (world space)
  14178. * @param position The position to set the bone
  14179. * @param mesh The mesh that this bone is attached to
  14180. */
  14181. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14182. /**
  14183. * Scale the bone on the x, y and z axes (in local space)
  14184. * @param x The amount to scale the bone on the x axis
  14185. * @param y The amount to scale the bone on the y axis
  14186. * @param z The amount to scale the bone on the z axis
  14187. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14188. */
  14189. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14190. /**
  14191. * Set the bone scaling in local space
  14192. * @param scale defines the scaling vector
  14193. */
  14194. setScale(scale: Vector3): void;
  14195. /**
  14196. * Gets the current scaling in local space
  14197. * @returns the current scaling vector
  14198. */
  14199. getScale(): Vector3;
  14200. /**
  14201. * Gets the current scaling in local space and stores it in a target vector
  14202. * @param result defines the target vector
  14203. */
  14204. getScaleToRef(result: Vector3): void;
  14205. /**
  14206. * Set the yaw, pitch, and roll of the bone in local or world space
  14207. * @param yaw The rotation of the bone on the y axis
  14208. * @param pitch The rotation of the bone on the x axis
  14209. * @param roll The rotation of the bone on the z axis
  14210. * @param space The space that the axes of rotation are in
  14211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14212. */
  14213. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14214. /**
  14215. * Add a rotation to the bone on an axis in local or world space
  14216. * @param axis The axis to rotate the bone on
  14217. * @param amount The amount to rotate the bone
  14218. * @param space The space that the axis is in
  14219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14220. */
  14221. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14222. /**
  14223. * Set the rotation of the bone to a particular axis angle in local or world space
  14224. * @param axis The axis to rotate the bone on
  14225. * @param angle The angle that the bone should be rotated to
  14226. * @param space The space that the axis is in
  14227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14228. */
  14229. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14230. /**
  14231. * Set the euler rotation of the bone in local of world space
  14232. * @param rotation The euler rotation that the bone should be set to
  14233. * @param space The space that the rotation is in
  14234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14235. */
  14236. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14237. /**
  14238. * Set the quaternion rotation of the bone in local of world space
  14239. * @param quat The quaternion rotation that the bone should be set to
  14240. * @param space The space that the rotation is in
  14241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14242. */
  14243. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14244. /**
  14245. * Set the rotation matrix of the bone in local of world space
  14246. * @param rotMat The rotation matrix that the bone should be set to
  14247. * @param space The space that the rotation is in
  14248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14249. */
  14250. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14251. private _rotateWithMatrix;
  14252. private _getNegativeRotationToRef;
  14253. /**
  14254. * Get the position of the bone in local or world space
  14255. * @param space The space that the returned position is in
  14256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14257. * @returns The position of the bone
  14258. */
  14259. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14260. /**
  14261. * Copy the position of the bone to a vector3 in local or world space
  14262. * @param space The space that the returned position is in
  14263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14264. * @param result The vector3 to copy the position to
  14265. */
  14266. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14267. /**
  14268. * Get the absolute position of the bone (world space)
  14269. * @param mesh The mesh that this bone is attached to
  14270. * @returns The absolute position of the bone
  14271. */
  14272. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14273. /**
  14274. * Copy the absolute position of the bone (world space) to the result param
  14275. * @param mesh The mesh that this bone is attached to
  14276. * @param result The vector3 to copy the absolute position to
  14277. */
  14278. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14279. /**
  14280. * Compute the absolute transforms of this bone and its children
  14281. */
  14282. computeAbsoluteTransforms(): void;
  14283. /**
  14284. * Get the world direction from an axis that is in the local space of the bone
  14285. * @param localAxis The local direction that is used to compute the world direction
  14286. * @param mesh The mesh that this bone is attached to
  14287. * @returns The world direction
  14288. */
  14289. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14290. /**
  14291. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14292. * @param localAxis The local direction that is used to compute the world direction
  14293. * @param mesh The mesh that this bone is attached to
  14294. * @param result The vector3 that the world direction will be copied to
  14295. */
  14296. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14297. /**
  14298. * Get the euler rotation of the bone in local or world space
  14299. * @param space The space that the rotation should be in
  14300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14301. * @returns The euler rotation
  14302. */
  14303. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14304. /**
  14305. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14306. * @param space The space that the rotation should be in
  14307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14308. * @param result The vector3 that the rotation should be copied to
  14309. */
  14310. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14311. /**
  14312. * Get the quaternion rotation of the bone in either local or world space
  14313. * @param space The space that the rotation should be in
  14314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14315. * @returns The quaternion rotation
  14316. */
  14317. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14318. /**
  14319. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14320. * @param space The space that the rotation should be in
  14321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14322. * @param result The quaternion that the rotation should be copied to
  14323. */
  14324. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14325. /**
  14326. * Get the rotation matrix of the bone in local or world space
  14327. * @param space The space that the rotation should be in
  14328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14329. * @returns The rotation matrix
  14330. */
  14331. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14332. /**
  14333. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14334. * @param space The space that the rotation should be in
  14335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14336. * @param result The quaternion that the rotation should be copied to
  14337. */
  14338. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14339. /**
  14340. * Get the world position of a point that is in the local space of the bone
  14341. * @param position The local position
  14342. * @param mesh The mesh that this bone is attached to
  14343. * @returns The world position
  14344. */
  14345. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14346. /**
  14347. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14348. * @param position The local position
  14349. * @param mesh The mesh that this bone is attached to
  14350. * @param result The vector3 that the world position should be copied to
  14351. */
  14352. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14353. /**
  14354. * Get the local position of a point that is in world space
  14355. * @param position The world position
  14356. * @param mesh The mesh that this bone is attached to
  14357. * @returns The local position
  14358. */
  14359. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14360. /**
  14361. * Get the local position of a point that is in world space and copy it to the result param
  14362. * @param position The world position
  14363. * @param mesh The mesh that this bone is attached to
  14364. * @param result The vector3 that the local position should be copied to
  14365. */
  14366. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14367. }
  14368. }
  14369. declare module "babylonjs/Meshes/transformNode" {
  14370. import { DeepImmutable } from "babylonjs/types";
  14371. import { Observable } from "babylonjs/Misc/observable";
  14372. import { Nullable } from "babylonjs/types";
  14373. import { Camera } from "babylonjs/Cameras/camera";
  14374. import { Scene } from "babylonjs/scene";
  14375. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14376. import { Node } from "babylonjs/node";
  14377. import { Bone } from "babylonjs/Bones/bone";
  14378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14379. import { Space } from "babylonjs/Maths/math.axis";
  14380. /**
  14381. * 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.
  14382. * @see https://doc.babylonjs.com/how_to/transformnode
  14383. */
  14384. export class TransformNode extends Node {
  14385. /**
  14386. * Object will not rotate to face the camera
  14387. */
  14388. static BILLBOARDMODE_NONE: number;
  14389. /**
  14390. * Object will rotate to face the camera but only on the x axis
  14391. */
  14392. static BILLBOARDMODE_X: number;
  14393. /**
  14394. * Object will rotate to face the camera but only on the y axis
  14395. */
  14396. static BILLBOARDMODE_Y: number;
  14397. /**
  14398. * Object will rotate to face the camera but only on the z axis
  14399. */
  14400. static BILLBOARDMODE_Z: number;
  14401. /**
  14402. * Object will rotate to face the camera
  14403. */
  14404. static BILLBOARDMODE_ALL: number;
  14405. /**
  14406. * Object will rotate to face the camera's position instead of orientation
  14407. */
  14408. static BILLBOARDMODE_USE_POSITION: number;
  14409. private _forward;
  14410. private _forwardInverted;
  14411. private _up;
  14412. private _right;
  14413. private _rightInverted;
  14414. private _position;
  14415. private _rotation;
  14416. private _rotationQuaternion;
  14417. protected _scaling: Vector3;
  14418. protected _isDirty: boolean;
  14419. private _transformToBoneReferal;
  14420. private _isAbsoluteSynced;
  14421. private _billboardMode;
  14422. /**
  14423. * Gets or sets the billboard mode. Default is 0.
  14424. *
  14425. * | Value | Type | Description |
  14426. * | --- | --- | --- |
  14427. * | 0 | BILLBOARDMODE_NONE | |
  14428. * | 1 | BILLBOARDMODE_X | |
  14429. * | 2 | BILLBOARDMODE_Y | |
  14430. * | 4 | BILLBOARDMODE_Z | |
  14431. * | 7 | BILLBOARDMODE_ALL | |
  14432. *
  14433. */
  14434. get billboardMode(): number;
  14435. set billboardMode(value: number);
  14436. private _preserveParentRotationForBillboard;
  14437. /**
  14438. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14439. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14440. */
  14441. get preserveParentRotationForBillboard(): boolean;
  14442. set preserveParentRotationForBillboard(value: boolean);
  14443. /**
  14444. * 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
  14445. */
  14446. scalingDeterminant: number;
  14447. private _infiniteDistance;
  14448. /**
  14449. * Gets or sets the distance of the object to max, often used by skybox
  14450. */
  14451. get infiniteDistance(): boolean;
  14452. set infiniteDistance(value: boolean);
  14453. /**
  14454. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14455. * By default the system will update normals to compensate
  14456. */
  14457. ignoreNonUniformScaling: boolean;
  14458. /**
  14459. * 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
  14460. */
  14461. reIntegrateRotationIntoRotationQuaternion: boolean;
  14462. /** @hidden */
  14463. _poseMatrix: Nullable<Matrix>;
  14464. /** @hidden */
  14465. _localMatrix: Matrix;
  14466. private _usePivotMatrix;
  14467. private _absolutePosition;
  14468. private _absoluteScaling;
  14469. private _absoluteRotationQuaternion;
  14470. private _pivotMatrix;
  14471. private _pivotMatrixInverse;
  14472. protected _postMultiplyPivotMatrix: boolean;
  14473. protected _isWorldMatrixFrozen: boolean;
  14474. /** @hidden */
  14475. _indexInSceneTransformNodesArray: number;
  14476. /**
  14477. * An event triggered after the world matrix is updated
  14478. */
  14479. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14480. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14481. /**
  14482. * Gets a string identifying the name of the class
  14483. * @returns "TransformNode" string
  14484. */
  14485. getClassName(): string;
  14486. /**
  14487. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14488. */
  14489. get position(): Vector3;
  14490. set position(newPosition: Vector3);
  14491. /**
  14492. * 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)).
  14493. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14494. */
  14495. get rotation(): Vector3;
  14496. set rotation(newRotation: Vector3);
  14497. /**
  14498. * 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)).
  14499. */
  14500. get scaling(): Vector3;
  14501. set scaling(newScaling: Vector3);
  14502. /**
  14503. * 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).
  14504. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14505. */
  14506. get rotationQuaternion(): Nullable<Quaternion>;
  14507. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14508. /**
  14509. * The forward direction of that transform in world space.
  14510. */
  14511. get forward(): Vector3;
  14512. /**
  14513. * The up direction of that transform in world space.
  14514. */
  14515. get up(): Vector3;
  14516. /**
  14517. * The right direction of that transform in world space.
  14518. */
  14519. get right(): Vector3;
  14520. /**
  14521. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14522. * @param matrix the matrix to copy the pose from
  14523. * @returns this TransformNode.
  14524. */
  14525. updatePoseMatrix(matrix: Matrix): TransformNode;
  14526. /**
  14527. * Returns the mesh Pose matrix.
  14528. * @returns the pose matrix
  14529. */
  14530. getPoseMatrix(): Matrix;
  14531. /** @hidden */
  14532. _isSynchronized(): boolean;
  14533. /** @hidden */
  14534. _initCache(): void;
  14535. /**
  14536. * Flag the transform node as dirty (Forcing it to update everything)
  14537. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14538. * @returns this transform node
  14539. */
  14540. markAsDirty(property: string): TransformNode;
  14541. /**
  14542. * Returns the current mesh absolute position.
  14543. * Returns a Vector3.
  14544. */
  14545. get absolutePosition(): Vector3;
  14546. /**
  14547. * Returns the current mesh absolute scaling.
  14548. * Returns a Vector3.
  14549. */
  14550. get absoluteScaling(): Vector3;
  14551. /**
  14552. * Returns the current mesh absolute rotation.
  14553. * Returns a Quaternion.
  14554. */
  14555. get absoluteRotationQuaternion(): Quaternion;
  14556. /**
  14557. * Sets a new matrix to apply before all other transformation
  14558. * @param matrix defines the transform matrix
  14559. * @returns the current TransformNode
  14560. */
  14561. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14562. /**
  14563. * Sets a new pivot matrix to the current node
  14564. * @param matrix defines the new pivot matrix to use
  14565. * @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
  14566. * @returns the current TransformNode
  14567. */
  14568. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14569. /**
  14570. * Returns the mesh pivot matrix.
  14571. * Default : Identity.
  14572. * @returns the matrix
  14573. */
  14574. getPivotMatrix(): Matrix;
  14575. /**
  14576. * Instantiate (when possible) or clone that node with its hierarchy
  14577. * @param newParent defines the new parent to use for the instance (or clone)
  14578. * @param options defines options to configure how copy is done
  14579. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14580. * @returns an instance (or a clone) of the current node with its hiearchy
  14581. */
  14582. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14583. doNotInstantiate: boolean;
  14584. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14585. /**
  14586. * Prevents the World matrix to be computed any longer
  14587. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14588. * @returns the TransformNode.
  14589. */
  14590. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14591. /**
  14592. * Allows back the World matrix computation.
  14593. * @returns the TransformNode.
  14594. */
  14595. unfreezeWorldMatrix(): this;
  14596. /**
  14597. * True if the World matrix has been frozen.
  14598. */
  14599. get isWorldMatrixFrozen(): boolean;
  14600. /**
  14601. * Retuns the mesh absolute position in the World.
  14602. * @returns a Vector3.
  14603. */
  14604. getAbsolutePosition(): Vector3;
  14605. /**
  14606. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14607. * @param absolutePosition the absolute position to set
  14608. * @returns the TransformNode.
  14609. */
  14610. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14611. /**
  14612. * Sets the mesh position in its local space.
  14613. * @param vector3 the position to set in localspace
  14614. * @returns the TransformNode.
  14615. */
  14616. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14617. /**
  14618. * Returns the mesh position in the local space from the current World matrix values.
  14619. * @returns a new Vector3.
  14620. */
  14621. getPositionExpressedInLocalSpace(): Vector3;
  14622. /**
  14623. * Translates the mesh along the passed Vector3 in its local space.
  14624. * @param vector3 the distance to translate in localspace
  14625. * @returns the TransformNode.
  14626. */
  14627. locallyTranslate(vector3: Vector3): TransformNode;
  14628. private static _lookAtVectorCache;
  14629. /**
  14630. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14631. * @param targetPoint the position (must be in same space as current mesh) to look at
  14632. * @param yawCor optional yaw (y-axis) correction in radians
  14633. * @param pitchCor optional pitch (x-axis) correction in radians
  14634. * @param rollCor optional roll (z-axis) correction in radians
  14635. * @param space the choosen space of the target
  14636. * @returns the TransformNode.
  14637. */
  14638. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14639. /**
  14640. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14641. * This Vector3 is expressed in the World space.
  14642. * @param localAxis axis to rotate
  14643. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14644. */
  14645. getDirection(localAxis: Vector3): Vector3;
  14646. /**
  14647. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14648. * localAxis is expressed in the mesh local space.
  14649. * result is computed in the Wordl space from the mesh World matrix.
  14650. * @param localAxis axis to rotate
  14651. * @param result the resulting transformnode
  14652. * @returns this TransformNode.
  14653. */
  14654. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14655. /**
  14656. * Sets this transform node rotation to the given local axis.
  14657. * @param localAxis the axis in local space
  14658. * @param yawCor optional yaw (y-axis) correction in radians
  14659. * @param pitchCor optional pitch (x-axis) correction in radians
  14660. * @param rollCor optional roll (z-axis) correction in radians
  14661. * @returns this TransformNode
  14662. */
  14663. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14664. /**
  14665. * Sets a new pivot point to the current node
  14666. * @param point defines the new pivot point to use
  14667. * @param space defines if the point is in world or local space (local by default)
  14668. * @returns the current TransformNode
  14669. */
  14670. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14671. /**
  14672. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14673. * @returns the pivot point
  14674. */
  14675. getPivotPoint(): Vector3;
  14676. /**
  14677. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14678. * @param result the vector3 to store the result
  14679. * @returns this TransformNode.
  14680. */
  14681. getPivotPointToRef(result: Vector3): TransformNode;
  14682. /**
  14683. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14684. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14685. */
  14686. getAbsolutePivotPoint(): Vector3;
  14687. /**
  14688. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14689. * @param result vector3 to store the result
  14690. * @returns this TransformNode.
  14691. */
  14692. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14693. /**
  14694. * Defines the passed node as the parent of the current node.
  14695. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14696. * @see https://doc.babylonjs.com/how_to/parenting
  14697. * @param node the node ot set as the parent
  14698. * @returns this TransformNode.
  14699. */
  14700. setParent(node: Nullable<Node>): TransformNode;
  14701. private _nonUniformScaling;
  14702. /**
  14703. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14704. */
  14705. get nonUniformScaling(): boolean;
  14706. /** @hidden */
  14707. _updateNonUniformScalingState(value: boolean): boolean;
  14708. /**
  14709. * Attach the current TransformNode to another TransformNode associated with a bone
  14710. * @param bone Bone affecting the TransformNode
  14711. * @param affectedTransformNode TransformNode associated with the bone
  14712. * @returns this object
  14713. */
  14714. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14715. /**
  14716. * Detach the transform node if its associated with a bone
  14717. * @returns this object
  14718. */
  14719. detachFromBone(): TransformNode;
  14720. private static _rotationAxisCache;
  14721. /**
  14722. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14723. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14724. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14725. * The passed axis is also normalized.
  14726. * @param axis the axis to rotate around
  14727. * @param amount the amount to rotate in radians
  14728. * @param space Space to rotate in (Default: local)
  14729. * @returns the TransformNode.
  14730. */
  14731. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14732. /**
  14733. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14734. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14735. * The passed axis is also normalized. .
  14736. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14737. * @param point the point to rotate around
  14738. * @param axis the axis to rotate around
  14739. * @param amount the amount to rotate in radians
  14740. * @returns the TransformNode
  14741. */
  14742. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14743. /**
  14744. * Translates the mesh along the axis vector for the passed distance in the given space.
  14745. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14746. * @param axis the axis to translate in
  14747. * @param distance the distance to translate
  14748. * @param space Space to rotate in (Default: local)
  14749. * @returns the TransformNode.
  14750. */
  14751. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14752. /**
  14753. * Adds a rotation step to the mesh current rotation.
  14754. * x, y, z are Euler angles expressed in radians.
  14755. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14756. * This means this rotation is made in the mesh local space only.
  14757. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14758. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14759. * ```javascript
  14760. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14761. * ```
  14762. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14763. * 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.
  14764. * @param x Rotation to add
  14765. * @param y Rotation to add
  14766. * @param z Rotation to add
  14767. * @returns the TransformNode.
  14768. */
  14769. addRotation(x: number, y: number, z: number): TransformNode;
  14770. /**
  14771. * @hidden
  14772. */
  14773. protected _getEffectiveParent(): Nullable<Node>;
  14774. /**
  14775. * Computes the world matrix of the node
  14776. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14777. * @returns the world matrix
  14778. */
  14779. computeWorldMatrix(force?: boolean): Matrix;
  14780. protected _afterComputeWorldMatrix(): void;
  14781. /**
  14782. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14783. * @param func callback function to add
  14784. *
  14785. * @returns the TransformNode.
  14786. */
  14787. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14788. /**
  14789. * Removes a registered callback function.
  14790. * @param func callback function to remove
  14791. * @returns the TransformNode.
  14792. */
  14793. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14794. /**
  14795. * Gets the position of the current mesh in camera space
  14796. * @param camera defines the camera to use
  14797. * @returns a position
  14798. */
  14799. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14800. /**
  14801. * Returns the distance from the mesh to the active camera
  14802. * @param camera defines the camera to use
  14803. * @returns the distance
  14804. */
  14805. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14806. /**
  14807. * Clone the current transform node
  14808. * @param name Name of the new clone
  14809. * @param newParent New parent for the clone
  14810. * @param doNotCloneChildren Do not clone children hierarchy
  14811. * @returns the new transform node
  14812. */
  14813. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14814. /**
  14815. * Serializes the objects information.
  14816. * @param currentSerializationObject defines the object to serialize in
  14817. * @returns the serialized object
  14818. */
  14819. serialize(currentSerializationObject?: any): any;
  14820. /**
  14821. * Returns a new TransformNode object parsed from the source provided.
  14822. * @param parsedTransformNode is the source.
  14823. * @param scene the scne the object belongs to
  14824. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14825. * @returns a new TransformNode object parsed from the source provided.
  14826. */
  14827. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14828. /**
  14829. * Get all child-transformNodes of this node
  14830. * @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
  14831. * @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
  14832. * @returns an array of TransformNode
  14833. */
  14834. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14835. /**
  14836. * Releases resources associated with this transform node.
  14837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14839. */
  14840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14841. /**
  14842. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14843. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14844. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14845. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14846. * @returns the current mesh
  14847. */
  14848. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14849. private _syncAbsoluteScalingAndRotation;
  14850. }
  14851. }
  14852. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14853. import { Observable } from "babylonjs/Misc/observable";
  14854. import { Nullable } from "babylonjs/types";
  14855. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14856. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14858. import { Ray } from "babylonjs/Culling/ray";
  14859. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14860. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14861. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14862. /**
  14863. * Defines the types of pose enabled controllers that are supported
  14864. */
  14865. export enum PoseEnabledControllerType {
  14866. /**
  14867. * HTC Vive
  14868. */
  14869. VIVE = 0,
  14870. /**
  14871. * Oculus Rift
  14872. */
  14873. OCULUS = 1,
  14874. /**
  14875. * Windows mixed reality
  14876. */
  14877. WINDOWS = 2,
  14878. /**
  14879. * Samsung gear VR
  14880. */
  14881. GEAR_VR = 3,
  14882. /**
  14883. * Google Daydream
  14884. */
  14885. DAYDREAM = 4,
  14886. /**
  14887. * Generic
  14888. */
  14889. GENERIC = 5
  14890. }
  14891. /**
  14892. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14893. */
  14894. export interface MutableGamepadButton {
  14895. /**
  14896. * Value of the button/trigger
  14897. */
  14898. value: number;
  14899. /**
  14900. * If the button/trigger is currently touched
  14901. */
  14902. touched: boolean;
  14903. /**
  14904. * If the button/trigger is currently pressed
  14905. */
  14906. pressed: boolean;
  14907. }
  14908. /**
  14909. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14910. * @hidden
  14911. */
  14912. export interface ExtendedGamepadButton extends GamepadButton {
  14913. /**
  14914. * If the button/trigger is currently pressed
  14915. */
  14916. readonly pressed: boolean;
  14917. /**
  14918. * If the button/trigger is currently touched
  14919. */
  14920. readonly touched: boolean;
  14921. /**
  14922. * Value of the button/trigger
  14923. */
  14924. readonly value: number;
  14925. }
  14926. /** @hidden */
  14927. export interface _GamePadFactory {
  14928. /**
  14929. * Returns wether or not the current gamepad can be created for this type of controller.
  14930. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14931. * @returns true if it can be created, otherwise false
  14932. */
  14933. canCreate(gamepadInfo: any): boolean;
  14934. /**
  14935. * Creates a new instance of the Gamepad.
  14936. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14937. * @returns the new gamepad instance
  14938. */
  14939. create(gamepadInfo: any): Gamepad;
  14940. }
  14941. /**
  14942. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14943. */
  14944. export class PoseEnabledControllerHelper {
  14945. /** @hidden */
  14946. static _ControllerFactories: _GamePadFactory[];
  14947. /** @hidden */
  14948. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14949. /**
  14950. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14951. * @param vrGamepad the gamepad to initialized
  14952. * @returns a vr controller of the type the gamepad identified as
  14953. */
  14954. static InitiateController(vrGamepad: any): Gamepad;
  14955. }
  14956. /**
  14957. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14958. */
  14959. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14960. /**
  14961. * If the controller is used in a webXR session
  14962. */
  14963. isXR: boolean;
  14964. private _deviceRoomPosition;
  14965. private _deviceRoomRotationQuaternion;
  14966. /**
  14967. * The device position in babylon space
  14968. */
  14969. devicePosition: Vector3;
  14970. /**
  14971. * The device rotation in babylon space
  14972. */
  14973. deviceRotationQuaternion: Quaternion;
  14974. /**
  14975. * The scale factor of the device in babylon space
  14976. */
  14977. deviceScaleFactor: number;
  14978. /**
  14979. * (Likely devicePosition should be used instead) The device position in its room space
  14980. */
  14981. position: Vector3;
  14982. /**
  14983. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14984. */
  14985. rotationQuaternion: Quaternion;
  14986. /**
  14987. * The type of controller (Eg. Windows mixed reality)
  14988. */
  14989. controllerType: PoseEnabledControllerType;
  14990. protected _calculatedPosition: Vector3;
  14991. private _calculatedRotation;
  14992. /**
  14993. * The raw pose from the device
  14994. */
  14995. rawPose: DevicePose;
  14996. private _trackPosition;
  14997. private _maxRotationDistFromHeadset;
  14998. private _draggedRoomRotation;
  14999. /**
  15000. * @hidden
  15001. */
  15002. _disableTrackPosition(fixedPosition: Vector3): void;
  15003. /**
  15004. * Internal, the mesh attached to the controller
  15005. * @hidden
  15006. */
  15007. _mesh: Nullable<AbstractMesh>;
  15008. private _poseControlledCamera;
  15009. private _leftHandSystemQuaternion;
  15010. /**
  15011. * Internal, matrix used to convert room space to babylon space
  15012. * @hidden
  15013. */
  15014. _deviceToWorld: Matrix;
  15015. /**
  15016. * Node to be used when casting a ray from the controller
  15017. * @hidden
  15018. */
  15019. _pointingPoseNode: Nullable<TransformNode>;
  15020. /**
  15021. * Name of the child mesh that can be used to cast a ray from the controller
  15022. */
  15023. static readonly POINTING_POSE: string;
  15024. /**
  15025. * Creates a new PoseEnabledController from a gamepad
  15026. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15027. */
  15028. constructor(browserGamepad: any);
  15029. private _workingMatrix;
  15030. /**
  15031. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15032. */
  15033. update(): void;
  15034. /**
  15035. * Updates only the pose device and mesh without doing any button event checking
  15036. */
  15037. protected _updatePoseAndMesh(): void;
  15038. /**
  15039. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15040. * @param poseData raw pose fromthe device
  15041. */
  15042. updateFromDevice(poseData: DevicePose): void;
  15043. /**
  15044. * @hidden
  15045. */
  15046. _meshAttachedObservable: Observable<AbstractMesh>;
  15047. /**
  15048. * Attaches a mesh to the controller
  15049. * @param mesh the mesh to be attached
  15050. */
  15051. attachToMesh(mesh: AbstractMesh): void;
  15052. /**
  15053. * Attaches the controllers mesh to a camera
  15054. * @param camera the camera the mesh should be attached to
  15055. */
  15056. attachToPoseControlledCamera(camera: TargetCamera): void;
  15057. /**
  15058. * Disposes of the controller
  15059. */
  15060. dispose(): void;
  15061. /**
  15062. * The mesh that is attached to the controller
  15063. */
  15064. get mesh(): Nullable<AbstractMesh>;
  15065. /**
  15066. * Gets the ray of the controller in the direction the controller is pointing
  15067. * @param length the length the resulting ray should be
  15068. * @returns a ray in the direction the controller is pointing
  15069. */
  15070. getForwardRay(length?: number): Ray;
  15071. }
  15072. }
  15073. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15074. import { Observable } from "babylonjs/Misc/observable";
  15075. import { Scene } from "babylonjs/scene";
  15076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15077. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15078. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15079. import { Nullable } from "babylonjs/types";
  15080. /**
  15081. * Defines the WebVRController object that represents controllers tracked in 3D space
  15082. */
  15083. export abstract class WebVRController extends PoseEnabledController {
  15084. /**
  15085. * Internal, the default controller model for the controller
  15086. */
  15087. protected _defaultModel: Nullable<AbstractMesh>;
  15088. /**
  15089. * Fired when the trigger state has changed
  15090. */
  15091. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15092. /**
  15093. * Fired when the main button state has changed
  15094. */
  15095. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15096. /**
  15097. * Fired when the secondary button state has changed
  15098. */
  15099. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15100. /**
  15101. * Fired when the pad state has changed
  15102. */
  15103. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15104. /**
  15105. * Fired when controllers stick values have changed
  15106. */
  15107. onPadValuesChangedObservable: Observable<StickValues>;
  15108. /**
  15109. * Array of button availible on the controller
  15110. */
  15111. protected _buttons: Array<MutableGamepadButton>;
  15112. private _onButtonStateChange;
  15113. /**
  15114. * Fired when a controller button's state has changed
  15115. * @param callback the callback containing the button that was modified
  15116. */
  15117. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15118. /**
  15119. * X and Y axis corresponding to the controllers joystick
  15120. */
  15121. pad: StickValues;
  15122. /**
  15123. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15124. */
  15125. hand: string;
  15126. /**
  15127. * The default controller model for the controller
  15128. */
  15129. get defaultModel(): Nullable<AbstractMesh>;
  15130. /**
  15131. * Creates a new WebVRController from a gamepad
  15132. * @param vrGamepad the gamepad that the WebVRController should be created from
  15133. */
  15134. constructor(vrGamepad: any);
  15135. /**
  15136. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15137. */
  15138. update(): void;
  15139. /**
  15140. * Function to be called when a button is modified
  15141. */
  15142. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15143. /**
  15144. * Loads a mesh and attaches it to the controller
  15145. * @param scene the scene the mesh should be added to
  15146. * @param meshLoaded callback for when the mesh has been loaded
  15147. */
  15148. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15149. private _setButtonValue;
  15150. private _changes;
  15151. private _checkChanges;
  15152. /**
  15153. * Disposes of th webVRCOntroller
  15154. */
  15155. dispose(): void;
  15156. }
  15157. }
  15158. declare module "babylonjs/Lights/hemisphericLight" {
  15159. import { Nullable } from "babylonjs/types";
  15160. import { Scene } from "babylonjs/scene";
  15161. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15162. import { Color3 } from "babylonjs/Maths/math.color";
  15163. import { Effect } from "babylonjs/Materials/effect";
  15164. import { Light } from "babylonjs/Lights/light";
  15165. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15166. /**
  15167. * The HemisphericLight simulates the ambient environment light,
  15168. * so the passed direction is the light reflection direction, not the incoming direction.
  15169. */
  15170. export class HemisphericLight extends Light {
  15171. /**
  15172. * The groundColor is the light in the opposite direction to the one specified during creation.
  15173. * 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.
  15174. */
  15175. groundColor: Color3;
  15176. /**
  15177. * The light reflection direction, not the incoming direction.
  15178. */
  15179. direction: Vector3;
  15180. /**
  15181. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15182. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15183. * The HemisphericLight can't cast shadows.
  15184. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15185. * @param name The friendly name of the light
  15186. * @param direction The direction of the light reflection
  15187. * @param scene The scene the light belongs to
  15188. */
  15189. constructor(name: string, direction: Vector3, scene: Scene);
  15190. protected _buildUniformLayout(): void;
  15191. /**
  15192. * Returns the string "HemisphericLight".
  15193. * @return The class name
  15194. */
  15195. getClassName(): string;
  15196. /**
  15197. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15198. * Returns the updated direction.
  15199. * @param target The target the direction should point to
  15200. * @return The computed direction
  15201. */
  15202. setDirectionToTarget(target: Vector3): Vector3;
  15203. /**
  15204. * Returns the shadow generator associated to the light.
  15205. * @returns Always null for hemispheric lights because it does not support shadows.
  15206. */
  15207. getShadowGenerator(): Nullable<IShadowGenerator>;
  15208. /**
  15209. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15210. * @param effect The effect to update
  15211. * @param lightIndex The index of the light in the effect to update
  15212. * @returns The hemispheric light
  15213. */
  15214. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15215. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15216. /**
  15217. * Computes the world matrix of the node
  15218. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15219. * @param useWasUpdatedFlag defines a reserved property
  15220. * @returns the world matrix
  15221. */
  15222. computeWorldMatrix(): Matrix;
  15223. /**
  15224. * Returns the integer 3.
  15225. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15226. */
  15227. getTypeID(): number;
  15228. /**
  15229. * Prepares the list of defines specific to the light type.
  15230. * @param defines the list of defines
  15231. * @param lightIndex defines the index of the light for the effect
  15232. */
  15233. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15234. }
  15235. }
  15236. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15237. /** @hidden */
  15238. export var vrMultiviewToSingleviewPixelShader: {
  15239. name: string;
  15240. shader: string;
  15241. };
  15242. }
  15243. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15244. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15245. import { Scene } from "babylonjs/scene";
  15246. /**
  15247. * Renders to multiple views with a single draw call
  15248. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15249. */
  15250. export class MultiviewRenderTarget extends RenderTargetTexture {
  15251. /**
  15252. * Creates a multiview render target
  15253. * @param scene scene used with the render target
  15254. * @param size the size of the render target (used for each view)
  15255. */
  15256. constructor(scene: Scene, size?: number | {
  15257. width: number;
  15258. height: number;
  15259. } | {
  15260. ratio: number;
  15261. });
  15262. /**
  15263. * @hidden
  15264. * @param faceIndex the face index, if its a cube texture
  15265. */
  15266. _bindFrameBuffer(faceIndex?: number): void;
  15267. /**
  15268. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15269. * @returns the view count
  15270. */
  15271. getViewCount(): number;
  15272. }
  15273. }
  15274. declare module "babylonjs/Maths/math.frustum" {
  15275. import { Matrix } from "babylonjs/Maths/math.vector";
  15276. import { DeepImmutable } from "babylonjs/types";
  15277. import { Plane } from "babylonjs/Maths/math.plane";
  15278. /**
  15279. * Represents a camera frustum
  15280. */
  15281. export class Frustum {
  15282. /**
  15283. * Gets the planes representing the frustum
  15284. * @param transform matrix to be applied to the returned planes
  15285. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15286. */
  15287. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15288. /**
  15289. * Gets the near frustum plane transformed by the transform matrix
  15290. * @param transform transformation matrix to be applied to the resulting frustum plane
  15291. * @param frustumPlane the resuling frustum plane
  15292. */
  15293. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15294. /**
  15295. * Gets the far frustum plane transformed by the transform matrix
  15296. * @param transform transformation matrix to be applied to the resulting frustum plane
  15297. * @param frustumPlane the resuling frustum plane
  15298. */
  15299. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15300. /**
  15301. * Gets the left frustum plane transformed by the transform matrix
  15302. * @param transform transformation matrix to be applied to the resulting frustum plane
  15303. * @param frustumPlane the resuling frustum plane
  15304. */
  15305. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15306. /**
  15307. * Gets the right frustum plane transformed by the transform matrix
  15308. * @param transform transformation matrix to be applied to the resulting frustum plane
  15309. * @param frustumPlane the resuling frustum plane
  15310. */
  15311. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15312. /**
  15313. * Gets the top frustum plane transformed by the transform matrix
  15314. * @param transform transformation matrix to be applied to the resulting frustum plane
  15315. * @param frustumPlane the resuling frustum plane
  15316. */
  15317. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15318. /**
  15319. * Gets the bottom frustum plane transformed by the transform matrix
  15320. * @param transform transformation matrix to be applied to the resulting frustum plane
  15321. * @param frustumPlane the resuling frustum plane
  15322. */
  15323. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15324. /**
  15325. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15326. * @param transform transformation matrix to be applied to the resulting frustum planes
  15327. * @param frustumPlanes the resuling frustum planes
  15328. */
  15329. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15330. }
  15331. }
  15332. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15333. import { Camera } from "babylonjs/Cameras/camera";
  15334. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15335. import { Nullable } from "babylonjs/types";
  15336. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15337. import { Matrix } from "babylonjs/Maths/math.vector";
  15338. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15339. module "babylonjs/Engines/engine" {
  15340. interface Engine {
  15341. /**
  15342. * Creates a new multiview render target
  15343. * @param width defines the width of the texture
  15344. * @param height defines the height of the texture
  15345. * @returns the created multiview texture
  15346. */
  15347. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15348. /**
  15349. * Binds a multiview framebuffer to be drawn to
  15350. * @param multiviewTexture texture to bind
  15351. */
  15352. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15353. }
  15354. }
  15355. module "babylonjs/Cameras/camera" {
  15356. interface Camera {
  15357. /**
  15358. * @hidden
  15359. * 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)
  15360. */
  15361. _useMultiviewToSingleView: boolean;
  15362. /**
  15363. * @hidden
  15364. * 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)
  15365. */
  15366. _multiviewTexture: Nullable<RenderTargetTexture>;
  15367. /**
  15368. * @hidden
  15369. * ensures the multiview texture of the camera exists and has the specified width/height
  15370. * @param width height to set on the multiview texture
  15371. * @param height width to set on the multiview texture
  15372. */
  15373. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15374. }
  15375. }
  15376. module "babylonjs/scene" {
  15377. interface Scene {
  15378. /** @hidden */
  15379. _transformMatrixR: Matrix;
  15380. /** @hidden */
  15381. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15382. /** @hidden */
  15383. _createMultiviewUbo(): void;
  15384. /** @hidden */
  15385. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15386. /** @hidden */
  15387. _renderMultiviewToSingleView(camera: Camera): void;
  15388. }
  15389. }
  15390. }
  15391. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15392. import { Camera } from "babylonjs/Cameras/camera";
  15393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15394. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15395. import "babylonjs/Engines/Extensions/engine.multiview";
  15396. /**
  15397. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15398. * This will not be used for webXR as it supports displaying texture arrays directly
  15399. */
  15400. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15401. /**
  15402. * Initializes a VRMultiviewToSingleview
  15403. * @param name name of the post process
  15404. * @param camera camera to be applied to
  15405. * @param scaleFactor scaling factor to the size of the output texture
  15406. */
  15407. constructor(name: string, camera: Camera, scaleFactor: number);
  15408. }
  15409. }
  15410. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15411. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15412. import { Nullable } from "babylonjs/types";
  15413. import { Size } from "babylonjs/Maths/math.size";
  15414. import { Observable } from "babylonjs/Misc/observable";
  15415. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15416. /**
  15417. * Interface used to define additional presentation attributes
  15418. */
  15419. export interface IVRPresentationAttributes {
  15420. /**
  15421. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15422. */
  15423. highRefreshRate: boolean;
  15424. /**
  15425. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15426. */
  15427. foveationLevel: number;
  15428. }
  15429. module "babylonjs/Engines/engine" {
  15430. interface Engine {
  15431. /** @hidden */
  15432. _vrDisplay: any;
  15433. /** @hidden */
  15434. _vrSupported: boolean;
  15435. /** @hidden */
  15436. _oldSize: Size;
  15437. /** @hidden */
  15438. _oldHardwareScaleFactor: number;
  15439. /** @hidden */
  15440. _vrExclusivePointerMode: boolean;
  15441. /** @hidden */
  15442. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15443. /** @hidden */
  15444. _onVRDisplayPointerRestricted: () => void;
  15445. /** @hidden */
  15446. _onVRDisplayPointerUnrestricted: () => void;
  15447. /** @hidden */
  15448. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15449. /** @hidden */
  15450. _onVrDisplayDisconnect: Nullable<() => void>;
  15451. /** @hidden */
  15452. _onVrDisplayPresentChange: Nullable<() => void>;
  15453. /**
  15454. * Observable signaled when VR display mode changes
  15455. */
  15456. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15457. /**
  15458. * Observable signaled when VR request present is complete
  15459. */
  15460. onVRRequestPresentComplete: Observable<boolean>;
  15461. /**
  15462. * Observable signaled when VR request present starts
  15463. */
  15464. onVRRequestPresentStart: Observable<Engine>;
  15465. /**
  15466. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15467. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15468. */
  15469. isInVRExclusivePointerMode: boolean;
  15470. /**
  15471. * Gets a boolean indicating if a webVR device was detected
  15472. * @returns true if a webVR device was detected
  15473. */
  15474. isVRDevicePresent(): boolean;
  15475. /**
  15476. * Gets the current webVR device
  15477. * @returns the current webVR device (or null)
  15478. */
  15479. getVRDevice(): any;
  15480. /**
  15481. * Initializes a webVR display and starts listening to display change events
  15482. * The onVRDisplayChangedObservable will be notified upon these changes
  15483. * @returns A promise containing a VRDisplay and if vr is supported
  15484. */
  15485. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15486. /** @hidden */
  15487. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15488. /**
  15489. * Gets or sets the presentation attributes used to configure VR rendering
  15490. */
  15491. vrPresentationAttributes?: IVRPresentationAttributes;
  15492. /**
  15493. * Call this function to switch to webVR mode
  15494. * Will do nothing if webVR is not supported or if there is no webVR device
  15495. * @param options the webvr options provided to the camera. mainly used for multiview
  15496. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15497. */
  15498. enableVR(options: WebVROptions): void;
  15499. /** @hidden */
  15500. _onVRFullScreenTriggered(): void;
  15501. }
  15502. }
  15503. }
  15504. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15505. import { Nullable } from "babylonjs/types";
  15506. import { Observable } from "babylonjs/Misc/observable";
  15507. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15508. import { Scene } from "babylonjs/scene";
  15509. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15510. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15511. import { Node } from "babylonjs/node";
  15512. import { Ray } from "babylonjs/Culling/ray";
  15513. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15514. import "babylonjs/Engines/Extensions/engine.webVR";
  15515. /**
  15516. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15517. * IMPORTANT!! The data is right-hand data.
  15518. * @export
  15519. * @interface DevicePose
  15520. */
  15521. export interface DevicePose {
  15522. /**
  15523. * The position of the device, values in array are [x,y,z].
  15524. */
  15525. readonly position: Nullable<Float32Array>;
  15526. /**
  15527. * The linearVelocity of the device, values in array are [x,y,z].
  15528. */
  15529. readonly linearVelocity: Nullable<Float32Array>;
  15530. /**
  15531. * The linearAcceleration of the device, values in array are [x,y,z].
  15532. */
  15533. readonly linearAcceleration: Nullable<Float32Array>;
  15534. /**
  15535. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15536. */
  15537. readonly orientation: Nullable<Float32Array>;
  15538. /**
  15539. * The angularVelocity of the device, values in array are [x,y,z].
  15540. */
  15541. readonly angularVelocity: Nullable<Float32Array>;
  15542. /**
  15543. * The angularAcceleration of the device, values in array are [x,y,z].
  15544. */
  15545. readonly angularAcceleration: Nullable<Float32Array>;
  15546. }
  15547. /**
  15548. * Interface representing a pose controlled object in Babylon.
  15549. * A pose controlled object has both regular pose values as well as pose values
  15550. * from an external device such as a VR head mounted display
  15551. */
  15552. export interface PoseControlled {
  15553. /**
  15554. * The position of the object in babylon space.
  15555. */
  15556. position: Vector3;
  15557. /**
  15558. * The rotation quaternion of the object in babylon space.
  15559. */
  15560. rotationQuaternion: Quaternion;
  15561. /**
  15562. * The position of the device in babylon space.
  15563. */
  15564. devicePosition?: Vector3;
  15565. /**
  15566. * The rotation quaternion of the device in babylon space.
  15567. */
  15568. deviceRotationQuaternion: Quaternion;
  15569. /**
  15570. * The raw pose coming from the device.
  15571. */
  15572. rawPose: Nullable<DevicePose>;
  15573. /**
  15574. * The scale of the device to be used when translating from device space to babylon space.
  15575. */
  15576. deviceScaleFactor: number;
  15577. /**
  15578. * Updates the poseControlled values based on the input device pose.
  15579. * @param poseData the pose data to update the object with
  15580. */
  15581. updateFromDevice(poseData: DevicePose): void;
  15582. }
  15583. /**
  15584. * Set of options to customize the webVRCamera
  15585. */
  15586. export interface WebVROptions {
  15587. /**
  15588. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15589. */
  15590. trackPosition?: boolean;
  15591. /**
  15592. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15593. */
  15594. positionScale?: number;
  15595. /**
  15596. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15597. */
  15598. displayName?: string;
  15599. /**
  15600. * Should the native controller meshes be initialized. (default: true)
  15601. */
  15602. controllerMeshes?: boolean;
  15603. /**
  15604. * Creating a default HemiLight only on controllers. (default: true)
  15605. */
  15606. defaultLightingOnControllers?: boolean;
  15607. /**
  15608. * If you don't want to use the default VR button of the helper. (default: false)
  15609. */
  15610. useCustomVRButton?: boolean;
  15611. /**
  15612. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15613. */
  15614. customVRButton?: HTMLButtonElement;
  15615. /**
  15616. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15617. */
  15618. rayLength?: number;
  15619. /**
  15620. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15621. */
  15622. defaultHeight?: number;
  15623. /**
  15624. * If multiview should be used if availible (default: false)
  15625. */
  15626. useMultiview?: boolean;
  15627. }
  15628. /**
  15629. * This represents a WebVR camera.
  15630. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15631. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15632. */
  15633. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15634. private webVROptions;
  15635. /**
  15636. * @hidden
  15637. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15638. */
  15639. _vrDevice: any;
  15640. /**
  15641. * The rawPose of the vrDevice.
  15642. */
  15643. rawPose: Nullable<DevicePose>;
  15644. private _onVREnabled;
  15645. private _specsVersion;
  15646. private _attached;
  15647. private _frameData;
  15648. protected _descendants: Array<Node>;
  15649. private _deviceRoomPosition;
  15650. /** @hidden */
  15651. _deviceRoomRotationQuaternion: Quaternion;
  15652. private _standingMatrix;
  15653. /**
  15654. * Represents device position in babylon space.
  15655. */
  15656. devicePosition: Vector3;
  15657. /**
  15658. * Represents device rotation in babylon space.
  15659. */
  15660. deviceRotationQuaternion: Quaternion;
  15661. /**
  15662. * The scale of the device to be used when translating from device space to babylon space.
  15663. */
  15664. deviceScaleFactor: number;
  15665. private _deviceToWorld;
  15666. private _worldToDevice;
  15667. /**
  15668. * References to the webVR controllers for the vrDevice.
  15669. */
  15670. controllers: Array<WebVRController>;
  15671. /**
  15672. * Emits an event when a controller is attached.
  15673. */
  15674. onControllersAttachedObservable: Observable<WebVRController[]>;
  15675. /**
  15676. * Emits an event when a controller's mesh has been loaded;
  15677. */
  15678. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15679. /**
  15680. * Emits an event when the HMD's pose has been updated.
  15681. */
  15682. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15683. private _poseSet;
  15684. /**
  15685. * If the rig cameras be used as parent instead of this camera.
  15686. */
  15687. rigParenting: boolean;
  15688. private _lightOnControllers;
  15689. private _defaultHeight?;
  15690. /**
  15691. * Instantiates a WebVRFreeCamera.
  15692. * @param name The name of the WebVRFreeCamera
  15693. * @param position The starting anchor position for the camera
  15694. * @param scene The scene the camera belongs to
  15695. * @param webVROptions a set of customizable options for the webVRCamera
  15696. */
  15697. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15698. /**
  15699. * Gets the device distance from the ground in meters.
  15700. * @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.
  15701. */
  15702. deviceDistanceToRoomGround(): number;
  15703. /**
  15704. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15705. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15706. */
  15707. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15708. /**
  15709. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15710. * @returns A promise with a boolean set to if the standing matrix is supported.
  15711. */
  15712. useStandingMatrixAsync(): Promise<boolean>;
  15713. /**
  15714. * Disposes the camera
  15715. */
  15716. dispose(): void;
  15717. /**
  15718. * Gets a vrController by name.
  15719. * @param name The name of the controller to retreive
  15720. * @returns the controller matching the name specified or null if not found
  15721. */
  15722. getControllerByName(name: string): Nullable<WebVRController>;
  15723. private _leftController;
  15724. /**
  15725. * The controller corresponding to the users left hand.
  15726. */
  15727. get leftController(): Nullable<WebVRController>;
  15728. private _rightController;
  15729. /**
  15730. * The controller corresponding to the users right hand.
  15731. */
  15732. get rightController(): Nullable<WebVRController>;
  15733. /**
  15734. * Casts a ray forward from the vrCamera's gaze.
  15735. * @param length Length of the ray (default: 100)
  15736. * @returns the ray corresponding to the gaze
  15737. */
  15738. getForwardRay(length?: number): Ray;
  15739. /**
  15740. * @hidden
  15741. * Updates the camera based on device's frame data
  15742. */
  15743. _checkInputs(): void;
  15744. /**
  15745. * Updates the poseControlled values based on the input device pose.
  15746. * @param poseData Pose coming from the device
  15747. */
  15748. updateFromDevice(poseData: DevicePose): void;
  15749. private _htmlElementAttached;
  15750. private _detachIfAttached;
  15751. /**
  15752. * WebVR's attach control will start broadcasting frames to the device.
  15753. * Note that in certain browsers (chrome for example) this function must be called
  15754. * within a user-interaction callback. Example:
  15755. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15756. *
  15757. * @param element html element to attach the vrDevice to
  15758. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15759. */
  15760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15761. /**
  15762. * Detaches the camera from the html element and disables VR
  15763. *
  15764. * @param element html element to detach from
  15765. */
  15766. detachControl(element: HTMLElement): void;
  15767. /**
  15768. * @returns the name of this class
  15769. */
  15770. getClassName(): string;
  15771. /**
  15772. * Calls resetPose on the vrDisplay
  15773. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15774. */
  15775. resetToCurrentRotation(): void;
  15776. /**
  15777. * @hidden
  15778. * Updates the rig cameras (left and right eye)
  15779. */
  15780. _updateRigCameras(): void;
  15781. private _workingVector;
  15782. private _oneVector;
  15783. private _workingMatrix;
  15784. private updateCacheCalled;
  15785. private _correctPositionIfNotTrackPosition;
  15786. /**
  15787. * @hidden
  15788. * Updates the cached values of the camera
  15789. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15790. */
  15791. _updateCache(ignoreParentClass?: boolean): void;
  15792. /**
  15793. * @hidden
  15794. * Get current device position in babylon world
  15795. */
  15796. _computeDevicePosition(): void;
  15797. /**
  15798. * Updates the current device position and rotation in the babylon world
  15799. */
  15800. update(): void;
  15801. /**
  15802. * @hidden
  15803. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15804. * @returns an identity matrix
  15805. */
  15806. _getViewMatrix(): Matrix;
  15807. private _tmpMatrix;
  15808. /**
  15809. * This function is called by the two RIG cameras.
  15810. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15811. * @hidden
  15812. */
  15813. _getWebVRViewMatrix(): Matrix;
  15814. /** @hidden */
  15815. _getWebVRProjectionMatrix(): Matrix;
  15816. private _onGamepadConnectedObserver;
  15817. private _onGamepadDisconnectedObserver;
  15818. private _updateCacheWhenTrackingDisabledObserver;
  15819. /**
  15820. * Initializes the controllers and their meshes
  15821. */
  15822. initControllers(): void;
  15823. }
  15824. }
  15825. declare module "babylonjs/PostProcesses/postProcess" {
  15826. import { Nullable } from "babylonjs/types";
  15827. import { SmartArray } from "babylonjs/Misc/smartArray";
  15828. import { Observable } from "babylonjs/Misc/observable";
  15829. import { Vector2 } from "babylonjs/Maths/math.vector";
  15830. import { Camera } from "babylonjs/Cameras/camera";
  15831. import { Effect } from "babylonjs/Materials/effect";
  15832. import "babylonjs/Shaders/postprocess.vertex";
  15833. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15834. import { Engine } from "babylonjs/Engines/engine";
  15835. import { Color4 } from "babylonjs/Maths/math.color";
  15836. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15837. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15838. /**
  15839. * Size options for a post process
  15840. */
  15841. export type PostProcessOptions = {
  15842. width: number;
  15843. height: number;
  15844. };
  15845. /**
  15846. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15847. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15848. */
  15849. export class PostProcess {
  15850. /** Name of the PostProcess. */
  15851. name: string;
  15852. /**
  15853. * Gets or sets the unique id of the post process
  15854. */
  15855. uniqueId: number;
  15856. /**
  15857. * Width of the texture to apply the post process on
  15858. */
  15859. width: number;
  15860. /**
  15861. * Height of the texture to apply the post process on
  15862. */
  15863. height: number;
  15864. /**
  15865. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15866. * @hidden
  15867. */
  15868. _outputTexture: Nullable<InternalTexture>;
  15869. /**
  15870. * Sampling mode used by the shader
  15871. * See https://doc.babylonjs.com/classes/3.1/texture
  15872. */
  15873. renderTargetSamplingMode: number;
  15874. /**
  15875. * Clear color to use when screen clearing
  15876. */
  15877. clearColor: Color4;
  15878. /**
  15879. * If the buffer needs to be cleared before applying the post process. (default: true)
  15880. * Should be set to false if shader will overwrite all previous pixels.
  15881. */
  15882. autoClear: boolean;
  15883. /**
  15884. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15885. */
  15886. alphaMode: number;
  15887. /**
  15888. * Sets the setAlphaBlendConstants of the babylon engine
  15889. */
  15890. alphaConstants: Color4;
  15891. /**
  15892. * Animations to be used for the post processing
  15893. */
  15894. animations: import("babylonjs/Animations/animation").Animation[];
  15895. /**
  15896. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15897. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15898. */
  15899. enablePixelPerfectMode: boolean;
  15900. /**
  15901. * Force the postprocess to be applied without taking in account viewport
  15902. */
  15903. forceFullscreenViewport: boolean;
  15904. /**
  15905. * List of inspectable custom properties (used by the Inspector)
  15906. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15907. */
  15908. inspectableCustomProperties: IInspectable[];
  15909. /**
  15910. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15911. *
  15912. * | Value | Type | Description |
  15913. * | ----- | ----------------------------------- | ----------- |
  15914. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15915. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15916. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15917. *
  15918. */
  15919. scaleMode: number;
  15920. /**
  15921. * Force textures to be a power of two (default: false)
  15922. */
  15923. alwaysForcePOT: boolean;
  15924. private _samples;
  15925. /**
  15926. * Number of sample textures (default: 1)
  15927. */
  15928. get samples(): number;
  15929. set samples(n: number);
  15930. /**
  15931. * Modify the scale of the post process to be the same as the viewport (default: false)
  15932. */
  15933. adaptScaleToCurrentViewport: boolean;
  15934. private _camera;
  15935. private _scene;
  15936. private _engine;
  15937. private _options;
  15938. private _reusable;
  15939. private _textureType;
  15940. private _textureFormat;
  15941. /**
  15942. * Smart array of input and output textures for the post process.
  15943. * @hidden
  15944. */
  15945. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15946. /**
  15947. * The index in _textures that corresponds to the output texture.
  15948. * @hidden
  15949. */
  15950. _currentRenderTextureInd: number;
  15951. private _effect;
  15952. private _samplers;
  15953. private _fragmentUrl;
  15954. private _vertexUrl;
  15955. private _parameters;
  15956. private _scaleRatio;
  15957. protected _indexParameters: any;
  15958. private _shareOutputWithPostProcess;
  15959. private _texelSize;
  15960. private _forcedOutputTexture;
  15961. /**
  15962. * Returns the fragment url or shader name used in the post process.
  15963. * @returns the fragment url or name in the shader store.
  15964. */
  15965. getEffectName(): string;
  15966. /**
  15967. * An event triggered when the postprocess is activated.
  15968. */
  15969. onActivateObservable: Observable<Camera>;
  15970. private _onActivateObserver;
  15971. /**
  15972. * A function that is added to the onActivateObservable
  15973. */
  15974. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15975. /**
  15976. * An event triggered when the postprocess changes its size.
  15977. */
  15978. onSizeChangedObservable: Observable<PostProcess>;
  15979. private _onSizeChangedObserver;
  15980. /**
  15981. * A function that is added to the onSizeChangedObservable
  15982. */
  15983. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15984. /**
  15985. * An event triggered when the postprocess applies its effect.
  15986. */
  15987. onApplyObservable: Observable<Effect>;
  15988. private _onApplyObserver;
  15989. /**
  15990. * A function that is added to the onApplyObservable
  15991. */
  15992. set onApply(callback: (effect: Effect) => void);
  15993. /**
  15994. * An event triggered before rendering the postprocess
  15995. */
  15996. onBeforeRenderObservable: Observable<Effect>;
  15997. private _onBeforeRenderObserver;
  15998. /**
  15999. * A function that is added to the onBeforeRenderObservable
  16000. */
  16001. set onBeforeRender(callback: (effect: Effect) => void);
  16002. /**
  16003. * An event triggered after rendering the postprocess
  16004. */
  16005. onAfterRenderObservable: Observable<Effect>;
  16006. private _onAfterRenderObserver;
  16007. /**
  16008. * A function that is added to the onAfterRenderObservable
  16009. */
  16010. set onAfterRender(callback: (efect: Effect) => void);
  16011. /**
  16012. * 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
  16013. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16014. */
  16015. get inputTexture(): InternalTexture;
  16016. set inputTexture(value: InternalTexture);
  16017. /**
  16018. * Gets the camera which post process is applied to.
  16019. * @returns The camera the post process is applied to.
  16020. */
  16021. getCamera(): Camera;
  16022. /**
  16023. * Gets the texel size of the postprocess.
  16024. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16025. */
  16026. get texelSize(): Vector2;
  16027. /**
  16028. * Creates a new instance PostProcess
  16029. * @param name The name of the PostProcess.
  16030. * @param fragmentUrl The url of the fragment shader to be used.
  16031. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16032. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16033. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16034. * @param camera The camera to apply the render pass to.
  16035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16036. * @param engine The engine which the post process will be applied. (default: current engine)
  16037. * @param reusable If the post process can be reused on the same frame. (default: false)
  16038. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16039. * @param textureType Type of textures used when performing the post process. (default: 0)
  16040. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16041. * @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
  16042. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16043. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  16044. */
  16045. constructor(
  16046. /** Name of the PostProcess. */
  16047. 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);
  16048. /**
  16049. * Gets a string idenfifying the name of the class
  16050. * @returns "PostProcess" string
  16051. */
  16052. getClassName(): string;
  16053. /**
  16054. * Gets the engine which this post process belongs to.
  16055. * @returns The engine the post process was enabled with.
  16056. */
  16057. getEngine(): Engine;
  16058. /**
  16059. * The effect that is created when initializing the post process.
  16060. * @returns The created effect corresponding the the postprocess.
  16061. */
  16062. getEffect(): Effect;
  16063. /**
  16064. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16065. * @param postProcess The post process to share the output with.
  16066. * @returns This post process.
  16067. */
  16068. shareOutputWith(postProcess: PostProcess): PostProcess;
  16069. /**
  16070. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16071. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16072. */
  16073. useOwnOutput(): void;
  16074. /**
  16075. * Updates the effect with the current post process compile time values and recompiles the shader.
  16076. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16077. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16078. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16079. * @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
  16080. * @param onCompiled Called when the shader has been compiled.
  16081. * @param onError Called if there is an error when compiling a shader.
  16082. */
  16083. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16084. /**
  16085. * The post process is reusable if it can be used multiple times within one frame.
  16086. * @returns If the post process is reusable
  16087. */
  16088. isReusable(): boolean;
  16089. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16090. markTextureDirty(): void;
  16091. /**
  16092. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16093. * 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.
  16094. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16095. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16096. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16097. * @returns The target texture that was bound to be written to.
  16098. */
  16099. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16100. /**
  16101. * If the post process is supported.
  16102. */
  16103. get isSupported(): boolean;
  16104. /**
  16105. * The aspect ratio of the output texture.
  16106. */
  16107. get aspectRatio(): number;
  16108. /**
  16109. * Get a value indicating if the post-process is ready to be used
  16110. * @returns true if the post-process is ready (shader is compiled)
  16111. */
  16112. isReady(): boolean;
  16113. /**
  16114. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16115. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16116. */
  16117. apply(): Nullable<Effect>;
  16118. private _disposeTextures;
  16119. /**
  16120. * Disposes the post process.
  16121. * @param camera The camera to dispose the post process on.
  16122. */
  16123. dispose(camera?: Camera): void;
  16124. }
  16125. }
  16126. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16127. /** @hidden */
  16128. export var kernelBlurVaryingDeclaration: {
  16129. name: string;
  16130. shader: string;
  16131. };
  16132. }
  16133. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16134. /** @hidden */
  16135. export var kernelBlurFragment: {
  16136. name: string;
  16137. shader: string;
  16138. };
  16139. }
  16140. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16141. /** @hidden */
  16142. export var kernelBlurFragment2: {
  16143. name: string;
  16144. shader: string;
  16145. };
  16146. }
  16147. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16148. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16149. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16150. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16151. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16152. /** @hidden */
  16153. export var kernelBlurPixelShader: {
  16154. name: string;
  16155. shader: string;
  16156. };
  16157. }
  16158. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16159. /** @hidden */
  16160. export var kernelBlurVertex: {
  16161. name: string;
  16162. shader: string;
  16163. };
  16164. }
  16165. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16166. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16167. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16168. /** @hidden */
  16169. export var kernelBlurVertexShader: {
  16170. name: string;
  16171. shader: string;
  16172. };
  16173. }
  16174. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16175. import { Vector2 } from "babylonjs/Maths/math.vector";
  16176. import { Nullable } from "babylonjs/types";
  16177. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16178. import { Camera } from "babylonjs/Cameras/camera";
  16179. import { Effect } from "babylonjs/Materials/effect";
  16180. import { Engine } from "babylonjs/Engines/engine";
  16181. import "babylonjs/Shaders/kernelBlur.fragment";
  16182. import "babylonjs/Shaders/kernelBlur.vertex";
  16183. /**
  16184. * The Blur Post Process which blurs an image based on a kernel and direction.
  16185. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16186. */
  16187. export class BlurPostProcess extends PostProcess {
  16188. /** The direction in which to blur the image. */
  16189. direction: Vector2;
  16190. private blockCompilation;
  16191. protected _kernel: number;
  16192. protected _idealKernel: number;
  16193. protected _packedFloat: boolean;
  16194. private _staticDefines;
  16195. /**
  16196. * Sets the length in pixels of the blur sample region
  16197. */
  16198. set kernel(v: number);
  16199. /**
  16200. * Gets the length in pixels of the blur sample region
  16201. */
  16202. get kernel(): number;
  16203. /**
  16204. * Sets wether or not the blur needs to unpack/repack floats
  16205. */
  16206. set packedFloat(v: boolean);
  16207. /**
  16208. * Gets wether or not the blur is unpacking/repacking floats
  16209. */
  16210. get packedFloat(): boolean;
  16211. /**
  16212. * Creates a new instance BlurPostProcess
  16213. * @param name The name of the effect.
  16214. * @param direction The direction in which to blur the image.
  16215. * @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.
  16216. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16217. * @param camera The camera to apply the render pass to.
  16218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16219. * @param engine The engine which the post process will be applied. (default: current engine)
  16220. * @param reusable If the post process can be reused on the same frame. (default: false)
  16221. * @param textureType Type of textures used when performing the post process. (default: 0)
  16222. * @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)
  16223. */
  16224. constructor(name: string,
  16225. /** The direction in which to blur the image. */
  16226. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16227. /**
  16228. * Updates the effect with the current post process compile time values and recompiles the shader.
  16229. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16230. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16231. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16232. * @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
  16233. * @param onCompiled Called when the shader has been compiled.
  16234. * @param onError Called if there is an error when compiling a shader.
  16235. */
  16236. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16237. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16238. /**
  16239. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16240. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16241. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16242. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16243. * The gaps between physical kernels are compensated for in the weighting of the samples
  16244. * @param idealKernel Ideal blur kernel.
  16245. * @return Nearest best kernel.
  16246. */
  16247. protected _nearestBestKernel(idealKernel: number): number;
  16248. /**
  16249. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16250. * @param x The point on the Gaussian distribution to sample.
  16251. * @return the value of the Gaussian function at x.
  16252. */
  16253. protected _gaussianWeight(x: number): number;
  16254. /**
  16255. * Generates a string that can be used as a floating point number in GLSL.
  16256. * @param x Value to print.
  16257. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16258. * @return GLSL float string.
  16259. */
  16260. protected _glslFloat(x: number, decimalFigures?: number): string;
  16261. }
  16262. }
  16263. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16264. import { Scene } from "babylonjs/scene";
  16265. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16266. import { Plane } from "babylonjs/Maths/math.plane";
  16267. /**
  16268. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16269. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16270. * You can then easily use it as a reflectionTexture on a flat surface.
  16271. * In case the surface is not a plane, please consider relying on reflection probes.
  16272. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16273. */
  16274. export class MirrorTexture extends RenderTargetTexture {
  16275. private scene;
  16276. /**
  16277. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16278. * 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.
  16279. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16280. */
  16281. mirrorPlane: Plane;
  16282. /**
  16283. * Define the blur ratio used to blur the reflection if needed.
  16284. */
  16285. set blurRatio(value: number);
  16286. get blurRatio(): number;
  16287. /**
  16288. * Define the adaptive blur kernel used to blur the reflection if needed.
  16289. * This will autocompute the closest best match for the `blurKernel`
  16290. */
  16291. set adaptiveBlurKernel(value: number);
  16292. /**
  16293. * Define the blur kernel used to blur the reflection if needed.
  16294. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16295. */
  16296. set blurKernel(value: number);
  16297. /**
  16298. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16299. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16300. */
  16301. set blurKernelX(value: number);
  16302. get blurKernelX(): number;
  16303. /**
  16304. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16305. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16306. */
  16307. set blurKernelY(value: number);
  16308. get blurKernelY(): number;
  16309. private _autoComputeBlurKernel;
  16310. protected _onRatioRescale(): void;
  16311. private _updateGammaSpace;
  16312. private _imageProcessingConfigChangeObserver;
  16313. private _transformMatrix;
  16314. private _mirrorMatrix;
  16315. private _savedViewMatrix;
  16316. private _blurX;
  16317. private _blurY;
  16318. private _adaptiveBlurKernel;
  16319. private _blurKernelX;
  16320. private _blurKernelY;
  16321. private _blurRatio;
  16322. /**
  16323. * Instantiates a Mirror Texture.
  16324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16326. * You can then easily use it as a reflectionTexture on a flat surface.
  16327. * In case the surface is not a plane, please consider relying on reflection probes.
  16328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16329. * @param name
  16330. * @param size
  16331. * @param scene
  16332. * @param generateMipMaps
  16333. * @param type
  16334. * @param samplingMode
  16335. * @param generateDepthBuffer
  16336. */
  16337. constructor(name: string, size: number | {
  16338. width: number;
  16339. height: number;
  16340. } | {
  16341. ratio: number;
  16342. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16343. private _preparePostProcesses;
  16344. /**
  16345. * Clone the mirror texture.
  16346. * @returns the cloned texture
  16347. */
  16348. clone(): MirrorTexture;
  16349. /**
  16350. * Serialize the texture to a JSON representation you could use in Parse later on
  16351. * @returns the serialized JSON representation
  16352. */
  16353. serialize(): any;
  16354. /**
  16355. * Dispose the texture and release its associated resources.
  16356. */
  16357. dispose(): void;
  16358. }
  16359. }
  16360. declare module "babylonjs/Materials/Textures/texture" {
  16361. import { Observable } from "babylonjs/Misc/observable";
  16362. import { Nullable } from "babylonjs/types";
  16363. import { Matrix } from "babylonjs/Maths/math.vector";
  16364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16365. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16366. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16367. import { Scene } from "babylonjs/scene";
  16368. /**
  16369. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16370. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16371. */
  16372. export class Texture extends BaseTexture {
  16373. /**
  16374. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16375. */
  16376. static SerializeBuffers: boolean;
  16377. /** @hidden */
  16378. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16379. /** @hidden */
  16380. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16381. /** @hidden */
  16382. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16383. /** nearest is mag = nearest and min = nearest and mip = linear */
  16384. static readonly NEAREST_SAMPLINGMODE: number;
  16385. /** nearest is mag = nearest and min = nearest and mip = linear */
  16386. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16387. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16388. static readonly BILINEAR_SAMPLINGMODE: number;
  16389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16390. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16391. /** Trilinear is mag = linear and min = linear and mip = linear */
  16392. static readonly TRILINEAR_SAMPLINGMODE: number;
  16393. /** Trilinear is mag = linear and min = linear and mip = linear */
  16394. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16395. /** mag = nearest and min = nearest and mip = nearest */
  16396. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16397. /** mag = nearest and min = linear and mip = nearest */
  16398. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16399. /** mag = nearest and min = linear and mip = linear */
  16400. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16401. /** mag = nearest and min = linear and mip = none */
  16402. static readonly NEAREST_LINEAR: number;
  16403. /** mag = nearest and min = nearest and mip = none */
  16404. static readonly NEAREST_NEAREST: number;
  16405. /** mag = linear and min = nearest and mip = nearest */
  16406. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16407. /** mag = linear and min = nearest and mip = linear */
  16408. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16409. /** mag = linear and min = linear and mip = none */
  16410. static readonly LINEAR_LINEAR: number;
  16411. /** mag = linear and min = nearest and mip = none */
  16412. static readonly LINEAR_NEAREST: number;
  16413. /** Explicit coordinates mode */
  16414. static readonly EXPLICIT_MODE: number;
  16415. /** Spherical coordinates mode */
  16416. static readonly SPHERICAL_MODE: number;
  16417. /** Planar coordinates mode */
  16418. static readonly PLANAR_MODE: number;
  16419. /** Cubic coordinates mode */
  16420. static readonly CUBIC_MODE: number;
  16421. /** Projection coordinates mode */
  16422. static readonly PROJECTION_MODE: number;
  16423. /** Inverse Cubic coordinates mode */
  16424. static readonly SKYBOX_MODE: number;
  16425. /** Inverse Cubic coordinates mode */
  16426. static readonly INVCUBIC_MODE: number;
  16427. /** Equirectangular coordinates mode */
  16428. static readonly EQUIRECTANGULAR_MODE: number;
  16429. /** Equirectangular Fixed coordinates mode */
  16430. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16431. /** Equirectangular Fixed Mirrored coordinates mode */
  16432. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16433. /** Texture is not repeating outside of 0..1 UVs */
  16434. static readonly CLAMP_ADDRESSMODE: number;
  16435. /** Texture is repeating outside of 0..1 UVs */
  16436. static readonly WRAP_ADDRESSMODE: number;
  16437. /** Texture is repeating and mirrored */
  16438. static readonly MIRROR_ADDRESSMODE: number;
  16439. /**
  16440. * 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
  16441. */
  16442. static UseSerializedUrlIfAny: boolean;
  16443. /**
  16444. * Define the url of the texture.
  16445. */
  16446. url: Nullable<string>;
  16447. /**
  16448. * Define an offset on the texture to offset the u coordinates of the UVs
  16449. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16450. */
  16451. uOffset: number;
  16452. /**
  16453. * Define an offset on the texture to offset the v coordinates of the UVs
  16454. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16455. */
  16456. vOffset: number;
  16457. /**
  16458. * Define an offset on the texture to scale the u coordinates of the UVs
  16459. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16460. */
  16461. uScale: number;
  16462. /**
  16463. * Define an offset on the texture to scale the v coordinates of the UVs
  16464. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16465. */
  16466. vScale: number;
  16467. /**
  16468. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16469. * @see http://doc.babylonjs.com/how_to/more_materials
  16470. */
  16471. uAng: number;
  16472. /**
  16473. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16474. * @see http://doc.babylonjs.com/how_to/more_materials
  16475. */
  16476. vAng: number;
  16477. /**
  16478. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16479. * @see http://doc.babylonjs.com/how_to/more_materials
  16480. */
  16481. wAng: number;
  16482. /**
  16483. * Defines the center of rotation (U)
  16484. */
  16485. uRotationCenter: number;
  16486. /**
  16487. * Defines the center of rotation (V)
  16488. */
  16489. vRotationCenter: number;
  16490. /**
  16491. * Defines the center of rotation (W)
  16492. */
  16493. wRotationCenter: number;
  16494. /**
  16495. * Are mip maps generated for this texture or not.
  16496. */
  16497. get noMipmap(): boolean;
  16498. /**
  16499. * List of inspectable custom properties (used by the Inspector)
  16500. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16501. */
  16502. inspectableCustomProperties: Nullable<IInspectable[]>;
  16503. private _noMipmap;
  16504. /** @hidden */
  16505. _invertY: boolean;
  16506. private _rowGenerationMatrix;
  16507. private _cachedTextureMatrix;
  16508. private _projectionModeMatrix;
  16509. private _t0;
  16510. private _t1;
  16511. private _t2;
  16512. private _cachedUOffset;
  16513. private _cachedVOffset;
  16514. private _cachedUScale;
  16515. private _cachedVScale;
  16516. private _cachedUAng;
  16517. private _cachedVAng;
  16518. private _cachedWAng;
  16519. private _cachedProjectionMatrixId;
  16520. private _cachedCoordinatesMode;
  16521. /** @hidden */
  16522. protected _initialSamplingMode: number;
  16523. /** @hidden */
  16524. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16525. private _deleteBuffer;
  16526. protected _format: Nullable<number>;
  16527. private _delayedOnLoad;
  16528. private _delayedOnError;
  16529. private _mimeType?;
  16530. /**
  16531. * Observable triggered once the texture has been loaded.
  16532. */
  16533. onLoadObservable: Observable<Texture>;
  16534. protected _isBlocking: boolean;
  16535. /**
  16536. * Is the texture preventing material to render while loading.
  16537. * If false, a default texture will be used instead of the loading one during the preparation step.
  16538. */
  16539. set isBlocking(value: boolean);
  16540. get isBlocking(): boolean;
  16541. /**
  16542. * Get the current sampling mode associated with the texture.
  16543. */
  16544. get samplingMode(): number;
  16545. /**
  16546. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16547. */
  16548. get invertY(): boolean;
  16549. /**
  16550. * Instantiates a new texture.
  16551. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16552. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16553. * @param url defines the url of the picture to load as a texture
  16554. * @param scene defines the scene or engine the texture will belong to
  16555. * @param noMipmap defines if the texture will require mip maps or not
  16556. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16557. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16558. * @param onLoad defines a callback triggered when the texture has been loaded
  16559. * @param onError defines a callback triggered when an error occurred during the loading session
  16560. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16561. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16562. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16563. * @param mimeType defines an optional mime type information
  16564. */
  16565. 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);
  16566. /**
  16567. * Update the url (and optional buffer) of this texture if url was null during construction.
  16568. * @param url the url of the texture
  16569. * @param buffer the buffer of the texture (defaults to null)
  16570. * @param onLoad callback called when the texture is loaded (defaults to null)
  16571. */
  16572. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16573. /**
  16574. * Finish the loading sequence of a texture flagged as delayed load.
  16575. * @hidden
  16576. */
  16577. delayLoad(): void;
  16578. private _prepareRowForTextureGeneration;
  16579. /**
  16580. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16581. * @returns the transform matrix of the texture.
  16582. */
  16583. getTextureMatrix(uBase?: number): Matrix;
  16584. /**
  16585. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16586. * @returns The reflection texture transform
  16587. */
  16588. getReflectionTextureMatrix(): Matrix;
  16589. /**
  16590. * Clones the texture.
  16591. * @returns the cloned texture
  16592. */
  16593. clone(): Texture;
  16594. /**
  16595. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16596. * @returns The JSON representation of the texture
  16597. */
  16598. serialize(): any;
  16599. /**
  16600. * Get the current class name of the texture useful for serialization or dynamic coding.
  16601. * @returns "Texture"
  16602. */
  16603. getClassName(): string;
  16604. /**
  16605. * Dispose the texture and release its associated resources.
  16606. */
  16607. dispose(): void;
  16608. /**
  16609. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16610. * @param parsedTexture Define the JSON representation of the texture
  16611. * @param scene Define the scene the parsed texture should be instantiated in
  16612. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16613. * @returns The parsed texture if successful
  16614. */
  16615. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16616. /**
  16617. * Creates a texture from its base 64 representation.
  16618. * @param data Define the base64 payload without the data: prefix
  16619. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16620. * @param scene Define the scene the texture should belong to
  16621. * @param noMipmap Forces the texture to not create mip map information if true
  16622. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16623. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16624. * @param onLoad define a callback triggered when the texture has been loaded
  16625. * @param onError define a callback triggered when an error occurred during the loading session
  16626. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16627. * @returns the created texture
  16628. */
  16629. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16630. /**
  16631. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16632. * @param data Define the base64 payload without the data: prefix
  16633. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16634. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16635. * @param scene Define the scene the texture should belong to
  16636. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16637. * @param noMipmap Forces the texture to not create mip map information if true
  16638. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16639. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16640. * @param onLoad define a callback triggered when the texture has been loaded
  16641. * @param onError define a callback triggered when an error occurred during the loading session
  16642. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16643. * @returns the created texture
  16644. */
  16645. 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;
  16646. }
  16647. }
  16648. declare module "babylonjs/PostProcesses/postProcessManager" {
  16649. import { Nullable } from "babylonjs/types";
  16650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16651. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16652. import { Scene } from "babylonjs/scene";
  16653. /**
  16654. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16655. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16656. */
  16657. export class PostProcessManager {
  16658. private _scene;
  16659. private _indexBuffer;
  16660. private _vertexBuffers;
  16661. /**
  16662. * Creates a new instance PostProcess
  16663. * @param scene The scene that the post process is associated with.
  16664. */
  16665. constructor(scene: Scene);
  16666. private _prepareBuffers;
  16667. private _buildIndexBuffer;
  16668. /**
  16669. * Rebuilds the vertex buffers of the manager.
  16670. * @hidden
  16671. */
  16672. _rebuild(): void;
  16673. /**
  16674. * Prepares a frame to be run through a post process.
  16675. * @param sourceTexture The input texture to the post procesess. (default: null)
  16676. * @param postProcesses An array of post processes to be run. (default: null)
  16677. * @returns True if the post processes were able to be run.
  16678. * @hidden
  16679. */
  16680. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16681. /**
  16682. * Manually render a set of post processes to a texture.
  16683. * @param postProcesses An array of post processes to be run.
  16684. * @param targetTexture The target texture to render to.
  16685. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16686. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16687. * @param lodLevel defines which lod of the texture to render to
  16688. */
  16689. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16690. /**
  16691. * Finalize the result of the output of the postprocesses.
  16692. * @param doNotPresent If true the result will not be displayed to the screen.
  16693. * @param targetTexture The target texture to render to.
  16694. * @param faceIndex The index of the face to bind the target texture to.
  16695. * @param postProcesses The array of post processes to render.
  16696. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16697. * @hidden
  16698. */
  16699. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16700. /**
  16701. * Disposes of the post process manager.
  16702. */
  16703. dispose(): void;
  16704. }
  16705. }
  16706. declare module "babylonjs/Misc/gradients" {
  16707. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16708. /** Interface used by value gradients (color, factor, ...) */
  16709. export interface IValueGradient {
  16710. /**
  16711. * Gets or sets the gradient value (between 0 and 1)
  16712. */
  16713. gradient: number;
  16714. }
  16715. /** Class used to store color4 gradient */
  16716. export class ColorGradient implements IValueGradient {
  16717. /**
  16718. * Gets or sets the gradient value (between 0 and 1)
  16719. */
  16720. gradient: number;
  16721. /**
  16722. * Gets or sets first associated color
  16723. */
  16724. color1: Color4;
  16725. /**
  16726. * Gets or sets second associated color
  16727. */
  16728. color2?: Color4;
  16729. /**
  16730. * Will get a color picked randomly between color1 and color2.
  16731. * If color2 is undefined then color1 will be used
  16732. * @param result defines the target Color4 to store the result in
  16733. */
  16734. getColorToRef(result: Color4): void;
  16735. }
  16736. /** Class used to store color 3 gradient */
  16737. export class Color3Gradient implements IValueGradient {
  16738. /**
  16739. * Gets or sets the gradient value (between 0 and 1)
  16740. */
  16741. gradient: number;
  16742. /**
  16743. * Gets or sets the associated color
  16744. */
  16745. color: Color3;
  16746. }
  16747. /** Class used to store factor gradient */
  16748. export class FactorGradient implements IValueGradient {
  16749. /**
  16750. * Gets or sets the gradient value (between 0 and 1)
  16751. */
  16752. gradient: number;
  16753. /**
  16754. * Gets or sets first associated factor
  16755. */
  16756. factor1: number;
  16757. /**
  16758. * Gets or sets second associated factor
  16759. */
  16760. factor2?: number;
  16761. /**
  16762. * Will get a number picked randomly between factor1 and factor2.
  16763. * If factor2 is undefined then factor1 will be used
  16764. * @returns the picked number
  16765. */
  16766. getFactor(): number;
  16767. }
  16768. /**
  16769. * Helper used to simplify some generic gradient tasks
  16770. */
  16771. export class GradientHelper {
  16772. /**
  16773. * Gets the current gradient from an array of IValueGradient
  16774. * @param ratio defines the current ratio to get
  16775. * @param gradients defines the array of IValueGradient
  16776. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16777. */
  16778. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16779. }
  16780. }
  16781. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16782. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16783. import { Nullable } from "babylonjs/types";
  16784. module "babylonjs/Engines/thinEngine" {
  16785. interface ThinEngine {
  16786. /**
  16787. * Creates a dynamic texture
  16788. * @param width defines the width of the texture
  16789. * @param height defines the height of the texture
  16790. * @param generateMipMaps defines if the engine should generate the mip levels
  16791. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16792. * @returns the dynamic texture inside an InternalTexture
  16793. */
  16794. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16795. /**
  16796. * Update the content of a dynamic texture
  16797. * @param texture defines the texture to update
  16798. * @param canvas defines the canvas containing the source
  16799. * @param invertY defines if data must be stored with Y axis inverted
  16800. * @param premulAlpha defines if alpha is stored as premultiplied
  16801. * @param format defines the format of the data
  16802. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16803. */
  16804. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16805. }
  16806. }
  16807. }
  16808. declare module "babylonjs/Misc/canvasGenerator" {
  16809. /**
  16810. * Helper class used to generate a canvas to manipulate images
  16811. */
  16812. export class CanvasGenerator {
  16813. /**
  16814. * Create a new canvas (or offscreen canvas depending on the context)
  16815. * @param width defines the expected width
  16816. * @param height defines the expected height
  16817. * @return a new canvas or offscreen canvas
  16818. */
  16819. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16820. }
  16821. }
  16822. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16823. import { Scene } from "babylonjs/scene";
  16824. import { Texture } from "babylonjs/Materials/Textures/texture";
  16825. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16826. /**
  16827. * A class extending Texture allowing drawing on a texture
  16828. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16829. */
  16830. export class DynamicTexture extends Texture {
  16831. private _generateMipMaps;
  16832. private _canvas;
  16833. private _context;
  16834. private _engine;
  16835. /**
  16836. * Creates a DynamicTexture
  16837. * @param name defines the name of the texture
  16838. * @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
  16839. * @param scene defines the scene where you want the texture
  16840. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16841. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16842. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16843. */
  16844. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16845. /**
  16846. * Get the current class name of the texture useful for serialization or dynamic coding.
  16847. * @returns "DynamicTexture"
  16848. */
  16849. getClassName(): string;
  16850. /**
  16851. * Gets the current state of canRescale
  16852. */
  16853. get canRescale(): boolean;
  16854. private _recreate;
  16855. /**
  16856. * Scales the texture
  16857. * @param ratio the scale factor to apply to both width and height
  16858. */
  16859. scale(ratio: number): void;
  16860. /**
  16861. * Resizes the texture
  16862. * @param width the new width
  16863. * @param height the new height
  16864. */
  16865. scaleTo(width: number, height: number): void;
  16866. /**
  16867. * Gets the context of the canvas used by the texture
  16868. * @returns the canvas context of the dynamic texture
  16869. */
  16870. getContext(): CanvasRenderingContext2D;
  16871. /**
  16872. * Clears the texture
  16873. */
  16874. clear(): void;
  16875. /**
  16876. * Updates the texture
  16877. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16878. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16879. */
  16880. update(invertY?: boolean, premulAlpha?: boolean): void;
  16881. /**
  16882. * Draws text onto the texture
  16883. * @param text defines the text to be drawn
  16884. * @param x defines the placement of the text from the left
  16885. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16886. * @param font defines the font to be used with font-style, font-size, font-name
  16887. * @param color defines the color used for the text
  16888. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16889. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16890. * @param update defines whether texture is immediately update (default is true)
  16891. */
  16892. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16893. /**
  16894. * Clones the texture
  16895. * @returns the clone of the texture.
  16896. */
  16897. clone(): DynamicTexture;
  16898. /**
  16899. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16900. * @returns a serialized dynamic texture object
  16901. */
  16902. serialize(): any;
  16903. /** @hidden */
  16904. _rebuild(): void;
  16905. }
  16906. }
  16907. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16908. import { Scene } from "babylonjs/scene";
  16909. import { ISceneComponent } from "babylonjs/sceneComponent";
  16910. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16911. module "babylonjs/abstractScene" {
  16912. interface AbstractScene {
  16913. /**
  16914. * The list of procedural textures added to the scene
  16915. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16916. */
  16917. proceduralTextures: Array<ProceduralTexture>;
  16918. }
  16919. }
  16920. /**
  16921. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16922. * in a given scene.
  16923. */
  16924. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16925. /**
  16926. * The component name helpfull to identify the component in the list of scene components.
  16927. */
  16928. readonly name: string;
  16929. /**
  16930. * The scene the component belongs to.
  16931. */
  16932. scene: Scene;
  16933. /**
  16934. * Creates a new instance of the component for the given scene
  16935. * @param scene Defines the scene to register the component in
  16936. */
  16937. constructor(scene: Scene);
  16938. /**
  16939. * Registers the component in a given scene
  16940. */
  16941. register(): void;
  16942. /**
  16943. * Rebuilds the elements related to this component in case of
  16944. * context lost for instance.
  16945. */
  16946. rebuild(): void;
  16947. /**
  16948. * Disposes the component and the associated ressources.
  16949. */
  16950. dispose(): void;
  16951. private _beforeClear;
  16952. }
  16953. }
  16954. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16956. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16957. module "babylonjs/Engines/thinEngine" {
  16958. interface ThinEngine {
  16959. /**
  16960. * Creates a new render target cube texture
  16961. * @param size defines the size of the texture
  16962. * @param options defines the options used to create the texture
  16963. * @returns a new render target cube texture stored in an InternalTexture
  16964. */
  16965. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16966. }
  16967. }
  16968. }
  16969. declare module "babylonjs/Shaders/procedural.vertex" {
  16970. /** @hidden */
  16971. export var proceduralVertexShader: {
  16972. name: string;
  16973. shader: string;
  16974. };
  16975. }
  16976. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16977. import { Observable } from "babylonjs/Misc/observable";
  16978. import { Nullable } from "babylonjs/types";
  16979. import { Scene } from "babylonjs/scene";
  16980. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16981. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16982. import { Effect } from "babylonjs/Materials/effect";
  16983. import { Texture } from "babylonjs/Materials/Textures/texture";
  16984. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16985. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16986. import "babylonjs/Shaders/procedural.vertex";
  16987. /**
  16988. * 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.
  16989. * This is the base class of any Procedural texture and contains most of the shareable code.
  16990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16991. */
  16992. export class ProceduralTexture extends Texture {
  16993. isCube: boolean;
  16994. /**
  16995. * Define if the texture is enabled or not (disabled texture will not render)
  16996. */
  16997. isEnabled: boolean;
  16998. /**
  16999. * Define if the texture must be cleared before rendering (default is true)
  17000. */
  17001. autoClear: boolean;
  17002. /**
  17003. * Callback called when the texture is generated
  17004. */
  17005. onGenerated: () => void;
  17006. /**
  17007. * Event raised when the texture is generated
  17008. */
  17009. onGeneratedObservable: Observable<ProceduralTexture>;
  17010. /** @hidden */
  17011. _generateMipMaps: boolean;
  17012. /** @hidden **/
  17013. _effect: Effect;
  17014. /** @hidden */
  17015. _textures: {
  17016. [key: string]: Texture;
  17017. };
  17018. private _size;
  17019. private _currentRefreshId;
  17020. private _frameId;
  17021. private _refreshRate;
  17022. private _vertexBuffers;
  17023. private _indexBuffer;
  17024. private _uniforms;
  17025. private _samplers;
  17026. private _fragment;
  17027. private _floats;
  17028. private _ints;
  17029. private _floatsArrays;
  17030. private _colors3;
  17031. private _colors4;
  17032. private _vectors2;
  17033. private _vectors3;
  17034. private _matrices;
  17035. private _fallbackTexture;
  17036. private _fallbackTextureUsed;
  17037. private _engine;
  17038. private _cachedDefines;
  17039. private _contentUpdateId;
  17040. private _contentData;
  17041. /**
  17042. * Instantiates a new procedural texture.
  17043. * 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.
  17044. * This is the base class of any Procedural texture and contains most of the shareable code.
  17045. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17046. * @param name Define the name of the texture
  17047. * @param size Define the size of the texture to create
  17048. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17049. * @param scene Define the scene the texture belongs to
  17050. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17051. * @param generateMipMaps Define if the texture should creates mip maps or not
  17052. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17053. */
  17054. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17055. /**
  17056. * The effect that is created when initializing the post process.
  17057. * @returns The created effect corresponding the the postprocess.
  17058. */
  17059. getEffect(): Effect;
  17060. /**
  17061. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17062. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17063. */
  17064. getContent(): Nullable<ArrayBufferView>;
  17065. private _createIndexBuffer;
  17066. /** @hidden */
  17067. _rebuild(): void;
  17068. /**
  17069. * Resets the texture in order to recreate its associated resources.
  17070. * This can be called in case of context loss
  17071. */
  17072. reset(): void;
  17073. protected _getDefines(): string;
  17074. /**
  17075. * Is the texture ready to be used ? (rendered at least once)
  17076. * @returns true if ready, otherwise, false.
  17077. */
  17078. isReady(): boolean;
  17079. /**
  17080. * Resets the refresh counter of the texture and start bak from scratch.
  17081. * Could be useful to regenerate the texture if it is setup to render only once.
  17082. */
  17083. resetRefreshCounter(): void;
  17084. /**
  17085. * Set the fragment shader to use in order to render the texture.
  17086. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17087. */
  17088. setFragment(fragment: any): void;
  17089. /**
  17090. * Define the refresh rate of the texture or the rendering frequency.
  17091. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17092. */
  17093. get refreshRate(): number;
  17094. set refreshRate(value: number);
  17095. /** @hidden */
  17096. _shouldRender(): boolean;
  17097. /**
  17098. * Get the size the texture is rendering at.
  17099. * @returns the size (texture is always squared)
  17100. */
  17101. getRenderSize(): number;
  17102. /**
  17103. * Resize the texture to new value.
  17104. * @param size Define the new size the texture should have
  17105. * @param generateMipMaps Define whether the new texture should create mip maps
  17106. */
  17107. resize(size: number, generateMipMaps: boolean): void;
  17108. private _checkUniform;
  17109. /**
  17110. * Set a texture in the shader program used to render.
  17111. * @param name Define the name of the uniform samplers as defined in the shader
  17112. * @param texture Define the texture to bind to this sampler
  17113. * @return the texture itself allowing "fluent" like uniform updates
  17114. */
  17115. setTexture(name: string, texture: Texture): ProceduralTexture;
  17116. /**
  17117. * Set a float in the shader.
  17118. * @param name Define the name of the uniform as defined in the shader
  17119. * @param value Define the value to give to the uniform
  17120. * @return the texture itself allowing "fluent" like uniform updates
  17121. */
  17122. setFloat(name: string, value: number): ProceduralTexture;
  17123. /**
  17124. * Set a int in the shader.
  17125. * @param name Define the name of the uniform as defined in the shader
  17126. * @param value Define the value to give to the uniform
  17127. * @return the texture itself allowing "fluent" like uniform updates
  17128. */
  17129. setInt(name: string, value: number): ProceduralTexture;
  17130. /**
  17131. * Set an array of floats in the shader.
  17132. * @param name Define the name of the uniform as defined in the shader
  17133. * @param value Define the value to give to the uniform
  17134. * @return the texture itself allowing "fluent" like uniform updates
  17135. */
  17136. setFloats(name: string, value: number[]): ProceduralTexture;
  17137. /**
  17138. * Set a vec3 in the shader from a Color3.
  17139. * @param name Define the name of the uniform as defined in the shader
  17140. * @param value Define the value to give to the uniform
  17141. * @return the texture itself allowing "fluent" like uniform updates
  17142. */
  17143. setColor3(name: string, value: Color3): ProceduralTexture;
  17144. /**
  17145. * Set a vec4 in the shader from a Color4.
  17146. * @param name Define the name of the uniform as defined in the shader
  17147. * @param value Define the value to give to the uniform
  17148. * @return the texture itself allowing "fluent" like uniform updates
  17149. */
  17150. setColor4(name: string, value: Color4): ProceduralTexture;
  17151. /**
  17152. * Set a vec2 in the shader from a Vector2.
  17153. * @param name Define the name of the uniform as defined in the shader
  17154. * @param value Define the value to give to the uniform
  17155. * @return the texture itself allowing "fluent" like uniform updates
  17156. */
  17157. setVector2(name: string, value: Vector2): ProceduralTexture;
  17158. /**
  17159. * Set a vec3 in the shader from a Vector3.
  17160. * @param name Define the name of the uniform as defined in the shader
  17161. * @param value Define the value to give to the uniform
  17162. * @return the texture itself allowing "fluent" like uniform updates
  17163. */
  17164. setVector3(name: string, value: Vector3): ProceduralTexture;
  17165. /**
  17166. * Set a mat4 in the shader from a MAtrix.
  17167. * @param name Define the name of the uniform as defined in the shader
  17168. * @param value Define the value to give to the uniform
  17169. * @return the texture itself allowing "fluent" like uniform updates
  17170. */
  17171. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17172. /**
  17173. * Render the texture to its associated render target.
  17174. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17175. */
  17176. render(useCameraPostProcess?: boolean): void;
  17177. /**
  17178. * Clone the texture.
  17179. * @returns the cloned texture
  17180. */
  17181. clone(): ProceduralTexture;
  17182. /**
  17183. * Dispose the texture and release its asoociated resources.
  17184. */
  17185. dispose(): void;
  17186. }
  17187. }
  17188. declare module "babylonjs/Particles/baseParticleSystem" {
  17189. import { Nullable } from "babylonjs/types";
  17190. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17192. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17193. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17194. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17195. import { Scene } from "babylonjs/scene";
  17196. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17197. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17198. import { Texture } from "babylonjs/Materials/Textures/texture";
  17199. import { Color4 } from "babylonjs/Maths/math.color";
  17200. import { Animation } from "babylonjs/Animations/animation";
  17201. /**
  17202. * This represents the base class for particle system in Babylon.
  17203. * 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.
  17204. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17205. * @example https://doc.babylonjs.com/babylon101/particles
  17206. */
  17207. export class BaseParticleSystem {
  17208. /**
  17209. * Source color is added to the destination color without alpha affecting the result
  17210. */
  17211. static BLENDMODE_ONEONE: number;
  17212. /**
  17213. * Blend current color and particle color using particle’s alpha
  17214. */
  17215. static BLENDMODE_STANDARD: number;
  17216. /**
  17217. * Add current color and particle color multiplied by particle’s alpha
  17218. */
  17219. static BLENDMODE_ADD: number;
  17220. /**
  17221. * Multiply current color with particle color
  17222. */
  17223. static BLENDMODE_MULTIPLY: number;
  17224. /**
  17225. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17226. */
  17227. static BLENDMODE_MULTIPLYADD: number;
  17228. /**
  17229. * List of animations used by the particle system.
  17230. */
  17231. animations: Animation[];
  17232. /**
  17233. * The id of the Particle system.
  17234. */
  17235. id: string;
  17236. /**
  17237. * The friendly name of the Particle system.
  17238. */
  17239. name: string;
  17240. /**
  17241. * The rendering group used by the Particle system to chose when to render.
  17242. */
  17243. renderingGroupId: number;
  17244. /**
  17245. * The emitter represents the Mesh or position we are attaching the particle system to.
  17246. */
  17247. emitter: Nullable<AbstractMesh | Vector3>;
  17248. /**
  17249. * The maximum number of particles to emit per frame
  17250. */
  17251. emitRate: number;
  17252. /**
  17253. * If you want to launch only a few particles at once, that can be done, as well.
  17254. */
  17255. manualEmitCount: number;
  17256. /**
  17257. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17258. */
  17259. updateSpeed: number;
  17260. /**
  17261. * The amount of time the particle system is running (depends of the overall update speed).
  17262. */
  17263. targetStopDuration: number;
  17264. /**
  17265. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17266. */
  17267. disposeOnStop: boolean;
  17268. /**
  17269. * Minimum power of emitting particles.
  17270. */
  17271. minEmitPower: number;
  17272. /**
  17273. * Maximum power of emitting particles.
  17274. */
  17275. maxEmitPower: number;
  17276. /**
  17277. * Minimum life time of emitting particles.
  17278. */
  17279. minLifeTime: number;
  17280. /**
  17281. * Maximum life time of emitting particles.
  17282. */
  17283. maxLifeTime: number;
  17284. /**
  17285. * Minimum Size of emitting particles.
  17286. */
  17287. minSize: number;
  17288. /**
  17289. * Maximum Size of emitting particles.
  17290. */
  17291. maxSize: number;
  17292. /**
  17293. * Minimum scale of emitting particles on X axis.
  17294. */
  17295. minScaleX: number;
  17296. /**
  17297. * Maximum scale of emitting particles on X axis.
  17298. */
  17299. maxScaleX: number;
  17300. /**
  17301. * Minimum scale of emitting particles on Y axis.
  17302. */
  17303. minScaleY: number;
  17304. /**
  17305. * Maximum scale of emitting particles on Y axis.
  17306. */
  17307. maxScaleY: number;
  17308. /**
  17309. * Gets or sets the minimal initial rotation in radians.
  17310. */
  17311. minInitialRotation: number;
  17312. /**
  17313. * Gets or sets the maximal initial rotation in radians.
  17314. */
  17315. maxInitialRotation: number;
  17316. /**
  17317. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17318. */
  17319. minAngularSpeed: number;
  17320. /**
  17321. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17322. */
  17323. maxAngularSpeed: number;
  17324. /**
  17325. * The texture used to render each particle. (this can be a spritesheet)
  17326. */
  17327. particleTexture: Nullable<Texture>;
  17328. /**
  17329. * The layer mask we are rendering the particles through.
  17330. */
  17331. layerMask: number;
  17332. /**
  17333. * This can help using your own shader to render the particle system.
  17334. * The according effect will be created
  17335. */
  17336. customShader: any;
  17337. /**
  17338. * By default particle system starts as soon as they are created. This prevents the
  17339. * automatic start to happen and let you decide when to start emitting particles.
  17340. */
  17341. preventAutoStart: boolean;
  17342. private _noiseTexture;
  17343. /**
  17344. * Gets or sets a texture used to add random noise to particle positions
  17345. */
  17346. get noiseTexture(): Nullable<ProceduralTexture>;
  17347. set noiseTexture(value: Nullable<ProceduralTexture>);
  17348. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17349. noiseStrength: Vector3;
  17350. /**
  17351. * Callback triggered when the particle animation is ending.
  17352. */
  17353. onAnimationEnd: Nullable<() => void>;
  17354. /**
  17355. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17356. */
  17357. blendMode: number;
  17358. /**
  17359. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17360. * to override the particles.
  17361. */
  17362. forceDepthWrite: boolean;
  17363. /** 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 */
  17364. preWarmCycles: number;
  17365. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17366. preWarmStepOffset: number;
  17367. /**
  17368. * 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)
  17369. */
  17370. spriteCellChangeSpeed: number;
  17371. /**
  17372. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17373. */
  17374. startSpriteCellID: number;
  17375. /**
  17376. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17377. */
  17378. endSpriteCellID: number;
  17379. /**
  17380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17381. */
  17382. spriteCellWidth: number;
  17383. /**
  17384. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17385. */
  17386. spriteCellHeight: number;
  17387. /**
  17388. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17389. */
  17390. spriteRandomStartCell: boolean;
  17391. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17392. translationPivot: Vector2;
  17393. /** @hidden */
  17394. protected _isAnimationSheetEnabled: boolean;
  17395. /**
  17396. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17397. */
  17398. beginAnimationOnStart: boolean;
  17399. /**
  17400. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17401. */
  17402. beginAnimationFrom: number;
  17403. /**
  17404. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17405. */
  17406. beginAnimationTo: number;
  17407. /**
  17408. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17409. */
  17410. beginAnimationLoop: boolean;
  17411. /**
  17412. * Gets or sets a world offset applied to all particles
  17413. */
  17414. worldOffset: Vector3;
  17415. /**
  17416. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17417. */
  17418. get isAnimationSheetEnabled(): boolean;
  17419. set isAnimationSheetEnabled(value: boolean);
  17420. /**
  17421. * Get hosting scene
  17422. * @returns the scene
  17423. */
  17424. getScene(): Scene;
  17425. /**
  17426. * You can use gravity if you want to give an orientation to your particles.
  17427. */
  17428. gravity: Vector3;
  17429. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17430. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17431. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17432. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17433. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17434. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17435. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17436. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17437. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17438. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17439. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17440. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17441. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17442. /**
  17443. * Defines the delay in milliseconds before starting the system (0 by default)
  17444. */
  17445. startDelay: number;
  17446. /**
  17447. * Gets the current list of drag gradients.
  17448. * You must use addDragGradient and removeDragGradient to udpate this list
  17449. * @returns the list of drag gradients
  17450. */
  17451. getDragGradients(): Nullable<Array<FactorGradient>>;
  17452. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17453. limitVelocityDamping: number;
  17454. /**
  17455. * Gets the current list of limit velocity gradients.
  17456. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17457. * @returns the list of limit velocity gradients
  17458. */
  17459. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17460. /**
  17461. * Gets the current list of color gradients.
  17462. * You must use addColorGradient and removeColorGradient to udpate this list
  17463. * @returns the list of color gradients
  17464. */
  17465. getColorGradients(): Nullable<Array<ColorGradient>>;
  17466. /**
  17467. * Gets the current list of size gradients.
  17468. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17469. * @returns the list of size gradients
  17470. */
  17471. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17472. /**
  17473. * Gets the current list of color remap gradients.
  17474. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17475. * @returns the list of color remap gradients
  17476. */
  17477. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17478. /**
  17479. * Gets the current list of alpha remap gradients.
  17480. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17481. * @returns the list of alpha remap gradients
  17482. */
  17483. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17484. /**
  17485. * Gets the current list of life time gradients.
  17486. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17487. * @returns the list of life time gradients
  17488. */
  17489. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17490. /**
  17491. * Gets the current list of angular speed gradients.
  17492. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17493. * @returns the list of angular speed gradients
  17494. */
  17495. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17496. /**
  17497. * Gets the current list of velocity gradients.
  17498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17499. * @returns the list of velocity gradients
  17500. */
  17501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17502. /**
  17503. * Gets the current list of start size gradients.
  17504. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17505. * @returns the list of start size gradients
  17506. */
  17507. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17508. /**
  17509. * Gets the current list of emit rate gradients.
  17510. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17511. * @returns the list of emit rate gradients
  17512. */
  17513. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17514. /**
  17515. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17516. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17517. */
  17518. get direction1(): Vector3;
  17519. set direction1(value: Vector3);
  17520. /**
  17521. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17522. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17523. */
  17524. get direction2(): Vector3;
  17525. set direction2(value: Vector3);
  17526. /**
  17527. * 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.
  17528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17529. */
  17530. get minEmitBox(): Vector3;
  17531. set minEmitBox(value: Vector3);
  17532. /**
  17533. * 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.
  17534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17535. */
  17536. get maxEmitBox(): Vector3;
  17537. set maxEmitBox(value: Vector3);
  17538. /**
  17539. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17540. */
  17541. color1: Color4;
  17542. /**
  17543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17544. */
  17545. color2: Color4;
  17546. /**
  17547. * Color the particle will have at the end of its lifetime
  17548. */
  17549. colorDead: Color4;
  17550. /**
  17551. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17552. */
  17553. textureMask: Color4;
  17554. /**
  17555. * The particle emitter type defines the emitter used by the particle system.
  17556. * It can be for example box, sphere, or cone...
  17557. */
  17558. particleEmitterType: IParticleEmitterType;
  17559. /** @hidden */
  17560. _isSubEmitter: boolean;
  17561. /**
  17562. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17563. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17564. */
  17565. billboardMode: number;
  17566. protected _isBillboardBased: boolean;
  17567. /**
  17568. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17569. */
  17570. get isBillboardBased(): boolean;
  17571. set isBillboardBased(value: boolean);
  17572. /**
  17573. * The scene the particle system belongs to.
  17574. */
  17575. protected _scene: Scene;
  17576. /**
  17577. * Local cache of defines for image processing.
  17578. */
  17579. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17580. /**
  17581. * Default configuration related to image processing available in the standard Material.
  17582. */
  17583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17584. /**
  17585. * Gets the image processing configuration used either in this material.
  17586. */
  17587. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17588. /**
  17589. * Sets the Default image processing configuration used either in the this material.
  17590. *
  17591. * If sets to null, the scene one is in use.
  17592. */
  17593. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17594. /**
  17595. * Attaches a new image processing configuration to the Standard Material.
  17596. * @param configuration
  17597. */
  17598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17599. /** @hidden */
  17600. protected _reset(): void;
  17601. /** @hidden */
  17602. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17603. /**
  17604. * Instantiates a particle system.
  17605. * 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.
  17606. * @param name The name of the particle system
  17607. */
  17608. constructor(name: string);
  17609. /**
  17610. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17611. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17612. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17613. * @returns the emitter
  17614. */
  17615. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17616. /**
  17617. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17618. * @param radius The radius of the hemisphere to emit from
  17619. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17620. * @returns the emitter
  17621. */
  17622. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17623. /**
  17624. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17625. * @param radius The radius of the sphere to emit from
  17626. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17627. * @returns the emitter
  17628. */
  17629. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17630. /**
  17631. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17632. * @param radius The radius of the sphere to emit from
  17633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17635. * @returns the emitter
  17636. */
  17637. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17638. /**
  17639. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17640. * @param radius The radius of the emission cylinder
  17641. * @param height The height of the emission cylinder
  17642. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17643. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17644. * @returns the emitter
  17645. */
  17646. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17647. /**
  17648. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17649. * @param radius The radius of the cylinder to emit from
  17650. * @param height The height of the emission cylinder
  17651. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17654. * @returns the emitter
  17655. */
  17656. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17657. /**
  17658. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17659. * @param radius The radius of the cone to emit from
  17660. * @param angle The base angle of the cone
  17661. * @returns the emitter
  17662. */
  17663. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17664. /**
  17665. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17668. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17669. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17670. * @returns the emitter
  17671. */
  17672. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17673. }
  17674. }
  17675. declare module "babylonjs/Particles/subEmitter" {
  17676. import { Scene } from "babylonjs/scene";
  17677. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17678. /**
  17679. * Type of sub emitter
  17680. */
  17681. export enum SubEmitterType {
  17682. /**
  17683. * Attached to the particle over it's lifetime
  17684. */
  17685. ATTACHED = 0,
  17686. /**
  17687. * Created when the particle dies
  17688. */
  17689. END = 1
  17690. }
  17691. /**
  17692. * Sub emitter class used to emit particles from an existing particle
  17693. */
  17694. export class SubEmitter {
  17695. /**
  17696. * the particle system to be used by the sub emitter
  17697. */
  17698. particleSystem: ParticleSystem;
  17699. /**
  17700. * Type of the submitter (Default: END)
  17701. */
  17702. type: SubEmitterType;
  17703. /**
  17704. * 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)
  17705. * Note: This only is supported when using an emitter of type Mesh
  17706. */
  17707. inheritDirection: boolean;
  17708. /**
  17709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17710. */
  17711. inheritedVelocityAmount: number;
  17712. /**
  17713. * Creates a sub emitter
  17714. * @param particleSystem the particle system to be used by the sub emitter
  17715. */
  17716. constructor(
  17717. /**
  17718. * the particle system to be used by the sub emitter
  17719. */
  17720. particleSystem: ParticleSystem);
  17721. /**
  17722. * Clones the sub emitter
  17723. * @returns the cloned sub emitter
  17724. */
  17725. clone(): SubEmitter;
  17726. /**
  17727. * Serialize current object to a JSON object
  17728. * @returns the serialized object
  17729. */
  17730. serialize(): any;
  17731. /** @hidden */
  17732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17733. /**
  17734. * Creates a new SubEmitter from a serialized JSON version
  17735. * @param serializationObject defines the JSON object to read from
  17736. * @param scene defines the hosting scene
  17737. * @param rootUrl defines the rootUrl for data loading
  17738. * @returns a new SubEmitter
  17739. */
  17740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17741. /** Release associated resources */
  17742. dispose(): void;
  17743. }
  17744. }
  17745. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17746. /** @hidden */
  17747. export var clipPlaneFragmentDeclaration: {
  17748. name: string;
  17749. shader: string;
  17750. };
  17751. }
  17752. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17753. /** @hidden */
  17754. export var imageProcessingDeclaration: {
  17755. name: string;
  17756. shader: string;
  17757. };
  17758. }
  17759. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17760. /** @hidden */
  17761. export var imageProcessingFunctions: {
  17762. name: string;
  17763. shader: string;
  17764. };
  17765. }
  17766. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17767. /** @hidden */
  17768. export var clipPlaneFragment: {
  17769. name: string;
  17770. shader: string;
  17771. };
  17772. }
  17773. declare module "babylonjs/Shaders/particles.fragment" {
  17774. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17775. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17776. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17777. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17778. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17779. /** @hidden */
  17780. export var particlesPixelShader: {
  17781. name: string;
  17782. shader: string;
  17783. };
  17784. }
  17785. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17786. /** @hidden */
  17787. export var clipPlaneVertexDeclaration: {
  17788. name: string;
  17789. shader: string;
  17790. };
  17791. }
  17792. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17793. /** @hidden */
  17794. export var clipPlaneVertex: {
  17795. name: string;
  17796. shader: string;
  17797. };
  17798. }
  17799. declare module "babylonjs/Shaders/particles.vertex" {
  17800. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17801. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17802. /** @hidden */
  17803. export var particlesVertexShader: {
  17804. name: string;
  17805. shader: string;
  17806. };
  17807. }
  17808. declare module "babylonjs/Particles/particleSystem" {
  17809. import { Nullable } from "babylonjs/types";
  17810. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17811. import { Observable } from "babylonjs/Misc/observable";
  17812. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17813. import { Effect } from "babylonjs/Materials/effect";
  17814. import { Scene, IDisposable } from "babylonjs/scene";
  17815. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17816. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17817. import { Particle } from "babylonjs/Particles/particle";
  17818. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17819. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17820. import "babylonjs/Shaders/particles.fragment";
  17821. import "babylonjs/Shaders/particles.vertex";
  17822. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17823. /**
  17824. * This represents a particle system in Babylon.
  17825. * 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.
  17826. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17827. * @example https://doc.babylonjs.com/babylon101/particles
  17828. */
  17829. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17830. /**
  17831. * Billboard mode will only apply to Y axis
  17832. */
  17833. static readonly BILLBOARDMODE_Y: number;
  17834. /**
  17835. * Billboard mode will apply to all axes
  17836. */
  17837. static readonly BILLBOARDMODE_ALL: number;
  17838. /**
  17839. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17840. */
  17841. static readonly BILLBOARDMODE_STRETCHED: number;
  17842. /**
  17843. * This function can be defined to provide custom update for active particles.
  17844. * This function will be called instead of regular update (age, position, color, etc.).
  17845. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17846. */
  17847. updateFunction: (particles: Particle[]) => void;
  17848. private _emitterWorldMatrix;
  17849. /**
  17850. * This function can be defined to specify initial direction for every new particle.
  17851. * It by default use the emitterType defined function
  17852. */
  17853. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17854. /**
  17855. * This function can be defined to specify initial position for every new particle.
  17856. * It by default use the emitterType defined function
  17857. */
  17858. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17859. /**
  17860. * @hidden
  17861. */
  17862. _inheritedVelocityOffset: Vector3;
  17863. /**
  17864. * An event triggered when the system is disposed
  17865. */
  17866. onDisposeObservable: Observable<ParticleSystem>;
  17867. private _onDisposeObserver;
  17868. /**
  17869. * Sets a callback that will be triggered when the system is disposed
  17870. */
  17871. set onDispose(callback: () => void);
  17872. private _particles;
  17873. private _epsilon;
  17874. private _capacity;
  17875. private _stockParticles;
  17876. private _newPartsExcess;
  17877. private _vertexData;
  17878. private _vertexBuffer;
  17879. private _vertexBuffers;
  17880. private _spriteBuffer;
  17881. private _indexBuffer;
  17882. private _effect;
  17883. private _customEffect;
  17884. private _cachedDefines;
  17885. private _scaledColorStep;
  17886. private _colorDiff;
  17887. private _scaledDirection;
  17888. private _scaledGravity;
  17889. private _currentRenderId;
  17890. private _alive;
  17891. private _useInstancing;
  17892. private _started;
  17893. private _stopped;
  17894. private _actualFrame;
  17895. private _scaledUpdateSpeed;
  17896. private _vertexBufferSize;
  17897. /** @hidden */
  17898. _currentEmitRateGradient: Nullable<FactorGradient>;
  17899. /** @hidden */
  17900. _currentEmitRate1: number;
  17901. /** @hidden */
  17902. _currentEmitRate2: number;
  17903. /** @hidden */
  17904. _currentStartSizeGradient: Nullable<FactorGradient>;
  17905. /** @hidden */
  17906. _currentStartSize1: number;
  17907. /** @hidden */
  17908. _currentStartSize2: number;
  17909. private readonly _rawTextureWidth;
  17910. private _rampGradientsTexture;
  17911. private _useRampGradients;
  17912. /** Gets or sets a boolean indicating that ramp gradients must be used
  17913. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17914. */
  17915. get useRampGradients(): boolean;
  17916. set useRampGradients(value: boolean);
  17917. /**
  17918. * 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.
  17919. * 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: [])
  17920. */
  17921. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17922. private _subEmitters;
  17923. /**
  17924. * @hidden
  17925. * If the particle systems emitter should be disposed when the particle system is disposed
  17926. */
  17927. _disposeEmitterOnDispose: boolean;
  17928. /**
  17929. * The current active Sub-systems, this property is used by the root particle system only.
  17930. */
  17931. activeSubSystems: Array<ParticleSystem>;
  17932. private _rootParticleSystem;
  17933. /**
  17934. * Gets the current list of active particles
  17935. */
  17936. get particles(): Particle[];
  17937. /**
  17938. * Returns the string "ParticleSystem"
  17939. * @returns a string containing the class name
  17940. */
  17941. getClassName(): string;
  17942. /**
  17943. * Instantiates a particle system.
  17944. * 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.
  17945. * @param name The name of the particle system
  17946. * @param capacity The max number of particles alive at the same time
  17947. * @param scene The scene the particle system belongs to
  17948. * @param customEffect a custom effect used to change the way particles are rendered by default
  17949. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17950. * @param epsilon Offset used to render the particles
  17951. */
  17952. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17953. private _addFactorGradient;
  17954. private _removeFactorGradient;
  17955. /**
  17956. * Adds a new life time gradient
  17957. * @param gradient defines the gradient to use (between 0 and 1)
  17958. * @param factor defines the life time factor to affect to the specified gradient
  17959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17960. * @returns the current particle system
  17961. */
  17962. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17963. /**
  17964. * Remove a specific life time gradient
  17965. * @param gradient defines the gradient to remove
  17966. * @returns the current particle system
  17967. */
  17968. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17969. /**
  17970. * Adds a new size gradient
  17971. * @param gradient defines the gradient to use (between 0 and 1)
  17972. * @param factor defines the size factor to affect to the specified gradient
  17973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17974. * @returns the current particle system
  17975. */
  17976. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17977. /**
  17978. * Remove a specific size gradient
  17979. * @param gradient defines the gradient to remove
  17980. * @returns the current particle system
  17981. */
  17982. removeSizeGradient(gradient: number): IParticleSystem;
  17983. /**
  17984. * Adds a new color remap gradient
  17985. * @param gradient defines the gradient to use (between 0 and 1)
  17986. * @param min defines the color remap minimal range
  17987. * @param max defines the color remap maximal range
  17988. * @returns the current particle system
  17989. */
  17990. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17991. /**
  17992. * Remove a specific color remap gradient
  17993. * @param gradient defines the gradient to remove
  17994. * @returns the current particle system
  17995. */
  17996. removeColorRemapGradient(gradient: number): IParticleSystem;
  17997. /**
  17998. * Adds a new alpha remap gradient
  17999. * @param gradient defines the gradient to use (between 0 and 1)
  18000. * @param min defines the alpha remap minimal range
  18001. * @param max defines the alpha remap maximal range
  18002. * @returns the current particle system
  18003. */
  18004. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18005. /**
  18006. * Remove a specific alpha remap gradient
  18007. * @param gradient defines the gradient to remove
  18008. * @returns the current particle system
  18009. */
  18010. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18011. /**
  18012. * Adds a new angular speed gradient
  18013. * @param gradient defines the gradient to use (between 0 and 1)
  18014. * @param factor defines the angular speed to affect to the specified gradient
  18015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18016. * @returns the current particle system
  18017. */
  18018. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18019. /**
  18020. * Remove a specific angular speed gradient
  18021. * @param gradient defines the gradient to remove
  18022. * @returns the current particle system
  18023. */
  18024. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18025. /**
  18026. * Adds a new velocity gradient
  18027. * @param gradient defines the gradient to use (between 0 and 1)
  18028. * @param factor defines the velocity to affect to the specified gradient
  18029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18030. * @returns the current particle system
  18031. */
  18032. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18033. /**
  18034. * Remove a specific velocity gradient
  18035. * @param gradient defines the gradient to remove
  18036. * @returns the current particle system
  18037. */
  18038. removeVelocityGradient(gradient: number): IParticleSystem;
  18039. /**
  18040. * Adds a new limit velocity gradient
  18041. * @param gradient defines the gradient to use (between 0 and 1)
  18042. * @param factor defines the limit velocity value to affect to the specified gradient
  18043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18044. * @returns the current particle system
  18045. */
  18046. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18047. /**
  18048. * Remove a specific limit velocity gradient
  18049. * @param gradient defines the gradient to remove
  18050. * @returns the current particle system
  18051. */
  18052. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18053. /**
  18054. * Adds a new drag gradient
  18055. * @param gradient defines the gradient to use (between 0 and 1)
  18056. * @param factor defines the drag value to affect to the specified gradient
  18057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18058. * @returns the current particle system
  18059. */
  18060. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18061. /**
  18062. * Remove a specific drag gradient
  18063. * @param gradient defines the gradient to remove
  18064. * @returns the current particle system
  18065. */
  18066. removeDragGradient(gradient: number): IParticleSystem;
  18067. /**
  18068. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18069. * @param gradient defines the gradient to use (between 0 and 1)
  18070. * @param factor defines the emit rate value to affect to the specified gradient
  18071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18072. * @returns the current particle system
  18073. */
  18074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18075. /**
  18076. * Remove a specific emit rate gradient
  18077. * @param gradient defines the gradient to remove
  18078. * @returns the current particle system
  18079. */
  18080. removeEmitRateGradient(gradient: number): IParticleSystem;
  18081. /**
  18082. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18083. * @param gradient defines the gradient to use (between 0 and 1)
  18084. * @param factor defines the start size value to affect to the specified gradient
  18085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18086. * @returns the current particle system
  18087. */
  18088. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18089. /**
  18090. * Remove a specific start size gradient
  18091. * @param gradient defines the gradient to remove
  18092. * @returns the current particle system
  18093. */
  18094. removeStartSizeGradient(gradient: number): IParticleSystem;
  18095. private _createRampGradientTexture;
  18096. /**
  18097. * Gets the current list of ramp gradients.
  18098. * You must use addRampGradient and removeRampGradient to udpate this list
  18099. * @returns the list of ramp gradients
  18100. */
  18101. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18102. /**
  18103. * Adds a new ramp gradient used to remap particle colors
  18104. * @param gradient defines the gradient to use (between 0 and 1)
  18105. * @param color defines the color to affect to the specified gradient
  18106. * @returns the current particle system
  18107. */
  18108. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18109. /**
  18110. * Remove a specific ramp gradient
  18111. * @param gradient defines the gradient to remove
  18112. * @returns the current particle system
  18113. */
  18114. removeRampGradient(gradient: number): ParticleSystem;
  18115. /**
  18116. * Adds a new color gradient
  18117. * @param gradient defines the gradient to use (between 0 and 1)
  18118. * @param color1 defines the color to affect to the specified gradient
  18119. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18120. * @returns this particle system
  18121. */
  18122. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18123. /**
  18124. * Remove a specific color gradient
  18125. * @param gradient defines the gradient to remove
  18126. * @returns this particle system
  18127. */
  18128. removeColorGradient(gradient: number): IParticleSystem;
  18129. private _fetchR;
  18130. protected _reset(): void;
  18131. private _resetEffect;
  18132. private _createVertexBuffers;
  18133. private _createIndexBuffer;
  18134. /**
  18135. * Gets the maximum number of particles active at the same time.
  18136. * @returns The max number of active particles.
  18137. */
  18138. getCapacity(): number;
  18139. /**
  18140. * Gets whether there are still active particles in the system.
  18141. * @returns True if it is alive, otherwise false.
  18142. */
  18143. isAlive(): boolean;
  18144. /**
  18145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18146. * @returns True if it has been started, otherwise false.
  18147. */
  18148. isStarted(): boolean;
  18149. private _prepareSubEmitterInternalArray;
  18150. /**
  18151. * Starts the particle system and begins to emit
  18152. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18153. */
  18154. start(delay?: number): void;
  18155. /**
  18156. * Stops the particle system.
  18157. * @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.
  18158. */
  18159. stop(stopSubEmitters?: boolean): void;
  18160. /**
  18161. * Remove all active particles
  18162. */
  18163. reset(): void;
  18164. /**
  18165. * @hidden (for internal use only)
  18166. */
  18167. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18168. /**
  18169. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18170. * Its lifetime will start back at 0.
  18171. */
  18172. recycleParticle: (particle: Particle) => void;
  18173. private _stopSubEmitters;
  18174. private _createParticle;
  18175. private _removeFromRoot;
  18176. private _emitFromParticle;
  18177. private _update;
  18178. /** @hidden */
  18179. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18180. /** @hidden */
  18181. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18182. /** @hidden */
  18183. private _getEffect;
  18184. /**
  18185. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18186. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18187. */
  18188. animate(preWarmOnly?: boolean): void;
  18189. private _appendParticleVertices;
  18190. /**
  18191. * Rebuilds the particle system.
  18192. */
  18193. rebuild(): void;
  18194. /**
  18195. * Is this system ready to be used/rendered
  18196. * @return true if the system is ready
  18197. */
  18198. isReady(): boolean;
  18199. private _render;
  18200. /**
  18201. * Renders the particle system in its current state.
  18202. * @returns the current number of particles
  18203. */
  18204. render(): number;
  18205. /**
  18206. * Disposes the particle system and free the associated resources
  18207. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18208. */
  18209. dispose(disposeTexture?: boolean): void;
  18210. /**
  18211. * Clones the particle system.
  18212. * @param name The name of the cloned object
  18213. * @param newEmitter The new emitter to use
  18214. * @returns the cloned particle system
  18215. */
  18216. clone(name: string, newEmitter: any): ParticleSystem;
  18217. /**
  18218. * Serializes the particle system to a JSON object.
  18219. * @returns the JSON object
  18220. */
  18221. serialize(): any;
  18222. /** @hidden */
  18223. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18224. /** @hidden */
  18225. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18226. /**
  18227. * Parses a JSON object to create a particle system.
  18228. * @param parsedParticleSystem The JSON object to parse
  18229. * @param scene The scene to create the particle system in
  18230. * @param rootUrl The root url to use to load external dependencies like texture
  18231. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18232. * @returns the Parsed particle system
  18233. */
  18234. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18235. }
  18236. }
  18237. declare module "babylonjs/Particles/particle" {
  18238. import { Nullable } from "babylonjs/types";
  18239. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18240. import { Color4 } from "babylonjs/Maths/math.color";
  18241. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18242. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18243. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18244. /**
  18245. * A particle represents one of the element emitted by a particle system.
  18246. * This is mainly define by its coordinates, direction, velocity and age.
  18247. */
  18248. export class Particle {
  18249. /**
  18250. * The particle system the particle belongs to.
  18251. */
  18252. particleSystem: ParticleSystem;
  18253. private static _Count;
  18254. /**
  18255. * Unique ID of the particle
  18256. */
  18257. id: number;
  18258. /**
  18259. * The world position of the particle in the scene.
  18260. */
  18261. position: Vector3;
  18262. /**
  18263. * The world direction of the particle in the scene.
  18264. */
  18265. direction: Vector3;
  18266. /**
  18267. * The color of the particle.
  18268. */
  18269. color: Color4;
  18270. /**
  18271. * The color change of the particle per step.
  18272. */
  18273. colorStep: Color4;
  18274. /**
  18275. * Defines how long will the life of the particle be.
  18276. */
  18277. lifeTime: number;
  18278. /**
  18279. * The current age of the particle.
  18280. */
  18281. age: number;
  18282. /**
  18283. * The current size of the particle.
  18284. */
  18285. size: number;
  18286. /**
  18287. * The current scale of the particle.
  18288. */
  18289. scale: Vector2;
  18290. /**
  18291. * The current angle of the particle.
  18292. */
  18293. angle: number;
  18294. /**
  18295. * Defines how fast is the angle changing.
  18296. */
  18297. angularSpeed: number;
  18298. /**
  18299. * Defines the cell index used by the particle to be rendered from a sprite.
  18300. */
  18301. cellIndex: number;
  18302. /**
  18303. * The information required to support color remapping
  18304. */
  18305. remapData: Vector4;
  18306. /** @hidden */
  18307. _randomCellOffset?: number;
  18308. /** @hidden */
  18309. _initialDirection: Nullable<Vector3>;
  18310. /** @hidden */
  18311. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18312. /** @hidden */
  18313. _initialStartSpriteCellID: number;
  18314. /** @hidden */
  18315. _initialEndSpriteCellID: number;
  18316. /** @hidden */
  18317. _currentColorGradient: Nullable<ColorGradient>;
  18318. /** @hidden */
  18319. _currentColor1: Color4;
  18320. /** @hidden */
  18321. _currentColor2: Color4;
  18322. /** @hidden */
  18323. _currentSizeGradient: Nullable<FactorGradient>;
  18324. /** @hidden */
  18325. _currentSize1: number;
  18326. /** @hidden */
  18327. _currentSize2: number;
  18328. /** @hidden */
  18329. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18330. /** @hidden */
  18331. _currentAngularSpeed1: number;
  18332. /** @hidden */
  18333. _currentAngularSpeed2: number;
  18334. /** @hidden */
  18335. _currentVelocityGradient: Nullable<FactorGradient>;
  18336. /** @hidden */
  18337. _currentVelocity1: number;
  18338. /** @hidden */
  18339. _currentVelocity2: number;
  18340. /** @hidden */
  18341. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18342. /** @hidden */
  18343. _currentLimitVelocity1: number;
  18344. /** @hidden */
  18345. _currentLimitVelocity2: number;
  18346. /** @hidden */
  18347. _currentDragGradient: Nullable<FactorGradient>;
  18348. /** @hidden */
  18349. _currentDrag1: number;
  18350. /** @hidden */
  18351. _currentDrag2: number;
  18352. /** @hidden */
  18353. _randomNoiseCoordinates1: Vector3;
  18354. /** @hidden */
  18355. _randomNoiseCoordinates2: Vector3;
  18356. /**
  18357. * Creates a new instance Particle
  18358. * @param particleSystem the particle system the particle belongs to
  18359. */
  18360. constructor(
  18361. /**
  18362. * The particle system the particle belongs to.
  18363. */
  18364. particleSystem: ParticleSystem);
  18365. private updateCellInfoFromSystem;
  18366. /**
  18367. * Defines how the sprite cell index is updated for the particle
  18368. */
  18369. updateCellIndex(): void;
  18370. /** @hidden */
  18371. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18372. /** @hidden */
  18373. _inheritParticleInfoToSubEmitters(): void;
  18374. /** @hidden */
  18375. _reset(): void;
  18376. /**
  18377. * Copy the properties of particle to another one.
  18378. * @param other the particle to copy the information to.
  18379. */
  18380. copyTo(other: Particle): void;
  18381. }
  18382. }
  18383. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18384. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18385. import { Effect } from "babylonjs/Materials/effect";
  18386. import { Particle } from "babylonjs/Particles/particle";
  18387. /**
  18388. * Particle emitter represents a volume emitting particles.
  18389. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18390. */
  18391. export interface IParticleEmitterType {
  18392. /**
  18393. * Called by the particle System when the direction is computed for the created particle.
  18394. * @param worldMatrix is the world matrix of the particle system
  18395. * @param directionToUpdate is the direction vector to update with the result
  18396. * @param particle is the particle we are computed the direction for
  18397. */
  18398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18399. /**
  18400. * Called by the particle System when the position is computed for the created particle.
  18401. * @param worldMatrix is the world matrix of the particle system
  18402. * @param positionToUpdate is the position vector to update with the result
  18403. * @param particle is the particle we are computed the position for
  18404. */
  18405. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18406. /**
  18407. * Clones the current emitter and returns a copy of it
  18408. * @returns the new emitter
  18409. */
  18410. clone(): IParticleEmitterType;
  18411. /**
  18412. * Called by the GPUParticleSystem to setup the update shader
  18413. * @param effect defines the update shader
  18414. */
  18415. applyToShader(effect: Effect): void;
  18416. /**
  18417. * Returns a string to use to update the GPU particles update shader
  18418. * @returns the effect defines string
  18419. */
  18420. getEffectDefines(): string;
  18421. /**
  18422. * Returns a string representing the class name
  18423. * @returns a string containing the class name
  18424. */
  18425. getClassName(): string;
  18426. /**
  18427. * Serializes the particle system to a JSON object.
  18428. * @returns the JSON object
  18429. */
  18430. serialize(): any;
  18431. /**
  18432. * Parse properties from a JSON object
  18433. * @param serializationObject defines the JSON object
  18434. */
  18435. parse(serializationObject: any): void;
  18436. }
  18437. }
  18438. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18439. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18440. import { Effect } from "babylonjs/Materials/effect";
  18441. import { Particle } from "babylonjs/Particles/particle";
  18442. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18443. /**
  18444. * Particle emitter emitting particles from the inside of a box.
  18445. * It emits the particles randomly between 2 given directions.
  18446. */
  18447. export class BoxParticleEmitter implements IParticleEmitterType {
  18448. /**
  18449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18450. */
  18451. direction1: Vector3;
  18452. /**
  18453. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18454. */
  18455. direction2: Vector3;
  18456. /**
  18457. * 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.
  18458. */
  18459. minEmitBox: Vector3;
  18460. /**
  18461. * 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.
  18462. */
  18463. maxEmitBox: Vector3;
  18464. /**
  18465. * Creates a new instance BoxParticleEmitter
  18466. */
  18467. constructor();
  18468. /**
  18469. * Called by the particle System when the direction is computed for the created particle.
  18470. * @param worldMatrix is the world matrix of the particle system
  18471. * @param directionToUpdate is the direction vector to update with the result
  18472. * @param particle is the particle we are computed the direction for
  18473. */
  18474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18475. /**
  18476. * Called by the particle System when the position is computed for the created particle.
  18477. * @param worldMatrix is the world matrix of the particle system
  18478. * @param positionToUpdate is the position vector to update with the result
  18479. * @param particle is the particle we are computed the position for
  18480. */
  18481. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18482. /**
  18483. * Clones the current emitter and returns a copy of it
  18484. * @returns the new emitter
  18485. */
  18486. clone(): BoxParticleEmitter;
  18487. /**
  18488. * Called by the GPUParticleSystem to setup the update shader
  18489. * @param effect defines the update shader
  18490. */
  18491. applyToShader(effect: Effect): void;
  18492. /**
  18493. * Returns a string to use to update the GPU particles update shader
  18494. * @returns a string containng the defines string
  18495. */
  18496. getEffectDefines(): string;
  18497. /**
  18498. * Returns the string "BoxParticleEmitter"
  18499. * @returns a string containing the class name
  18500. */
  18501. getClassName(): string;
  18502. /**
  18503. * Serializes the particle system to a JSON object.
  18504. * @returns the JSON object
  18505. */
  18506. serialize(): any;
  18507. /**
  18508. * Parse properties from a JSON object
  18509. * @param serializationObject defines the JSON object
  18510. */
  18511. parse(serializationObject: any): void;
  18512. }
  18513. }
  18514. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18515. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18516. import { Effect } from "babylonjs/Materials/effect";
  18517. import { Particle } from "babylonjs/Particles/particle";
  18518. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18519. /**
  18520. * Particle emitter emitting particles from the inside of a cone.
  18521. * It emits the particles alongside the cone volume from the base to the particle.
  18522. * The emission direction might be randomized.
  18523. */
  18524. export class ConeParticleEmitter implements IParticleEmitterType {
  18525. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18526. directionRandomizer: number;
  18527. private _radius;
  18528. private _angle;
  18529. private _height;
  18530. /**
  18531. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18532. */
  18533. radiusRange: number;
  18534. /**
  18535. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18536. */
  18537. heightRange: number;
  18538. /**
  18539. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18540. */
  18541. emitFromSpawnPointOnly: boolean;
  18542. /**
  18543. * Gets or sets the radius of the emission cone
  18544. */
  18545. get radius(): number;
  18546. set radius(value: number);
  18547. /**
  18548. * Gets or sets the angle of the emission cone
  18549. */
  18550. get angle(): number;
  18551. set angle(value: number);
  18552. private _buildHeight;
  18553. /**
  18554. * Creates a new instance ConeParticleEmitter
  18555. * @param radius the radius of the emission cone (1 by default)
  18556. * @param angle the cone base angle (PI by default)
  18557. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18558. */
  18559. constructor(radius?: number, angle?: number,
  18560. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18561. directionRandomizer?: number);
  18562. /**
  18563. * Called by the particle System when the direction is computed for the created particle.
  18564. * @param worldMatrix is the world matrix of the particle system
  18565. * @param directionToUpdate is the direction vector to update with the result
  18566. * @param particle is the particle we are computed the direction for
  18567. */
  18568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18569. /**
  18570. * Called by the particle System when the position is computed for the created particle.
  18571. * @param worldMatrix is the world matrix of the particle system
  18572. * @param positionToUpdate is the position vector to update with the result
  18573. * @param particle is the particle we are computed the position for
  18574. */
  18575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18576. /**
  18577. * Clones the current emitter and returns a copy of it
  18578. * @returns the new emitter
  18579. */
  18580. clone(): ConeParticleEmitter;
  18581. /**
  18582. * Called by the GPUParticleSystem to setup the update shader
  18583. * @param effect defines the update shader
  18584. */
  18585. applyToShader(effect: Effect): void;
  18586. /**
  18587. * Returns a string to use to update the GPU particles update shader
  18588. * @returns a string containng the defines string
  18589. */
  18590. getEffectDefines(): string;
  18591. /**
  18592. * Returns the string "ConeParticleEmitter"
  18593. * @returns a string containing the class name
  18594. */
  18595. getClassName(): string;
  18596. /**
  18597. * Serializes the particle system to a JSON object.
  18598. * @returns the JSON object
  18599. */
  18600. serialize(): any;
  18601. /**
  18602. * Parse properties from a JSON object
  18603. * @param serializationObject defines the JSON object
  18604. */
  18605. parse(serializationObject: any): void;
  18606. }
  18607. }
  18608. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18609. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18610. import { Effect } from "babylonjs/Materials/effect";
  18611. import { Particle } from "babylonjs/Particles/particle";
  18612. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18613. /**
  18614. * Particle emitter emitting particles from the inside of a cylinder.
  18615. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18616. */
  18617. export class CylinderParticleEmitter implements IParticleEmitterType {
  18618. /**
  18619. * The radius of the emission cylinder.
  18620. */
  18621. radius: number;
  18622. /**
  18623. * The height of the emission cylinder.
  18624. */
  18625. height: number;
  18626. /**
  18627. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18628. */
  18629. radiusRange: number;
  18630. /**
  18631. * How much to randomize the particle direction [0-1].
  18632. */
  18633. directionRandomizer: number;
  18634. /**
  18635. * Creates a new instance CylinderParticleEmitter
  18636. * @param radius the radius of the emission cylinder (1 by default)
  18637. * @param height the height of the emission cylinder (1 by default)
  18638. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18639. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18640. */
  18641. constructor(
  18642. /**
  18643. * The radius of the emission cylinder.
  18644. */
  18645. radius?: number,
  18646. /**
  18647. * The height of the emission cylinder.
  18648. */
  18649. height?: number,
  18650. /**
  18651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18652. */
  18653. radiusRange?: number,
  18654. /**
  18655. * How much to randomize the particle direction [0-1].
  18656. */
  18657. directionRandomizer?: number);
  18658. /**
  18659. * Called by the particle System when the direction is computed for the created particle.
  18660. * @param worldMatrix is the world matrix of the particle system
  18661. * @param directionToUpdate is the direction vector to update with the result
  18662. * @param particle is the particle we are computed the direction for
  18663. */
  18664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18665. /**
  18666. * Called by the particle System when the position is computed for the created particle.
  18667. * @param worldMatrix is the world matrix of the particle system
  18668. * @param positionToUpdate is the position vector to update with the result
  18669. * @param particle is the particle we are computed the position for
  18670. */
  18671. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18672. /**
  18673. * Clones the current emitter and returns a copy of it
  18674. * @returns the new emitter
  18675. */
  18676. clone(): CylinderParticleEmitter;
  18677. /**
  18678. * Called by the GPUParticleSystem to setup the update shader
  18679. * @param effect defines the update shader
  18680. */
  18681. applyToShader(effect: Effect): void;
  18682. /**
  18683. * Returns a string to use to update the GPU particles update shader
  18684. * @returns a string containng the defines string
  18685. */
  18686. getEffectDefines(): string;
  18687. /**
  18688. * Returns the string "CylinderParticleEmitter"
  18689. * @returns a string containing the class name
  18690. */
  18691. getClassName(): string;
  18692. /**
  18693. * Serializes the particle system to a JSON object.
  18694. * @returns the JSON object
  18695. */
  18696. serialize(): any;
  18697. /**
  18698. * Parse properties from a JSON object
  18699. * @param serializationObject defines the JSON object
  18700. */
  18701. parse(serializationObject: any): void;
  18702. }
  18703. /**
  18704. * Particle emitter emitting particles from the inside of a cylinder.
  18705. * It emits the particles randomly between two vectors.
  18706. */
  18707. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18708. /**
  18709. * The min limit of the emission direction.
  18710. */
  18711. direction1: Vector3;
  18712. /**
  18713. * The max limit of the emission direction.
  18714. */
  18715. direction2: Vector3;
  18716. /**
  18717. * Creates a new instance CylinderDirectedParticleEmitter
  18718. * @param radius the radius of the emission cylinder (1 by default)
  18719. * @param height the height of the emission cylinder (1 by default)
  18720. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18721. * @param direction1 the min limit of the emission direction (up vector by default)
  18722. * @param direction2 the max limit of the emission direction (up vector by default)
  18723. */
  18724. constructor(radius?: number, height?: number, radiusRange?: number,
  18725. /**
  18726. * The min limit of the emission direction.
  18727. */
  18728. direction1?: Vector3,
  18729. /**
  18730. * The max limit of the emission direction.
  18731. */
  18732. direction2?: Vector3);
  18733. /**
  18734. * Called by the particle System when the direction is computed for the created particle.
  18735. * @param worldMatrix is the world matrix of the particle system
  18736. * @param directionToUpdate is the direction vector to update with the result
  18737. * @param particle is the particle we are computed the direction for
  18738. */
  18739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18740. /**
  18741. * Clones the current emitter and returns a copy of it
  18742. * @returns the new emitter
  18743. */
  18744. clone(): CylinderDirectedParticleEmitter;
  18745. /**
  18746. * Called by the GPUParticleSystem to setup the update shader
  18747. * @param effect defines the update shader
  18748. */
  18749. applyToShader(effect: Effect): void;
  18750. /**
  18751. * Returns a string to use to update the GPU particles update shader
  18752. * @returns a string containng the defines string
  18753. */
  18754. getEffectDefines(): string;
  18755. /**
  18756. * Returns the string "CylinderDirectedParticleEmitter"
  18757. * @returns a string containing the class name
  18758. */
  18759. getClassName(): string;
  18760. /**
  18761. * Serializes the particle system to a JSON object.
  18762. * @returns the JSON object
  18763. */
  18764. serialize(): any;
  18765. /**
  18766. * Parse properties from a JSON object
  18767. * @param serializationObject defines the JSON object
  18768. */
  18769. parse(serializationObject: any): void;
  18770. }
  18771. }
  18772. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18774. import { Effect } from "babylonjs/Materials/effect";
  18775. import { Particle } from "babylonjs/Particles/particle";
  18776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18777. /**
  18778. * Particle emitter emitting particles from the inside of a hemisphere.
  18779. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18780. */
  18781. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18782. /**
  18783. * The radius of the emission hemisphere.
  18784. */
  18785. radius: number;
  18786. /**
  18787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18788. */
  18789. radiusRange: number;
  18790. /**
  18791. * How much to randomize the particle direction [0-1].
  18792. */
  18793. directionRandomizer: number;
  18794. /**
  18795. * Creates a new instance HemisphericParticleEmitter
  18796. * @param radius the radius of the emission hemisphere (1 by default)
  18797. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18798. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18799. */
  18800. constructor(
  18801. /**
  18802. * The radius of the emission hemisphere.
  18803. */
  18804. radius?: number,
  18805. /**
  18806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18807. */
  18808. radiusRange?: number,
  18809. /**
  18810. * How much to randomize the particle direction [0-1].
  18811. */
  18812. directionRandomizer?: number);
  18813. /**
  18814. * Called by the particle System when the direction is computed for the created particle.
  18815. * @param worldMatrix is the world matrix of the particle system
  18816. * @param directionToUpdate is the direction vector to update with the result
  18817. * @param particle is the particle we are computed the direction for
  18818. */
  18819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18820. /**
  18821. * Called by the particle System when the position is computed for the created particle.
  18822. * @param worldMatrix is the world matrix of the particle system
  18823. * @param positionToUpdate is the position vector to update with the result
  18824. * @param particle is the particle we are computed the position for
  18825. */
  18826. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18827. /**
  18828. * Clones the current emitter and returns a copy of it
  18829. * @returns the new emitter
  18830. */
  18831. clone(): HemisphericParticleEmitter;
  18832. /**
  18833. * Called by the GPUParticleSystem to setup the update shader
  18834. * @param effect defines the update shader
  18835. */
  18836. applyToShader(effect: Effect): void;
  18837. /**
  18838. * Returns a string to use to update the GPU particles update shader
  18839. * @returns a string containng the defines string
  18840. */
  18841. getEffectDefines(): string;
  18842. /**
  18843. * Returns the string "HemisphericParticleEmitter"
  18844. * @returns a string containing the class name
  18845. */
  18846. getClassName(): string;
  18847. /**
  18848. * Serializes the particle system to a JSON object.
  18849. * @returns the JSON object
  18850. */
  18851. serialize(): any;
  18852. /**
  18853. * Parse properties from a JSON object
  18854. * @param serializationObject defines the JSON object
  18855. */
  18856. parse(serializationObject: any): void;
  18857. }
  18858. }
  18859. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18860. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18861. import { Effect } from "babylonjs/Materials/effect";
  18862. import { Particle } from "babylonjs/Particles/particle";
  18863. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18864. /**
  18865. * Particle emitter emitting particles from a point.
  18866. * It emits the particles randomly between 2 given directions.
  18867. */
  18868. export class PointParticleEmitter implements IParticleEmitterType {
  18869. /**
  18870. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18871. */
  18872. direction1: Vector3;
  18873. /**
  18874. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18875. */
  18876. direction2: Vector3;
  18877. /**
  18878. * Creates a new instance PointParticleEmitter
  18879. */
  18880. constructor();
  18881. /**
  18882. * Called by the particle System when the direction is computed for the created particle.
  18883. * @param worldMatrix is the world matrix of the particle system
  18884. * @param directionToUpdate is the direction vector to update with the result
  18885. * @param particle is the particle we are computed the direction for
  18886. */
  18887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18888. /**
  18889. * Called by the particle System when the position is computed for the created particle.
  18890. * @param worldMatrix is the world matrix of the particle system
  18891. * @param positionToUpdate is the position vector to update with the result
  18892. * @param particle is the particle we are computed the position for
  18893. */
  18894. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18895. /**
  18896. * Clones the current emitter and returns a copy of it
  18897. * @returns the new emitter
  18898. */
  18899. clone(): PointParticleEmitter;
  18900. /**
  18901. * Called by the GPUParticleSystem to setup the update shader
  18902. * @param effect defines the update shader
  18903. */
  18904. applyToShader(effect: Effect): void;
  18905. /**
  18906. * Returns a string to use to update the GPU particles update shader
  18907. * @returns a string containng the defines string
  18908. */
  18909. getEffectDefines(): string;
  18910. /**
  18911. * Returns the string "PointParticleEmitter"
  18912. * @returns a string containing the class name
  18913. */
  18914. getClassName(): string;
  18915. /**
  18916. * Serializes the particle system to a JSON object.
  18917. * @returns the JSON object
  18918. */
  18919. serialize(): any;
  18920. /**
  18921. * Parse properties from a JSON object
  18922. * @param serializationObject defines the JSON object
  18923. */
  18924. parse(serializationObject: any): void;
  18925. }
  18926. }
  18927. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18928. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18929. import { Effect } from "babylonjs/Materials/effect";
  18930. import { Particle } from "babylonjs/Particles/particle";
  18931. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18932. /**
  18933. * Particle emitter emitting particles from the inside of a sphere.
  18934. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18935. */
  18936. export class SphereParticleEmitter implements IParticleEmitterType {
  18937. /**
  18938. * The radius of the emission sphere.
  18939. */
  18940. radius: number;
  18941. /**
  18942. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18943. */
  18944. radiusRange: number;
  18945. /**
  18946. * How much to randomize the particle direction [0-1].
  18947. */
  18948. directionRandomizer: number;
  18949. /**
  18950. * Creates a new instance SphereParticleEmitter
  18951. * @param radius the radius of the emission sphere (1 by default)
  18952. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18953. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18954. */
  18955. constructor(
  18956. /**
  18957. * The radius of the emission sphere.
  18958. */
  18959. radius?: number,
  18960. /**
  18961. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18962. */
  18963. radiusRange?: number,
  18964. /**
  18965. * How much to randomize the particle direction [0-1].
  18966. */
  18967. directionRandomizer?: number);
  18968. /**
  18969. * Called by the particle System when the direction is computed for the created particle.
  18970. * @param worldMatrix is the world matrix of the particle system
  18971. * @param directionToUpdate is the direction vector to update with the result
  18972. * @param particle is the particle we are computed the direction for
  18973. */
  18974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18975. /**
  18976. * Called by the particle System when the position is computed for the created particle.
  18977. * @param worldMatrix is the world matrix of the particle system
  18978. * @param positionToUpdate is the position vector to update with the result
  18979. * @param particle is the particle we are computed the position for
  18980. */
  18981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18982. /**
  18983. * Clones the current emitter and returns a copy of it
  18984. * @returns the new emitter
  18985. */
  18986. clone(): SphereParticleEmitter;
  18987. /**
  18988. * Called by the GPUParticleSystem to setup the update shader
  18989. * @param effect defines the update shader
  18990. */
  18991. applyToShader(effect: Effect): void;
  18992. /**
  18993. * Returns a string to use to update the GPU particles update shader
  18994. * @returns a string containng the defines string
  18995. */
  18996. getEffectDefines(): string;
  18997. /**
  18998. * Returns the string "SphereParticleEmitter"
  18999. * @returns a string containing the class name
  19000. */
  19001. getClassName(): string;
  19002. /**
  19003. * Serializes the particle system to a JSON object.
  19004. * @returns the JSON object
  19005. */
  19006. serialize(): any;
  19007. /**
  19008. * Parse properties from a JSON object
  19009. * @param serializationObject defines the JSON object
  19010. */
  19011. parse(serializationObject: any): void;
  19012. }
  19013. /**
  19014. * Particle emitter emitting particles from the inside of a sphere.
  19015. * It emits the particles randomly between two vectors.
  19016. */
  19017. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19018. /**
  19019. * The min limit of the emission direction.
  19020. */
  19021. direction1: Vector3;
  19022. /**
  19023. * The max limit of the emission direction.
  19024. */
  19025. direction2: Vector3;
  19026. /**
  19027. * Creates a new instance SphereDirectedParticleEmitter
  19028. * @param radius the radius of the emission sphere (1 by default)
  19029. * @param direction1 the min limit of the emission direction (up vector by default)
  19030. * @param direction2 the max limit of the emission direction (up vector by default)
  19031. */
  19032. constructor(radius?: number,
  19033. /**
  19034. * The min limit of the emission direction.
  19035. */
  19036. direction1?: Vector3,
  19037. /**
  19038. * The max limit of the emission direction.
  19039. */
  19040. direction2?: Vector3);
  19041. /**
  19042. * Called by the particle System when the direction is computed for the created particle.
  19043. * @param worldMatrix is the world matrix of the particle system
  19044. * @param directionToUpdate is the direction vector to update with the result
  19045. * @param particle is the particle we are computed the direction for
  19046. */
  19047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19048. /**
  19049. * Clones the current emitter and returns a copy of it
  19050. * @returns the new emitter
  19051. */
  19052. clone(): SphereDirectedParticleEmitter;
  19053. /**
  19054. * Called by the GPUParticleSystem to setup the update shader
  19055. * @param effect defines the update shader
  19056. */
  19057. applyToShader(effect: Effect): void;
  19058. /**
  19059. * Returns a string to use to update the GPU particles update shader
  19060. * @returns a string containng the defines string
  19061. */
  19062. getEffectDefines(): string;
  19063. /**
  19064. * Returns the string "SphereDirectedParticleEmitter"
  19065. * @returns a string containing the class name
  19066. */
  19067. getClassName(): string;
  19068. /**
  19069. * Serializes the particle system to a JSON object.
  19070. * @returns the JSON object
  19071. */
  19072. serialize(): any;
  19073. /**
  19074. * Parse properties from a JSON object
  19075. * @param serializationObject defines the JSON object
  19076. */
  19077. parse(serializationObject: any): void;
  19078. }
  19079. }
  19080. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  19081. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19082. import { Effect } from "babylonjs/Materials/effect";
  19083. import { Particle } from "babylonjs/Particles/particle";
  19084. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19085. import { Nullable } from "babylonjs/types";
  19086. /**
  19087. * Particle emitter emitting particles from a custom list of positions.
  19088. */
  19089. export class CustomParticleEmitter implements IParticleEmitterType {
  19090. /**
  19091. * Gets or sets the position generator that will create the inital position of each particle.
  19092. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19093. */
  19094. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  19095. /**
  19096. * Gets or sets the destination generator that will create the final destination of each particle.
  19097. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19098. */
  19099. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  19100. /**
  19101. * Creates a new instance CustomParticleEmitter
  19102. */
  19103. constructor();
  19104. /**
  19105. * Called by the particle System when the direction is computed for the created particle.
  19106. * @param worldMatrix is the world matrix of the particle system
  19107. * @param directionToUpdate is the direction vector to update with the result
  19108. * @param particle is the particle we are computed the direction for
  19109. */
  19110. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19111. /**
  19112. * Called by the particle System when the position is computed for the created particle.
  19113. * @param worldMatrix is the world matrix of the particle system
  19114. * @param positionToUpdate is the position vector to update with the result
  19115. * @param particle is the particle we are computed the position for
  19116. */
  19117. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19118. /**
  19119. * Clones the current emitter and returns a copy of it
  19120. * @returns the new emitter
  19121. */
  19122. clone(): CustomParticleEmitter;
  19123. /**
  19124. * Called by the GPUParticleSystem to setup the update shader
  19125. * @param effect defines the update shader
  19126. */
  19127. applyToShader(effect: Effect): void;
  19128. /**
  19129. * Returns a string to use to update the GPU particles update shader
  19130. * @returns a string containng the defines string
  19131. */
  19132. getEffectDefines(): string;
  19133. /**
  19134. * Returns the string "PointParticleEmitter"
  19135. * @returns a string containing the class name
  19136. */
  19137. getClassName(): string;
  19138. /**
  19139. * Serializes the particle system to a JSON object.
  19140. * @returns the JSON object
  19141. */
  19142. serialize(): any;
  19143. /**
  19144. * Parse properties from a JSON object
  19145. * @param serializationObject defines the JSON object
  19146. */
  19147. parse(serializationObject: any): void;
  19148. }
  19149. }
  19150. declare module "babylonjs/Particles/EmitterTypes/index" {
  19151. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19152. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19153. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19154. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19155. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19156. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19157. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19158. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  19159. }
  19160. declare module "babylonjs/Particles/IParticleSystem" {
  19161. import { Nullable } from "babylonjs/types";
  19162. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19163. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19166. import { Texture } from "babylonjs/Materials/Textures/texture";
  19167. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19168. import { Scene } from "babylonjs/scene";
  19169. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19170. import { Animation } from "babylonjs/Animations/animation";
  19171. /**
  19172. * Interface representing a particle system in Babylon.js.
  19173. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19174. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19175. */
  19176. export interface IParticleSystem {
  19177. /**
  19178. * List of animations used by the particle system.
  19179. */
  19180. animations: Animation[];
  19181. /**
  19182. * The id of the Particle system.
  19183. */
  19184. id: string;
  19185. /**
  19186. * The name of the Particle system.
  19187. */
  19188. name: string;
  19189. /**
  19190. * The emitter represents the Mesh or position we are attaching the particle system to.
  19191. */
  19192. emitter: Nullable<AbstractMesh | Vector3>;
  19193. /**
  19194. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19195. */
  19196. isBillboardBased: boolean;
  19197. /**
  19198. * The rendering group used by the Particle system to chose when to render.
  19199. */
  19200. renderingGroupId: number;
  19201. /**
  19202. * The layer mask we are rendering the particles through.
  19203. */
  19204. layerMask: number;
  19205. /**
  19206. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19207. */
  19208. updateSpeed: number;
  19209. /**
  19210. * The amount of time the particle system is running (depends of the overall update speed).
  19211. */
  19212. targetStopDuration: number;
  19213. /**
  19214. * The texture used to render each particle. (this can be a spritesheet)
  19215. */
  19216. particleTexture: Nullable<Texture>;
  19217. /**
  19218. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19219. */
  19220. blendMode: number;
  19221. /**
  19222. * Minimum life time of emitting particles.
  19223. */
  19224. minLifeTime: number;
  19225. /**
  19226. * Maximum life time of emitting particles.
  19227. */
  19228. maxLifeTime: number;
  19229. /**
  19230. * Minimum Size of emitting particles.
  19231. */
  19232. minSize: number;
  19233. /**
  19234. * Maximum Size of emitting particles.
  19235. */
  19236. maxSize: number;
  19237. /**
  19238. * Minimum scale of emitting particles on X axis.
  19239. */
  19240. minScaleX: number;
  19241. /**
  19242. * Maximum scale of emitting particles on X axis.
  19243. */
  19244. maxScaleX: number;
  19245. /**
  19246. * Minimum scale of emitting particles on Y axis.
  19247. */
  19248. minScaleY: number;
  19249. /**
  19250. * Maximum scale of emitting particles on Y axis.
  19251. */
  19252. maxScaleY: number;
  19253. /**
  19254. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19255. */
  19256. color1: Color4;
  19257. /**
  19258. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19259. */
  19260. color2: Color4;
  19261. /**
  19262. * Color the particle will have at the end of its lifetime.
  19263. */
  19264. colorDead: Color4;
  19265. /**
  19266. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19267. */
  19268. emitRate: number;
  19269. /**
  19270. * You can use gravity if you want to give an orientation to your particles.
  19271. */
  19272. gravity: Vector3;
  19273. /**
  19274. * Minimum power of emitting particles.
  19275. */
  19276. minEmitPower: number;
  19277. /**
  19278. * Maximum power of emitting particles.
  19279. */
  19280. maxEmitPower: number;
  19281. /**
  19282. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19283. */
  19284. minAngularSpeed: number;
  19285. /**
  19286. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19287. */
  19288. maxAngularSpeed: number;
  19289. /**
  19290. * Gets or sets the minimal initial rotation in radians.
  19291. */
  19292. minInitialRotation: number;
  19293. /**
  19294. * Gets or sets the maximal initial rotation in radians.
  19295. */
  19296. maxInitialRotation: number;
  19297. /**
  19298. * The particle emitter type defines the emitter used by the particle system.
  19299. * It can be for example box, sphere, or cone...
  19300. */
  19301. particleEmitterType: Nullable<IParticleEmitterType>;
  19302. /**
  19303. * Defines the delay in milliseconds before starting the system (0 by default)
  19304. */
  19305. startDelay: number;
  19306. /**
  19307. * 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
  19308. */
  19309. preWarmCycles: number;
  19310. /**
  19311. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19312. */
  19313. preWarmStepOffset: number;
  19314. /**
  19315. * 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)
  19316. */
  19317. spriteCellChangeSpeed: number;
  19318. /**
  19319. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19320. */
  19321. startSpriteCellID: number;
  19322. /**
  19323. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19324. */
  19325. endSpriteCellID: number;
  19326. /**
  19327. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19328. */
  19329. spriteCellWidth: number;
  19330. /**
  19331. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19332. */
  19333. spriteCellHeight: number;
  19334. /**
  19335. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19336. */
  19337. spriteRandomStartCell: boolean;
  19338. /**
  19339. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19340. */
  19341. isAnimationSheetEnabled: boolean;
  19342. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19343. translationPivot: Vector2;
  19344. /**
  19345. * Gets or sets a texture used to add random noise to particle positions
  19346. */
  19347. noiseTexture: Nullable<BaseTexture>;
  19348. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19349. noiseStrength: Vector3;
  19350. /**
  19351. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19352. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19353. */
  19354. billboardMode: number;
  19355. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19356. limitVelocityDamping: number;
  19357. /**
  19358. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19359. */
  19360. beginAnimationOnStart: boolean;
  19361. /**
  19362. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19363. */
  19364. beginAnimationFrom: number;
  19365. /**
  19366. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19367. */
  19368. beginAnimationTo: number;
  19369. /**
  19370. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19371. */
  19372. beginAnimationLoop: boolean;
  19373. /**
  19374. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19375. */
  19376. disposeOnStop: boolean;
  19377. /**
  19378. * Gets the maximum number of particles active at the same time.
  19379. * @returns The max number of active particles.
  19380. */
  19381. getCapacity(): number;
  19382. /**
  19383. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19384. * @returns True if it has been started, otherwise false.
  19385. */
  19386. isStarted(): boolean;
  19387. /**
  19388. * Animates the particle system for this frame.
  19389. */
  19390. animate(): void;
  19391. /**
  19392. * Renders the particle system in its current state.
  19393. * @returns the current number of particles
  19394. */
  19395. render(): number;
  19396. /**
  19397. * Dispose the particle system and frees its associated resources.
  19398. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19399. */
  19400. dispose(disposeTexture?: boolean): void;
  19401. /**
  19402. * Clones the particle system.
  19403. * @param name The name of the cloned object
  19404. * @param newEmitter The new emitter to use
  19405. * @returns the cloned particle system
  19406. */
  19407. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19408. /**
  19409. * Serializes the particle system to a JSON object.
  19410. * @returns the JSON object
  19411. */
  19412. serialize(): any;
  19413. /**
  19414. * Rebuild the particle system
  19415. */
  19416. rebuild(): void;
  19417. /**
  19418. * Starts the particle system and begins to emit
  19419. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19420. */
  19421. start(delay?: number): void;
  19422. /**
  19423. * Stops the particle system.
  19424. */
  19425. stop(): void;
  19426. /**
  19427. * Remove all active particles
  19428. */
  19429. reset(): void;
  19430. /**
  19431. * Is this system ready to be used/rendered
  19432. * @return true if the system is ready
  19433. */
  19434. isReady(): boolean;
  19435. /**
  19436. * Adds a new color gradient
  19437. * @param gradient defines the gradient to use (between 0 and 1)
  19438. * @param color1 defines the color to affect to the specified gradient
  19439. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19440. * @returns the current particle system
  19441. */
  19442. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19443. /**
  19444. * Remove a specific color gradient
  19445. * @param gradient defines the gradient to remove
  19446. * @returns the current particle system
  19447. */
  19448. removeColorGradient(gradient: number): IParticleSystem;
  19449. /**
  19450. * Adds a new size gradient
  19451. * @param gradient defines the gradient to use (between 0 and 1)
  19452. * @param factor defines the size factor to affect to the specified gradient
  19453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19454. * @returns the current particle system
  19455. */
  19456. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19457. /**
  19458. * Remove a specific size gradient
  19459. * @param gradient defines the gradient to remove
  19460. * @returns the current particle system
  19461. */
  19462. removeSizeGradient(gradient: number): IParticleSystem;
  19463. /**
  19464. * Gets the current list of color gradients.
  19465. * You must use addColorGradient and removeColorGradient to udpate this list
  19466. * @returns the list of color gradients
  19467. */
  19468. getColorGradients(): Nullable<Array<ColorGradient>>;
  19469. /**
  19470. * Gets the current list of size gradients.
  19471. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19472. * @returns the list of size gradients
  19473. */
  19474. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19475. /**
  19476. * Gets the current list of angular speed gradients.
  19477. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19478. * @returns the list of angular speed gradients
  19479. */
  19480. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19481. /**
  19482. * Adds a new angular speed gradient
  19483. * @param gradient defines the gradient to use (between 0 and 1)
  19484. * @param factor defines the angular speed to affect to the specified gradient
  19485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19486. * @returns the current particle system
  19487. */
  19488. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19489. /**
  19490. * Remove a specific angular speed gradient
  19491. * @param gradient defines the gradient to remove
  19492. * @returns the current particle system
  19493. */
  19494. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19495. /**
  19496. * Gets the current list of velocity gradients.
  19497. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19498. * @returns the list of velocity gradients
  19499. */
  19500. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19501. /**
  19502. * Adds a new velocity gradient
  19503. * @param gradient defines the gradient to use (between 0 and 1)
  19504. * @param factor defines the velocity to affect to the specified gradient
  19505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19506. * @returns the current particle system
  19507. */
  19508. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19509. /**
  19510. * Remove a specific velocity gradient
  19511. * @param gradient defines the gradient to remove
  19512. * @returns the current particle system
  19513. */
  19514. removeVelocityGradient(gradient: number): IParticleSystem;
  19515. /**
  19516. * Gets the current list of limit velocity gradients.
  19517. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19518. * @returns the list of limit velocity gradients
  19519. */
  19520. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19521. /**
  19522. * Adds a new limit velocity gradient
  19523. * @param gradient defines the gradient to use (between 0 and 1)
  19524. * @param factor defines the limit velocity to affect to the specified gradient
  19525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19526. * @returns the current particle system
  19527. */
  19528. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19529. /**
  19530. * Remove a specific limit velocity gradient
  19531. * @param gradient defines the gradient to remove
  19532. * @returns the current particle system
  19533. */
  19534. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19535. /**
  19536. * Adds a new drag gradient
  19537. * @param gradient defines the gradient to use (between 0 and 1)
  19538. * @param factor defines the drag to affect to the specified gradient
  19539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19540. * @returns the current particle system
  19541. */
  19542. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19543. /**
  19544. * Remove a specific drag gradient
  19545. * @param gradient defines the gradient to remove
  19546. * @returns the current particle system
  19547. */
  19548. removeDragGradient(gradient: number): IParticleSystem;
  19549. /**
  19550. * Gets the current list of drag gradients.
  19551. * You must use addDragGradient and removeDragGradient to udpate this list
  19552. * @returns the list of drag gradients
  19553. */
  19554. getDragGradients(): Nullable<Array<FactorGradient>>;
  19555. /**
  19556. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19557. * @param gradient defines the gradient to use (between 0 and 1)
  19558. * @param factor defines the emit rate to affect to the specified gradient
  19559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19560. * @returns the current particle system
  19561. */
  19562. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19563. /**
  19564. * Remove a specific emit rate gradient
  19565. * @param gradient defines the gradient to remove
  19566. * @returns the current particle system
  19567. */
  19568. removeEmitRateGradient(gradient: number): IParticleSystem;
  19569. /**
  19570. * Gets the current list of emit rate gradients.
  19571. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19572. * @returns the list of emit rate gradients
  19573. */
  19574. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19575. /**
  19576. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19577. * @param gradient defines the gradient to use (between 0 and 1)
  19578. * @param factor defines the start size to affect to the specified gradient
  19579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19580. * @returns the current particle system
  19581. */
  19582. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19583. /**
  19584. * Remove a specific start size gradient
  19585. * @param gradient defines the gradient to remove
  19586. * @returns the current particle system
  19587. */
  19588. removeStartSizeGradient(gradient: number): IParticleSystem;
  19589. /**
  19590. * Gets the current list of start size gradients.
  19591. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19592. * @returns the list of start size gradients
  19593. */
  19594. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19595. /**
  19596. * Adds a new life time gradient
  19597. * @param gradient defines the gradient to use (between 0 and 1)
  19598. * @param factor defines the life time factor to affect to the specified gradient
  19599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19600. * @returns the current particle system
  19601. */
  19602. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19603. /**
  19604. * Remove a specific life time gradient
  19605. * @param gradient defines the gradient to remove
  19606. * @returns the current particle system
  19607. */
  19608. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19609. /**
  19610. * Gets the current list of life time gradients.
  19611. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19612. * @returns the list of life time gradients
  19613. */
  19614. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19615. /**
  19616. * Gets the current list of color gradients.
  19617. * You must use addColorGradient and removeColorGradient to udpate this list
  19618. * @returns the list of color gradients
  19619. */
  19620. getColorGradients(): Nullable<Array<ColorGradient>>;
  19621. /**
  19622. * Adds a new ramp gradient used to remap particle colors
  19623. * @param gradient defines the gradient to use (between 0 and 1)
  19624. * @param color defines the color to affect to the specified gradient
  19625. * @returns the current particle system
  19626. */
  19627. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19628. /**
  19629. * Gets the current list of ramp gradients.
  19630. * You must use addRampGradient and removeRampGradient to udpate this list
  19631. * @returns the list of ramp gradients
  19632. */
  19633. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19634. /** Gets or sets a boolean indicating that ramp gradients must be used
  19635. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19636. */
  19637. useRampGradients: boolean;
  19638. /**
  19639. * Adds a new color remap gradient
  19640. * @param gradient defines the gradient to use (between 0 and 1)
  19641. * @param min defines the color remap minimal range
  19642. * @param max defines the color remap maximal range
  19643. * @returns the current particle system
  19644. */
  19645. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19646. /**
  19647. * Gets the current list of color remap gradients.
  19648. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19649. * @returns the list of color remap gradients
  19650. */
  19651. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19652. /**
  19653. * Adds a new alpha remap gradient
  19654. * @param gradient defines the gradient to use (between 0 and 1)
  19655. * @param min defines the alpha remap minimal range
  19656. * @param max defines the alpha remap maximal range
  19657. * @returns the current particle system
  19658. */
  19659. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19660. /**
  19661. * Gets the current list of alpha remap gradients.
  19662. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19663. * @returns the list of alpha remap gradients
  19664. */
  19665. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19666. /**
  19667. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19670. * @returns the emitter
  19671. */
  19672. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19673. /**
  19674. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19675. * @param radius The radius of the hemisphere to emit from
  19676. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19677. * @returns the emitter
  19678. */
  19679. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19680. /**
  19681. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19682. * @param radius The radius of the sphere to emit from
  19683. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19684. * @returns the emitter
  19685. */
  19686. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19687. /**
  19688. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19689. * @param radius The radius of the sphere to emit from
  19690. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19691. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19692. * @returns the emitter
  19693. */
  19694. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19695. /**
  19696. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19697. * @param radius The radius of the emission cylinder
  19698. * @param height The height of the emission cylinder
  19699. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19700. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19701. * @returns the emitter
  19702. */
  19703. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19704. /**
  19705. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19706. * @param radius The radius of the cylinder to emit from
  19707. * @param height The height of the emission cylinder
  19708. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19711. * @returns the emitter
  19712. */
  19713. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19714. /**
  19715. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19716. * @param radius The radius of the cone to emit from
  19717. * @param angle The base angle of the cone
  19718. * @returns the emitter
  19719. */
  19720. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19721. /**
  19722. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19723. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19724. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19725. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19726. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19727. * @returns the emitter
  19728. */
  19729. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19730. /**
  19731. * Get hosting scene
  19732. * @returns the scene
  19733. */
  19734. getScene(): Scene;
  19735. }
  19736. }
  19737. declare module "babylonjs/Meshes/instancedMesh" {
  19738. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19740. import { Camera } from "babylonjs/Cameras/camera";
  19741. import { Node } from "babylonjs/node";
  19742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19743. import { Mesh } from "babylonjs/Meshes/mesh";
  19744. import { Material } from "babylonjs/Materials/material";
  19745. import { Skeleton } from "babylonjs/Bones/skeleton";
  19746. import { Light } from "babylonjs/Lights/light";
  19747. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19748. /**
  19749. * Creates an instance based on a source mesh.
  19750. */
  19751. export class InstancedMesh extends AbstractMesh {
  19752. private _sourceMesh;
  19753. private _currentLOD;
  19754. /** @hidden */
  19755. _indexInSourceMeshInstanceArray: number;
  19756. constructor(name: string, source: Mesh);
  19757. /**
  19758. * Returns the string "InstancedMesh".
  19759. */
  19760. getClassName(): string;
  19761. /** Gets the list of lights affecting that mesh */
  19762. get lightSources(): Light[];
  19763. _resyncLightSources(): void;
  19764. _resyncLightSource(light: Light): void;
  19765. _removeLightSource(light: Light, dispose: boolean): void;
  19766. /**
  19767. * If the source mesh receives shadows
  19768. */
  19769. get receiveShadows(): boolean;
  19770. /**
  19771. * The material of the source mesh
  19772. */
  19773. get material(): Nullable<Material>;
  19774. /**
  19775. * Visibility of the source mesh
  19776. */
  19777. get visibility(): number;
  19778. /**
  19779. * Skeleton of the source mesh
  19780. */
  19781. get skeleton(): Nullable<Skeleton>;
  19782. /**
  19783. * Rendering ground id of the source mesh
  19784. */
  19785. get renderingGroupId(): number;
  19786. set renderingGroupId(value: number);
  19787. /**
  19788. * Returns the total number of vertices (integer).
  19789. */
  19790. getTotalVertices(): number;
  19791. /**
  19792. * Returns a positive integer : the total number of indices in this mesh geometry.
  19793. * @returns the numner of indices or zero if the mesh has no geometry.
  19794. */
  19795. getTotalIndices(): number;
  19796. /**
  19797. * The source mesh of the instance
  19798. */
  19799. get sourceMesh(): Mesh;
  19800. /**
  19801. * Is this node ready to be used/rendered
  19802. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19803. * @return {boolean} is it ready
  19804. */
  19805. isReady(completeCheck?: boolean): boolean;
  19806. /**
  19807. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19808. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19809. * @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.
  19810. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19811. */
  19812. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19813. /**
  19814. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19815. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19816. * The `data` are either a numeric array either a Float32Array.
  19817. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19818. * 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).
  19819. * Note that a new underlying VertexBuffer object is created each call.
  19820. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19821. *
  19822. * Possible `kind` values :
  19823. * - VertexBuffer.PositionKind
  19824. * - VertexBuffer.UVKind
  19825. * - VertexBuffer.UV2Kind
  19826. * - VertexBuffer.UV3Kind
  19827. * - VertexBuffer.UV4Kind
  19828. * - VertexBuffer.UV5Kind
  19829. * - VertexBuffer.UV6Kind
  19830. * - VertexBuffer.ColorKind
  19831. * - VertexBuffer.MatricesIndicesKind
  19832. * - VertexBuffer.MatricesIndicesExtraKind
  19833. * - VertexBuffer.MatricesWeightsKind
  19834. * - VertexBuffer.MatricesWeightsExtraKind
  19835. *
  19836. * Returns the Mesh.
  19837. */
  19838. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19839. /**
  19840. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19841. * If the mesh has no geometry, it is simply returned as it is.
  19842. * The `data` are either a numeric array either a Float32Array.
  19843. * No new underlying VertexBuffer object is created.
  19844. * 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.
  19845. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19846. *
  19847. * Possible `kind` values :
  19848. * - VertexBuffer.PositionKind
  19849. * - VertexBuffer.UVKind
  19850. * - VertexBuffer.UV2Kind
  19851. * - VertexBuffer.UV3Kind
  19852. * - VertexBuffer.UV4Kind
  19853. * - VertexBuffer.UV5Kind
  19854. * - VertexBuffer.UV6Kind
  19855. * - VertexBuffer.ColorKind
  19856. * - VertexBuffer.MatricesIndicesKind
  19857. * - VertexBuffer.MatricesIndicesExtraKind
  19858. * - VertexBuffer.MatricesWeightsKind
  19859. * - VertexBuffer.MatricesWeightsExtraKind
  19860. *
  19861. * Returns the Mesh.
  19862. */
  19863. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19864. /**
  19865. * Sets the mesh indices.
  19866. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19867. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19868. * This method creates a new index buffer each call.
  19869. * Returns the Mesh.
  19870. */
  19871. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19872. /**
  19873. * Boolean : True if the mesh owns the requested kind of data.
  19874. */
  19875. isVerticesDataPresent(kind: string): boolean;
  19876. /**
  19877. * Returns an array of indices (IndicesArray).
  19878. */
  19879. getIndices(): Nullable<IndicesArray>;
  19880. get _positions(): Nullable<Vector3[]>;
  19881. /**
  19882. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19883. * This means the mesh underlying bounding box and sphere are recomputed.
  19884. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19885. * @returns the current mesh
  19886. */
  19887. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19888. /** @hidden */
  19889. _preActivate(): InstancedMesh;
  19890. /** @hidden */
  19891. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19892. /** @hidden */
  19893. _postActivate(): void;
  19894. getWorldMatrix(): Matrix;
  19895. get isAnInstance(): boolean;
  19896. /**
  19897. * Returns the current associated LOD AbstractMesh.
  19898. */
  19899. getLOD(camera: Camera): AbstractMesh;
  19900. /** @hidden */
  19901. _syncSubMeshes(): InstancedMesh;
  19902. /** @hidden */
  19903. _generatePointsArray(): boolean;
  19904. /**
  19905. * Creates a new InstancedMesh from the current mesh.
  19906. * - name (string) : the cloned mesh name
  19907. * - newParent (optional Node) : the optional Node to parent the clone to.
  19908. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19909. *
  19910. * Returns the clone.
  19911. */
  19912. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19913. /**
  19914. * Disposes the InstancedMesh.
  19915. * Returns nothing.
  19916. */
  19917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19918. }
  19919. module "babylonjs/Meshes/mesh" {
  19920. interface Mesh {
  19921. /**
  19922. * Register a custom buffer that will be instanced
  19923. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19924. * @param kind defines the buffer kind
  19925. * @param stride defines the stride in floats
  19926. */
  19927. registerInstancedBuffer(kind: string, stride: number): void;
  19928. /** @hidden */
  19929. _userInstancedBuffersStorage: {
  19930. data: {
  19931. [key: string]: Float32Array;
  19932. };
  19933. sizes: {
  19934. [key: string]: number;
  19935. };
  19936. vertexBuffers: {
  19937. [key: string]: Nullable<VertexBuffer>;
  19938. };
  19939. strides: {
  19940. [key: string]: number;
  19941. };
  19942. };
  19943. }
  19944. }
  19945. module "babylonjs/Meshes/abstractMesh" {
  19946. interface AbstractMesh {
  19947. /**
  19948. * Object used to store instanced buffers defined by user
  19949. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19950. */
  19951. instancedBuffers: {
  19952. [key: string]: any;
  19953. };
  19954. }
  19955. }
  19956. }
  19957. declare module "babylonjs/Materials/shaderMaterial" {
  19958. import { Scene } from "babylonjs/scene";
  19959. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19961. import { Mesh } from "babylonjs/Meshes/mesh";
  19962. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19963. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19964. import { Texture } from "babylonjs/Materials/Textures/texture";
  19965. import { Material } from "babylonjs/Materials/material";
  19966. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19967. /**
  19968. * Defines the options associated with the creation of a shader material.
  19969. */
  19970. export interface IShaderMaterialOptions {
  19971. /**
  19972. * Does the material work in alpha blend mode
  19973. */
  19974. needAlphaBlending: boolean;
  19975. /**
  19976. * Does the material work in alpha test mode
  19977. */
  19978. needAlphaTesting: boolean;
  19979. /**
  19980. * The list of attribute names used in the shader
  19981. */
  19982. attributes: string[];
  19983. /**
  19984. * The list of unifrom names used in the shader
  19985. */
  19986. uniforms: string[];
  19987. /**
  19988. * The list of UBO names used in the shader
  19989. */
  19990. uniformBuffers: string[];
  19991. /**
  19992. * The list of sampler names used in the shader
  19993. */
  19994. samplers: string[];
  19995. /**
  19996. * The list of defines used in the shader
  19997. */
  19998. defines: string[];
  19999. }
  20000. /**
  20001. * 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.
  20002. *
  20003. * This returned material effects how the mesh will look based on the code in the shaders.
  20004. *
  20005. * @see http://doc.babylonjs.com/how_to/shader_material
  20006. */
  20007. export class ShaderMaterial extends Material {
  20008. private _shaderPath;
  20009. private _options;
  20010. private _textures;
  20011. private _textureArrays;
  20012. private _floats;
  20013. private _ints;
  20014. private _floatsArrays;
  20015. private _colors3;
  20016. private _colors3Arrays;
  20017. private _colors4;
  20018. private _colors4Arrays;
  20019. private _vectors2;
  20020. private _vectors3;
  20021. private _vectors4;
  20022. private _matrices;
  20023. private _matrixArrays;
  20024. private _matrices3x3;
  20025. private _matrices2x2;
  20026. private _vectors2Arrays;
  20027. private _vectors3Arrays;
  20028. private _vectors4Arrays;
  20029. private _cachedWorldViewMatrix;
  20030. private _cachedWorldViewProjectionMatrix;
  20031. private _renderId;
  20032. private _multiview;
  20033. /**
  20034. * Instantiate a new shader material.
  20035. * 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.
  20036. * This returned material effects how the mesh will look based on the code in the shaders.
  20037. * @see http://doc.babylonjs.com/how_to/shader_material
  20038. * @param name Define the name of the material in the scene
  20039. * @param scene Define the scene the material belongs to
  20040. * @param shaderPath Defines the route to the shader code in one of three ways:
  20041. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  20042. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  20043. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  20044. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  20045. * @param options Define the options used to create the shader
  20046. */
  20047. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  20048. /**
  20049. * Gets the shader path used to define the shader code
  20050. * It can be modified to trigger a new compilation
  20051. */
  20052. get shaderPath(): any;
  20053. /**
  20054. * Sets the shader path used to define the shader code
  20055. * It can be modified to trigger a new compilation
  20056. */
  20057. set shaderPath(shaderPath: any);
  20058. /**
  20059. * Gets the options used to compile the shader.
  20060. * They can be modified to trigger a new compilation
  20061. */
  20062. get options(): IShaderMaterialOptions;
  20063. /**
  20064. * Gets the current class name of the material e.g. "ShaderMaterial"
  20065. * Mainly use in serialization.
  20066. * @returns the class name
  20067. */
  20068. getClassName(): string;
  20069. /**
  20070. * Specifies if the material will require alpha blending
  20071. * @returns a boolean specifying if alpha blending is needed
  20072. */
  20073. needAlphaBlending(): boolean;
  20074. /**
  20075. * Specifies if this material should be rendered in alpha test mode
  20076. * @returns a boolean specifying if an alpha test is needed.
  20077. */
  20078. needAlphaTesting(): boolean;
  20079. private _checkUniform;
  20080. /**
  20081. * Set a texture in the shader.
  20082. * @param name Define the name of the uniform samplers as defined in the shader
  20083. * @param texture Define the texture to bind to this sampler
  20084. * @return the material itself allowing "fluent" like uniform updates
  20085. */
  20086. setTexture(name: string, texture: Texture): ShaderMaterial;
  20087. /**
  20088. * Set a texture array in the shader.
  20089. * @param name Define the name of the uniform sampler array as defined in the shader
  20090. * @param textures Define the list of textures to bind to this sampler
  20091. * @return the material itself allowing "fluent" like uniform updates
  20092. */
  20093. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20094. /**
  20095. * Set a float in the shader.
  20096. * @param name Define the name of the uniform as defined in the shader
  20097. * @param value Define the value to give to the uniform
  20098. * @return the material itself allowing "fluent" like uniform updates
  20099. */
  20100. setFloat(name: string, value: number): ShaderMaterial;
  20101. /**
  20102. * Set a int in the shader.
  20103. * @param name Define the name of the uniform as defined in the shader
  20104. * @param value Define the value to give to the uniform
  20105. * @return the material itself allowing "fluent" like uniform updates
  20106. */
  20107. setInt(name: string, value: number): ShaderMaterial;
  20108. /**
  20109. * Set an array of floats in the shader.
  20110. * @param name Define the name of the uniform as defined in the shader
  20111. * @param value Define the value to give to the uniform
  20112. * @return the material itself allowing "fluent" like uniform updates
  20113. */
  20114. setFloats(name: string, value: number[]): ShaderMaterial;
  20115. /**
  20116. * Set a vec3 in the shader from a Color3.
  20117. * @param name Define the name of the uniform as defined in the shader
  20118. * @param value Define the value to give to the uniform
  20119. * @return the material itself allowing "fluent" like uniform updates
  20120. */
  20121. setColor3(name: string, value: Color3): ShaderMaterial;
  20122. /**
  20123. * Set a vec3 array in the shader from a Color3 array.
  20124. * @param name Define the name of the uniform as defined in the shader
  20125. * @param value Define the value to give to the uniform
  20126. * @return the material itself allowing "fluent" like uniform updates
  20127. */
  20128. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20129. /**
  20130. * Set a vec4 in the shader from a Color4.
  20131. * @param name Define the name of the uniform as defined in the shader
  20132. * @param value Define the value to give to the uniform
  20133. * @return the material itself allowing "fluent" like uniform updates
  20134. */
  20135. setColor4(name: string, value: Color4): ShaderMaterial;
  20136. /**
  20137. * Set a vec4 array in the shader from a Color4 array.
  20138. * @param name Define the name of the uniform as defined in the shader
  20139. * @param value Define the value to give to the uniform
  20140. * @return the material itself allowing "fluent" like uniform updates
  20141. */
  20142. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20143. /**
  20144. * Set a vec2 in the shader from a Vector2.
  20145. * @param name Define the name of the uniform as defined in the shader
  20146. * @param value Define the value to give to the uniform
  20147. * @return the material itself allowing "fluent" like uniform updates
  20148. */
  20149. setVector2(name: string, value: Vector2): ShaderMaterial;
  20150. /**
  20151. * Set a vec3 in the shader from a Vector3.
  20152. * @param name Define the name of the uniform as defined in the shader
  20153. * @param value Define the value to give to the uniform
  20154. * @return the material itself allowing "fluent" like uniform updates
  20155. */
  20156. setVector3(name: string, value: Vector3): ShaderMaterial;
  20157. /**
  20158. * Set a vec4 in the shader from a Vector4.
  20159. * @param name Define the name of the uniform as defined in the shader
  20160. * @param value Define the value to give to the uniform
  20161. * @return the material itself allowing "fluent" like uniform updates
  20162. */
  20163. setVector4(name: string, value: Vector4): ShaderMaterial;
  20164. /**
  20165. * Set a mat4 in the shader from a Matrix.
  20166. * @param name Define the name of the uniform as defined in the shader
  20167. * @param value Define the value to give to the uniform
  20168. * @return the material itself allowing "fluent" like uniform updates
  20169. */
  20170. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20171. /**
  20172. * Set a float32Array in the shader from a matrix array.
  20173. * @param name Define the name of the uniform as defined in the shader
  20174. * @param value Define the value to give to the uniform
  20175. * @return the material itself allowing "fluent" like uniform updates
  20176. */
  20177. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20178. /**
  20179. * Set a mat3 in the shader from a Float32Array.
  20180. * @param name Define the name of the uniform as defined in the shader
  20181. * @param value Define the value to give to the uniform
  20182. * @return the material itself allowing "fluent" like uniform updates
  20183. */
  20184. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20185. /**
  20186. * Set a mat2 in the shader from a Float32Array.
  20187. * @param name Define the name of the uniform as defined in the shader
  20188. * @param value Define the value to give to the uniform
  20189. * @return the material itself allowing "fluent" like uniform updates
  20190. */
  20191. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20192. /**
  20193. * Set a vec2 array in the shader from a number array.
  20194. * @param name Define the name of the uniform as defined in the shader
  20195. * @param value Define the value to give to the uniform
  20196. * @return the material itself allowing "fluent" like uniform updates
  20197. */
  20198. setArray2(name: string, value: number[]): ShaderMaterial;
  20199. /**
  20200. * Set a vec3 array in the shader from a number array.
  20201. * @param name Define the name of the uniform as defined in the shader
  20202. * @param value Define the value to give to the uniform
  20203. * @return the material itself allowing "fluent" like uniform updates
  20204. */
  20205. setArray3(name: string, value: number[]): ShaderMaterial;
  20206. /**
  20207. * Set a vec4 array in the shader from a number array.
  20208. * @param name Define the name of the uniform as defined in the shader
  20209. * @param value Define the value to give to the uniform
  20210. * @return the material itself allowing "fluent" like uniform updates
  20211. */
  20212. setArray4(name: string, value: number[]): ShaderMaterial;
  20213. private _checkCache;
  20214. /**
  20215. * Specifies that the submesh is ready to be used
  20216. * @param mesh defines the mesh to check
  20217. * @param subMesh defines which submesh to check
  20218. * @param useInstances specifies that instances should be used
  20219. * @returns a boolean indicating that the submesh is ready or not
  20220. */
  20221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20222. /**
  20223. * Checks if the material is ready to render the requested mesh
  20224. * @param mesh Define the mesh to render
  20225. * @param useInstances Define whether or not the material is used with instances
  20226. * @returns true if ready, otherwise false
  20227. */
  20228. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20229. /**
  20230. * Binds the world matrix to the material
  20231. * @param world defines the world transformation matrix
  20232. */
  20233. bindOnlyWorldMatrix(world: Matrix): void;
  20234. /**
  20235. * Binds the material to the mesh
  20236. * @param world defines the world transformation matrix
  20237. * @param mesh defines the mesh to bind the material to
  20238. */
  20239. bind(world: Matrix, mesh?: Mesh): void;
  20240. /**
  20241. * Gets the active textures from the material
  20242. * @returns an array of textures
  20243. */
  20244. getActiveTextures(): BaseTexture[];
  20245. /**
  20246. * Specifies if the material uses a texture
  20247. * @param texture defines the texture to check against the material
  20248. * @returns a boolean specifying if the material uses the texture
  20249. */
  20250. hasTexture(texture: BaseTexture): boolean;
  20251. /**
  20252. * Makes a duplicate of the material, and gives it a new name
  20253. * @param name defines the new name for the duplicated material
  20254. * @returns the cloned material
  20255. */
  20256. clone(name: string): ShaderMaterial;
  20257. /**
  20258. * Disposes the material
  20259. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20260. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20261. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20262. */
  20263. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20264. /**
  20265. * Serializes this material in a JSON representation
  20266. * @returns the serialized material object
  20267. */
  20268. serialize(): any;
  20269. /**
  20270. * Creates a shader material from parsed shader material data
  20271. * @param source defines the JSON represnetation of the material
  20272. * @param scene defines the hosting scene
  20273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20274. * @returns a new material
  20275. */
  20276. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20277. }
  20278. }
  20279. declare module "babylonjs/Shaders/color.fragment" {
  20280. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20281. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20282. /** @hidden */
  20283. export var colorPixelShader: {
  20284. name: string;
  20285. shader: string;
  20286. };
  20287. }
  20288. declare module "babylonjs/Shaders/color.vertex" {
  20289. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20291. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20292. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20293. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20294. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20295. /** @hidden */
  20296. export var colorVertexShader: {
  20297. name: string;
  20298. shader: string;
  20299. };
  20300. }
  20301. declare module "babylonjs/Meshes/linesMesh" {
  20302. import { Nullable } from "babylonjs/types";
  20303. import { Scene } from "babylonjs/scene";
  20304. import { Color3 } from "babylonjs/Maths/math.color";
  20305. import { Node } from "babylonjs/node";
  20306. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20307. import { Mesh } from "babylonjs/Meshes/mesh";
  20308. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20309. import { Effect } from "babylonjs/Materials/effect";
  20310. import { Material } from "babylonjs/Materials/material";
  20311. import "babylonjs/Shaders/color.fragment";
  20312. import "babylonjs/Shaders/color.vertex";
  20313. /**
  20314. * Line mesh
  20315. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20316. */
  20317. export class LinesMesh extends Mesh {
  20318. /**
  20319. * If vertex color should be applied to the mesh
  20320. */
  20321. readonly useVertexColor?: boolean | undefined;
  20322. /**
  20323. * If vertex alpha should be applied to the mesh
  20324. */
  20325. readonly useVertexAlpha?: boolean | undefined;
  20326. /**
  20327. * Color of the line (Default: White)
  20328. */
  20329. color: Color3;
  20330. /**
  20331. * Alpha of the line (Default: 1)
  20332. */
  20333. alpha: number;
  20334. /**
  20335. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20336. * This margin is expressed in world space coordinates, so its value may vary.
  20337. * Default value is 0.1
  20338. */
  20339. intersectionThreshold: number;
  20340. private _colorShader;
  20341. private color4;
  20342. /**
  20343. * Creates a new LinesMesh
  20344. * @param name defines the name
  20345. * @param scene defines the hosting scene
  20346. * @param parent defines the parent mesh if any
  20347. * @param source defines the optional source LinesMesh used to clone data from
  20348. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20349. * When false, achieved by calling a clone(), also passing False.
  20350. * This will make creation of children, recursive.
  20351. * @param useVertexColor defines if this LinesMesh supports vertex color
  20352. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20353. */
  20354. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20355. /**
  20356. * If vertex color should be applied to the mesh
  20357. */
  20358. useVertexColor?: boolean | undefined,
  20359. /**
  20360. * If vertex alpha should be applied to the mesh
  20361. */
  20362. useVertexAlpha?: boolean | undefined);
  20363. private _addClipPlaneDefine;
  20364. private _removeClipPlaneDefine;
  20365. isReady(): boolean;
  20366. /**
  20367. * Returns the string "LineMesh"
  20368. */
  20369. getClassName(): string;
  20370. /**
  20371. * @hidden
  20372. */
  20373. get material(): Material;
  20374. /**
  20375. * @hidden
  20376. */
  20377. set material(value: Material);
  20378. /**
  20379. * @hidden
  20380. */
  20381. get checkCollisions(): boolean;
  20382. /** @hidden */
  20383. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20384. /** @hidden */
  20385. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20386. /**
  20387. * Disposes of the line mesh
  20388. * @param doNotRecurse If children should be disposed
  20389. */
  20390. dispose(doNotRecurse?: boolean): void;
  20391. /**
  20392. * Returns a new LineMesh object cloned from the current one.
  20393. */
  20394. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  20395. /**
  20396. * Creates a new InstancedLinesMesh object from the mesh model.
  20397. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20398. * @param name defines the name of the new instance
  20399. * @returns a new InstancedLinesMesh
  20400. */
  20401. createInstance(name: string): InstancedLinesMesh;
  20402. }
  20403. /**
  20404. * Creates an instance based on a source LinesMesh
  20405. */
  20406. export class InstancedLinesMesh extends InstancedMesh {
  20407. /**
  20408. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20409. * This margin is expressed in world space coordinates, so its value may vary.
  20410. * Initilized with the intersectionThreshold value of the source LinesMesh
  20411. */
  20412. intersectionThreshold: number;
  20413. constructor(name: string, source: LinesMesh);
  20414. /**
  20415. * Returns the string "InstancedLinesMesh".
  20416. */
  20417. getClassName(): string;
  20418. }
  20419. }
  20420. declare module "babylonjs/Shaders/line.fragment" {
  20421. /** @hidden */
  20422. export var linePixelShader: {
  20423. name: string;
  20424. shader: string;
  20425. };
  20426. }
  20427. declare module "babylonjs/Shaders/line.vertex" {
  20428. /** @hidden */
  20429. export var lineVertexShader: {
  20430. name: string;
  20431. shader: string;
  20432. };
  20433. }
  20434. declare module "babylonjs/Rendering/edgesRenderer" {
  20435. import { Nullable } from "babylonjs/types";
  20436. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20438. import { Vector3 } from "babylonjs/Maths/math.vector";
  20439. import { IDisposable } from "babylonjs/scene";
  20440. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20441. import "babylonjs/Shaders/line.fragment";
  20442. import "babylonjs/Shaders/line.vertex";
  20443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20444. module "babylonjs/Meshes/abstractMesh" {
  20445. interface AbstractMesh {
  20446. /**
  20447. * Gets the edgesRenderer associated with the mesh
  20448. */
  20449. edgesRenderer: Nullable<EdgesRenderer>;
  20450. }
  20451. }
  20452. module "babylonjs/Meshes/linesMesh" {
  20453. interface LinesMesh {
  20454. /**
  20455. * Enables the edge rendering mode on the mesh.
  20456. * This mode makes the mesh edges visible
  20457. * @param epsilon defines the maximal distance between two angles to detect a face
  20458. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20459. * @returns the currentAbstractMesh
  20460. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20461. */
  20462. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20463. }
  20464. }
  20465. module "babylonjs/Meshes/linesMesh" {
  20466. interface InstancedLinesMesh {
  20467. /**
  20468. * Enables the edge rendering mode on the mesh.
  20469. * This mode makes the mesh edges visible
  20470. * @param epsilon defines the maximal distance between two angles to detect a face
  20471. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20472. * @returns the current InstancedLinesMesh
  20473. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20474. */
  20475. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20476. }
  20477. }
  20478. /**
  20479. * Defines the minimum contract an Edges renderer should follow.
  20480. */
  20481. export interface IEdgesRenderer extends IDisposable {
  20482. /**
  20483. * Gets or sets a boolean indicating if the edgesRenderer is active
  20484. */
  20485. isEnabled: boolean;
  20486. /**
  20487. * Renders the edges of the attached mesh,
  20488. */
  20489. render(): void;
  20490. /**
  20491. * Checks wether or not the edges renderer is ready to render.
  20492. * @return true if ready, otherwise false.
  20493. */
  20494. isReady(): boolean;
  20495. }
  20496. /**
  20497. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20498. */
  20499. export class EdgesRenderer implements IEdgesRenderer {
  20500. /**
  20501. * Define the size of the edges with an orthographic camera
  20502. */
  20503. edgesWidthScalerForOrthographic: number;
  20504. /**
  20505. * Define the size of the edges with a perspective camera
  20506. */
  20507. edgesWidthScalerForPerspective: number;
  20508. protected _source: AbstractMesh;
  20509. protected _linesPositions: number[];
  20510. protected _linesNormals: number[];
  20511. protected _linesIndices: number[];
  20512. protected _epsilon: number;
  20513. protected _indicesCount: number;
  20514. protected _lineShader: ShaderMaterial;
  20515. protected _ib: DataBuffer;
  20516. protected _buffers: {
  20517. [key: string]: Nullable<VertexBuffer>;
  20518. };
  20519. protected _checkVerticesInsteadOfIndices: boolean;
  20520. private _meshRebuildObserver;
  20521. private _meshDisposeObserver;
  20522. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20523. isEnabled: boolean;
  20524. /**
  20525. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20526. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20527. * @param source Mesh used to create edges
  20528. * @param epsilon sum of angles in adjacency to check for edge
  20529. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20530. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20531. */
  20532. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20533. protected _prepareRessources(): void;
  20534. /** @hidden */
  20535. _rebuild(): void;
  20536. /**
  20537. * Releases the required resources for the edges renderer
  20538. */
  20539. dispose(): void;
  20540. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20541. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20542. /**
  20543. * Checks if the pair of p0 and p1 is en edge
  20544. * @param faceIndex
  20545. * @param edge
  20546. * @param faceNormals
  20547. * @param p0
  20548. * @param p1
  20549. * @private
  20550. */
  20551. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20552. /**
  20553. * push line into the position, normal and index buffer
  20554. * @protected
  20555. */
  20556. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20557. /**
  20558. * Generates lines edges from adjacencjes
  20559. * @private
  20560. */
  20561. _generateEdgesLines(): void;
  20562. /**
  20563. * Checks wether or not the edges renderer is ready to render.
  20564. * @return true if ready, otherwise false.
  20565. */
  20566. isReady(): boolean;
  20567. /**
  20568. * Renders the edges of the attached mesh,
  20569. */
  20570. render(): void;
  20571. }
  20572. /**
  20573. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20574. */
  20575. export class LineEdgesRenderer extends EdgesRenderer {
  20576. /**
  20577. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20578. * @param source LineMesh used to generate edges
  20579. * @param epsilon not important (specified angle for edge detection)
  20580. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20581. */
  20582. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20583. /**
  20584. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20585. */
  20586. _generateEdgesLines(): void;
  20587. }
  20588. }
  20589. declare module "babylonjs/Rendering/renderingGroup" {
  20590. import { SmartArray } from "babylonjs/Misc/smartArray";
  20591. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20593. import { Nullable } from "babylonjs/types";
  20594. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20595. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20596. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20597. import { Material } from "babylonjs/Materials/material";
  20598. import { Scene } from "babylonjs/scene";
  20599. /**
  20600. * This represents the object necessary to create a rendering group.
  20601. * This is exclusively used and created by the rendering manager.
  20602. * To modify the behavior, you use the available helpers in your scene or meshes.
  20603. * @hidden
  20604. */
  20605. export class RenderingGroup {
  20606. index: number;
  20607. private static _zeroVector;
  20608. private _scene;
  20609. private _opaqueSubMeshes;
  20610. private _transparentSubMeshes;
  20611. private _alphaTestSubMeshes;
  20612. private _depthOnlySubMeshes;
  20613. private _particleSystems;
  20614. private _spriteManagers;
  20615. private _opaqueSortCompareFn;
  20616. private _alphaTestSortCompareFn;
  20617. private _transparentSortCompareFn;
  20618. private _renderOpaque;
  20619. private _renderAlphaTest;
  20620. private _renderTransparent;
  20621. /** @hidden */
  20622. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20623. onBeforeTransparentRendering: () => void;
  20624. /**
  20625. * Set the opaque sort comparison function.
  20626. * If null the sub meshes will be render in the order they were created
  20627. */
  20628. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20629. /**
  20630. * Set the alpha test sort comparison function.
  20631. * If null the sub meshes will be render in the order they were created
  20632. */
  20633. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20634. /**
  20635. * Set the transparent sort comparison function.
  20636. * If null the sub meshes will be render in the order they were created
  20637. */
  20638. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20639. /**
  20640. * Creates a new rendering group.
  20641. * @param index The rendering group index
  20642. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20643. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20644. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20645. */
  20646. 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>);
  20647. /**
  20648. * Render all the sub meshes contained in the group.
  20649. * @param customRenderFunction Used to override the default render behaviour of the group.
  20650. * @returns true if rendered some submeshes.
  20651. */
  20652. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20653. /**
  20654. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20655. * @param subMeshes The submeshes to render
  20656. */
  20657. private renderOpaqueSorted;
  20658. /**
  20659. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20660. * @param subMeshes The submeshes to render
  20661. */
  20662. private renderAlphaTestSorted;
  20663. /**
  20664. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20665. * @param subMeshes The submeshes to render
  20666. */
  20667. private renderTransparentSorted;
  20668. /**
  20669. * Renders the submeshes in a specified order.
  20670. * @param subMeshes The submeshes to sort before render
  20671. * @param sortCompareFn The comparison function use to sort
  20672. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20673. * @param transparent Specifies to activate blending if true
  20674. */
  20675. private static renderSorted;
  20676. /**
  20677. * Renders the submeshes in the order they were dispatched (no sort applied).
  20678. * @param subMeshes The submeshes to render
  20679. */
  20680. private static renderUnsorted;
  20681. /**
  20682. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20683. * are rendered back to front if in the same alpha index.
  20684. *
  20685. * @param a The first submesh
  20686. * @param b The second submesh
  20687. * @returns The result of the comparison
  20688. */
  20689. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20690. /**
  20691. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20692. * are rendered back to front.
  20693. *
  20694. * @param a The first submesh
  20695. * @param b The second submesh
  20696. * @returns The result of the comparison
  20697. */
  20698. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20699. /**
  20700. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20701. * are rendered front to back (prevent overdraw).
  20702. *
  20703. * @param a The first submesh
  20704. * @param b The second submesh
  20705. * @returns The result of the comparison
  20706. */
  20707. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20708. /**
  20709. * Resets the different lists of submeshes to prepare a new frame.
  20710. */
  20711. prepare(): void;
  20712. dispose(): void;
  20713. /**
  20714. * Inserts the submesh in its correct queue depending on its material.
  20715. * @param subMesh The submesh to dispatch
  20716. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20717. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20718. */
  20719. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20720. dispatchSprites(spriteManager: ISpriteManager): void;
  20721. dispatchParticles(particleSystem: IParticleSystem): void;
  20722. private _renderParticles;
  20723. private _renderSprites;
  20724. }
  20725. }
  20726. declare module "babylonjs/Rendering/renderingManager" {
  20727. import { Nullable } from "babylonjs/types";
  20728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20729. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20730. import { SmartArray } from "babylonjs/Misc/smartArray";
  20731. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20732. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20733. import { Material } from "babylonjs/Materials/material";
  20734. import { Scene } from "babylonjs/scene";
  20735. import { Camera } from "babylonjs/Cameras/camera";
  20736. /**
  20737. * Interface describing the different options available in the rendering manager
  20738. * regarding Auto Clear between groups.
  20739. */
  20740. export interface IRenderingManagerAutoClearSetup {
  20741. /**
  20742. * Defines whether or not autoclear is enable.
  20743. */
  20744. autoClear: boolean;
  20745. /**
  20746. * Defines whether or not to autoclear the depth buffer.
  20747. */
  20748. depth: boolean;
  20749. /**
  20750. * Defines whether or not to autoclear the stencil buffer.
  20751. */
  20752. stencil: boolean;
  20753. }
  20754. /**
  20755. * This class is used by the onRenderingGroupObservable
  20756. */
  20757. export class RenderingGroupInfo {
  20758. /**
  20759. * The Scene that being rendered
  20760. */
  20761. scene: Scene;
  20762. /**
  20763. * The camera currently used for the rendering pass
  20764. */
  20765. camera: Nullable<Camera>;
  20766. /**
  20767. * The ID of the renderingGroup being processed
  20768. */
  20769. renderingGroupId: number;
  20770. }
  20771. /**
  20772. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20773. * It is enable to manage the different groups as well as the different necessary sort functions.
  20774. * This should not be used directly aside of the few static configurations
  20775. */
  20776. export class RenderingManager {
  20777. /**
  20778. * The max id used for rendering groups (not included)
  20779. */
  20780. static MAX_RENDERINGGROUPS: number;
  20781. /**
  20782. * The min id used for rendering groups (included)
  20783. */
  20784. static MIN_RENDERINGGROUPS: number;
  20785. /**
  20786. * Used to globally prevent autoclearing scenes.
  20787. */
  20788. static AUTOCLEAR: boolean;
  20789. /**
  20790. * @hidden
  20791. */
  20792. _useSceneAutoClearSetup: boolean;
  20793. private _scene;
  20794. private _renderingGroups;
  20795. private _depthStencilBufferAlreadyCleaned;
  20796. private _autoClearDepthStencil;
  20797. private _customOpaqueSortCompareFn;
  20798. private _customAlphaTestSortCompareFn;
  20799. private _customTransparentSortCompareFn;
  20800. private _renderingGroupInfo;
  20801. /**
  20802. * Instantiates a new rendering group for a particular scene
  20803. * @param scene Defines the scene the groups belongs to
  20804. */
  20805. constructor(scene: Scene);
  20806. private _clearDepthStencilBuffer;
  20807. /**
  20808. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20809. * @hidden
  20810. */
  20811. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20812. /**
  20813. * Resets the different information of the group to prepare a new frame
  20814. * @hidden
  20815. */
  20816. reset(): void;
  20817. /**
  20818. * Dispose and release the group and its associated resources.
  20819. * @hidden
  20820. */
  20821. dispose(): void;
  20822. /**
  20823. * Clear the info related to rendering groups preventing retention points during dispose.
  20824. */
  20825. freeRenderingGroups(): void;
  20826. private _prepareRenderingGroup;
  20827. /**
  20828. * Add a sprite manager to the rendering manager in order to render it this frame.
  20829. * @param spriteManager Define the sprite manager to render
  20830. */
  20831. dispatchSprites(spriteManager: ISpriteManager): void;
  20832. /**
  20833. * Add a particle system to the rendering manager in order to render it this frame.
  20834. * @param particleSystem Define the particle system to render
  20835. */
  20836. dispatchParticles(particleSystem: IParticleSystem): void;
  20837. /**
  20838. * Add a submesh to the manager in order to render it this frame
  20839. * @param subMesh The submesh to dispatch
  20840. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20841. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20842. */
  20843. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20844. /**
  20845. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20846. * This allowed control for front to back rendering or reversly depending of the special needs.
  20847. *
  20848. * @param renderingGroupId The rendering group id corresponding to its index
  20849. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20850. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20851. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20852. */
  20853. 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;
  20854. /**
  20855. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20856. *
  20857. * @param renderingGroupId The rendering group id corresponding to its index
  20858. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20859. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20860. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20861. */
  20862. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20863. /**
  20864. * Gets the current auto clear configuration for one rendering group of the rendering
  20865. * manager.
  20866. * @param index the rendering group index to get the information for
  20867. * @returns The auto clear setup for the requested rendering group
  20868. */
  20869. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20870. }
  20871. }
  20872. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20873. import { Observable } from "babylonjs/Misc/observable";
  20874. import { SmartArray } from "babylonjs/Misc/smartArray";
  20875. import { Nullable } from "babylonjs/types";
  20876. import { Camera } from "babylonjs/Cameras/camera";
  20877. import { Scene } from "babylonjs/scene";
  20878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20879. import { Color4 } from "babylonjs/Maths/math.color";
  20880. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20884. import { Texture } from "babylonjs/Materials/Textures/texture";
  20885. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20886. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20887. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20888. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20889. import { Engine } from "babylonjs/Engines/engine";
  20890. /**
  20891. * This Helps creating a texture that will be created from a camera in your scene.
  20892. * It is basically a dynamic texture that could be used to create special effects for instance.
  20893. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20894. */
  20895. export class RenderTargetTexture extends Texture {
  20896. isCube: boolean;
  20897. /**
  20898. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20899. */
  20900. static readonly REFRESHRATE_RENDER_ONCE: number;
  20901. /**
  20902. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20903. */
  20904. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20905. /**
  20906. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20907. * the central point of your effect and can save a lot of performances.
  20908. */
  20909. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20910. /**
  20911. * Use this predicate to dynamically define the list of mesh you want to render.
  20912. * If set, the renderList property will be overwritten.
  20913. */
  20914. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20915. private _renderList;
  20916. /**
  20917. * Use this list to define the list of mesh you want to render.
  20918. */
  20919. get renderList(): Nullable<Array<AbstractMesh>>;
  20920. set renderList(value: Nullable<Array<AbstractMesh>>);
  20921. private _hookArray;
  20922. /**
  20923. * Define if particles should be rendered in your texture.
  20924. */
  20925. renderParticles: boolean;
  20926. /**
  20927. * Define if sprites should be rendered in your texture.
  20928. */
  20929. renderSprites: boolean;
  20930. /**
  20931. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20932. */
  20933. coordinatesMode: number;
  20934. /**
  20935. * Define the camera used to render the texture.
  20936. */
  20937. activeCamera: Nullable<Camera>;
  20938. /**
  20939. * Override the render function of the texture with your own one.
  20940. */
  20941. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20942. /**
  20943. * Define if camera post processes should be use while rendering the texture.
  20944. */
  20945. useCameraPostProcesses: boolean;
  20946. /**
  20947. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20948. */
  20949. ignoreCameraViewport: boolean;
  20950. private _postProcessManager;
  20951. private _postProcesses;
  20952. private _resizeObserver;
  20953. /**
  20954. * An event triggered when the texture is unbind.
  20955. */
  20956. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20957. /**
  20958. * An event triggered when the texture is unbind.
  20959. */
  20960. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20961. private _onAfterUnbindObserver;
  20962. /**
  20963. * Set a after unbind callback in the texture.
  20964. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20965. */
  20966. set onAfterUnbind(callback: () => void);
  20967. /**
  20968. * An event triggered before rendering the texture
  20969. */
  20970. onBeforeRenderObservable: Observable<number>;
  20971. private _onBeforeRenderObserver;
  20972. /**
  20973. * Set a before render callback in the texture.
  20974. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20975. */
  20976. set onBeforeRender(callback: (faceIndex: number) => void);
  20977. /**
  20978. * An event triggered after rendering the texture
  20979. */
  20980. onAfterRenderObservable: Observable<number>;
  20981. private _onAfterRenderObserver;
  20982. /**
  20983. * Set a after render callback in the texture.
  20984. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20985. */
  20986. set onAfterRender(callback: (faceIndex: number) => void);
  20987. /**
  20988. * An event triggered after the texture clear
  20989. */
  20990. onClearObservable: Observable<Engine>;
  20991. private _onClearObserver;
  20992. /**
  20993. * Set a clear callback in the texture.
  20994. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20995. */
  20996. set onClear(callback: (Engine: Engine) => void);
  20997. /**
  20998. * An event triggered when the texture is resized.
  20999. */
  21000. onResizeObservable: Observable<RenderTargetTexture>;
  21001. /**
  21002. * Define the clear color of the Render Target if it should be different from the scene.
  21003. */
  21004. clearColor: Color4;
  21005. protected _size: number | {
  21006. width: number;
  21007. height: number;
  21008. layers?: number;
  21009. };
  21010. protected _initialSizeParameter: number | {
  21011. width: number;
  21012. height: number;
  21013. } | {
  21014. ratio: number;
  21015. };
  21016. protected _sizeRatio: Nullable<number>;
  21017. /** @hidden */
  21018. _generateMipMaps: boolean;
  21019. protected _renderingManager: RenderingManager;
  21020. /** @hidden */
  21021. _waitingRenderList: string[];
  21022. protected _doNotChangeAspectRatio: boolean;
  21023. protected _currentRefreshId: number;
  21024. protected _refreshRate: number;
  21025. protected _textureMatrix: Matrix;
  21026. protected _samples: number;
  21027. protected _renderTargetOptions: RenderTargetCreationOptions;
  21028. /**
  21029. * Gets render target creation options that were used.
  21030. */
  21031. get renderTargetOptions(): RenderTargetCreationOptions;
  21032. protected _engine: Engine;
  21033. protected _onRatioRescale(): void;
  21034. /**
  21035. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21036. * It must define where the camera used to render the texture is set
  21037. */
  21038. boundingBoxPosition: Vector3;
  21039. private _boundingBoxSize;
  21040. /**
  21041. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21042. * When defined, the cubemap will switch to local mode
  21043. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21044. * @example https://www.babylonjs-playground.com/#RNASML
  21045. */
  21046. set boundingBoxSize(value: Vector3);
  21047. get boundingBoxSize(): Vector3;
  21048. /**
  21049. * In case the RTT has been created with a depth texture, get the associated
  21050. * depth texture.
  21051. * Otherwise, return null.
  21052. */
  21053. get depthStencilTexture(): Nullable<InternalTexture>;
  21054. /**
  21055. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21056. * or used a shadow, depth texture...
  21057. * @param name The friendly name of the texture
  21058. * @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)
  21059. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21060. * @param generateMipMaps True if mip maps need to be generated after render.
  21061. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21062. * @param type The type of the buffer in the RTT (int, half float, float...)
  21063. * @param isCube True if a cube texture needs to be created
  21064. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21065. * @param generateDepthBuffer True to generate a depth buffer
  21066. * @param generateStencilBuffer True to generate a stencil buffer
  21067. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21068. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21069. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21070. */
  21071. constructor(name: string, size: number | {
  21072. width: number;
  21073. height: number;
  21074. layers?: number;
  21075. } | {
  21076. ratio: number;
  21077. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21078. /**
  21079. * Creates a depth stencil texture.
  21080. * This is only available in WebGL 2 or with the depth texture extension available.
  21081. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21082. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21083. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21084. */
  21085. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21086. private _processSizeParameter;
  21087. /**
  21088. * Define the number of samples to use in case of MSAA.
  21089. * It defaults to one meaning no MSAA has been enabled.
  21090. */
  21091. get samples(): number;
  21092. set samples(value: number);
  21093. /**
  21094. * Resets the refresh counter of the texture and start bak from scratch.
  21095. * Could be useful to regenerate the texture if it is setup to render only once.
  21096. */
  21097. resetRefreshCounter(): void;
  21098. /**
  21099. * Define the refresh rate of the texture or the rendering frequency.
  21100. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21101. */
  21102. get refreshRate(): number;
  21103. set refreshRate(value: number);
  21104. /**
  21105. * Adds a post process to the render target rendering passes.
  21106. * @param postProcess define the post process to add
  21107. */
  21108. addPostProcess(postProcess: PostProcess): void;
  21109. /**
  21110. * Clear all the post processes attached to the render target
  21111. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21112. */
  21113. clearPostProcesses(dispose?: boolean): void;
  21114. /**
  21115. * Remove one of the post process from the list of attached post processes to the texture
  21116. * @param postProcess define the post process to remove from the list
  21117. */
  21118. removePostProcess(postProcess: PostProcess): void;
  21119. /** @hidden */
  21120. _shouldRender(): boolean;
  21121. /**
  21122. * Gets the actual render size of the texture.
  21123. * @returns the width of the render size
  21124. */
  21125. getRenderSize(): number;
  21126. /**
  21127. * Gets the actual render width of the texture.
  21128. * @returns the width of the render size
  21129. */
  21130. getRenderWidth(): number;
  21131. /**
  21132. * Gets the actual render height of the texture.
  21133. * @returns the height of the render size
  21134. */
  21135. getRenderHeight(): number;
  21136. /**
  21137. * Gets the actual number of layers of the texture.
  21138. * @returns the number of layers
  21139. */
  21140. getRenderLayers(): number;
  21141. /**
  21142. * Get if the texture can be rescaled or not.
  21143. */
  21144. get canRescale(): boolean;
  21145. /**
  21146. * Resize the texture using a ratio.
  21147. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21148. */
  21149. scale(ratio: number): void;
  21150. /**
  21151. * Get the texture reflection matrix used to rotate/transform the reflection.
  21152. * @returns the reflection matrix
  21153. */
  21154. getReflectionTextureMatrix(): Matrix;
  21155. /**
  21156. * Resize the texture to a new desired size.
  21157. * Be carrefull as it will recreate all the data in the new texture.
  21158. * @param size Define the new size. It can be:
  21159. * - a number for squared texture,
  21160. * - an object containing { width: number, height: number }
  21161. * - or an object containing a ratio { ratio: number }
  21162. */
  21163. resize(size: number | {
  21164. width: number;
  21165. height: number;
  21166. } | {
  21167. ratio: number;
  21168. }): void;
  21169. /**
  21170. * Renders all the objects from the render list into the texture.
  21171. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21172. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21173. */
  21174. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21175. private _bestReflectionRenderTargetDimension;
  21176. /**
  21177. * @hidden
  21178. * @param faceIndex face index to bind to if this is a cubetexture
  21179. * @param layer defines the index of the texture to bind in the array
  21180. */
  21181. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21182. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21183. private renderToTarget;
  21184. /**
  21185. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21186. * This allowed control for front to back rendering or reversly depending of the special needs.
  21187. *
  21188. * @param renderingGroupId The rendering group id corresponding to its index
  21189. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21190. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21191. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21192. */
  21193. 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;
  21194. /**
  21195. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21196. *
  21197. * @param renderingGroupId The rendering group id corresponding to its index
  21198. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21199. */
  21200. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21201. /**
  21202. * Clones the texture.
  21203. * @returns the cloned texture
  21204. */
  21205. clone(): RenderTargetTexture;
  21206. /**
  21207. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21208. * @returns The JSON representation of the texture
  21209. */
  21210. serialize(): any;
  21211. /**
  21212. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21213. */
  21214. disposeFramebufferObjects(): void;
  21215. /**
  21216. * Dispose the texture and release its associated resources.
  21217. */
  21218. dispose(): void;
  21219. /** @hidden */
  21220. _rebuild(): void;
  21221. /**
  21222. * Clear the info related to rendering groups preventing retention point in material dispose.
  21223. */
  21224. freeRenderingGroups(): void;
  21225. /**
  21226. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21227. * @returns the view count
  21228. */
  21229. getViewCount(): number;
  21230. }
  21231. }
  21232. declare module "babylonjs/Materials/material" {
  21233. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21234. import { SmartArray } from "babylonjs/Misc/smartArray";
  21235. import { Observable } from "babylonjs/Misc/observable";
  21236. import { Nullable } from "babylonjs/types";
  21237. import { Scene } from "babylonjs/scene";
  21238. import { Matrix } from "babylonjs/Maths/math.vector";
  21239. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21241. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21242. import { Effect } from "babylonjs/Materials/effect";
  21243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21244. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21245. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21246. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21247. import { Mesh } from "babylonjs/Meshes/mesh";
  21248. import { Animation } from "babylonjs/Animations/animation";
  21249. /**
  21250. * Options for compiling materials.
  21251. */
  21252. export interface IMaterialCompilationOptions {
  21253. /**
  21254. * Defines whether clip planes are enabled.
  21255. */
  21256. clipPlane: boolean;
  21257. /**
  21258. * Defines whether instances are enabled.
  21259. */
  21260. useInstances: boolean;
  21261. }
  21262. /**
  21263. * Base class for the main features of a material in Babylon.js
  21264. */
  21265. export class Material implements IAnimatable {
  21266. /**
  21267. * Returns the triangle fill mode
  21268. */
  21269. static readonly TriangleFillMode: number;
  21270. /**
  21271. * Returns the wireframe mode
  21272. */
  21273. static readonly WireFrameFillMode: number;
  21274. /**
  21275. * Returns the point fill mode
  21276. */
  21277. static readonly PointFillMode: number;
  21278. /**
  21279. * Returns the point list draw mode
  21280. */
  21281. static readonly PointListDrawMode: number;
  21282. /**
  21283. * Returns the line list draw mode
  21284. */
  21285. static readonly LineListDrawMode: number;
  21286. /**
  21287. * Returns the line loop draw mode
  21288. */
  21289. static readonly LineLoopDrawMode: number;
  21290. /**
  21291. * Returns the line strip draw mode
  21292. */
  21293. static readonly LineStripDrawMode: number;
  21294. /**
  21295. * Returns the triangle strip draw mode
  21296. */
  21297. static readonly TriangleStripDrawMode: number;
  21298. /**
  21299. * Returns the triangle fan draw mode
  21300. */
  21301. static readonly TriangleFanDrawMode: number;
  21302. /**
  21303. * Stores the clock-wise side orientation
  21304. */
  21305. static readonly ClockWiseSideOrientation: number;
  21306. /**
  21307. * Stores the counter clock-wise side orientation
  21308. */
  21309. static readonly CounterClockWiseSideOrientation: number;
  21310. /**
  21311. * The dirty texture flag value
  21312. */
  21313. static readonly TextureDirtyFlag: number;
  21314. /**
  21315. * The dirty light flag value
  21316. */
  21317. static readonly LightDirtyFlag: number;
  21318. /**
  21319. * The dirty fresnel flag value
  21320. */
  21321. static readonly FresnelDirtyFlag: number;
  21322. /**
  21323. * The dirty attribute flag value
  21324. */
  21325. static readonly AttributesDirtyFlag: number;
  21326. /**
  21327. * The dirty misc flag value
  21328. */
  21329. static readonly MiscDirtyFlag: number;
  21330. /**
  21331. * The all dirty flag value
  21332. */
  21333. static readonly AllDirtyFlag: number;
  21334. /**
  21335. * The ID of the material
  21336. */
  21337. id: string;
  21338. /**
  21339. * Gets or sets the unique id of the material
  21340. */
  21341. uniqueId: number;
  21342. /**
  21343. * The name of the material
  21344. */
  21345. name: string;
  21346. /**
  21347. * Gets or sets user defined metadata
  21348. */
  21349. metadata: any;
  21350. /**
  21351. * For internal use only. Please do not use.
  21352. */
  21353. reservedDataStore: any;
  21354. /**
  21355. * Specifies if the ready state should be checked on each call
  21356. */
  21357. checkReadyOnEveryCall: boolean;
  21358. /**
  21359. * Specifies if the ready state should be checked once
  21360. */
  21361. checkReadyOnlyOnce: boolean;
  21362. /**
  21363. * The state of the material
  21364. */
  21365. state: string;
  21366. /**
  21367. * The alpha value of the material
  21368. */
  21369. protected _alpha: number;
  21370. /**
  21371. * List of inspectable custom properties (used by the Inspector)
  21372. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21373. */
  21374. inspectableCustomProperties: IInspectable[];
  21375. /**
  21376. * Sets the alpha value of the material
  21377. */
  21378. set alpha(value: number);
  21379. /**
  21380. * Gets the alpha value of the material
  21381. */
  21382. get alpha(): number;
  21383. /**
  21384. * Specifies if back face culling is enabled
  21385. */
  21386. protected _backFaceCulling: boolean;
  21387. /**
  21388. * Sets the back-face culling state
  21389. */
  21390. set backFaceCulling(value: boolean);
  21391. /**
  21392. * Gets the back-face culling state
  21393. */
  21394. get backFaceCulling(): boolean;
  21395. /**
  21396. * Stores the value for side orientation
  21397. */
  21398. sideOrientation: number;
  21399. /**
  21400. * Callback triggered when the material is compiled
  21401. */
  21402. onCompiled: Nullable<(effect: Effect) => void>;
  21403. /**
  21404. * Callback triggered when an error occurs
  21405. */
  21406. onError: Nullable<(effect: Effect, errors: string) => void>;
  21407. /**
  21408. * Callback triggered to get the render target textures
  21409. */
  21410. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21411. /**
  21412. * Gets a boolean indicating that current material needs to register RTT
  21413. */
  21414. get hasRenderTargetTextures(): boolean;
  21415. /**
  21416. * Specifies if the material should be serialized
  21417. */
  21418. doNotSerialize: boolean;
  21419. /**
  21420. * @hidden
  21421. */
  21422. _storeEffectOnSubMeshes: boolean;
  21423. /**
  21424. * Stores the animations for the material
  21425. */
  21426. animations: Nullable<Array<Animation>>;
  21427. /**
  21428. * An event triggered when the material is disposed
  21429. */
  21430. onDisposeObservable: Observable<Material>;
  21431. /**
  21432. * An observer which watches for dispose events
  21433. */
  21434. private _onDisposeObserver;
  21435. private _onUnBindObservable;
  21436. /**
  21437. * Called during a dispose event
  21438. */
  21439. set onDispose(callback: () => void);
  21440. private _onBindObservable;
  21441. /**
  21442. * An event triggered when the material is bound
  21443. */
  21444. get onBindObservable(): Observable<AbstractMesh>;
  21445. /**
  21446. * An observer which watches for bind events
  21447. */
  21448. private _onBindObserver;
  21449. /**
  21450. * Called during a bind event
  21451. */
  21452. set onBind(callback: (Mesh: AbstractMesh) => void);
  21453. /**
  21454. * An event triggered when the material is unbound
  21455. */
  21456. get onUnBindObservable(): Observable<Material>;
  21457. /**
  21458. * Stores the value of the alpha mode
  21459. */
  21460. private _alphaMode;
  21461. /**
  21462. * Sets the value of the alpha mode.
  21463. *
  21464. * | Value | Type | Description |
  21465. * | --- | --- | --- |
  21466. * | 0 | ALPHA_DISABLE | |
  21467. * | 1 | ALPHA_ADD | |
  21468. * | 2 | ALPHA_COMBINE | |
  21469. * | 3 | ALPHA_SUBTRACT | |
  21470. * | 4 | ALPHA_MULTIPLY | |
  21471. * | 5 | ALPHA_MAXIMIZED | |
  21472. * | 6 | ALPHA_ONEONE | |
  21473. * | 7 | ALPHA_PREMULTIPLIED | |
  21474. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21475. * | 9 | ALPHA_INTERPOLATE | |
  21476. * | 10 | ALPHA_SCREENMODE | |
  21477. *
  21478. */
  21479. set alphaMode(value: number);
  21480. /**
  21481. * Gets the value of the alpha mode
  21482. */
  21483. get alphaMode(): number;
  21484. /**
  21485. * Stores the state of the need depth pre-pass value
  21486. */
  21487. private _needDepthPrePass;
  21488. /**
  21489. * Sets the need depth pre-pass value
  21490. */
  21491. set needDepthPrePass(value: boolean);
  21492. /**
  21493. * Gets the depth pre-pass value
  21494. */
  21495. get needDepthPrePass(): boolean;
  21496. /**
  21497. * Specifies if depth writing should be disabled
  21498. */
  21499. disableDepthWrite: boolean;
  21500. /**
  21501. * Specifies if depth writing should be forced
  21502. */
  21503. forceDepthWrite: boolean;
  21504. /**
  21505. * Specifies the depth function that should be used. 0 means the default engine function
  21506. */
  21507. depthFunction: number;
  21508. /**
  21509. * Specifies if there should be a separate pass for culling
  21510. */
  21511. separateCullingPass: boolean;
  21512. /**
  21513. * Stores the state specifing if fog should be enabled
  21514. */
  21515. private _fogEnabled;
  21516. /**
  21517. * Sets the state for enabling fog
  21518. */
  21519. set fogEnabled(value: boolean);
  21520. /**
  21521. * Gets the value of the fog enabled state
  21522. */
  21523. get fogEnabled(): boolean;
  21524. /**
  21525. * Stores the size of points
  21526. */
  21527. pointSize: number;
  21528. /**
  21529. * Stores the z offset value
  21530. */
  21531. zOffset: number;
  21532. /**
  21533. * Gets a value specifying if wireframe mode is enabled
  21534. */
  21535. get wireframe(): boolean;
  21536. /**
  21537. * Sets the state of wireframe mode
  21538. */
  21539. set wireframe(value: boolean);
  21540. /**
  21541. * Gets the value specifying if point clouds are enabled
  21542. */
  21543. get pointsCloud(): boolean;
  21544. /**
  21545. * Sets the state of point cloud mode
  21546. */
  21547. set pointsCloud(value: boolean);
  21548. /**
  21549. * Gets the material fill mode
  21550. */
  21551. get fillMode(): number;
  21552. /**
  21553. * Sets the material fill mode
  21554. */
  21555. set fillMode(value: number);
  21556. /**
  21557. * @hidden
  21558. * Stores the effects for the material
  21559. */
  21560. _effect: Nullable<Effect>;
  21561. /**
  21562. * Specifies if uniform buffers should be used
  21563. */
  21564. private _useUBO;
  21565. /**
  21566. * Stores a reference to the scene
  21567. */
  21568. private _scene;
  21569. /**
  21570. * Stores the fill mode state
  21571. */
  21572. private _fillMode;
  21573. /**
  21574. * Specifies if the depth write state should be cached
  21575. */
  21576. private _cachedDepthWriteState;
  21577. /**
  21578. * Specifies if the depth function state should be cached
  21579. */
  21580. private _cachedDepthFunctionState;
  21581. /**
  21582. * Stores the uniform buffer
  21583. */
  21584. protected _uniformBuffer: UniformBuffer;
  21585. /** @hidden */
  21586. _indexInSceneMaterialArray: number;
  21587. /** @hidden */
  21588. meshMap: Nullable<{
  21589. [id: string]: AbstractMesh | undefined;
  21590. }>;
  21591. /**
  21592. * Creates a material instance
  21593. * @param name defines the name of the material
  21594. * @param scene defines the scene to reference
  21595. * @param doNotAdd specifies if the material should be added to the scene
  21596. */
  21597. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21598. /**
  21599. * Returns a string representation of the current material
  21600. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21601. * @returns a string with material information
  21602. */
  21603. toString(fullDetails?: boolean): string;
  21604. /**
  21605. * Gets the class name of the material
  21606. * @returns a string with the class name of the material
  21607. */
  21608. getClassName(): string;
  21609. /**
  21610. * Specifies if updates for the material been locked
  21611. */
  21612. get isFrozen(): boolean;
  21613. /**
  21614. * Locks updates for the material
  21615. */
  21616. freeze(): void;
  21617. /**
  21618. * Unlocks updates for the material
  21619. */
  21620. unfreeze(): void;
  21621. /**
  21622. * Specifies if the material is ready to be used
  21623. * @param mesh defines the mesh to check
  21624. * @param useInstances specifies if instances should be used
  21625. * @returns a boolean indicating if the material is ready to be used
  21626. */
  21627. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21628. /**
  21629. * Specifies that the submesh is ready to be used
  21630. * @param mesh defines the mesh to check
  21631. * @param subMesh defines which submesh to check
  21632. * @param useInstances specifies that instances should be used
  21633. * @returns a boolean indicating that the submesh is ready or not
  21634. */
  21635. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21636. /**
  21637. * Returns the material effect
  21638. * @returns the effect associated with the material
  21639. */
  21640. getEffect(): Nullable<Effect>;
  21641. /**
  21642. * Returns the current scene
  21643. * @returns a Scene
  21644. */
  21645. getScene(): Scene;
  21646. /**
  21647. * Specifies if the material will require alpha blending
  21648. * @returns a boolean specifying if alpha blending is needed
  21649. */
  21650. needAlphaBlending(): boolean;
  21651. /**
  21652. * Specifies if the mesh will require alpha blending
  21653. * @param mesh defines the mesh to check
  21654. * @returns a boolean specifying if alpha blending is needed for the mesh
  21655. */
  21656. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21657. /**
  21658. * Specifies if this material should be rendered in alpha test mode
  21659. * @returns a boolean specifying if an alpha test is needed.
  21660. */
  21661. needAlphaTesting(): boolean;
  21662. /**
  21663. * Gets the texture used for the alpha test
  21664. * @returns the texture to use for alpha testing
  21665. */
  21666. getAlphaTestTexture(): Nullable<BaseTexture>;
  21667. /**
  21668. * Marks the material to indicate that it needs to be re-calculated
  21669. */
  21670. markDirty(): void;
  21671. /** @hidden */
  21672. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21673. /**
  21674. * Binds the material to the mesh
  21675. * @param world defines the world transformation matrix
  21676. * @param mesh defines the mesh to bind the material to
  21677. */
  21678. bind(world: Matrix, mesh?: Mesh): void;
  21679. /**
  21680. * Binds the submesh to the material
  21681. * @param world defines the world transformation matrix
  21682. * @param mesh defines the mesh containing the submesh
  21683. * @param subMesh defines the submesh to bind the material to
  21684. */
  21685. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21686. /**
  21687. * Binds the world matrix to the material
  21688. * @param world defines the world transformation matrix
  21689. */
  21690. bindOnlyWorldMatrix(world: Matrix): void;
  21691. /**
  21692. * Binds the scene's uniform buffer to the effect.
  21693. * @param effect defines the effect to bind to the scene uniform buffer
  21694. * @param sceneUbo defines the uniform buffer storing scene data
  21695. */
  21696. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21697. /**
  21698. * Binds the view matrix to the effect
  21699. * @param effect defines the effect to bind the view matrix to
  21700. */
  21701. bindView(effect: Effect): void;
  21702. /**
  21703. * Binds the view projection matrix to the effect
  21704. * @param effect defines the effect to bind the view projection matrix to
  21705. */
  21706. bindViewProjection(effect: Effect): void;
  21707. /**
  21708. * Specifies if material alpha testing should be turned on for the mesh
  21709. * @param mesh defines the mesh to check
  21710. */
  21711. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21712. /**
  21713. * Processes to execute after binding the material to a mesh
  21714. * @param mesh defines the rendered mesh
  21715. */
  21716. protected _afterBind(mesh?: Mesh): void;
  21717. /**
  21718. * Unbinds the material from the mesh
  21719. */
  21720. unbind(): void;
  21721. /**
  21722. * Gets the active textures from the material
  21723. * @returns an array of textures
  21724. */
  21725. getActiveTextures(): BaseTexture[];
  21726. /**
  21727. * Specifies if the material uses a texture
  21728. * @param texture defines the texture to check against the material
  21729. * @returns a boolean specifying if the material uses the texture
  21730. */
  21731. hasTexture(texture: BaseTexture): boolean;
  21732. /**
  21733. * Makes a duplicate of the material, and gives it a new name
  21734. * @param name defines the new name for the duplicated material
  21735. * @returns the cloned material
  21736. */
  21737. clone(name: string): Nullable<Material>;
  21738. /**
  21739. * Gets the meshes bound to the material
  21740. * @returns an array of meshes bound to the material
  21741. */
  21742. getBindedMeshes(): AbstractMesh[];
  21743. /**
  21744. * Force shader compilation
  21745. * @param mesh defines the mesh associated with this material
  21746. * @param onCompiled defines a function to execute once the material is compiled
  21747. * @param options defines the options to configure the compilation
  21748. * @param onError defines a function to execute if the material fails compiling
  21749. */
  21750. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21751. /**
  21752. * Force shader compilation
  21753. * @param mesh defines the mesh that will use this material
  21754. * @param options defines additional options for compiling the shaders
  21755. * @returns a promise that resolves when the compilation completes
  21756. */
  21757. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21758. private static readonly _AllDirtyCallBack;
  21759. private static readonly _ImageProcessingDirtyCallBack;
  21760. private static readonly _TextureDirtyCallBack;
  21761. private static readonly _FresnelDirtyCallBack;
  21762. private static readonly _MiscDirtyCallBack;
  21763. private static readonly _LightsDirtyCallBack;
  21764. private static readonly _AttributeDirtyCallBack;
  21765. private static _FresnelAndMiscDirtyCallBack;
  21766. private static _TextureAndMiscDirtyCallBack;
  21767. private static readonly _DirtyCallbackArray;
  21768. private static readonly _RunDirtyCallBacks;
  21769. /**
  21770. * Marks a define in the material to indicate that it needs to be re-computed
  21771. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21772. */
  21773. markAsDirty(flag: number): void;
  21774. /**
  21775. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21776. * @param func defines a function which checks material defines against the submeshes
  21777. */
  21778. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21779. /**
  21780. * Indicates that we need to re-calculated for all submeshes
  21781. */
  21782. protected _markAllSubMeshesAsAllDirty(): void;
  21783. /**
  21784. * Indicates that image processing needs to be re-calculated for all submeshes
  21785. */
  21786. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21787. /**
  21788. * Indicates that textures need to be re-calculated for all submeshes
  21789. */
  21790. protected _markAllSubMeshesAsTexturesDirty(): void;
  21791. /**
  21792. * Indicates that fresnel needs to be re-calculated for all submeshes
  21793. */
  21794. protected _markAllSubMeshesAsFresnelDirty(): void;
  21795. /**
  21796. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21797. */
  21798. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21799. /**
  21800. * Indicates that lights need to be re-calculated for all submeshes
  21801. */
  21802. protected _markAllSubMeshesAsLightsDirty(): void;
  21803. /**
  21804. * Indicates that attributes need to be re-calculated for all submeshes
  21805. */
  21806. protected _markAllSubMeshesAsAttributesDirty(): void;
  21807. /**
  21808. * Indicates that misc needs to be re-calculated for all submeshes
  21809. */
  21810. protected _markAllSubMeshesAsMiscDirty(): void;
  21811. /**
  21812. * Indicates that textures and misc need to be re-calculated for all submeshes
  21813. */
  21814. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21815. /**
  21816. * Disposes the material
  21817. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21818. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21819. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21820. */
  21821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21822. /** @hidden */
  21823. private releaseVertexArrayObject;
  21824. /**
  21825. * Serializes this material
  21826. * @returns the serialized material object
  21827. */
  21828. serialize(): any;
  21829. /**
  21830. * Creates a material from parsed material data
  21831. * @param parsedMaterial defines parsed material data
  21832. * @param scene defines the hosting scene
  21833. * @param rootUrl defines the root URL to use to load textures
  21834. * @returns a new material
  21835. */
  21836. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21837. }
  21838. }
  21839. declare module "babylonjs/Materials/multiMaterial" {
  21840. import { Nullable } from "babylonjs/types";
  21841. import { Scene } from "babylonjs/scene";
  21842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21843. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21845. import { Material } from "babylonjs/Materials/material";
  21846. /**
  21847. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21848. * separate meshes. This can be use to improve performances.
  21849. * @see http://doc.babylonjs.com/how_to/multi_materials
  21850. */
  21851. export class MultiMaterial extends Material {
  21852. private _subMaterials;
  21853. /**
  21854. * Gets or Sets the list of Materials used within the multi material.
  21855. * They need to be ordered according to the submeshes order in the associated mesh
  21856. */
  21857. get subMaterials(): Nullable<Material>[];
  21858. set subMaterials(value: Nullable<Material>[]);
  21859. /**
  21860. * Function used to align with Node.getChildren()
  21861. * @returns the list of Materials used within the multi material
  21862. */
  21863. getChildren(): Nullable<Material>[];
  21864. /**
  21865. * Instantiates a new Multi Material
  21866. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21867. * separate meshes. This can be use to improve performances.
  21868. * @see http://doc.babylonjs.com/how_to/multi_materials
  21869. * @param name Define the name in the scene
  21870. * @param scene Define the scene the material belongs to
  21871. */
  21872. constructor(name: string, scene: Scene);
  21873. private _hookArray;
  21874. /**
  21875. * Get one of the submaterial by its index in the submaterials array
  21876. * @param index The index to look the sub material at
  21877. * @returns The Material if the index has been defined
  21878. */
  21879. getSubMaterial(index: number): Nullable<Material>;
  21880. /**
  21881. * Get the list of active textures for the whole sub materials list.
  21882. * @returns All the textures that will be used during the rendering
  21883. */
  21884. getActiveTextures(): BaseTexture[];
  21885. /**
  21886. * Gets the current class name of the material e.g. "MultiMaterial"
  21887. * Mainly use in serialization.
  21888. * @returns the class name
  21889. */
  21890. getClassName(): string;
  21891. /**
  21892. * Checks if the material is ready to render the requested sub mesh
  21893. * @param mesh Define the mesh the submesh belongs to
  21894. * @param subMesh Define the sub mesh to look readyness for
  21895. * @param useInstances Define whether or not the material is used with instances
  21896. * @returns true if ready, otherwise false
  21897. */
  21898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21899. /**
  21900. * Clones the current material and its related sub materials
  21901. * @param name Define the name of the newly cloned material
  21902. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21903. * @returns the cloned material
  21904. */
  21905. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21906. /**
  21907. * Serializes the materials into a JSON representation.
  21908. * @returns the JSON representation
  21909. */
  21910. serialize(): any;
  21911. /**
  21912. * Dispose the material and release its associated resources
  21913. * @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)
  21914. * @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)
  21915. * @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)
  21916. */
  21917. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21918. /**
  21919. * Creates a MultiMaterial from parsed MultiMaterial data.
  21920. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21921. * @param scene defines the hosting scene
  21922. * @returns a new MultiMaterial
  21923. */
  21924. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21925. }
  21926. }
  21927. declare module "babylonjs/Meshes/subMesh" {
  21928. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21929. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21930. import { Engine } from "babylonjs/Engines/engine";
  21931. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21932. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21933. import { Effect } from "babylonjs/Materials/effect";
  21934. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21935. import { Plane } from "babylonjs/Maths/math.plane";
  21936. import { Collider } from "babylonjs/Collisions/collider";
  21937. import { Material } from "babylonjs/Materials/material";
  21938. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21940. import { Mesh } from "babylonjs/Meshes/mesh";
  21941. import { Ray } from "babylonjs/Culling/ray";
  21942. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21943. /**
  21944. * Base class for submeshes
  21945. */
  21946. export class BaseSubMesh {
  21947. /** @hidden */
  21948. _materialDefines: Nullable<MaterialDefines>;
  21949. /** @hidden */
  21950. _materialEffect: Nullable<Effect>;
  21951. /**
  21952. * Gets material defines used by the effect associated to the sub mesh
  21953. */
  21954. get materialDefines(): Nullable<MaterialDefines>;
  21955. /**
  21956. * Sets material defines used by the effect associated to the sub mesh
  21957. */
  21958. set materialDefines(defines: Nullable<MaterialDefines>);
  21959. /**
  21960. * Gets associated effect
  21961. */
  21962. get effect(): Nullable<Effect>;
  21963. /**
  21964. * Sets associated effect (effect used to render this submesh)
  21965. * @param effect defines the effect to associate with
  21966. * @param defines defines the set of defines used to compile this effect
  21967. */
  21968. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21969. }
  21970. /**
  21971. * Defines a subdivision inside a mesh
  21972. */
  21973. export class SubMesh extends BaseSubMesh implements ICullable {
  21974. /** the material index to use */
  21975. materialIndex: number;
  21976. /** vertex index start */
  21977. verticesStart: number;
  21978. /** vertices count */
  21979. verticesCount: number;
  21980. /** index start */
  21981. indexStart: number;
  21982. /** indices count */
  21983. indexCount: number;
  21984. /** @hidden */
  21985. _linesIndexCount: number;
  21986. private _mesh;
  21987. private _renderingMesh;
  21988. private _boundingInfo;
  21989. private _linesIndexBuffer;
  21990. /** @hidden */
  21991. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21992. /** @hidden */
  21993. _trianglePlanes: Plane[];
  21994. /** @hidden */
  21995. _lastColliderTransformMatrix: Nullable<Matrix>;
  21996. /** @hidden */
  21997. _renderId: number;
  21998. /** @hidden */
  21999. _alphaIndex: number;
  22000. /** @hidden */
  22001. _distanceToCamera: number;
  22002. /** @hidden */
  22003. _id: number;
  22004. private _currentMaterial;
  22005. /**
  22006. * Add a new submesh to a mesh
  22007. * @param materialIndex defines the material index to use
  22008. * @param verticesStart defines vertex index start
  22009. * @param verticesCount defines vertices count
  22010. * @param indexStart defines index start
  22011. * @param indexCount defines indices count
  22012. * @param mesh defines the parent mesh
  22013. * @param renderingMesh defines an optional rendering mesh
  22014. * @param createBoundingBox defines if bounding box should be created for this submesh
  22015. * @returns the new submesh
  22016. */
  22017. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22018. /**
  22019. * Creates a new submesh
  22020. * @param materialIndex defines the material index to use
  22021. * @param verticesStart defines vertex index start
  22022. * @param verticesCount defines vertices count
  22023. * @param indexStart defines index start
  22024. * @param indexCount defines indices count
  22025. * @param mesh defines the parent mesh
  22026. * @param renderingMesh defines an optional rendering mesh
  22027. * @param createBoundingBox defines if bounding box should be created for this submesh
  22028. */
  22029. constructor(
  22030. /** the material index to use */
  22031. materialIndex: number,
  22032. /** vertex index start */
  22033. verticesStart: number,
  22034. /** vertices count */
  22035. verticesCount: number,
  22036. /** index start */
  22037. indexStart: number,
  22038. /** indices count */
  22039. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22040. /**
  22041. * Returns true if this submesh covers the entire parent mesh
  22042. * @ignorenaming
  22043. */
  22044. get IsGlobal(): boolean;
  22045. /**
  22046. * Returns the submesh BoudingInfo object
  22047. * @returns current bounding info (or mesh's one if the submesh is global)
  22048. */
  22049. getBoundingInfo(): BoundingInfo;
  22050. /**
  22051. * Sets the submesh BoundingInfo
  22052. * @param boundingInfo defines the new bounding info to use
  22053. * @returns the SubMesh
  22054. */
  22055. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22056. /**
  22057. * Returns the mesh of the current submesh
  22058. * @return the parent mesh
  22059. */
  22060. getMesh(): AbstractMesh;
  22061. /**
  22062. * Returns the rendering mesh of the submesh
  22063. * @returns the rendering mesh (could be different from parent mesh)
  22064. */
  22065. getRenderingMesh(): Mesh;
  22066. /**
  22067. * Returns the submesh material
  22068. * @returns null or the current material
  22069. */
  22070. getMaterial(): Nullable<Material>;
  22071. /**
  22072. * Sets a new updated BoundingInfo object to the submesh
  22073. * @param data defines an optional position array to use to determine the bounding info
  22074. * @returns the SubMesh
  22075. */
  22076. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22077. /** @hidden */
  22078. _checkCollision(collider: Collider): boolean;
  22079. /**
  22080. * Updates the submesh BoundingInfo
  22081. * @param world defines the world matrix to use to update the bounding info
  22082. * @returns the submesh
  22083. */
  22084. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22085. /**
  22086. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22087. * @param frustumPlanes defines the frustum planes
  22088. * @returns true if the submesh is intersecting with the frustum
  22089. */
  22090. isInFrustum(frustumPlanes: Plane[]): boolean;
  22091. /**
  22092. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22093. * @param frustumPlanes defines the frustum planes
  22094. * @returns true if the submesh is inside the frustum
  22095. */
  22096. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22097. /**
  22098. * Renders the submesh
  22099. * @param enableAlphaMode defines if alpha needs to be used
  22100. * @returns the submesh
  22101. */
  22102. render(enableAlphaMode: boolean): SubMesh;
  22103. /**
  22104. * @hidden
  22105. */
  22106. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22107. /**
  22108. * Checks if the submesh intersects with a ray
  22109. * @param ray defines the ray to test
  22110. * @returns true is the passed ray intersects the submesh bounding box
  22111. */
  22112. canIntersects(ray: Ray): boolean;
  22113. /**
  22114. * Intersects current submesh with a ray
  22115. * @param ray defines the ray to test
  22116. * @param positions defines mesh's positions array
  22117. * @param indices defines mesh's indices array
  22118. * @param fastCheck defines if only bounding info should be used
  22119. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22120. * @returns intersection info or null if no intersection
  22121. */
  22122. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22123. /** @hidden */
  22124. private _intersectLines;
  22125. /** @hidden */
  22126. private _intersectUnIndexedLines;
  22127. /** @hidden */
  22128. private _intersectTriangles;
  22129. /** @hidden */
  22130. private _intersectUnIndexedTriangles;
  22131. /** @hidden */
  22132. _rebuild(): void;
  22133. /**
  22134. * Creates a new submesh from the passed mesh
  22135. * @param newMesh defines the new hosting mesh
  22136. * @param newRenderingMesh defines an optional rendering mesh
  22137. * @returns the new submesh
  22138. */
  22139. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22140. /**
  22141. * Release associated resources
  22142. */
  22143. dispose(): void;
  22144. /**
  22145. * Gets the class name
  22146. * @returns the string "SubMesh".
  22147. */
  22148. getClassName(): string;
  22149. /**
  22150. * Creates a new submesh from indices data
  22151. * @param materialIndex the index of the main mesh material
  22152. * @param startIndex the index where to start the copy in the mesh indices array
  22153. * @param indexCount the number of indices to copy then from the startIndex
  22154. * @param mesh the main mesh to create the submesh from
  22155. * @param renderingMesh the optional rendering mesh
  22156. * @returns a new submesh
  22157. */
  22158. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22159. }
  22160. }
  22161. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22162. /**
  22163. * Class used to represent data loading progression
  22164. */
  22165. export class SceneLoaderFlags {
  22166. private static _ForceFullSceneLoadingForIncremental;
  22167. private static _ShowLoadingScreen;
  22168. private static _CleanBoneMatrixWeights;
  22169. private static _loggingLevel;
  22170. /**
  22171. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22172. */
  22173. static get ForceFullSceneLoadingForIncremental(): boolean;
  22174. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22175. /**
  22176. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22177. */
  22178. static get ShowLoadingScreen(): boolean;
  22179. static set ShowLoadingScreen(value: boolean);
  22180. /**
  22181. * Defines the current logging level (while loading the scene)
  22182. * @ignorenaming
  22183. */
  22184. static get loggingLevel(): number;
  22185. static set loggingLevel(value: number);
  22186. /**
  22187. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22188. */
  22189. static get CleanBoneMatrixWeights(): boolean;
  22190. static set CleanBoneMatrixWeights(value: boolean);
  22191. }
  22192. }
  22193. declare module "babylonjs/Meshes/geometry" {
  22194. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22195. import { Scene } from "babylonjs/scene";
  22196. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22197. import { Engine } from "babylonjs/Engines/engine";
  22198. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22199. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22200. import { Effect } from "babylonjs/Materials/effect";
  22201. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22202. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22203. import { Mesh } from "babylonjs/Meshes/mesh";
  22204. /**
  22205. * Class used to store geometry data (vertex buffers + index buffer)
  22206. */
  22207. export class Geometry implements IGetSetVerticesData {
  22208. /**
  22209. * Gets or sets the ID of the geometry
  22210. */
  22211. id: string;
  22212. /**
  22213. * Gets or sets the unique ID of the geometry
  22214. */
  22215. uniqueId: number;
  22216. /**
  22217. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22218. */
  22219. delayLoadState: number;
  22220. /**
  22221. * Gets the file containing the data to load when running in delay load state
  22222. */
  22223. delayLoadingFile: Nullable<string>;
  22224. /**
  22225. * Callback called when the geometry is updated
  22226. */
  22227. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22228. private _scene;
  22229. private _engine;
  22230. private _meshes;
  22231. private _totalVertices;
  22232. /** @hidden */
  22233. _indices: IndicesArray;
  22234. /** @hidden */
  22235. _vertexBuffers: {
  22236. [key: string]: VertexBuffer;
  22237. };
  22238. private _isDisposed;
  22239. private _extend;
  22240. private _boundingBias;
  22241. /** @hidden */
  22242. _delayInfo: Array<string>;
  22243. private _indexBuffer;
  22244. private _indexBufferIsUpdatable;
  22245. /** @hidden */
  22246. _boundingInfo: Nullable<BoundingInfo>;
  22247. /** @hidden */
  22248. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22249. /** @hidden */
  22250. _softwareSkinningFrameId: number;
  22251. private _vertexArrayObjects;
  22252. private _updatable;
  22253. /** @hidden */
  22254. _positions: Nullable<Vector3[]>;
  22255. /**
  22256. * 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
  22257. */
  22258. get boundingBias(): Vector2;
  22259. /**
  22260. * 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
  22261. */
  22262. set boundingBias(value: Vector2);
  22263. /**
  22264. * Static function used to attach a new empty geometry to a mesh
  22265. * @param mesh defines the mesh to attach the geometry to
  22266. * @returns the new Geometry
  22267. */
  22268. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22269. /**
  22270. * Creates a new geometry
  22271. * @param id defines the unique ID
  22272. * @param scene defines the hosting scene
  22273. * @param vertexData defines the VertexData used to get geometry data
  22274. * @param updatable defines if geometry must be updatable (false by default)
  22275. * @param mesh defines the mesh that will be associated with the geometry
  22276. */
  22277. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22278. /**
  22279. * Gets the current extend of the geometry
  22280. */
  22281. get extend(): {
  22282. minimum: Vector3;
  22283. maximum: Vector3;
  22284. };
  22285. /**
  22286. * Gets the hosting scene
  22287. * @returns the hosting Scene
  22288. */
  22289. getScene(): Scene;
  22290. /**
  22291. * Gets the hosting engine
  22292. * @returns the hosting Engine
  22293. */
  22294. getEngine(): Engine;
  22295. /**
  22296. * Defines if the geometry is ready to use
  22297. * @returns true if the geometry is ready to be used
  22298. */
  22299. isReady(): boolean;
  22300. /**
  22301. * Gets a value indicating that the geometry should not be serialized
  22302. */
  22303. get doNotSerialize(): boolean;
  22304. /** @hidden */
  22305. _rebuild(): void;
  22306. /**
  22307. * Affects all geometry data in one call
  22308. * @param vertexData defines the geometry data
  22309. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22310. */
  22311. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22312. /**
  22313. * Set specific vertex data
  22314. * @param kind defines the data kind (Position, normal, etc...)
  22315. * @param data defines the vertex data to use
  22316. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22317. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22318. */
  22319. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22320. /**
  22321. * Removes a specific vertex data
  22322. * @param kind defines the data kind (Position, normal, etc...)
  22323. */
  22324. removeVerticesData(kind: string): void;
  22325. /**
  22326. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22327. * @param buffer defines the vertex buffer to use
  22328. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22329. */
  22330. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22331. /**
  22332. * Update a specific vertex buffer
  22333. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22334. * It will do nothing if the buffer is not updatable
  22335. * @param kind defines the data kind (Position, normal, etc...)
  22336. * @param data defines the data to use
  22337. * @param offset defines the offset in the target buffer where to store the data
  22338. * @param useBytes set to true if the offset is in bytes
  22339. */
  22340. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22341. /**
  22342. * Update a specific vertex buffer
  22343. * This function will create a new buffer if the current one is not updatable
  22344. * @param kind defines the data kind (Position, normal, etc...)
  22345. * @param data defines the data to use
  22346. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22347. */
  22348. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22349. private _updateBoundingInfo;
  22350. /** @hidden */
  22351. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22352. /**
  22353. * Gets total number of vertices
  22354. * @returns the total number of vertices
  22355. */
  22356. getTotalVertices(): number;
  22357. /**
  22358. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22359. * @param kind defines the data kind (Position, normal, etc...)
  22360. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22361. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22362. * @returns a float array containing vertex data
  22363. */
  22364. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22365. /**
  22366. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22367. * @param kind defines the data kind (Position, normal, etc...)
  22368. * @returns true if the vertex buffer with the specified kind is updatable
  22369. */
  22370. isVertexBufferUpdatable(kind: string): boolean;
  22371. /**
  22372. * Gets a specific vertex buffer
  22373. * @param kind defines the data kind (Position, normal, etc...)
  22374. * @returns a VertexBuffer
  22375. */
  22376. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22377. /**
  22378. * Returns all vertex buffers
  22379. * @return an object holding all vertex buffers indexed by kind
  22380. */
  22381. getVertexBuffers(): Nullable<{
  22382. [key: string]: VertexBuffer;
  22383. }>;
  22384. /**
  22385. * Gets a boolean indicating if specific vertex buffer is present
  22386. * @param kind defines the data kind (Position, normal, etc...)
  22387. * @returns true if data is present
  22388. */
  22389. isVerticesDataPresent(kind: string): boolean;
  22390. /**
  22391. * Gets a list of all attached data kinds (Position, normal, etc...)
  22392. * @returns a list of string containing all kinds
  22393. */
  22394. getVerticesDataKinds(): string[];
  22395. /**
  22396. * Update index buffer
  22397. * @param indices defines the indices to store in the index buffer
  22398. * @param offset defines the offset in the target buffer where to store the data
  22399. * @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)
  22400. */
  22401. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22402. /**
  22403. * Creates a new index buffer
  22404. * @param indices defines the indices to store in the index buffer
  22405. * @param totalVertices defines the total number of vertices (could be null)
  22406. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22407. */
  22408. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22409. /**
  22410. * Return the total number of indices
  22411. * @returns the total number of indices
  22412. */
  22413. getTotalIndices(): number;
  22414. /**
  22415. * Gets the index buffer array
  22416. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22417. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22418. * @returns the index buffer array
  22419. */
  22420. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22421. /**
  22422. * Gets the index buffer
  22423. * @return the index buffer
  22424. */
  22425. getIndexBuffer(): Nullable<DataBuffer>;
  22426. /** @hidden */
  22427. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22428. /**
  22429. * Release the associated resources for a specific mesh
  22430. * @param mesh defines the source mesh
  22431. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22432. */
  22433. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22434. /**
  22435. * Apply current geometry to a given mesh
  22436. * @param mesh defines the mesh to apply geometry to
  22437. */
  22438. applyToMesh(mesh: Mesh): void;
  22439. private _updateExtend;
  22440. private _applyToMesh;
  22441. private notifyUpdate;
  22442. /**
  22443. * Load the geometry if it was flagged as delay loaded
  22444. * @param scene defines the hosting scene
  22445. * @param onLoaded defines a callback called when the geometry is loaded
  22446. */
  22447. load(scene: Scene, onLoaded?: () => void): void;
  22448. private _queueLoad;
  22449. /**
  22450. * Invert the geometry to move from a right handed system to a left handed one.
  22451. */
  22452. toLeftHanded(): void;
  22453. /** @hidden */
  22454. _resetPointsArrayCache(): void;
  22455. /** @hidden */
  22456. _generatePointsArray(): boolean;
  22457. /**
  22458. * Gets a value indicating if the geometry is disposed
  22459. * @returns true if the geometry was disposed
  22460. */
  22461. isDisposed(): boolean;
  22462. private _disposeVertexArrayObjects;
  22463. /**
  22464. * Free all associated resources
  22465. */
  22466. dispose(): void;
  22467. /**
  22468. * Clone the current geometry into a new geometry
  22469. * @param id defines the unique ID of the new geometry
  22470. * @returns a new geometry object
  22471. */
  22472. copy(id: string): Geometry;
  22473. /**
  22474. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22475. * @return a JSON representation of the current geometry data (without the vertices data)
  22476. */
  22477. serialize(): any;
  22478. private toNumberArray;
  22479. /**
  22480. * Serialize all vertices data into a JSON oject
  22481. * @returns a JSON representation of the current geometry data
  22482. */
  22483. serializeVerticeData(): any;
  22484. /**
  22485. * Extracts a clone of a mesh geometry
  22486. * @param mesh defines the source mesh
  22487. * @param id defines the unique ID of the new geometry object
  22488. * @returns the new geometry object
  22489. */
  22490. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22491. /**
  22492. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22493. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22494. * Be aware Math.random() could cause collisions, but:
  22495. * "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"
  22496. * @returns a string containing a new GUID
  22497. */
  22498. static RandomId(): string;
  22499. /** @hidden */
  22500. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22501. private static _CleanMatricesWeights;
  22502. /**
  22503. * Create a new geometry from persisted data (Using .babylon file format)
  22504. * @param parsedVertexData defines the persisted data
  22505. * @param scene defines the hosting scene
  22506. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22507. * @returns the new geometry object
  22508. */
  22509. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22510. }
  22511. }
  22512. declare module "babylonjs/Meshes/mesh.vertexData" {
  22513. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22514. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22515. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22516. import { Geometry } from "babylonjs/Meshes/geometry";
  22517. import { Mesh } from "babylonjs/Meshes/mesh";
  22518. /**
  22519. * Define an interface for all classes that will get and set the data on vertices
  22520. */
  22521. export interface IGetSetVerticesData {
  22522. /**
  22523. * Gets a boolean indicating if specific vertex data is present
  22524. * @param kind defines the vertex data kind to use
  22525. * @returns true is data kind is present
  22526. */
  22527. isVerticesDataPresent(kind: string): boolean;
  22528. /**
  22529. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22530. * @param kind defines the data kind (Position, normal, etc...)
  22531. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22532. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22533. * @returns a float array containing vertex data
  22534. */
  22535. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22536. /**
  22537. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22538. * @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.
  22539. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22540. * @returns the indices array or an empty array if the mesh has no geometry
  22541. */
  22542. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22543. /**
  22544. * Set specific vertex data
  22545. * @param kind defines the data kind (Position, normal, etc...)
  22546. * @param data defines the vertex data to use
  22547. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22548. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22549. */
  22550. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22551. /**
  22552. * Update a specific associated vertex buffer
  22553. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22554. * - VertexBuffer.PositionKind
  22555. * - VertexBuffer.UVKind
  22556. * - VertexBuffer.UV2Kind
  22557. * - VertexBuffer.UV3Kind
  22558. * - VertexBuffer.UV4Kind
  22559. * - VertexBuffer.UV5Kind
  22560. * - VertexBuffer.UV6Kind
  22561. * - VertexBuffer.ColorKind
  22562. * - VertexBuffer.MatricesIndicesKind
  22563. * - VertexBuffer.MatricesIndicesExtraKind
  22564. * - VertexBuffer.MatricesWeightsKind
  22565. * - VertexBuffer.MatricesWeightsExtraKind
  22566. * @param data defines the data source
  22567. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22568. * @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)
  22569. */
  22570. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22571. /**
  22572. * Creates a new index buffer
  22573. * @param indices defines the indices to store in the index buffer
  22574. * @param totalVertices defines the total number of vertices (could be null)
  22575. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22576. */
  22577. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22578. }
  22579. /**
  22580. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22581. */
  22582. export class VertexData {
  22583. /**
  22584. * Mesh side orientation : usually the external or front surface
  22585. */
  22586. static readonly FRONTSIDE: number;
  22587. /**
  22588. * Mesh side orientation : usually the internal or back surface
  22589. */
  22590. static readonly BACKSIDE: number;
  22591. /**
  22592. * Mesh side orientation : both internal and external or front and back surfaces
  22593. */
  22594. static readonly DOUBLESIDE: number;
  22595. /**
  22596. * Mesh side orientation : by default, `FRONTSIDE`
  22597. */
  22598. static readonly DEFAULTSIDE: number;
  22599. /**
  22600. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22601. */
  22602. positions: Nullable<FloatArray>;
  22603. /**
  22604. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22605. */
  22606. normals: Nullable<FloatArray>;
  22607. /**
  22608. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22609. */
  22610. tangents: Nullable<FloatArray>;
  22611. /**
  22612. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22613. */
  22614. uvs: Nullable<FloatArray>;
  22615. /**
  22616. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22617. */
  22618. uvs2: Nullable<FloatArray>;
  22619. /**
  22620. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22621. */
  22622. uvs3: Nullable<FloatArray>;
  22623. /**
  22624. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22625. */
  22626. uvs4: Nullable<FloatArray>;
  22627. /**
  22628. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22629. */
  22630. uvs5: Nullable<FloatArray>;
  22631. /**
  22632. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22633. */
  22634. uvs6: Nullable<FloatArray>;
  22635. /**
  22636. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22637. */
  22638. colors: Nullable<FloatArray>;
  22639. /**
  22640. * 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).
  22641. */
  22642. matricesIndices: Nullable<FloatArray>;
  22643. /**
  22644. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22645. */
  22646. matricesWeights: Nullable<FloatArray>;
  22647. /**
  22648. * An array extending the number of possible indices
  22649. */
  22650. matricesIndicesExtra: Nullable<FloatArray>;
  22651. /**
  22652. * An array extending the number of possible weights when the number of indices is extended
  22653. */
  22654. matricesWeightsExtra: Nullable<FloatArray>;
  22655. /**
  22656. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22657. */
  22658. indices: Nullable<IndicesArray>;
  22659. /**
  22660. * Uses the passed data array to set the set the values for the specified kind of data
  22661. * @param data a linear array of floating numbers
  22662. * @param kind the type of data that is being set, eg positions, colors etc
  22663. */
  22664. set(data: FloatArray, kind: string): void;
  22665. /**
  22666. * Associates the vertexData to the passed Mesh.
  22667. * Sets it as updatable or not (default `false`)
  22668. * @param mesh the mesh the vertexData is applied to
  22669. * @param updatable when used and having the value true allows new data to update the vertexData
  22670. * @returns the VertexData
  22671. */
  22672. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22673. /**
  22674. * Associates the vertexData to the passed Geometry.
  22675. * Sets it as updatable or not (default `false`)
  22676. * @param geometry the geometry the vertexData is applied to
  22677. * @param updatable when used and having the value true allows new data to update the vertexData
  22678. * @returns VertexData
  22679. */
  22680. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22681. /**
  22682. * Updates the associated mesh
  22683. * @param mesh the mesh to be updated
  22684. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22685. * @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
  22686. * @returns VertexData
  22687. */
  22688. updateMesh(mesh: Mesh): VertexData;
  22689. /**
  22690. * Updates the associated geometry
  22691. * @param geometry the geometry to be updated
  22692. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22693. * @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
  22694. * @returns VertexData.
  22695. */
  22696. updateGeometry(geometry: Geometry): VertexData;
  22697. private _applyTo;
  22698. private _update;
  22699. /**
  22700. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22701. * @param matrix the transforming matrix
  22702. * @returns the VertexData
  22703. */
  22704. transform(matrix: Matrix): VertexData;
  22705. /**
  22706. * Merges the passed VertexData into the current one
  22707. * @param other the VertexData to be merged into the current one
  22708. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22709. * @returns the modified VertexData
  22710. */
  22711. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22712. private _mergeElement;
  22713. private _validate;
  22714. /**
  22715. * Serializes the VertexData
  22716. * @returns a serialized object
  22717. */
  22718. serialize(): any;
  22719. /**
  22720. * Extracts the vertexData from a mesh
  22721. * @param mesh the mesh from which to extract the VertexData
  22722. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22723. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22724. * @returns the object VertexData associated to the passed mesh
  22725. */
  22726. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22727. /**
  22728. * Extracts the vertexData from the geometry
  22729. * @param geometry the geometry from which to extract the VertexData
  22730. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22731. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22732. * @returns the object VertexData associated to the passed mesh
  22733. */
  22734. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22735. private static _ExtractFrom;
  22736. /**
  22737. * Creates the VertexData for a Ribbon
  22738. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22739. * * pathArray array of paths, each of which an array of successive Vector3
  22740. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22741. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22742. * * 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
  22743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22744. * * 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)
  22745. * * 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)
  22746. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22747. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22748. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22749. * @returns the VertexData of the ribbon
  22750. */
  22751. static CreateRibbon(options: {
  22752. pathArray: Vector3[][];
  22753. closeArray?: boolean;
  22754. closePath?: boolean;
  22755. offset?: number;
  22756. sideOrientation?: number;
  22757. frontUVs?: Vector4;
  22758. backUVs?: Vector4;
  22759. invertUV?: boolean;
  22760. uvs?: Vector2[];
  22761. colors?: Color4[];
  22762. }): VertexData;
  22763. /**
  22764. * Creates the VertexData for a box
  22765. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22766. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22767. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22768. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22769. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22770. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22771. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * 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)
  22774. * * 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)
  22775. * @returns the VertexData of the box
  22776. */
  22777. static CreateBox(options: {
  22778. size?: number;
  22779. width?: number;
  22780. height?: number;
  22781. depth?: number;
  22782. faceUV?: Vector4[];
  22783. faceColors?: Color4[];
  22784. sideOrientation?: number;
  22785. frontUVs?: Vector4;
  22786. backUVs?: Vector4;
  22787. }): VertexData;
  22788. /**
  22789. * Creates the VertexData for a tiled box
  22790. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22791. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22792. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22793. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22795. * @returns the VertexData of the box
  22796. */
  22797. static CreateTiledBox(options: {
  22798. pattern?: number;
  22799. width?: number;
  22800. height?: number;
  22801. depth?: number;
  22802. tileSize?: number;
  22803. tileWidth?: number;
  22804. tileHeight?: number;
  22805. alignHorizontal?: number;
  22806. alignVertical?: number;
  22807. faceUV?: Vector4[];
  22808. faceColors?: Color4[];
  22809. sideOrientation?: number;
  22810. }): VertexData;
  22811. /**
  22812. * Creates the VertexData for a tiled plane
  22813. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22814. * * pattern a limited pattern arrangement depending on the number
  22815. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22816. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22817. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22819. * * 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)
  22820. * * 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)
  22821. * @returns the VertexData of the tiled plane
  22822. */
  22823. static CreateTiledPlane(options: {
  22824. pattern?: number;
  22825. tileSize?: number;
  22826. tileWidth?: number;
  22827. tileHeight?: number;
  22828. size?: number;
  22829. width?: number;
  22830. height?: number;
  22831. alignHorizontal?: number;
  22832. alignVertical?: number;
  22833. sideOrientation?: number;
  22834. frontUVs?: Vector4;
  22835. backUVs?: Vector4;
  22836. }): VertexData;
  22837. /**
  22838. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22839. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22840. * * segments sets the number of horizontal strips optional, default 32
  22841. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22842. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22843. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22844. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22845. * * 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
  22846. * * 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
  22847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22848. * * 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)
  22849. * * 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)
  22850. * @returns the VertexData of the ellipsoid
  22851. */
  22852. static CreateSphere(options: {
  22853. segments?: number;
  22854. diameter?: number;
  22855. diameterX?: number;
  22856. diameterY?: number;
  22857. diameterZ?: number;
  22858. arc?: number;
  22859. slice?: number;
  22860. sideOrientation?: number;
  22861. frontUVs?: Vector4;
  22862. backUVs?: Vector4;
  22863. }): VertexData;
  22864. /**
  22865. * Creates the VertexData for a cylinder, cone or prism
  22866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22867. * * height sets the height (y direction) of the cylinder, optional, default 2
  22868. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22869. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22870. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22871. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22872. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22873. * * 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
  22874. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22875. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22876. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22877. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22879. * * 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)
  22880. * * 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)
  22881. * @returns the VertexData of the cylinder, cone or prism
  22882. */
  22883. static CreateCylinder(options: {
  22884. height?: number;
  22885. diameterTop?: number;
  22886. diameterBottom?: number;
  22887. diameter?: number;
  22888. tessellation?: number;
  22889. subdivisions?: number;
  22890. arc?: number;
  22891. faceColors?: Color4[];
  22892. faceUV?: Vector4[];
  22893. hasRings?: boolean;
  22894. enclose?: boolean;
  22895. sideOrientation?: number;
  22896. frontUVs?: Vector4;
  22897. backUVs?: Vector4;
  22898. }): VertexData;
  22899. /**
  22900. * Creates the VertexData for a torus
  22901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22902. * * diameter the diameter of the torus, optional default 1
  22903. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22904. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22906. * * 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)
  22907. * * 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)
  22908. * @returns the VertexData of the torus
  22909. */
  22910. static CreateTorus(options: {
  22911. diameter?: number;
  22912. thickness?: number;
  22913. tessellation?: number;
  22914. sideOrientation?: number;
  22915. frontUVs?: Vector4;
  22916. backUVs?: Vector4;
  22917. }): VertexData;
  22918. /**
  22919. * Creates the VertexData of the LineSystem
  22920. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22921. * - lines an array of lines, each line being an array of successive Vector3
  22922. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22923. * @returns the VertexData of the LineSystem
  22924. */
  22925. static CreateLineSystem(options: {
  22926. lines: Vector3[][];
  22927. colors?: Nullable<Color4[][]>;
  22928. }): VertexData;
  22929. /**
  22930. * Create the VertexData for a DashedLines
  22931. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22932. * - points an array successive Vector3
  22933. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22934. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22935. * - dashNb the intended total number of dashes, optional, default 200
  22936. * @returns the VertexData for the DashedLines
  22937. */
  22938. static CreateDashedLines(options: {
  22939. points: Vector3[];
  22940. dashSize?: number;
  22941. gapSize?: number;
  22942. dashNb?: number;
  22943. }): VertexData;
  22944. /**
  22945. * Creates the VertexData for a Ground
  22946. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22947. * - width the width (x direction) of the ground, optional, default 1
  22948. * - height the height (z direction) of the ground, optional, default 1
  22949. * - subdivisions the number of subdivisions per side, optional, default 1
  22950. * @returns the VertexData of the Ground
  22951. */
  22952. static CreateGround(options: {
  22953. width?: number;
  22954. height?: number;
  22955. subdivisions?: number;
  22956. subdivisionsX?: number;
  22957. subdivisionsY?: number;
  22958. }): VertexData;
  22959. /**
  22960. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22961. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22962. * * xmin the ground minimum X coordinate, optional, default -1
  22963. * * zmin the ground minimum Z coordinate, optional, default -1
  22964. * * xmax the ground maximum X coordinate, optional, default 1
  22965. * * zmax the ground maximum Z coordinate, optional, default 1
  22966. * * 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}
  22967. * * 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}
  22968. * @returns the VertexData of the TiledGround
  22969. */
  22970. static CreateTiledGround(options: {
  22971. xmin: number;
  22972. zmin: number;
  22973. xmax: number;
  22974. zmax: number;
  22975. subdivisions?: {
  22976. w: number;
  22977. h: number;
  22978. };
  22979. precision?: {
  22980. w: number;
  22981. h: number;
  22982. };
  22983. }): VertexData;
  22984. /**
  22985. * Creates the VertexData of the Ground designed from a heightmap
  22986. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22987. * * width the width (x direction) of the ground
  22988. * * height the height (z direction) of the ground
  22989. * * subdivisions the number of subdivisions per side
  22990. * * minHeight the minimum altitude on the ground, optional, default 0
  22991. * * maxHeight the maximum altitude on the ground, optional default 1
  22992. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22993. * * buffer the array holding the image color data
  22994. * * bufferWidth the width of image
  22995. * * bufferHeight the height of image
  22996. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22997. * @returns the VertexData of the Ground designed from a heightmap
  22998. */
  22999. static CreateGroundFromHeightMap(options: {
  23000. width: number;
  23001. height: number;
  23002. subdivisions: number;
  23003. minHeight: number;
  23004. maxHeight: number;
  23005. colorFilter: Color3;
  23006. buffer: Uint8Array;
  23007. bufferWidth: number;
  23008. bufferHeight: number;
  23009. alphaFilter: number;
  23010. }): VertexData;
  23011. /**
  23012. * Creates the VertexData for a Plane
  23013. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23014. * * size sets the width and height of the plane to the value of size, optional default 1
  23015. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23016. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23017. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23018. * * 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)
  23019. * * 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)
  23020. * @returns the VertexData of the box
  23021. */
  23022. static CreatePlane(options: {
  23023. size?: number;
  23024. width?: number;
  23025. height?: number;
  23026. sideOrientation?: number;
  23027. frontUVs?: Vector4;
  23028. backUVs?: Vector4;
  23029. }): VertexData;
  23030. /**
  23031. * Creates the VertexData of the Disc or regular Polygon
  23032. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23033. * * radius the radius of the disc, optional default 0.5
  23034. * * tessellation the number of polygon sides, optional, default 64
  23035. * * 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
  23036. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23037. * * 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)
  23038. * * 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)
  23039. * @returns the VertexData of the box
  23040. */
  23041. static CreateDisc(options: {
  23042. radius?: number;
  23043. tessellation?: number;
  23044. arc?: number;
  23045. sideOrientation?: number;
  23046. frontUVs?: Vector4;
  23047. backUVs?: Vector4;
  23048. }): VertexData;
  23049. /**
  23050. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23051. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23052. * @param polygon a mesh built from polygonTriangulation.build()
  23053. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23054. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23055. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23056. * @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)
  23057. * @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)
  23058. * @returns the VertexData of the Polygon
  23059. */
  23060. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23061. /**
  23062. * Creates the VertexData of the IcoSphere
  23063. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23064. * * radius the radius of the IcoSphere, optional default 1
  23065. * * radiusX allows stretching in the x direction, optional, default radius
  23066. * * radiusY allows stretching in the y direction, optional, default radius
  23067. * * radiusZ allows stretching in the z direction, optional, default radius
  23068. * * flat when true creates a flat shaded mesh, optional, default true
  23069. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23070. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23071. * * 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)
  23072. * * 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)
  23073. * @returns the VertexData of the IcoSphere
  23074. */
  23075. static CreateIcoSphere(options: {
  23076. radius?: number;
  23077. radiusX?: number;
  23078. radiusY?: number;
  23079. radiusZ?: number;
  23080. flat?: boolean;
  23081. subdivisions?: number;
  23082. sideOrientation?: number;
  23083. frontUVs?: Vector4;
  23084. backUVs?: Vector4;
  23085. }): VertexData;
  23086. /**
  23087. * Creates the VertexData for a Polyhedron
  23088. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23089. * * type provided types are:
  23090. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23091. * * 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)
  23092. * * size the size of the IcoSphere, optional default 1
  23093. * * sizeX allows stretching in the x direction, optional, default size
  23094. * * sizeY allows stretching in the y direction, optional, default size
  23095. * * sizeZ allows stretching in the z direction, optional, default size
  23096. * * 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
  23097. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23098. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23099. * * flat when true creates a flat shaded mesh, optional, default true
  23100. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23102. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23103. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23104. * @returns the VertexData of the Polyhedron
  23105. */
  23106. static CreatePolyhedron(options: {
  23107. type?: number;
  23108. size?: number;
  23109. sizeX?: number;
  23110. sizeY?: number;
  23111. sizeZ?: number;
  23112. custom?: any;
  23113. faceUV?: Vector4[];
  23114. faceColors?: Color4[];
  23115. flat?: boolean;
  23116. sideOrientation?: number;
  23117. frontUVs?: Vector4;
  23118. backUVs?: Vector4;
  23119. }): VertexData;
  23120. /**
  23121. * Creates the VertexData for a TorusKnot
  23122. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23123. * * radius the radius of the torus knot, optional, default 2
  23124. * * tube the thickness of the tube, optional, default 0.5
  23125. * * radialSegments the number of sides on each tube segments, optional, default 32
  23126. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23127. * * p the number of windings around the z axis, optional, default 2
  23128. * * q the number of windings around the x axis, optional, default 3
  23129. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23130. * * 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)
  23131. * * 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)
  23132. * @returns the VertexData of the Torus Knot
  23133. */
  23134. static CreateTorusKnot(options: {
  23135. radius?: number;
  23136. tube?: number;
  23137. radialSegments?: number;
  23138. tubularSegments?: number;
  23139. p?: number;
  23140. q?: number;
  23141. sideOrientation?: number;
  23142. frontUVs?: Vector4;
  23143. backUVs?: Vector4;
  23144. }): VertexData;
  23145. /**
  23146. * Compute normals for given positions and indices
  23147. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23148. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23149. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23150. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23151. * * facetNormals : optional array of facet normals (vector3)
  23152. * * facetPositions : optional array of facet positions (vector3)
  23153. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23154. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23155. * * bInfo : optional bounding info, required for facetPartitioning computation
  23156. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23157. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23158. * * useRightHandedSystem: optional boolean to for right handed system computation
  23159. * * depthSort : optional boolean to enable the facet depth sort computation
  23160. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23161. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23162. */
  23163. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23164. facetNormals?: any;
  23165. facetPositions?: any;
  23166. facetPartitioning?: any;
  23167. ratio?: number;
  23168. bInfo?: any;
  23169. bbSize?: Vector3;
  23170. subDiv?: any;
  23171. useRightHandedSystem?: boolean;
  23172. depthSort?: boolean;
  23173. distanceTo?: Vector3;
  23174. depthSortedFacets?: any;
  23175. }): void;
  23176. /** @hidden */
  23177. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23178. /**
  23179. * Applies VertexData created from the imported parameters to the geometry
  23180. * @param parsedVertexData the parsed data from an imported file
  23181. * @param geometry the geometry to apply the VertexData to
  23182. */
  23183. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23184. }
  23185. }
  23186. declare module "babylonjs/Morph/morphTarget" {
  23187. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23188. import { Observable } from "babylonjs/Misc/observable";
  23189. import { Nullable, FloatArray } from "babylonjs/types";
  23190. import { Scene } from "babylonjs/scene";
  23191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23192. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23193. /**
  23194. * Defines a target to use with MorphTargetManager
  23195. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23196. */
  23197. export class MorphTarget implements IAnimatable {
  23198. /** defines the name of the target */
  23199. name: string;
  23200. /**
  23201. * Gets or sets the list of animations
  23202. */
  23203. animations: import("babylonjs/Animations/animation").Animation[];
  23204. private _scene;
  23205. private _positions;
  23206. private _normals;
  23207. private _tangents;
  23208. private _uvs;
  23209. private _influence;
  23210. private _uniqueId;
  23211. /**
  23212. * Observable raised when the influence changes
  23213. */
  23214. onInfluenceChanged: Observable<boolean>;
  23215. /** @hidden */
  23216. _onDataLayoutChanged: Observable<void>;
  23217. /**
  23218. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23219. */
  23220. get influence(): number;
  23221. set influence(influence: number);
  23222. /**
  23223. * Gets or sets the id of the morph Target
  23224. */
  23225. id: string;
  23226. private _animationPropertiesOverride;
  23227. /**
  23228. * Gets or sets the animation properties override
  23229. */
  23230. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23231. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23232. /**
  23233. * Creates a new MorphTarget
  23234. * @param name defines the name of the target
  23235. * @param influence defines the influence to use
  23236. * @param scene defines the scene the morphtarget belongs to
  23237. */
  23238. constructor(
  23239. /** defines the name of the target */
  23240. name: string, influence?: number, scene?: Nullable<Scene>);
  23241. /**
  23242. * Gets the unique ID of this manager
  23243. */
  23244. get uniqueId(): number;
  23245. /**
  23246. * Gets a boolean defining if the target contains position data
  23247. */
  23248. get hasPositions(): boolean;
  23249. /**
  23250. * Gets a boolean defining if the target contains normal data
  23251. */
  23252. get hasNormals(): boolean;
  23253. /**
  23254. * Gets a boolean defining if the target contains tangent data
  23255. */
  23256. get hasTangents(): boolean;
  23257. /**
  23258. * Gets a boolean defining if the target contains texture coordinates data
  23259. */
  23260. get hasUVs(): boolean;
  23261. /**
  23262. * Affects position data to this target
  23263. * @param data defines the position data to use
  23264. */
  23265. setPositions(data: Nullable<FloatArray>): void;
  23266. /**
  23267. * Gets the position data stored in this target
  23268. * @returns a FloatArray containing the position data (or null if not present)
  23269. */
  23270. getPositions(): Nullable<FloatArray>;
  23271. /**
  23272. * Affects normal data to this target
  23273. * @param data defines the normal data to use
  23274. */
  23275. setNormals(data: Nullable<FloatArray>): void;
  23276. /**
  23277. * Gets the normal data stored in this target
  23278. * @returns a FloatArray containing the normal data (or null if not present)
  23279. */
  23280. getNormals(): Nullable<FloatArray>;
  23281. /**
  23282. * Affects tangent data to this target
  23283. * @param data defines the tangent data to use
  23284. */
  23285. setTangents(data: Nullable<FloatArray>): void;
  23286. /**
  23287. * Gets the tangent data stored in this target
  23288. * @returns a FloatArray containing the tangent data (or null if not present)
  23289. */
  23290. getTangents(): Nullable<FloatArray>;
  23291. /**
  23292. * Affects texture coordinates data to this target
  23293. * @param data defines the texture coordinates data to use
  23294. */
  23295. setUVs(data: Nullable<FloatArray>): void;
  23296. /**
  23297. * Gets the texture coordinates data stored in this target
  23298. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23299. */
  23300. getUVs(): Nullable<FloatArray>;
  23301. /**
  23302. * Clone the current target
  23303. * @returns a new MorphTarget
  23304. */
  23305. clone(): MorphTarget;
  23306. /**
  23307. * Serializes the current target into a Serialization object
  23308. * @returns the serialized object
  23309. */
  23310. serialize(): any;
  23311. /**
  23312. * Returns the string "MorphTarget"
  23313. * @returns "MorphTarget"
  23314. */
  23315. getClassName(): string;
  23316. /**
  23317. * Creates a new target from serialized data
  23318. * @param serializationObject defines the serialized data to use
  23319. * @returns a new MorphTarget
  23320. */
  23321. static Parse(serializationObject: any): MorphTarget;
  23322. /**
  23323. * Creates a MorphTarget from mesh data
  23324. * @param mesh defines the source mesh
  23325. * @param name defines the name to use for the new target
  23326. * @param influence defines the influence to attach to the target
  23327. * @returns a new MorphTarget
  23328. */
  23329. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23330. }
  23331. }
  23332. declare module "babylonjs/Morph/morphTargetManager" {
  23333. import { Nullable } from "babylonjs/types";
  23334. import { Scene } from "babylonjs/scene";
  23335. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23336. /**
  23337. * This class is used to deform meshes using morphing between different targets
  23338. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23339. */
  23340. export class MorphTargetManager {
  23341. private _targets;
  23342. private _targetInfluenceChangedObservers;
  23343. private _targetDataLayoutChangedObservers;
  23344. private _activeTargets;
  23345. private _scene;
  23346. private _influences;
  23347. private _supportsNormals;
  23348. private _supportsTangents;
  23349. private _supportsUVs;
  23350. private _vertexCount;
  23351. private _uniqueId;
  23352. private _tempInfluences;
  23353. /**
  23354. * Gets or sets a boolean indicating if normals must be morphed
  23355. */
  23356. enableNormalMorphing: boolean;
  23357. /**
  23358. * Gets or sets a boolean indicating if tangents must be morphed
  23359. */
  23360. enableTangentMorphing: boolean;
  23361. /**
  23362. * Gets or sets a boolean indicating if UV must be morphed
  23363. */
  23364. enableUVMorphing: boolean;
  23365. /**
  23366. * Creates a new MorphTargetManager
  23367. * @param scene defines the current scene
  23368. */
  23369. constructor(scene?: Nullable<Scene>);
  23370. /**
  23371. * Gets the unique ID of this manager
  23372. */
  23373. get uniqueId(): number;
  23374. /**
  23375. * Gets the number of vertices handled by this manager
  23376. */
  23377. get vertexCount(): number;
  23378. /**
  23379. * Gets a boolean indicating if this manager supports morphing of normals
  23380. */
  23381. get supportsNormals(): boolean;
  23382. /**
  23383. * Gets a boolean indicating if this manager supports morphing of tangents
  23384. */
  23385. get supportsTangents(): boolean;
  23386. /**
  23387. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23388. */
  23389. get supportsUVs(): boolean;
  23390. /**
  23391. * Gets the number of targets stored in this manager
  23392. */
  23393. get numTargets(): number;
  23394. /**
  23395. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23396. */
  23397. get numInfluencers(): number;
  23398. /**
  23399. * Gets the list of influences (one per target)
  23400. */
  23401. get influences(): Float32Array;
  23402. /**
  23403. * Gets the active target at specified index. An active target is a target with an influence > 0
  23404. * @param index defines the index to check
  23405. * @returns the requested target
  23406. */
  23407. getActiveTarget(index: number): MorphTarget;
  23408. /**
  23409. * Gets the target at specified index
  23410. * @param index defines the index to check
  23411. * @returns the requested target
  23412. */
  23413. getTarget(index: number): MorphTarget;
  23414. /**
  23415. * Add a new target to this manager
  23416. * @param target defines the target to add
  23417. */
  23418. addTarget(target: MorphTarget): void;
  23419. /**
  23420. * Removes a target from the manager
  23421. * @param target defines the target to remove
  23422. */
  23423. removeTarget(target: MorphTarget): void;
  23424. /**
  23425. * Clone the current manager
  23426. * @returns a new MorphTargetManager
  23427. */
  23428. clone(): MorphTargetManager;
  23429. /**
  23430. * Serializes the current manager into a Serialization object
  23431. * @returns the serialized object
  23432. */
  23433. serialize(): any;
  23434. private _syncActiveTargets;
  23435. /**
  23436. * Syncrhonize the targets with all the meshes using this morph target manager
  23437. */
  23438. synchronize(): void;
  23439. /**
  23440. * Creates a new MorphTargetManager from serialized data
  23441. * @param serializationObject defines the serialized data
  23442. * @param scene defines the hosting scene
  23443. * @returns the new MorphTargetManager
  23444. */
  23445. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23446. }
  23447. }
  23448. declare module "babylonjs/Meshes/meshLODLevel" {
  23449. import { Mesh } from "babylonjs/Meshes/mesh";
  23450. import { Nullable } from "babylonjs/types";
  23451. /**
  23452. * Class used to represent a specific level of detail of a mesh
  23453. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23454. */
  23455. export class MeshLODLevel {
  23456. /** Defines the distance where this level should start being displayed */
  23457. distance: number;
  23458. /** Defines the mesh to use to render this level */
  23459. mesh: Nullable<Mesh>;
  23460. /**
  23461. * Creates a new LOD level
  23462. * @param distance defines the distance where this level should star being displayed
  23463. * @param mesh defines the mesh to use to render this level
  23464. */
  23465. constructor(
  23466. /** Defines the distance where this level should start being displayed */
  23467. distance: number,
  23468. /** Defines the mesh to use to render this level */
  23469. mesh: Nullable<Mesh>);
  23470. }
  23471. }
  23472. declare module "babylonjs/Meshes/groundMesh" {
  23473. import { Scene } from "babylonjs/scene";
  23474. import { Vector3 } from "babylonjs/Maths/math.vector";
  23475. import { Mesh } from "babylonjs/Meshes/mesh";
  23476. /**
  23477. * Mesh representing the gorund
  23478. */
  23479. export class GroundMesh extends Mesh {
  23480. /** If octree should be generated */
  23481. generateOctree: boolean;
  23482. private _heightQuads;
  23483. /** @hidden */
  23484. _subdivisionsX: number;
  23485. /** @hidden */
  23486. _subdivisionsY: number;
  23487. /** @hidden */
  23488. _width: number;
  23489. /** @hidden */
  23490. _height: number;
  23491. /** @hidden */
  23492. _minX: number;
  23493. /** @hidden */
  23494. _maxX: number;
  23495. /** @hidden */
  23496. _minZ: number;
  23497. /** @hidden */
  23498. _maxZ: number;
  23499. constructor(name: string, scene: Scene);
  23500. /**
  23501. * "GroundMesh"
  23502. * @returns "GroundMesh"
  23503. */
  23504. getClassName(): string;
  23505. /**
  23506. * The minimum of x and y subdivisions
  23507. */
  23508. get subdivisions(): number;
  23509. /**
  23510. * X subdivisions
  23511. */
  23512. get subdivisionsX(): number;
  23513. /**
  23514. * Y subdivisions
  23515. */
  23516. get subdivisionsY(): number;
  23517. /**
  23518. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23519. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23520. * @param chunksCount the number of subdivisions for x and y
  23521. * @param octreeBlocksSize (Default: 32)
  23522. */
  23523. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23524. /**
  23525. * Returns a height (y) value in the Worl system :
  23526. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23527. * @param x x coordinate
  23528. * @param z z coordinate
  23529. * @returns the ground y position if (x, z) are outside the ground surface.
  23530. */
  23531. getHeightAtCoordinates(x: number, z: number): number;
  23532. /**
  23533. * Returns a normalized vector (Vector3) orthogonal to the ground
  23534. * at the ground coordinates (x, z) expressed in the World system.
  23535. * @param x x coordinate
  23536. * @param z z coordinate
  23537. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23538. */
  23539. getNormalAtCoordinates(x: number, z: number): Vector3;
  23540. /**
  23541. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23542. * at the ground coordinates (x, z) expressed in the World system.
  23543. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23544. * @param x x coordinate
  23545. * @param z z coordinate
  23546. * @param ref vector to store the result
  23547. * @returns the GroundMesh.
  23548. */
  23549. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23550. /**
  23551. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23552. * if the ground has been updated.
  23553. * This can be used in the render loop.
  23554. * @returns the GroundMesh.
  23555. */
  23556. updateCoordinateHeights(): GroundMesh;
  23557. private _getFacetAt;
  23558. private _initHeightQuads;
  23559. private _computeHeightQuads;
  23560. /**
  23561. * Serializes this ground mesh
  23562. * @param serializationObject object to write serialization to
  23563. */
  23564. serialize(serializationObject: any): void;
  23565. /**
  23566. * Parses a serialized ground mesh
  23567. * @param parsedMesh the serialized mesh
  23568. * @param scene the scene to create the ground mesh in
  23569. * @returns the created ground mesh
  23570. */
  23571. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23572. }
  23573. }
  23574. declare module "babylonjs/Physics/physicsJoint" {
  23575. import { Vector3 } from "babylonjs/Maths/math.vector";
  23576. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23577. /**
  23578. * Interface for Physics-Joint data
  23579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23580. */
  23581. export interface PhysicsJointData {
  23582. /**
  23583. * The main pivot of the joint
  23584. */
  23585. mainPivot?: Vector3;
  23586. /**
  23587. * The connected pivot of the joint
  23588. */
  23589. connectedPivot?: Vector3;
  23590. /**
  23591. * The main axis of the joint
  23592. */
  23593. mainAxis?: Vector3;
  23594. /**
  23595. * The connected axis of the joint
  23596. */
  23597. connectedAxis?: Vector3;
  23598. /**
  23599. * The collision of the joint
  23600. */
  23601. collision?: boolean;
  23602. /**
  23603. * Native Oimo/Cannon/Energy data
  23604. */
  23605. nativeParams?: any;
  23606. }
  23607. /**
  23608. * This is a holder class for the physics joint created by the physics plugin
  23609. * It holds a set of functions to control the underlying joint
  23610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23611. */
  23612. export class PhysicsJoint {
  23613. /**
  23614. * The type of the physics joint
  23615. */
  23616. type: number;
  23617. /**
  23618. * The data for the physics joint
  23619. */
  23620. jointData: PhysicsJointData;
  23621. private _physicsJoint;
  23622. protected _physicsPlugin: IPhysicsEnginePlugin;
  23623. /**
  23624. * Initializes the physics joint
  23625. * @param type The type of the physics joint
  23626. * @param jointData The data for the physics joint
  23627. */
  23628. constructor(
  23629. /**
  23630. * The type of the physics joint
  23631. */
  23632. type: number,
  23633. /**
  23634. * The data for the physics joint
  23635. */
  23636. jointData: PhysicsJointData);
  23637. /**
  23638. * Gets the physics joint
  23639. */
  23640. get physicsJoint(): any;
  23641. /**
  23642. * Sets the physics joint
  23643. */
  23644. set physicsJoint(newJoint: any);
  23645. /**
  23646. * Sets the physics plugin
  23647. */
  23648. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23649. /**
  23650. * Execute a function that is physics-plugin specific.
  23651. * @param {Function} func the function that will be executed.
  23652. * It accepts two parameters: the physics world and the physics joint
  23653. */
  23654. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23655. /**
  23656. * Distance-Joint type
  23657. */
  23658. static DistanceJoint: number;
  23659. /**
  23660. * Hinge-Joint type
  23661. */
  23662. static HingeJoint: number;
  23663. /**
  23664. * Ball-and-Socket joint type
  23665. */
  23666. static BallAndSocketJoint: number;
  23667. /**
  23668. * Wheel-Joint type
  23669. */
  23670. static WheelJoint: number;
  23671. /**
  23672. * Slider-Joint type
  23673. */
  23674. static SliderJoint: number;
  23675. /**
  23676. * Prismatic-Joint type
  23677. */
  23678. static PrismaticJoint: number;
  23679. /**
  23680. * Universal-Joint type
  23681. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23682. */
  23683. static UniversalJoint: number;
  23684. /**
  23685. * Hinge-Joint 2 type
  23686. */
  23687. static Hinge2Joint: number;
  23688. /**
  23689. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23690. */
  23691. static PointToPointJoint: number;
  23692. /**
  23693. * Spring-Joint type
  23694. */
  23695. static SpringJoint: number;
  23696. /**
  23697. * Lock-Joint type
  23698. */
  23699. static LockJoint: number;
  23700. }
  23701. /**
  23702. * A class representing a physics distance joint
  23703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23704. */
  23705. export class DistanceJoint extends PhysicsJoint {
  23706. /**
  23707. *
  23708. * @param jointData The data for the Distance-Joint
  23709. */
  23710. constructor(jointData: DistanceJointData);
  23711. /**
  23712. * Update the predefined distance.
  23713. * @param maxDistance The maximum preferred distance
  23714. * @param minDistance The minimum preferred distance
  23715. */
  23716. updateDistance(maxDistance: number, minDistance?: number): void;
  23717. }
  23718. /**
  23719. * Represents a Motor-Enabled Joint
  23720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23721. */
  23722. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23723. /**
  23724. * Initializes the Motor-Enabled Joint
  23725. * @param type The type of the joint
  23726. * @param jointData The physica joint data for the joint
  23727. */
  23728. constructor(type: number, jointData: PhysicsJointData);
  23729. /**
  23730. * Set the motor values.
  23731. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23732. * @param force the force to apply
  23733. * @param maxForce max force for this motor.
  23734. */
  23735. setMotor(force?: number, maxForce?: number): void;
  23736. /**
  23737. * Set the motor's limits.
  23738. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23739. * @param upperLimit The upper limit of the motor
  23740. * @param lowerLimit The lower limit of the motor
  23741. */
  23742. setLimit(upperLimit: number, lowerLimit?: number): void;
  23743. }
  23744. /**
  23745. * This class represents a single physics Hinge-Joint
  23746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23747. */
  23748. export class HingeJoint extends MotorEnabledJoint {
  23749. /**
  23750. * Initializes the Hinge-Joint
  23751. * @param jointData The joint data for the Hinge-Joint
  23752. */
  23753. constructor(jointData: PhysicsJointData);
  23754. /**
  23755. * Set the motor values.
  23756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23757. * @param {number} force the force to apply
  23758. * @param {number} maxForce max force for this motor.
  23759. */
  23760. setMotor(force?: number, maxForce?: number): void;
  23761. /**
  23762. * Set the motor's limits.
  23763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23764. * @param upperLimit The upper limit of the motor
  23765. * @param lowerLimit The lower limit of the motor
  23766. */
  23767. setLimit(upperLimit: number, lowerLimit?: number): void;
  23768. }
  23769. /**
  23770. * This class represents a dual hinge physics joint (same as wheel joint)
  23771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23772. */
  23773. export class Hinge2Joint extends MotorEnabledJoint {
  23774. /**
  23775. * Initializes the Hinge2-Joint
  23776. * @param jointData The joint data for the Hinge2-Joint
  23777. */
  23778. constructor(jointData: PhysicsJointData);
  23779. /**
  23780. * Set the motor values.
  23781. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23782. * @param {number} targetSpeed the speed the motor is to reach
  23783. * @param {number} maxForce max force for this motor.
  23784. * @param {motorIndex} the motor's index, 0 or 1.
  23785. */
  23786. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23787. /**
  23788. * Set the motor limits.
  23789. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23790. * @param {number} upperLimit the upper limit
  23791. * @param {number} lowerLimit lower limit
  23792. * @param {motorIndex} the motor's index, 0 or 1.
  23793. */
  23794. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23795. }
  23796. /**
  23797. * Interface for a motor enabled joint
  23798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23799. */
  23800. export interface IMotorEnabledJoint {
  23801. /**
  23802. * Physics joint
  23803. */
  23804. physicsJoint: any;
  23805. /**
  23806. * Sets the motor of the motor-enabled joint
  23807. * @param force The force of the motor
  23808. * @param maxForce The maximum force of the motor
  23809. * @param motorIndex The index of the motor
  23810. */
  23811. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23812. /**
  23813. * Sets the limit of the motor
  23814. * @param upperLimit The upper limit of the motor
  23815. * @param lowerLimit The lower limit of the motor
  23816. * @param motorIndex The index of the motor
  23817. */
  23818. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23819. }
  23820. /**
  23821. * Joint data for a Distance-Joint
  23822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23823. */
  23824. export interface DistanceJointData extends PhysicsJointData {
  23825. /**
  23826. * Max distance the 2 joint objects can be apart
  23827. */
  23828. maxDistance: number;
  23829. }
  23830. /**
  23831. * Joint data from a spring joint
  23832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23833. */
  23834. export interface SpringJointData extends PhysicsJointData {
  23835. /**
  23836. * Length of the spring
  23837. */
  23838. length: number;
  23839. /**
  23840. * Stiffness of the spring
  23841. */
  23842. stiffness: number;
  23843. /**
  23844. * Damping of the spring
  23845. */
  23846. damping: number;
  23847. /** this callback will be called when applying the force to the impostors. */
  23848. forceApplicationCallback: () => void;
  23849. }
  23850. }
  23851. declare module "babylonjs/Physics/physicsRaycastResult" {
  23852. import { Vector3 } from "babylonjs/Maths/math.vector";
  23853. /**
  23854. * Holds the data for the raycast result
  23855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23856. */
  23857. export class PhysicsRaycastResult {
  23858. private _hasHit;
  23859. private _hitDistance;
  23860. private _hitNormalWorld;
  23861. private _hitPointWorld;
  23862. private _rayFromWorld;
  23863. private _rayToWorld;
  23864. /**
  23865. * Gets if there was a hit
  23866. */
  23867. get hasHit(): boolean;
  23868. /**
  23869. * Gets the distance from the hit
  23870. */
  23871. get hitDistance(): number;
  23872. /**
  23873. * Gets the hit normal/direction in the world
  23874. */
  23875. get hitNormalWorld(): Vector3;
  23876. /**
  23877. * Gets the hit point in the world
  23878. */
  23879. get hitPointWorld(): Vector3;
  23880. /**
  23881. * Gets the ray "start point" of the ray in the world
  23882. */
  23883. get rayFromWorld(): Vector3;
  23884. /**
  23885. * Gets the ray "end point" of the ray in the world
  23886. */
  23887. get rayToWorld(): Vector3;
  23888. /**
  23889. * Sets the hit data (normal & point in world space)
  23890. * @param hitNormalWorld defines the normal in world space
  23891. * @param hitPointWorld defines the point in world space
  23892. */
  23893. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23894. /**
  23895. * Sets the distance from the start point to the hit point
  23896. * @param distance
  23897. */
  23898. setHitDistance(distance: number): void;
  23899. /**
  23900. * Calculates the distance manually
  23901. */
  23902. calculateHitDistance(): void;
  23903. /**
  23904. * Resets all the values to default
  23905. * @param from The from point on world space
  23906. * @param to The to point on world space
  23907. */
  23908. reset(from?: Vector3, to?: Vector3): void;
  23909. }
  23910. /**
  23911. * Interface for the size containing width and height
  23912. */
  23913. interface IXYZ {
  23914. /**
  23915. * X
  23916. */
  23917. x: number;
  23918. /**
  23919. * Y
  23920. */
  23921. y: number;
  23922. /**
  23923. * Z
  23924. */
  23925. z: number;
  23926. }
  23927. }
  23928. declare module "babylonjs/Physics/IPhysicsEngine" {
  23929. import { Nullable } from "babylonjs/types";
  23930. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23932. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23933. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23934. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23935. /**
  23936. * Interface used to describe a physics joint
  23937. */
  23938. export interface PhysicsImpostorJoint {
  23939. /** Defines the main impostor to which the joint is linked */
  23940. mainImpostor: PhysicsImpostor;
  23941. /** Defines the impostor that is connected to the main impostor using this joint */
  23942. connectedImpostor: PhysicsImpostor;
  23943. /** Defines the joint itself */
  23944. joint: PhysicsJoint;
  23945. }
  23946. /** @hidden */
  23947. export interface IPhysicsEnginePlugin {
  23948. world: any;
  23949. name: string;
  23950. setGravity(gravity: Vector3): void;
  23951. setTimeStep(timeStep: number): void;
  23952. getTimeStep(): number;
  23953. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23954. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23955. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23956. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23957. removePhysicsBody(impostor: PhysicsImpostor): void;
  23958. generateJoint(joint: PhysicsImpostorJoint): void;
  23959. removeJoint(joint: PhysicsImpostorJoint): void;
  23960. isSupported(): boolean;
  23961. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23962. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23963. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23964. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23965. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23966. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23967. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23968. getBodyMass(impostor: PhysicsImpostor): number;
  23969. getBodyFriction(impostor: PhysicsImpostor): number;
  23970. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23971. getBodyRestitution(impostor: PhysicsImpostor): number;
  23972. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23973. getBodyPressure?(impostor: PhysicsImpostor): number;
  23974. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23975. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23976. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23977. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23978. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23979. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23980. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23981. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23982. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23983. sleepBody(impostor: PhysicsImpostor): void;
  23984. wakeUpBody(impostor: PhysicsImpostor): void;
  23985. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23986. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23987. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23988. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23989. getRadius(impostor: PhysicsImpostor): number;
  23990. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23991. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23992. dispose(): void;
  23993. }
  23994. /**
  23995. * Interface used to define a physics engine
  23996. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23997. */
  23998. export interface IPhysicsEngine {
  23999. /**
  24000. * Gets the gravity vector used by the simulation
  24001. */
  24002. gravity: Vector3;
  24003. /**
  24004. * Sets the gravity vector used by the simulation
  24005. * @param gravity defines the gravity vector to use
  24006. */
  24007. setGravity(gravity: Vector3): void;
  24008. /**
  24009. * Set the time step of the physics engine.
  24010. * Default is 1/60.
  24011. * To slow it down, enter 1/600 for example.
  24012. * To speed it up, 1/30
  24013. * @param newTimeStep the new timestep to apply to this world.
  24014. */
  24015. setTimeStep(newTimeStep: number): void;
  24016. /**
  24017. * Get the time step of the physics engine.
  24018. * @returns the current time step
  24019. */
  24020. getTimeStep(): number;
  24021. /**
  24022. * Set the sub time step of the physics engine.
  24023. * Default is 0 meaning there is no sub steps
  24024. * To increase physics resolution precision, set a small value (like 1 ms)
  24025. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24026. */
  24027. setSubTimeStep(subTimeStep: number): void;
  24028. /**
  24029. * Get the sub time step of the physics engine.
  24030. * @returns the current sub time step
  24031. */
  24032. getSubTimeStep(): number;
  24033. /**
  24034. * Release all resources
  24035. */
  24036. dispose(): void;
  24037. /**
  24038. * Gets the name of the current physics plugin
  24039. * @returns the name of the plugin
  24040. */
  24041. getPhysicsPluginName(): string;
  24042. /**
  24043. * Adding a new impostor for the impostor tracking.
  24044. * This will be done by the impostor itself.
  24045. * @param impostor the impostor to add
  24046. */
  24047. addImpostor(impostor: PhysicsImpostor): void;
  24048. /**
  24049. * Remove an impostor from the engine.
  24050. * This impostor and its mesh will not longer be updated by the physics engine.
  24051. * @param impostor the impostor to remove
  24052. */
  24053. removeImpostor(impostor: PhysicsImpostor): void;
  24054. /**
  24055. * Add a joint to the physics engine
  24056. * @param mainImpostor defines the main impostor to which the joint is added.
  24057. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24058. * @param joint defines the joint that will connect both impostors.
  24059. */
  24060. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24061. /**
  24062. * Removes a joint from the simulation
  24063. * @param mainImpostor defines the impostor used with the joint
  24064. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24065. * @param joint defines the joint to remove
  24066. */
  24067. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24068. /**
  24069. * Gets the current plugin used to run the simulation
  24070. * @returns current plugin
  24071. */
  24072. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24073. /**
  24074. * Gets the list of physic impostors
  24075. * @returns an array of PhysicsImpostor
  24076. */
  24077. getImpostors(): Array<PhysicsImpostor>;
  24078. /**
  24079. * Gets the impostor for a physics enabled object
  24080. * @param object defines the object impersonated by the impostor
  24081. * @returns the PhysicsImpostor or null if not found
  24082. */
  24083. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24084. /**
  24085. * Gets the impostor for a physics body object
  24086. * @param body defines physics body used by the impostor
  24087. * @returns the PhysicsImpostor or null if not found
  24088. */
  24089. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24090. /**
  24091. * Does a raycast in the physics world
  24092. * @param from when should the ray start?
  24093. * @param to when should the ray end?
  24094. * @returns PhysicsRaycastResult
  24095. */
  24096. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24097. /**
  24098. * Called by the scene. No need to call it.
  24099. * @param delta defines the timespam between frames
  24100. */
  24101. _step(delta: number): void;
  24102. }
  24103. }
  24104. declare module "babylonjs/Physics/physicsImpostor" {
  24105. import { Nullable, IndicesArray } from "babylonjs/types";
  24106. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24107. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24109. import { Scene } from "babylonjs/scene";
  24110. import { Bone } from "babylonjs/Bones/bone";
  24111. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24112. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24113. import { Space } from "babylonjs/Maths/math.axis";
  24114. /**
  24115. * The interface for the physics imposter parameters
  24116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24117. */
  24118. export interface PhysicsImpostorParameters {
  24119. /**
  24120. * The mass of the physics imposter
  24121. */
  24122. mass: number;
  24123. /**
  24124. * The friction of the physics imposter
  24125. */
  24126. friction?: number;
  24127. /**
  24128. * The coefficient of restitution of the physics imposter
  24129. */
  24130. restitution?: number;
  24131. /**
  24132. * The native options of the physics imposter
  24133. */
  24134. nativeOptions?: any;
  24135. /**
  24136. * Specifies if the parent should be ignored
  24137. */
  24138. ignoreParent?: boolean;
  24139. /**
  24140. * Specifies if bi-directional transformations should be disabled
  24141. */
  24142. disableBidirectionalTransformation?: boolean;
  24143. /**
  24144. * The pressure inside the physics imposter, soft object only
  24145. */
  24146. pressure?: number;
  24147. /**
  24148. * The stiffness the physics imposter, soft object only
  24149. */
  24150. stiffness?: number;
  24151. /**
  24152. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24153. */
  24154. velocityIterations?: number;
  24155. /**
  24156. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24157. */
  24158. positionIterations?: number;
  24159. /**
  24160. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24161. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24162. * Add to fix multiple points
  24163. */
  24164. fixedPoints?: number;
  24165. /**
  24166. * The collision margin around a soft object
  24167. */
  24168. margin?: number;
  24169. /**
  24170. * The collision margin around a soft object
  24171. */
  24172. damping?: number;
  24173. /**
  24174. * The path for a rope based on an extrusion
  24175. */
  24176. path?: any;
  24177. /**
  24178. * The shape of an extrusion used for a rope based on an extrusion
  24179. */
  24180. shape?: any;
  24181. }
  24182. /**
  24183. * Interface for a physics-enabled object
  24184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24185. */
  24186. export interface IPhysicsEnabledObject {
  24187. /**
  24188. * The position of the physics-enabled object
  24189. */
  24190. position: Vector3;
  24191. /**
  24192. * The rotation of the physics-enabled object
  24193. */
  24194. rotationQuaternion: Nullable<Quaternion>;
  24195. /**
  24196. * The scale of the physics-enabled object
  24197. */
  24198. scaling: Vector3;
  24199. /**
  24200. * The rotation of the physics-enabled object
  24201. */
  24202. rotation?: Vector3;
  24203. /**
  24204. * The parent of the physics-enabled object
  24205. */
  24206. parent?: any;
  24207. /**
  24208. * The bounding info of the physics-enabled object
  24209. * @returns The bounding info of the physics-enabled object
  24210. */
  24211. getBoundingInfo(): BoundingInfo;
  24212. /**
  24213. * Computes the world matrix
  24214. * @param force Specifies if the world matrix should be computed by force
  24215. * @returns A world matrix
  24216. */
  24217. computeWorldMatrix(force: boolean): Matrix;
  24218. /**
  24219. * Gets the world matrix
  24220. * @returns A world matrix
  24221. */
  24222. getWorldMatrix?(): Matrix;
  24223. /**
  24224. * Gets the child meshes
  24225. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24226. * @returns An array of abstract meshes
  24227. */
  24228. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24229. /**
  24230. * Gets the vertex data
  24231. * @param kind The type of vertex data
  24232. * @returns A nullable array of numbers, or a float32 array
  24233. */
  24234. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24235. /**
  24236. * Gets the indices from the mesh
  24237. * @returns A nullable array of index arrays
  24238. */
  24239. getIndices?(): Nullable<IndicesArray>;
  24240. /**
  24241. * Gets the scene from the mesh
  24242. * @returns the indices array or null
  24243. */
  24244. getScene?(): Scene;
  24245. /**
  24246. * Gets the absolute position from the mesh
  24247. * @returns the absolute position
  24248. */
  24249. getAbsolutePosition(): Vector3;
  24250. /**
  24251. * Gets the absolute pivot point from the mesh
  24252. * @returns the absolute pivot point
  24253. */
  24254. getAbsolutePivotPoint(): Vector3;
  24255. /**
  24256. * Rotates the mesh
  24257. * @param axis The axis of rotation
  24258. * @param amount The amount of rotation
  24259. * @param space The space of the rotation
  24260. * @returns The rotation transform node
  24261. */
  24262. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24263. /**
  24264. * Translates the mesh
  24265. * @param axis The axis of translation
  24266. * @param distance The distance of translation
  24267. * @param space The space of the translation
  24268. * @returns The transform node
  24269. */
  24270. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24271. /**
  24272. * Sets the absolute position of the mesh
  24273. * @param absolutePosition The absolute position of the mesh
  24274. * @returns The transform node
  24275. */
  24276. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24277. /**
  24278. * Gets the class name of the mesh
  24279. * @returns The class name
  24280. */
  24281. getClassName(): string;
  24282. }
  24283. /**
  24284. * Represents a physics imposter
  24285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24286. */
  24287. export class PhysicsImpostor {
  24288. /**
  24289. * The physics-enabled object used as the physics imposter
  24290. */
  24291. object: IPhysicsEnabledObject;
  24292. /**
  24293. * The type of the physics imposter
  24294. */
  24295. type: number;
  24296. private _options;
  24297. private _scene?;
  24298. /**
  24299. * The default object size of the imposter
  24300. */
  24301. static DEFAULT_OBJECT_SIZE: Vector3;
  24302. /**
  24303. * The identity quaternion of the imposter
  24304. */
  24305. static IDENTITY_QUATERNION: Quaternion;
  24306. /** @hidden */
  24307. _pluginData: any;
  24308. private _physicsEngine;
  24309. private _physicsBody;
  24310. private _bodyUpdateRequired;
  24311. private _onBeforePhysicsStepCallbacks;
  24312. private _onAfterPhysicsStepCallbacks;
  24313. /** @hidden */
  24314. _onPhysicsCollideCallbacks: Array<{
  24315. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24316. otherImpostors: Array<PhysicsImpostor>;
  24317. }>;
  24318. private _deltaPosition;
  24319. private _deltaRotation;
  24320. private _deltaRotationConjugated;
  24321. /** @hidden */
  24322. _isFromLine: boolean;
  24323. private _parent;
  24324. private _isDisposed;
  24325. private static _tmpVecs;
  24326. private static _tmpQuat;
  24327. /**
  24328. * Specifies if the physics imposter is disposed
  24329. */
  24330. get isDisposed(): boolean;
  24331. /**
  24332. * Gets the mass of the physics imposter
  24333. */
  24334. get mass(): number;
  24335. set mass(value: number);
  24336. /**
  24337. * Gets the coefficient of friction
  24338. */
  24339. get friction(): number;
  24340. /**
  24341. * Sets the coefficient of friction
  24342. */
  24343. set friction(value: number);
  24344. /**
  24345. * Gets the coefficient of restitution
  24346. */
  24347. get restitution(): number;
  24348. /**
  24349. * Sets the coefficient of restitution
  24350. */
  24351. set restitution(value: number);
  24352. /**
  24353. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24354. */
  24355. get pressure(): number;
  24356. /**
  24357. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24358. */
  24359. set pressure(value: number);
  24360. /**
  24361. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24362. */
  24363. get stiffness(): number;
  24364. /**
  24365. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24366. */
  24367. set stiffness(value: number);
  24368. /**
  24369. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24370. */
  24371. get velocityIterations(): number;
  24372. /**
  24373. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24374. */
  24375. set velocityIterations(value: number);
  24376. /**
  24377. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24378. */
  24379. get positionIterations(): number;
  24380. /**
  24381. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24382. */
  24383. set positionIterations(value: number);
  24384. /**
  24385. * The unique id of the physics imposter
  24386. * set by the physics engine when adding this impostor to the array
  24387. */
  24388. uniqueId: number;
  24389. /**
  24390. * @hidden
  24391. */
  24392. soft: boolean;
  24393. /**
  24394. * @hidden
  24395. */
  24396. segments: number;
  24397. private _joints;
  24398. /**
  24399. * Initializes the physics imposter
  24400. * @param object The physics-enabled object used as the physics imposter
  24401. * @param type The type of the physics imposter
  24402. * @param _options The options for the physics imposter
  24403. * @param _scene The Babylon scene
  24404. */
  24405. constructor(
  24406. /**
  24407. * The physics-enabled object used as the physics imposter
  24408. */
  24409. object: IPhysicsEnabledObject,
  24410. /**
  24411. * The type of the physics imposter
  24412. */
  24413. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24414. /**
  24415. * This function will completly initialize this impostor.
  24416. * It will create a new body - but only if this mesh has no parent.
  24417. * If it has, this impostor will not be used other than to define the impostor
  24418. * of the child mesh.
  24419. * @hidden
  24420. */
  24421. _init(): void;
  24422. private _getPhysicsParent;
  24423. /**
  24424. * Should a new body be generated.
  24425. * @returns boolean specifying if body initialization is required
  24426. */
  24427. isBodyInitRequired(): boolean;
  24428. /**
  24429. * Sets the updated scaling
  24430. * @param updated Specifies if the scaling is updated
  24431. */
  24432. setScalingUpdated(): void;
  24433. /**
  24434. * Force a regeneration of this or the parent's impostor's body.
  24435. * Use under cautious - This will remove all joints already implemented.
  24436. */
  24437. forceUpdate(): void;
  24438. /**
  24439. * Gets the body that holds this impostor. Either its own, or its parent.
  24440. */
  24441. get physicsBody(): any;
  24442. /**
  24443. * Get the parent of the physics imposter
  24444. * @returns Physics imposter or null
  24445. */
  24446. get parent(): Nullable<PhysicsImpostor>;
  24447. /**
  24448. * Sets the parent of the physics imposter
  24449. */
  24450. set parent(value: Nullable<PhysicsImpostor>);
  24451. /**
  24452. * Set the physics body. Used mainly by the physics engine/plugin
  24453. */
  24454. set physicsBody(physicsBody: any);
  24455. /**
  24456. * Resets the update flags
  24457. */
  24458. resetUpdateFlags(): void;
  24459. /**
  24460. * Gets the object extend size
  24461. * @returns the object extend size
  24462. */
  24463. getObjectExtendSize(): Vector3;
  24464. /**
  24465. * Gets the object center
  24466. * @returns The object center
  24467. */
  24468. getObjectCenter(): Vector3;
  24469. /**
  24470. * Get a specific parametes from the options parameter
  24471. * @param paramName The object parameter name
  24472. * @returns The object parameter
  24473. */
  24474. getParam(paramName: string): any;
  24475. /**
  24476. * Sets a specific parameter in the options given to the physics plugin
  24477. * @param paramName The parameter name
  24478. * @param value The value of the parameter
  24479. */
  24480. setParam(paramName: string, value: number): void;
  24481. /**
  24482. * Specifically change the body's mass option. Won't recreate the physics body object
  24483. * @param mass The mass of the physics imposter
  24484. */
  24485. setMass(mass: number): void;
  24486. /**
  24487. * Gets the linear velocity
  24488. * @returns linear velocity or null
  24489. */
  24490. getLinearVelocity(): Nullable<Vector3>;
  24491. /**
  24492. * Sets the linear velocity
  24493. * @param velocity linear velocity or null
  24494. */
  24495. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24496. /**
  24497. * Gets the angular velocity
  24498. * @returns angular velocity or null
  24499. */
  24500. getAngularVelocity(): Nullable<Vector3>;
  24501. /**
  24502. * Sets the angular velocity
  24503. * @param velocity The velocity or null
  24504. */
  24505. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24506. /**
  24507. * Execute a function with the physics plugin native code
  24508. * Provide a function the will have two variables - the world object and the physics body object
  24509. * @param func The function to execute with the physics plugin native code
  24510. */
  24511. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24512. /**
  24513. * Register a function that will be executed before the physics world is stepping forward
  24514. * @param func The function to execute before the physics world is stepped forward
  24515. */
  24516. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24517. /**
  24518. * Unregister a function that will be executed before the physics world is stepping forward
  24519. * @param func The function to execute before the physics world is stepped forward
  24520. */
  24521. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24522. /**
  24523. * Register a function that will be executed after the physics step
  24524. * @param func The function to execute after physics step
  24525. */
  24526. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24527. /**
  24528. * Unregisters a function that will be executed after the physics step
  24529. * @param func The function to execute after physics step
  24530. */
  24531. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24532. /**
  24533. * register a function that will be executed when this impostor collides against a different body
  24534. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24535. * @param func Callback that is executed on collision
  24536. */
  24537. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24538. /**
  24539. * Unregisters the physics imposter on contact
  24540. * @param collideAgainst The physics object to collide against
  24541. * @param func Callback to execute on collision
  24542. */
  24543. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24544. private _tmpQuat;
  24545. private _tmpQuat2;
  24546. /**
  24547. * Get the parent rotation
  24548. * @returns The parent rotation
  24549. */
  24550. getParentsRotation(): Quaternion;
  24551. /**
  24552. * this function is executed by the physics engine.
  24553. */
  24554. beforeStep: () => void;
  24555. /**
  24556. * this function is executed by the physics engine
  24557. */
  24558. afterStep: () => void;
  24559. /**
  24560. * Legacy collision detection event support
  24561. */
  24562. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24563. /**
  24564. * event and body object due to cannon's event-based architecture.
  24565. */
  24566. onCollide: (e: {
  24567. body: any;
  24568. }) => void;
  24569. /**
  24570. * Apply a force
  24571. * @param force The force to apply
  24572. * @param contactPoint The contact point for the force
  24573. * @returns The physics imposter
  24574. */
  24575. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24576. /**
  24577. * Apply an impulse
  24578. * @param force The impulse force
  24579. * @param contactPoint The contact point for the impulse force
  24580. * @returns The physics imposter
  24581. */
  24582. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24583. /**
  24584. * A help function to create a joint
  24585. * @param otherImpostor A physics imposter used to create a joint
  24586. * @param jointType The type of joint
  24587. * @param jointData The data for the joint
  24588. * @returns The physics imposter
  24589. */
  24590. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24591. /**
  24592. * Add a joint to this impostor with a different impostor
  24593. * @param otherImpostor A physics imposter used to add a joint
  24594. * @param joint The joint to add
  24595. * @returns The physics imposter
  24596. */
  24597. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24598. /**
  24599. * Add an anchor to a cloth impostor
  24600. * @param otherImpostor rigid impostor to anchor to
  24601. * @param width ratio across width from 0 to 1
  24602. * @param height ratio up height from 0 to 1
  24603. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24604. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24605. * @returns impostor the soft imposter
  24606. */
  24607. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24608. /**
  24609. * Add a hook to a rope impostor
  24610. * @param otherImpostor rigid impostor to anchor to
  24611. * @param length ratio across rope from 0 to 1
  24612. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24613. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24614. * @returns impostor the rope imposter
  24615. */
  24616. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24617. /**
  24618. * Will keep this body still, in a sleep mode.
  24619. * @returns the physics imposter
  24620. */
  24621. sleep(): PhysicsImpostor;
  24622. /**
  24623. * Wake the body up.
  24624. * @returns The physics imposter
  24625. */
  24626. wakeUp(): PhysicsImpostor;
  24627. /**
  24628. * Clones the physics imposter
  24629. * @param newObject The physics imposter clones to this physics-enabled object
  24630. * @returns A nullable physics imposter
  24631. */
  24632. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24633. /**
  24634. * Disposes the physics imposter
  24635. */
  24636. dispose(): void;
  24637. /**
  24638. * Sets the delta position
  24639. * @param position The delta position amount
  24640. */
  24641. setDeltaPosition(position: Vector3): void;
  24642. /**
  24643. * Sets the delta rotation
  24644. * @param rotation The delta rotation amount
  24645. */
  24646. setDeltaRotation(rotation: Quaternion): void;
  24647. /**
  24648. * Gets the box size of the physics imposter and stores the result in the input parameter
  24649. * @param result Stores the box size
  24650. * @returns The physics imposter
  24651. */
  24652. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24653. /**
  24654. * Gets the radius of the physics imposter
  24655. * @returns Radius of the physics imposter
  24656. */
  24657. getRadius(): number;
  24658. /**
  24659. * Sync a bone with this impostor
  24660. * @param bone The bone to sync to the impostor.
  24661. * @param boneMesh The mesh that the bone is influencing.
  24662. * @param jointPivot The pivot of the joint / bone in local space.
  24663. * @param distToJoint Optional distance from the impostor to the joint.
  24664. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24665. */
  24666. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24667. /**
  24668. * Sync impostor to a bone
  24669. * @param bone The bone that the impostor will be synced to.
  24670. * @param boneMesh The mesh that the bone is influencing.
  24671. * @param jointPivot The pivot of the joint / bone in local space.
  24672. * @param distToJoint Optional distance from the impostor to the joint.
  24673. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24674. * @param boneAxis Optional vector3 axis the bone is aligned with
  24675. */
  24676. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24677. /**
  24678. * No-Imposter type
  24679. */
  24680. static NoImpostor: number;
  24681. /**
  24682. * Sphere-Imposter type
  24683. */
  24684. static SphereImpostor: number;
  24685. /**
  24686. * Box-Imposter type
  24687. */
  24688. static BoxImpostor: number;
  24689. /**
  24690. * Plane-Imposter type
  24691. */
  24692. static PlaneImpostor: number;
  24693. /**
  24694. * Mesh-imposter type
  24695. */
  24696. static MeshImpostor: number;
  24697. /**
  24698. * Capsule-Impostor type (Ammo.js plugin only)
  24699. */
  24700. static CapsuleImpostor: number;
  24701. /**
  24702. * Cylinder-Imposter type
  24703. */
  24704. static CylinderImpostor: number;
  24705. /**
  24706. * Particle-Imposter type
  24707. */
  24708. static ParticleImpostor: number;
  24709. /**
  24710. * Heightmap-Imposter type
  24711. */
  24712. static HeightmapImpostor: number;
  24713. /**
  24714. * ConvexHull-Impostor type (Ammo.js plugin only)
  24715. */
  24716. static ConvexHullImpostor: number;
  24717. /**
  24718. * Custom-Imposter type (Ammo.js plugin only)
  24719. */
  24720. static CustomImpostor: number;
  24721. /**
  24722. * Rope-Imposter type
  24723. */
  24724. static RopeImpostor: number;
  24725. /**
  24726. * Cloth-Imposter type
  24727. */
  24728. static ClothImpostor: number;
  24729. /**
  24730. * Softbody-Imposter type
  24731. */
  24732. static SoftbodyImpostor: number;
  24733. }
  24734. }
  24735. declare module "babylonjs/Meshes/mesh" {
  24736. import { Observable } from "babylonjs/Misc/observable";
  24737. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24738. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24739. import { Camera } from "babylonjs/Cameras/camera";
  24740. import { Scene } from "babylonjs/scene";
  24741. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24742. import { Color4 } from "babylonjs/Maths/math.color";
  24743. import { Engine } from "babylonjs/Engines/engine";
  24744. import { Node } from "babylonjs/node";
  24745. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24746. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24747. import { Buffer } from "babylonjs/Meshes/buffer";
  24748. import { Geometry } from "babylonjs/Meshes/geometry";
  24749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24751. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24752. import { Effect } from "babylonjs/Materials/effect";
  24753. import { Material } from "babylonjs/Materials/material";
  24754. import { Skeleton } from "babylonjs/Bones/skeleton";
  24755. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24756. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24757. import { Path3D } from "babylonjs/Maths/math.path";
  24758. import { Plane } from "babylonjs/Maths/math.plane";
  24759. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24760. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24761. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24762. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24763. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24764. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24765. /**
  24766. * @hidden
  24767. **/
  24768. export class _CreationDataStorage {
  24769. closePath?: boolean;
  24770. closeArray?: boolean;
  24771. idx: number[];
  24772. dashSize: number;
  24773. gapSize: number;
  24774. path3D: Path3D;
  24775. pathArray: Vector3[][];
  24776. arc: number;
  24777. radius: number;
  24778. cap: number;
  24779. tessellation: number;
  24780. }
  24781. /**
  24782. * @hidden
  24783. **/
  24784. class _InstanceDataStorage {
  24785. visibleInstances: any;
  24786. batchCache: _InstancesBatch;
  24787. instancesBufferSize: number;
  24788. instancesBuffer: Nullable<Buffer>;
  24789. instancesData: Float32Array;
  24790. overridenInstanceCount: number;
  24791. isFrozen: boolean;
  24792. previousBatch: Nullable<_InstancesBatch>;
  24793. hardwareInstancedRendering: boolean;
  24794. sideOrientation: number;
  24795. manualUpdate: boolean;
  24796. }
  24797. /**
  24798. * @hidden
  24799. **/
  24800. export class _InstancesBatch {
  24801. mustReturn: boolean;
  24802. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24803. renderSelf: boolean[];
  24804. hardwareInstancedRendering: boolean[];
  24805. }
  24806. /**
  24807. * Class used to represent renderable models
  24808. */
  24809. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24810. /**
  24811. * Mesh side orientation : usually the external or front surface
  24812. */
  24813. static readonly FRONTSIDE: number;
  24814. /**
  24815. * Mesh side orientation : usually the internal or back surface
  24816. */
  24817. static readonly BACKSIDE: number;
  24818. /**
  24819. * Mesh side orientation : both internal and external or front and back surfaces
  24820. */
  24821. static readonly DOUBLESIDE: number;
  24822. /**
  24823. * Mesh side orientation : by default, `FRONTSIDE`
  24824. */
  24825. static readonly DEFAULTSIDE: number;
  24826. /**
  24827. * Mesh cap setting : no cap
  24828. */
  24829. static readonly NO_CAP: number;
  24830. /**
  24831. * Mesh cap setting : one cap at the beginning of the mesh
  24832. */
  24833. static readonly CAP_START: number;
  24834. /**
  24835. * Mesh cap setting : one cap at the end of the mesh
  24836. */
  24837. static readonly CAP_END: number;
  24838. /**
  24839. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24840. */
  24841. static readonly CAP_ALL: number;
  24842. /**
  24843. * Mesh pattern setting : no flip or rotate
  24844. */
  24845. static readonly NO_FLIP: number;
  24846. /**
  24847. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24848. */
  24849. static readonly FLIP_TILE: number;
  24850. /**
  24851. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24852. */
  24853. static readonly ROTATE_TILE: number;
  24854. /**
  24855. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24856. */
  24857. static readonly FLIP_ROW: number;
  24858. /**
  24859. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24860. */
  24861. static readonly ROTATE_ROW: number;
  24862. /**
  24863. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24864. */
  24865. static readonly FLIP_N_ROTATE_TILE: number;
  24866. /**
  24867. * Mesh pattern setting : rotate pattern and rotate
  24868. */
  24869. static readonly FLIP_N_ROTATE_ROW: number;
  24870. /**
  24871. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24872. */
  24873. static readonly CENTER: number;
  24874. /**
  24875. * Mesh tile positioning : part tiles on left
  24876. */
  24877. static readonly LEFT: number;
  24878. /**
  24879. * Mesh tile positioning : part tiles on right
  24880. */
  24881. static readonly RIGHT: number;
  24882. /**
  24883. * Mesh tile positioning : part tiles on top
  24884. */
  24885. static readonly TOP: number;
  24886. /**
  24887. * Mesh tile positioning : part tiles on bottom
  24888. */
  24889. static readonly BOTTOM: number;
  24890. /**
  24891. * Gets the default side orientation.
  24892. * @param orientation the orientation to value to attempt to get
  24893. * @returns the default orientation
  24894. * @hidden
  24895. */
  24896. static _GetDefaultSideOrientation(orientation?: number): number;
  24897. private _internalMeshDataInfo;
  24898. /**
  24899. * An event triggered before rendering the mesh
  24900. */
  24901. get onBeforeRenderObservable(): Observable<Mesh>;
  24902. /**
  24903. * An event triggered before binding the mesh
  24904. */
  24905. get onBeforeBindObservable(): Observable<Mesh>;
  24906. /**
  24907. * An event triggered after rendering the mesh
  24908. */
  24909. get onAfterRenderObservable(): Observable<Mesh>;
  24910. /**
  24911. * An event triggered before drawing the mesh
  24912. */
  24913. get onBeforeDrawObservable(): Observable<Mesh>;
  24914. private _onBeforeDrawObserver;
  24915. /**
  24916. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24917. */
  24918. set onBeforeDraw(callback: () => void);
  24919. get hasInstances(): boolean;
  24920. /**
  24921. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24922. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24923. */
  24924. delayLoadState: number;
  24925. /**
  24926. * Gets the list of instances created from this mesh
  24927. * it is not supposed to be modified manually.
  24928. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24929. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24930. */
  24931. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24932. /**
  24933. * Gets the file containing delay loading data for this mesh
  24934. */
  24935. delayLoadingFile: string;
  24936. /** @hidden */
  24937. _binaryInfo: any;
  24938. /**
  24939. * User defined function used to change how LOD level selection is done
  24940. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24941. */
  24942. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24943. /**
  24944. * Gets or sets the morph target manager
  24945. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24946. */
  24947. get morphTargetManager(): Nullable<MorphTargetManager>;
  24948. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24949. /** @hidden */
  24950. _creationDataStorage: Nullable<_CreationDataStorage>;
  24951. /** @hidden */
  24952. _geometry: Nullable<Geometry>;
  24953. /** @hidden */
  24954. _delayInfo: Array<string>;
  24955. /** @hidden */
  24956. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24957. /** @hidden */
  24958. _instanceDataStorage: _InstanceDataStorage;
  24959. private _effectiveMaterial;
  24960. /** @hidden */
  24961. _shouldGenerateFlatShading: boolean;
  24962. /** @hidden */
  24963. _originalBuilderSideOrientation: number;
  24964. /**
  24965. * Use this property to change the original side orientation defined at construction time
  24966. */
  24967. overrideMaterialSideOrientation: Nullable<number>;
  24968. /**
  24969. * Gets the source mesh (the one used to clone this one from)
  24970. */
  24971. get source(): Nullable<Mesh>;
  24972. /**
  24973. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24974. */
  24975. get isUnIndexed(): boolean;
  24976. set isUnIndexed(value: boolean);
  24977. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24978. get worldMatrixInstancedBuffer(): Float32Array;
  24979. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24980. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24981. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24982. /**
  24983. * @constructor
  24984. * @param name The value used by scene.getMeshByName() to do a lookup.
  24985. * @param scene The scene to add this mesh to.
  24986. * @param parent The parent of this mesh, if it has one
  24987. * @param source An optional Mesh from which geometry is shared, cloned.
  24988. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24989. * When false, achieved by calling a clone(), also passing False.
  24990. * This will make creation of children, recursive.
  24991. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24992. */
  24993. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24994. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24995. doNotInstantiate: boolean;
  24996. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24997. /**
  24998. * Gets the class name
  24999. * @returns the string "Mesh".
  25000. */
  25001. getClassName(): string;
  25002. /** @hidden */
  25003. get _isMesh(): boolean;
  25004. /**
  25005. * Returns a description of this mesh
  25006. * @param fullDetails define if full details about this mesh must be used
  25007. * @returns a descriptive string representing this mesh
  25008. */
  25009. toString(fullDetails?: boolean): string;
  25010. /** @hidden */
  25011. _unBindEffect(): void;
  25012. /**
  25013. * Gets a boolean indicating if this mesh has LOD
  25014. */
  25015. get hasLODLevels(): boolean;
  25016. /**
  25017. * Gets the list of MeshLODLevel associated with the current mesh
  25018. * @returns an array of MeshLODLevel
  25019. */
  25020. getLODLevels(): MeshLODLevel[];
  25021. private _sortLODLevels;
  25022. /**
  25023. * Add a mesh as LOD level triggered at the given distance.
  25024. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25025. * @param distance The distance from the center of the object to show this level
  25026. * @param mesh The mesh to be added as LOD level (can be null)
  25027. * @return This mesh (for chaining)
  25028. */
  25029. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25030. /**
  25031. * Returns the LOD level mesh at the passed distance or null if not found.
  25032. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25033. * @param distance The distance from the center of the object to show this level
  25034. * @returns a Mesh or `null`
  25035. */
  25036. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25037. /**
  25038. * Remove a mesh from the LOD array
  25039. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25040. * @param mesh defines the mesh to be removed
  25041. * @return This mesh (for chaining)
  25042. */
  25043. removeLODLevel(mesh: Mesh): Mesh;
  25044. /**
  25045. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25046. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25047. * @param camera defines the camera to use to compute distance
  25048. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25049. * @return This mesh (for chaining)
  25050. */
  25051. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25052. /**
  25053. * Gets the mesh internal Geometry object
  25054. */
  25055. get geometry(): Nullable<Geometry>;
  25056. /**
  25057. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25058. * @returns the total number of vertices
  25059. */
  25060. getTotalVertices(): number;
  25061. /**
  25062. * Returns the content of an associated vertex buffer
  25063. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25064. * - VertexBuffer.PositionKind
  25065. * - VertexBuffer.UVKind
  25066. * - VertexBuffer.UV2Kind
  25067. * - VertexBuffer.UV3Kind
  25068. * - VertexBuffer.UV4Kind
  25069. * - VertexBuffer.UV5Kind
  25070. * - VertexBuffer.UV6Kind
  25071. * - VertexBuffer.ColorKind
  25072. * - VertexBuffer.MatricesIndicesKind
  25073. * - VertexBuffer.MatricesIndicesExtraKind
  25074. * - VertexBuffer.MatricesWeightsKind
  25075. * - VertexBuffer.MatricesWeightsExtraKind
  25076. * @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
  25077. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25078. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25079. */
  25080. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25081. /**
  25082. * Returns the mesh VertexBuffer object from the requested `kind`
  25083. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25084. * - VertexBuffer.PositionKind
  25085. * - VertexBuffer.NormalKind
  25086. * - VertexBuffer.UVKind
  25087. * - VertexBuffer.UV2Kind
  25088. * - VertexBuffer.UV3Kind
  25089. * - VertexBuffer.UV4Kind
  25090. * - VertexBuffer.UV5Kind
  25091. * - VertexBuffer.UV6Kind
  25092. * - VertexBuffer.ColorKind
  25093. * - VertexBuffer.MatricesIndicesKind
  25094. * - VertexBuffer.MatricesIndicesExtraKind
  25095. * - VertexBuffer.MatricesWeightsKind
  25096. * - VertexBuffer.MatricesWeightsExtraKind
  25097. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25098. */
  25099. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25100. /**
  25101. * Tests if a specific vertex buffer is associated with this mesh
  25102. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25103. * - VertexBuffer.PositionKind
  25104. * - VertexBuffer.NormalKind
  25105. * - VertexBuffer.UVKind
  25106. * - VertexBuffer.UV2Kind
  25107. * - VertexBuffer.UV3Kind
  25108. * - VertexBuffer.UV4Kind
  25109. * - VertexBuffer.UV5Kind
  25110. * - VertexBuffer.UV6Kind
  25111. * - VertexBuffer.ColorKind
  25112. * - VertexBuffer.MatricesIndicesKind
  25113. * - VertexBuffer.MatricesIndicesExtraKind
  25114. * - VertexBuffer.MatricesWeightsKind
  25115. * - VertexBuffer.MatricesWeightsExtraKind
  25116. * @returns a boolean
  25117. */
  25118. isVerticesDataPresent(kind: string): boolean;
  25119. /**
  25120. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25121. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25122. * - VertexBuffer.PositionKind
  25123. * - VertexBuffer.UVKind
  25124. * - VertexBuffer.UV2Kind
  25125. * - VertexBuffer.UV3Kind
  25126. * - VertexBuffer.UV4Kind
  25127. * - VertexBuffer.UV5Kind
  25128. * - VertexBuffer.UV6Kind
  25129. * - VertexBuffer.ColorKind
  25130. * - VertexBuffer.MatricesIndicesKind
  25131. * - VertexBuffer.MatricesIndicesExtraKind
  25132. * - VertexBuffer.MatricesWeightsKind
  25133. * - VertexBuffer.MatricesWeightsExtraKind
  25134. * @returns a boolean
  25135. */
  25136. isVertexBufferUpdatable(kind: string): boolean;
  25137. /**
  25138. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25139. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25140. * - VertexBuffer.PositionKind
  25141. * - VertexBuffer.NormalKind
  25142. * - VertexBuffer.UVKind
  25143. * - VertexBuffer.UV2Kind
  25144. * - VertexBuffer.UV3Kind
  25145. * - VertexBuffer.UV4Kind
  25146. * - VertexBuffer.UV5Kind
  25147. * - VertexBuffer.UV6Kind
  25148. * - VertexBuffer.ColorKind
  25149. * - VertexBuffer.MatricesIndicesKind
  25150. * - VertexBuffer.MatricesIndicesExtraKind
  25151. * - VertexBuffer.MatricesWeightsKind
  25152. * - VertexBuffer.MatricesWeightsExtraKind
  25153. * @returns an array of strings
  25154. */
  25155. getVerticesDataKinds(): string[];
  25156. /**
  25157. * Returns a positive integer : the total number of indices in this mesh geometry.
  25158. * @returns the numner of indices or zero if the mesh has no geometry.
  25159. */
  25160. getTotalIndices(): number;
  25161. /**
  25162. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25163. * @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.
  25164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25165. * @returns the indices array or an empty array if the mesh has no geometry
  25166. */
  25167. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25168. get isBlocked(): boolean;
  25169. /**
  25170. * Determine if the current mesh is ready to be rendered
  25171. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25172. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25173. * @returns true if all associated assets are ready (material, textures, shaders)
  25174. */
  25175. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25176. /**
  25177. * 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.
  25178. */
  25179. get areNormalsFrozen(): boolean;
  25180. /**
  25181. * 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.
  25182. * @returns the current mesh
  25183. */
  25184. freezeNormals(): Mesh;
  25185. /**
  25186. * 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
  25187. * @returns the current mesh
  25188. */
  25189. unfreezeNormals(): Mesh;
  25190. /**
  25191. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25192. */
  25193. set overridenInstanceCount(count: number);
  25194. /** @hidden */
  25195. _preActivate(): Mesh;
  25196. /** @hidden */
  25197. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25198. /** @hidden */
  25199. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25200. /**
  25201. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25202. * This means the mesh underlying bounding box and sphere are recomputed.
  25203. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25204. * @returns the current mesh
  25205. */
  25206. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25207. /** @hidden */
  25208. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25209. /**
  25210. * This function will subdivide the mesh into multiple submeshes
  25211. * @param count defines the expected number of submeshes
  25212. */
  25213. subdivide(count: number): void;
  25214. /**
  25215. * Copy a FloatArray into a specific associated vertex buffer
  25216. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25217. * - VertexBuffer.PositionKind
  25218. * - VertexBuffer.UVKind
  25219. * - VertexBuffer.UV2Kind
  25220. * - VertexBuffer.UV3Kind
  25221. * - VertexBuffer.UV4Kind
  25222. * - VertexBuffer.UV5Kind
  25223. * - VertexBuffer.UV6Kind
  25224. * - VertexBuffer.ColorKind
  25225. * - VertexBuffer.MatricesIndicesKind
  25226. * - VertexBuffer.MatricesIndicesExtraKind
  25227. * - VertexBuffer.MatricesWeightsKind
  25228. * - VertexBuffer.MatricesWeightsExtraKind
  25229. * @param data defines the data source
  25230. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25231. * @param stride defines the data stride size (can be null)
  25232. * @returns the current mesh
  25233. */
  25234. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25235. /**
  25236. * Delete a vertex buffer associated with this mesh
  25237. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25238. * - VertexBuffer.PositionKind
  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. */
  25251. removeVerticesData(kind: string): void;
  25252. /**
  25253. * Flags an associated vertex buffer as updatable
  25254. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25255. * - VertexBuffer.PositionKind
  25256. * - VertexBuffer.UVKind
  25257. * - VertexBuffer.UV2Kind
  25258. * - VertexBuffer.UV3Kind
  25259. * - VertexBuffer.UV4Kind
  25260. * - VertexBuffer.UV5Kind
  25261. * - VertexBuffer.UV6Kind
  25262. * - VertexBuffer.ColorKind
  25263. * - VertexBuffer.MatricesIndicesKind
  25264. * - VertexBuffer.MatricesIndicesExtraKind
  25265. * - VertexBuffer.MatricesWeightsKind
  25266. * - VertexBuffer.MatricesWeightsExtraKind
  25267. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25268. */
  25269. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25270. /**
  25271. * Sets the mesh global Vertex Buffer
  25272. * @param buffer defines the buffer to use
  25273. * @returns the current mesh
  25274. */
  25275. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25276. /**
  25277. * Update a specific associated vertex buffer
  25278. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25279. * - VertexBuffer.PositionKind
  25280. * - VertexBuffer.UVKind
  25281. * - VertexBuffer.UV2Kind
  25282. * - VertexBuffer.UV3Kind
  25283. * - VertexBuffer.UV4Kind
  25284. * - VertexBuffer.UV5Kind
  25285. * - VertexBuffer.UV6Kind
  25286. * - VertexBuffer.ColorKind
  25287. * - VertexBuffer.MatricesIndicesKind
  25288. * - VertexBuffer.MatricesIndicesExtraKind
  25289. * - VertexBuffer.MatricesWeightsKind
  25290. * - VertexBuffer.MatricesWeightsExtraKind
  25291. * @param data defines the data source
  25292. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25293. * @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)
  25294. * @returns the current mesh
  25295. */
  25296. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25297. /**
  25298. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25299. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25300. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25301. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25302. * @returns the current mesh
  25303. */
  25304. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25305. /**
  25306. * Creates a un-shared specific occurence of the geometry for the mesh.
  25307. * @returns the current mesh
  25308. */
  25309. makeGeometryUnique(): Mesh;
  25310. /**
  25311. * Set the index buffer of this mesh
  25312. * @param indices defines the source data
  25313. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25314. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25315. * @returns the current mesh
  25316. */
  25317. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25318. /**
  25319. * Update the current index buffer
  25320. * @param indices defines the source data
  25321. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25322. * @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)
  25323. * @returns the current mesh
  25324. */
  25325. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25326. /**
  25327. * Invert the geometry to move from a right handed system to a left handed one.
  25328. * @returns the current mesh
  25329. */
  25330. toLeftHanded(): Mesh;
  25331. /** @hidden */
  25332. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25333. /** @hidden */
  25334. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25335. /**
  25336. * Registers for this mesh a javascript function called just before the rendering process
  25337. * @param func defines the function to call before rendering this mesh
  25338. * @returns the current mesh
  25339. */
  25340. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25341. /**
  25342. * Disposes a previously registered javascript function called before the rendering
  25343. * @param func defines the function to remove
  25344. * @returns the current mesh
  25345. */
  25346. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25347. /**
  25348. * Registers for this mesh a javascript function called just after the rendering is complete
  25349. * @param func defines the function to call after rendering this mesh
  25350. * @returns the current mesh
  25351. */
  25352. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25353. /**
  25354. * Disposes a previously registered javascript function called after the rendering.
  25355. * @param func defines the function to remove
  25356. * @returns the current mesh
  25357. */
  25358. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25359. /** @hidden */
  25360. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25361. /** @hidden */
  25362. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25363. /** @hidden */
  25364. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25365. /** @hidden */
  25366. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25367. /** @hidden */
  25368. _rebuild(): void;
  25369. /** @hidden */
  25370. _freeze(): void;
  25371. /** @hidden */
  25372. _unFreeze(): void;
  25373. /**
  25374. * 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
  25375. * @param subMesh defines the subMesh to render
  25376. * @param enableAlphaMode defines if alpha mode can be changed
  25377. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25378. * @returns the current mesh
  25379. */
  25380. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25381. private _onBeforeDraw;
  25382. /**
  25383. * Renormalize the mesh and patch it up if there are no weights
  25384. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25385. * However in the case of zero weights then we set just a single influence to 1.
  25386. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25387. */
  25388. cleanMatrixWeights(): void;
  25389. private normalizeSkinFourWeights;
  25390. private normalizeSkinWeightsAndExtra;
  25391. /**
  25392. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25393. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25394. * the user know there was an issue with importing the mesh
  25395. * @returns a validation object with skinned, valid and report string
  25396. */
  25397. validateSkinning(): {
  25398. skinned: boolean;
  25399. valid: boolean;
  25400. report: string;
  25401. };
  25402. /** @hidden */
  25403. _checkDelayState(): Mesh;
  25404. private _queueLoad;
  25405. /**
  25406. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25407. * A mesh is in the frustum if its bounding box intersects the frustum
  25408. * @param frustumPlanes defines the frustum to test
  25409. * @returns true if the mesh is in the frustum planes
  25410. */
  25411. isInFrustum(frustumPlanes: Plane[]): boolean;
  25412. /**
  25413. * Sets the mesh material by the material or multiMaterial `id` property
  25414. * @param id is a string identifying the material or the multiMaterial
  25415. * @returns the current mesh
  25416. */
  25417. setMaterialByID(id: string): Mesh;
  25418. /**
  25419. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25420. * @returns an array of IAnimatable
  25421. */
  25422. getAnimatables(): IAnimatable[];
  25423. /**
  25424. * Modifies the mesh geometry according to the passed transformation matrix.
  25425. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25426. * The mesh normals are modified using the same transformation.
  25427. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25428. * @param transform defines the transform matrix to use
  25429. * @see http://doc.babylonjs.com/resources/baking_transformations
  25430. * @returns the current mesh
  25431. */
  25432. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25433. /**
  25434. * Modifies the mesh geometry according to its own current World Matrix.
  25435. * The mesh World Matrix is then reset.
  25436. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25437. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25438. * @see http://doc.babylonjs.com/resources/baking_transformations
  25439. * @returns the current mesh
  25440. */
  25441. bakeCurrentTransformIntoVertices(): Mesh;
  25442. /** @hidden */
  25443. get _positions(): Nullable<Vector3[]>;
  25444. /** @hidden */
  25445. _resetPointsArrayCache(): Mesh;
  25446. /** @hidden */
  25447. _generatePointsArray(): boolean;
  25448. /**
  25449. * Returns a new Mesh object generated from the current mesh properties.
  25450. * This method must not get confused with createInstance()
  25451. * @param name is a string, the name given to the new mesh
  25452. * @param newParent can be any Node object (default `null`)
  25453. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25454. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25455. * @returns a new mesh
  25456. */
  25457. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25458. /**
  25459. * Releases resources associated with this mesh.
  25460. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25461. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25462. */
  25463. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25464. /** @hidden */
  25465. _disposeInstanceSpecificData(): void;
  25466. /**
  25467. * Modifies the mesh geometry according to a displacement map.
  25468. * 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.
  25469. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25470. * @param url is a string, the URL from the image file is to be downloaded.
  25471. * @param minHeight is the lower limit of the displacement.
  25472. * @param maxHeight is the upper limit of the displacement.
  25473. * @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.
  25474. * @param uvOffset is an optional vector2 used to offset UV.
  25475. * @param uvScale is an optional vector2 used to scale UV.
  25476. * @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.
  25477. * @returns the Mesh.
  25478. */
  25479. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25480. /**
  25481. * Modifies the mesh geometry according to a displacementMap buffer.
  25482. * 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.
  25483. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25484. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25485. * @param heightMapWidth is the width of the buffer image.
  25486. * @param heightMapHeight is the height of the buffer image.
  25487. * @param minHeight is the lower limit of the displacement.
  25488. * @param maxHeight is the upper limit of the displacement.
  25489. * @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.
  25490. * @param uvOffset is an optional vector2 used to offset UV.
  25491. * @param uvScale is an optional vector2 used to scale UV.
  25492. * @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.
  25493. * @returns the Mesh.
  25494. */
  25495. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25496. /**
  25497. * Modify the mesh to get a flat shading rendering.
  25498. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25499. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25500. * @returns current mesh
  25501. */
  25502. convertToFlatShadedMesh(): Mesh;
  25503. /**
  25504. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25505. * In other words, more vertices, no more indices and a single bigger VBO.
  25506. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25507. * @returns current mesh
  25508. */
  25509. convertToUnIndexedMesh(): Mesh;
  25510. /**
  25511. * Inverses facet orientations.
  25512. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25513. * @param flipNormals will also inverts the normals
  25514. * @returns current mesh
  25515. */
  25516. flipFaces(flipNormals?: boolean): Mesh;
  25517. /**
  25518. * Increase the number of facets and hence vertices in a mesh
  25519. * Vertex normals are interpolated from existing vertex normals
  25520. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25521. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25522. */
  25523. increaseVertices(numberPerEdge: number): void;
  25524. /**
  25525. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25526. * This will undo any application of covertToFlatShadedMesh
  25527. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25528. */
  25529. forceSharedVertices(): void;
  25530. /** @hidden */
  25531. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25532. /** @hidden */
  25533. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25534. /**
  25535. * Creates a new InstancedMesh object from the mesh model.
  25536. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25537. * @param name defines the name of the new instance
  25538. * @returns a new InstancedMesh
  25539. */
  25540. createInstance(name: string): InstancedMesh;
  25541. /**
  25542. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25543. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25544. * @returns the current mesh
  25545. */
  25546. synchronizeInstances(): Mesh;
  25547. /**
  25548. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25549. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25550. * This should be used together with the simplification to avoid disappearing triangles.
  25551. * @param successCallback an optional success callback to be called after the optimization finished.
  25552. * @returns the current mesh
  25553. */
  25554. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25555. /**
  25556. * Serialize current mesh
  25557. * @param serializationObject defines the object which will receive the serialization data
  25558. */
  25559. serialize(serializationObject: any): void;
  25560. /** @hidden */
  25561. _syncGeometryWithMorphTargetManager(): void;
  25562. /** @hidden */
  25563. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25564. /**
  25565. * Returns a new Mesh object parsed from the source provided.
  25566. * @param parsedMesh is the source
  25567. * @param scene defines the hosting scene
  25568. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25569. * @returns a new Mesh
  25570. */
  25571. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25572. /**
  25573. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25574. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25575. * @param name defines the name of the mesh to create
  25576. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25577. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25578. * @param closePath creates a seam between the first and the last points of each path of the path array
  25579. * @param offset is taken in account only if the `pathArray` is containing a single path
  25580. * @param scene defines the hosting scene
  25581. * @param updatable defines if the mesh must be flagged as updatable
  25582. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25583. * @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)
  25584. * @returns a new Mesh
  25585. */
  25586. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25587. /**
  25588. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25589. * @param name defines the name of the mesh to create
  25590. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25591. * @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
  25592. * @param scene defines the hosting scene
  25593. * @param updatable defines if the mesh must be flagged as updatable
  25594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25595. * @returns a new Mesh
  25596. */
  25597. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25598. /**
  25599. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25600. * @param name defines the name of the mesh to create
  25601. * @param size sets the size (float) of each box side (default 1)
  25602. * @param scene defines the hosting scene
  25603. * @param updatable defines if the mesh must be flagged as updatable
  25604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25605. * @returns a new Mesh
  25606. */
  25607. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25608. /**
  25609. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25610. * @param name defines the name of the mesh to create
  25611. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25612. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25613. * @param scene defines the hosting scene
  25614. * @param updatable defines if the mesh must be flagged as updatable
  25615. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25616. * @returns a new Mesh
  25617. */
  25618. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25619. /**
  25620. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25621. * @param name defines the name of the mesh to create
  25622. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25623. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25624. * @param scene defines the hosting scene
  25625. * @returns a new Mesh
  25626. */
  25627. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25628. /**
  25629. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25630. * @param name defines the name of the mesh to create
  25631. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25632. * @param diameterTop set the top cap diameter (floats, default 1)
  25633. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25634. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25635. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25636. * @param scene defines the hosting scene
  25637. * @param updatable defines if the mesh must be flagged as updatable
  25638. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25639. * @returns a new Mesh
  25640. */
  25641. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25642. /**
  25643. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25644. * @param name defines the name of the mesh to create
  25645. * @param diameter sets the diameter size (float) of the torus (default 1)
  25646. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25647. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25648. * @param scene defines the hosting scene
  25649. * @param updatable defines if the mesh must be flagged as updatable
  25650. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25651. * @returns a new Mesh
  25652. */
  25653. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25654. /**
  25655. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25656. * @param name defines the name of the mesh to create
  25657. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25658. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25659. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25660. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25661. * @param p the number of windings on X axis (positive integers, default 2)
  25662. * @param q the number of windings on Y axis (positive integers, default 3)
  25663. * @param scene defines the hosting scene
  25664. * @param updatable defines if the mesh must be flagged as updatable
  25665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25666. * @returns a new Mesh
  25667. */
  25668. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25669. /**
  25670. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25671. * @param name defines the name of the mesh to create
  25672. * @param points is an array successive Vector3
  25673. * @param scene defines the hosting scene
  25674. * @param updatable defines if the mesh must be flagged as updatable
  25675. * @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).
  25676. * @returns a new Mesh
  25677. */
  25678. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25679. /**
  25680. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25681. * @param name defines the name of the mesh to create
  25682. * @param points is an array successive Vector3
  25683. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25684. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25685. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25686. * @param scene defines the hosting scene
  25687. * @param updatable defines if the mesh must be flagged as updatable
  25688. * @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)
  25689. * @returns a new Mesh
  25690. */
  25691. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25692. /**
  25693. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25694. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25695. * 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.
  25696. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25697. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25698. * Remember you can only change the shape positions, not their number when updating a polygon.
  25699. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25700. * @param name defines the name of the mesh to create
  25701. * @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
  25702. * @param scene defines the hosting scene
  25703. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25704. * @param updatable defines if the mesh must be flagged as updatable
  25705. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25706. * @param earcutInjection can be used to inject your own earcut reference
  25707. * @returns a new Mesh
  25708. */
  25709. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25710. /**
  25711. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25712. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25713. * @param name defines the name of the mesh to create
  25714. * @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
  25715. * @param depth defines the height of extrusion
  25716. * @param scene defines the hosting scene
  25717. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25718. * @param updatable defines if the mesh must be flagged as updatable
  25719. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25720. * @param earcutInjection can be used to inject your own earcut reference
  25721. * @returns a new Mesh
  25722. */
  25723. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25724. /**
  25725. * Creates an extruded shape mesh.
  25726. * 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
  25727. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25728. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25729. * @param name defines the name of the mesh to create
  25730. * @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
  25731. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25732. * @param scale is the value to scale the shape
  25733. * @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
  25734. * @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
  25735. * @param scene defines the hosting scene
  25736. * @param updatable defines if the mesh must be flagged as updatable
  25737. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25738. * @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)
  25739. * @returns a new Mesh
  25740. */
  25741. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25742. /**
  25743. * Creates an custom extruded shape mesh.
  25744. * The custom extrusion is a parametric shape.
  25745. * It has no predefined shape. Its final shape will depend on the input parameters.
  25746. * Please consider using the same method from the MeshBuilder class instead
  25747. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25748. * @param name defines the name of the mesh to create
  25749. * @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
  25750. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25751. * @param scaleFunction is a custom Javascript function called on each path point
  25752. * @param rotationFunction is a custom Javascript function called on each path point
  25753. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25754. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25755. * @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
  25756. * @param scene defines the hosting scene
  25757. * @param updatable defines if the mesh must be flagged as updatable
  25758. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25759. * @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)
  25760. * @returns a new Mesh
  25761. */
  25762. 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;
  25763. /**
  25764. * Creates lathe mesh.
  25765. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25766. * Please consider using the same method from the MeshBuilder class instead
  25767. * @param name defines the name of the mesh to create
  25768. * @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
  25769. * @param radius is the radius value of the lathe
  25770. * @param tessellation is the side number of the lathe.
  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 CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25777. /**
  25778. * Creates a plane 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 size sets the size (float) of both sides of the plane at once (default 1)
  25781. * @param scene defines the hosting scene
  25782. * @param updatable defines if the mesh must be flagged as updatable
  25783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25784. * @returns a new Mesh
  25785. */
  25786. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25787. /**
  25788. * Creates a ground mesh.
  25789. * Please consider using the same method from the MeshBuilder class instead
  25790. * @param name defines the name of the mesh to create
  25791. * @param width set the width of the ground
  25792. * @param height set the height of the ground
  25793. * @param subdivisions sets the number of subdivisions per side
  25794. * @param scene defines the hosting scene
  25795. * @param updatable defines if the mesh must be flagged as updatable
  25796. * @returns a new Mesh
  25797. */
  25798. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25799. /**
  25800. * Creates a tiled ground mesh.
  25801. * Please consider using the same method from the MeshBuilder class instead
  25802. * @param name defines the name of the mesh to create
  25803. * @param xmin set the ground minimum X coordinate
  25804. * @param zmin set the ground minimum Y coordinate
  25805. * @param xmax set the ground maximum X coordinate
  25806. * @param zmax set the ground maximum Z coordinate
  25807. * @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
  25808. * @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
  25809. * @param scene defines the hosting scene
  25810. * @param updatable defines if the mesh must be flagged as updatable
  25811. * @returns a new Mesh
  25812. */
  25813. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25814. w: number;
  25815. h: number;
  25816. }, precision: {
  25817. w: number;
  25818. h: number;
  25819. }, scene: Scene, updatable?: boolean): Mesh;
  25820. /**
  25821. * Creates a ground mesh from a height map.
  25822. * Please consider using the same method from the MeshBuilder class instead
  25823. * @see http://doc.babylonjs.com/babylon101/height_map
  25824. * @param name defines the name of the mesh to create
  25825. * @param url sets the URL of the height map image resource
  25826. * @param width set the ground width size
  25827. * @param height set the ground height size
  25828. * @param subdivisions sets the number of subdivision per side
  25829. * @param minHeight is the minimum altitude on the ground
  25830. * @param maxHeight is the maximum altitude on the ground
  25831. * @param scene defines the hosting scene
  25832. * @param updatable defines if the mesh must be flagged as updatable
  25833. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25834. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25835. * @returns a new Mesh
  25836. */
  25837. 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;
  25838. /**
  25839. * Creates a tube mesh.
  25840. * The tube is a parametric shape.
  25841. * It has no predefined shape. Its final shape will depend on the input parameters.
  25842. * Please consider using the same method from the MeshBuilder class instead
  25843. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25844. * @param name defines the name of the mesh to create
  25845. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25846. * @param radius sets the tube radius size
  25847. * @param tessellation is the number of sides on the tubular surface
  25848. * @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
  25849. * @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
  25850. * @param scene defines the hosting scene
  25851. * @param updatable defines if the mesh must be flagged as updatable
  25852. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25853. * @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)
  25854. * @returns a new Mesh
  25855. */
  25856. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25857. (i: number, distance: number): number;
  25858. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25859. /**
  25860. * Creates a polyhedron mesh.
  25861. * Please consider using the same method from the MeshBuilder class instead.
  25862. * * 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
  25863. * * The parameter `size` (positive float, default 1) sets the polygon size
  25864. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25865. * * 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`
  25866. * * 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
  25867. * * 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)`)
  25868. * * 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
  25869. * * 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
  25870. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25871. * * If you create a double-sided mesh, you can choose what parts of 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
  25872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25873. * @param name defines the name of the mesh to create
  25874. * @param options defines the options used to create the mesh
  25875. * @param scene defines the hosting scene
  25876. * @returns a new Mesh
  25877. */
  25878. static CreatePolyhedron(name: string, options: {
  25879. type?: number;
  25880. size?: number;
  25881. sizeX?: number;
  25882. sizeY?: number;
  25883. sizeZ?: number;
  25884. custom?: any;
  25885. faceUV?: Vector4[];
  25886. faceColors?: Color4[];
  25887. updatable?: boolean;
  25888. sideOrientation?: number;
  25889. }, scene: Scene): Mesh;
  25890. /**
  25891. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25892. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25893. * * 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`)
  25894. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25895. * * 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
  25896. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25897. * * If you create a double-sided mesh, you can choose what parts of 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
  25898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25899. * @param name defines the name of the mesh
  25900. * @param options defines the options used to create the mesh
  25901. * @param scene defines the hosting scene
  25902. * @returns a new Mesh
  25903. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25904. */
  25905. static CreateIcoSphere(name: string, options: {
  25906. radius?: number;
  25907. flat?: boolean;
  25908. subdivisions?: number;
  25909. sideOrientation?: number;
  25910. updatable?: boolean;
  25911. }, scene: Scene): Mesh;
  25912. /**
  25913. * Creates a decal mesh.
  25914. * Please consider using the same method from the MeshBuilder class instead.
  25915. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25916. * @param name defines the name of the mesh
  25917. * @param sourceMesh defines the mesh receiving the decal
  25918. * @param position sets the position of the decal in world coordinates
  25919. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25920. * @param size sets the decal scaling
  25921. * @param angle sets the angle to rotate the decal
  25922. * @returns a new Mesh
  25923. */
  25924. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25925. /**
  25926. * Prepare internal position array for software CPU skinning
  25927. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25928. */
  25929. setPositionsForCPUSkinning(): Float32Array;
  25930. /**
  25931. * Prepare internal normal array for software CPU skinning
  25932. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25933. */
  25934. setNormalsForCPUSkinning(): Float32Array;
  25935. /**
  25936. * Updates the vertex buffer by applying transformation from the bones
  25937. * @param skeleton defines the skeleton to apply to current mesh
  25938. * @returns the current mesh
  25939. */
  25940. applySkeleton(skeleton: Skeleton): Mesh;
  25941. /**
  25942. * 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
  25943. * @param meshes defines the list of meshes to scan
  25944. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25945. */
  25946. static MinMax(meshes: AbstractMesh[]): {
  25947. min: Vector3;
  25948. max: Vector3;
  25949. };
  25950. /**
  25951. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25952. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25953. * @returns a vector3
  25954. */
  25955. static Center(meshesOrMinMaxVector: {
  25956. min: Vector3;
  25957. max: Vector3;
  25958. } | AbstractMesh[]): Vector3;
  25959. /**
  25960. * Merge the array of meshes into a single mesh for performance reasons.
  25961. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25962. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25963. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25964. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25965. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25966. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25967. * @returns a new mesh
  25968. */
  25969. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25970. /** @hidden */
  25971. addInstance(instance: InstancedMesh): void;
  25972. /** @hidden */
  25973. removeInstance(instance: InstancedMesh): void;
  25974. }
  25975. }
  25976. declare module "babylonjs/Cameras/camera" {
  25977. import { SmartArray } from "babylonjs/Misc/smartArray";
  25978. import { Observable } from "babylonjs/Misc/observable";
  25979. import { Nullable } from "babylonjs/types";
  25980. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25981. import { Scene } from "babylonjs/scene";
  25982. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25983. import { Node } from "babylonjs/node";
  25984. import { Mesh } from "babylonjs/Meshes/mesh";
  25985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25986. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25987. import { Viewport } from "babylonjs/Maths/math.viewport";
  25988. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25989. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25990. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25991. import { Ray } from "babylonjs/Culling/ray";
  25992. /**
  25993. * This is the base class of all the camera used in the application.
  25994. * @see http://doc.babylonjs.com/features/cameras
  25995. */
  25996. export class Camera extends Node {
  25997. /** @hidden */
  25998. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25999. /**
  26000. * This is the default projection mode used by the cameras.
  26001. * It helps recreating a feeling of perspective and better appreciate depth.
  26002. * This is the best way to simulate real life cameras.
  26003. */
  26004. static readonly PERSPECTIVE_CAMERA: number;
  26005. /**
  26006. * This helps creating camera with an orthographic mode.
  26007. * 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.
  26008. */
  26009. static readonly ORTHOGRAPHIC_CAMERA: number;
  26010. /**
  26011. * This is the default FOV mode for perspective cameras.
  26012. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26013. */
  26014. static readonly FOVMODE_VERTICAL_FIXED: number;
  26015. /**
  26016. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26017. */
  26018. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26019. /**
  26020. * This specifies ther is no need for a camera rig.
  26021. * Basically only one eye is rendered corresponding to the camera.
  26022. */
  26023. static readonly RIG_MODE_NONE: number;
  26024. /**
  26025. * Simulates a camera Rig with one blue eye and one red eye.
  26026. * This can be use with 3d blue and red glasses.
  26027. */
  26028. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26029. /**
  26030. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26031. */
  26032. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26033. /**
  26034. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26035. */
  26036. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26037. /**
  26038. * Defines that both eyes of the camera will be rendered over under each other.
  26039. */
  26040. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26041. /**
  26042. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26043. */
  26044. static readonly RIG_MODE_VR: number;
  26045. /**
  26046. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26047. */
  26048. static readonly RIG_MODE_WEBVR: number;
  26049. /**
  26050. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26051. */
  26052. static readonly RIG_MODE_CUSTOM: number;
  26053. /**
  26054. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26055. */
  26056. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26057. /**
  26058. * Define the input manager associated with the camera.
  26059. */
  26060. inputs: CameraInputsManager<Camera>;
  26061. /** @hidden */
  26062. _position: Vector3;
  26063. /**
  26064. * Define the current local position of the camera in the scene
  26065. */
  26066. get position(): Vector3;
  26067. set position(newPosition: Vector3);
  26068. /**
  26069. * The vector the camera should consider as up.
  26070. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26071. */
  26072. upVector: Vector3;
  26073. /**
  26074. * Define the current limit on the left side for an orthographic camera
  26075. * In scene unit
  26076. */
  26077. orthoLeft: Nullable<number>;
  26078. /**
  26079. * Define the current limit on the right side for an orthographic camera
  26080. * In scene unit
  26081. */
  26082. orthoRight: Nullable<number>;
  26083. /**
  26084. * Define the current limit on the bottom side for an orthographic camera
  26085. * In scene unit
  26086. */
  26087. orthoBottom: Nullable<number>;
  26088. /**
  26089. * Define the current limit on the top side for an orthographic camera
  26090. * In scene unit
  26091. */
  26092. orthoTop: Nullable<number>;
  26093. /**
  26094. * Field Of View is set in Radians. (default is 0.8)
  26095. */
  26096. fov: number;
  26097. /**
  26098. * Define the minimum distance the camera can see from.
  26099. * This is important to note that the depth buffer are not infinite and the closer it starts
  26100. * the more your scene might encounter depth fighting issue.
  26101. */
  26102. minZ: number;
  26103. /**
  26104. * Define the maximum distance the camera can see to.
  26105. * This is important to note that the depth buffer are not infinite and the further it end
  26106. * the more your scene might encounter depth fighting issue.
  26107. */
  26108. maxZ: number;
  26109. /**
  26110. * Define the default inertia of the camera.
  26111. * This helps giving a smooth feeling to the camera movement.
  26112. */
  26113. inertia: number;
  26114. /**
  26115. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26116. */
  26117. mode: number;
  26118. /**
  26119. * Define wether the camera is intermediate.
  26120. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26121. */
  26122. isIntermediate: boolean;
  26123. /**
  26124. * Define the viewport of the camera.
  26125. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26126. */
  26127. viewport: Viewport;
  26128. /**
  26129. * Restricts the camera to viewing objects with the same layerMask.
  26130. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26131. */
  26132. layerMask: number;
  26133. /**
  26134. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26135. */
  26136. fovMode: number;
  26137. /**
  26138. * Rig mode of the camera.
  26139. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26140. * This is normally controlled byt the camera themselves as internal use.
  26141. */
  26142. cameraRigMode: number;
  26143. /**
  26144. * Defines the distance between both "eyes" in case of a RIG
  26145. */
  26146. interaxialDistance: number;
  26147. /**
  26148. * Defines if stereoscopic rendering is done side by side or over under.
  26149. */
  26150. isStereoscopicSideBySide: boolean;
  26151. /**
  26152. * 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
  26153. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26154. * else in the scene. (Eg. security camera)
  26155. *
  26156. * 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)
  26157. */
  26158. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26159. /**
  26160. * When set, the camera will render to this render target instead of the default canvas
  26161. *
  26162. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26163. */
  26164. outputRenderTarget: Nullable<RenderTargetTexture>;
  26165. /**
  26166. * Observable triggered when the camera view matrix has changed.
  26167. */
  26168. onViewMatrixChangedObservable: Observable<Camera>;
  26169. /**
  26170. * Observable triggered when the camera Projection matrix has changed.
  26171. */
  26172. onProjectionMatrixChangedObservable: Observable<Camera>;
  26173. /**
  26174. * Observable triggered when the inputs have been processed.
  26175. */
  26176. onAfterCheckInputsObservable: Observable<Camera>;
  26177. /**
  26178. * Observable triggered when reset has been called and applied to the camera.
  26179. */
  26180. onRestoreStateObservable: Observable<Camera>;
  26181. /** @hidden */
  26182. _cameraRigParams: any;
  26183. /** @hidden */
  26184. _rigCameras: Camera[];
  26185. /** @hidden */
  26186. _rigPostProcess: Nullable<PostProcess>;
  26187. protected _webvrViewMatrix: Matrix;
  26188. /** @hidden */
  26189. _skipRendering: boolean;
  26190. /** @hidden */
  26191. _projectionMatrix: Matrix;
  26192. /** @hidden */
  26193. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26194. /** @hidden */
  26195. _activeMeshes: SmartArray<AbstractMesh>;
  26196. protected _globalPosition: Vector3;
  26197. /** @hidden */
  26198. _computedViewMatrix: Matrix;
  26199. private _doNotComputeProjectionMatrix;
  26200. private _transformMatrix;
  26201. private _frustumPlanes;
  26202. private _refreshFrustumPlanes;
  26203. private _storedFov;
  26204. private _stateStored;
  26205. /**
  26206. * Instantiates a new camera object.
  26207. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26208. * @see http://doc.babylonjs.com/features/cameras
  26209. * @param name Defines the name of the camera in the scene
  26210. * @param position Defines the position of the camera
  26211. * @param scene Defines the scene the camera belongs too
  26212. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26213. */
  26214. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26215. /**
  26216. * Store current camera state (fov, position, etc..)
  26217. * @returns the camera
  26218. */
  26219. storeState(): Camera;
  26220. /**
  26221. * Restores the camera state values if it has been stored. You must call storeState() first
  26222. */
  26223. protected _restoreStateValues(): boolean;
  26224. /**
  26225. * Restored camera state. You must call storeState() first.
  26226. * @returns true if restored and false otherwise
  26227. */
  26228. restoreState(): boolean;
  26229. /**
  26230. * Gets the class name of the camera.
  26231. * @returns the class name
  26232. */
  26233. getClassName(): string;
  26234. /** @hidden */
  26235. readonly _isCamera: boolean;
  26236. /**
  26237. * Gets a string representation of the camera useful for debug purpose.
  26238. * @param fullDetails Defines that a more verboe level of logging is required
  26239. * @returns the string representation
  26240. */
  26241. toString(fullDetails?: boolean): string;
  26242. /**
  26243. * Gets the current world space position of the camera.
  26244. */
  26245. get globalPosition(): Vector3;
  26246. /**
  26247. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26248. * @returns the active meshe list
  26249. */
  26250. getActiveMeshes(): SmartArray<AbstractMesh>;
  26251. /**
  26252. * Check wether a mesh is part of the current active mesh list of the camera
  26253. * @param mesh Defines the mesh to check
  26254. * @returns true if active, false otherwise
  26255. */
  26256. isActiveMesh(mesh: Mesh): boolean;
  26257. /**
  26258. * Is this camera ready to be used/rendered
  26259. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26260. * @return true if the camera is ready
  26261. */
  26262. isReady(completeCheck?: boolean): boolean;
  26263. /** @hidden */
  26264. _initCache(): void;
  26265. /** @hidden */
  26266. _updateCache(ignoreParentClass?: boolean): void;
  26267. /** @hidden */
  26268. _isSynchronized(): boolean;
  26269. /** @hidden */
  26270. _isSynchronizedViewMatrix(): boolean;
  26271. /** @hidden */
  26272. _isSynchronizedProjectionMatrix(): boolean;
  26273. /**
  26274. * Attach the input controls to a specific dom element to get the input from.
  26275. * @param element Defines the element the controls should be listened from
  26276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26277. */
  26278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26279. /**
  26280. * Detach the current controls from the specified dom element.
  26281. * @param element Defines the element to stop listening the inputs from
  26282. */
  26283. detachControl(element: HTMLElement): void;
  26284. /**
  26285. * Update the camera state according to the different inputs gathered during the frame.
  26286. */
  26287. update(): void;
  26288. /** @hidden */
  26289. _checkInputs(): void;
  26290. /** @hidden */
  26291. get rigCameras(): Camera[];
  26292. /**
  26293. * Gets the post process used by the rig cameras
  26294. */
  26295. get rigPostProcess(): Nullable<PostProcess>;
  26296. /**
  26297. * Internal, gets the first post proces.
  26298. * @returns the first post process to be run on this camera.
  26299. */
  26300. _getFirstPostProcess(): Nullable<PostProcess>;
  26301. private _cascadePostProcessesToRigCams;
  26302. /**
  26303. * Attach a post process to the camera.
  26304. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26305. * @param postProcess The post process to attach to the camera
  26306. * @param insertAt The position of the post process in case several of them are in use in the scene
  26307. * @returns the position the post process has been inserted at
  26308. */
  26309. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26310. /**
  26311. * Detach a post process to the camera.
  26312. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26313. * @param postProcess The post process to detach from the camera
  26314. */
  26315. detachPostProcess(postProcess: PostProcess): void;
  26316. /**
  26317. * Gets the current world matrix of the camera
  26318. */
  26319. getWorldMatrix(): Matrix;
  26320. /** @hidden */
  26321. _getViewMatrix(): Matrix;
  26322. /**
  26323. * Gets the current view matrix of the camera.
  26324. * @param force forces the camera to recompute the matrix without looking at the cached state
  26325. * @returns the view matrix
  26326. */
  26327. getViewMatrix(force?: boolean): Matrix;
  26328. /**
  26329. * Freeze the projection matrix.
  26330. * It will prevent the cache check of the camera projection compute and can speed up perf
  26331. * if no parameter of the camera are meant to change
  26332. * @param projection Defines manually a projection if necessary
  26333. */
  26334. freezeProjectionMatrix(projection?: Matrix): void;
  26335. /**
  26336. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26337. */
  26338. unfreezeProjectionMatrix(): void;
  26339. /**
  26340. * Gets the current projection matrix of the camera.
  26341. * @param force forces the camera to recompute the matrix without looking at the cached state
  26342. * @returns the projection matrix
  26343. */
  26344. getProjectionMatrix(force?: boolean): Matrix;
  26345. /**
  26346. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26347. * @returns a Matrix
  26348. */
  26349. getTransformationMatrix(): Matrix;
  26350. private _updateFrustumPlanes;
  26351. /**
  26352. * Checks if a cullable object (mesh...) is in the camera frustum
  26353. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26354. * @param target The object to check
  26355. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26356. * @returns true if the object is in frustum otherwise false
  26357. */
  26358. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26359. /**
  26360. * Checks if a cullable object (mesh...) is in the camera frustum
  26361. * Unlike isInFrustum this cheks the full bounding box
  26362. * @param target The object to check
  26363. * @returns true if the object is in frustum otherwise false
  26364. */
  26365. isCompletelyInFrustum(target: ICullable): boolean;
  26366. /**
  26367. * Gets a ray in the forward direction from the camera.
  26368. * @param length Defines the length of the ray to create
  26369. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26370. * @param origin Defines the start point of the ray which defaults to the camera position
  26371. * @returns the forward ray
  26372. */
  26373. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26374. /**
  26375. * Releases resources associated with this node.
  26376. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26377. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26378. */
  26379. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26380. /** @hidden */
  26381. _isLeftCamera: boolean;
  26382. /**
  26383. * Gets the left camera of a rig setup in case of Rigged Camera
  26384. */
  26385. get isLeftCamera(): boolean;
  26386. /** @hidden */
  26387. _isRightCamera: boolean;
  26388. /**
  26389. * Gets the right camera of a rig setup in case of Rigged Camera
  26390. */
  26391. get isRightCamera(): boolean;
  26392. /**
  26393. * Gets the left camera of a rig setup in case of Rigged Camera
  26394. */
  26395. get leftCamera(): Nullable<FreeCamera>;
  26396. /**
  26397. * Gets the right camera of a rig setup in case of Rigged Camera
  26398. */
  26399. get rightCamera(): Nullable<FreeCamera>;
  26400. /**
  26401. * Gets the left camera target of a rig setup in case of Rigged Camera
  26402. * @returns the target position
  26403. */
  26404. getLeftTarget(): Nullable<Vector3>;
  26405. /**
  26406. * Gets the right camera target of a rig setup in case of Rigged Camera
  26407. * @returns the target position
  26408. */
  26409. getRightTarget(): Nullable<Vector3>;
  26410. /**
  26411. * @hidden
  26412. */
  26413. setCameraRigMode(mode: number, rigParams: any): void;
  26414. /** @hidden */
  26415. static _setStereoscopicRigMode(camera: Camera): void;
  26416. /** @hidden */
  26417. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26418. /** @hidden */
  26419. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26420. /** @hidden */
  26421. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26422. /** @hidden */
  26423. _getVRProjectionMatrix(): Matrix;
  26424. protected _updateCameraRotationMatrix(): void;
  26425. protected _updateWebVRCameraRotationMatrix(): void;
  26426. /**
  26427. * This function MUST be overwritten by the different WebVR cameras available.
  26428. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26429. * @hidden
  26430. */
  26431. _getWebVRProjectionMatrix(): Matrix;
  26432. /**
  26433. * This function MUST be overwritten by the different WebVR cameras available.
  26434. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26435. * @hidden
  26436. */
  26437. _getWebVRViewMatrix(): Matrix;
  26438. /** @hidden */
  26439. setCameraRigParameter(name: string, value: any): void;
  26440. /**
  26441. * needs to be overridden by children so sub has required properties to be copied
  26442. * @hidden
  26443. */
  26444. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26445. /**
  26446. * May need to be overridden by children
  26447. * @hidden
  26448. */
  26449. _updateRigCameras(): void;
  26450. /** @hidden */
  26451. _setupInputs(): void;
  26452. /**
  26453. * Serialiaze the camera setup to a json represention
  26454. * @returns the JSON representation
  26455. */
  26456. serialize(): any;
  26457. /**
  26458. * Clones the current camera.
  26459. * @param name The cloned camera name
  26460. * @returns the cloned camera
  26461. */
  26462. clone(name: string): Camera;
  26463. /**
  26464. * Gets the direction of the camera relative to a given local axis.
  26465. * @param localAxis Defines the reference axis to provide a relative direction.
  26466. * @return the direction
  26467. */
  26468. getDirection(localAxis: Vector3): Vector3;
  26469. /**
  26470. * Returns the current camera absolute rotation
  26471. */
  26472. get absoluteRotation(): Quaternion;
  26473. /**
  26474. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26475. * @param localAxis Defines the reference axis to provide a relative direction.
  26476. * @param result Defines the vector to store the result in
  26477. */
  26478. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26479. /**
  26480. * Gets a camera constructor for a given camera type
  26481. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26482. * @param name The name of the camera the result will be able to instantiate
  26483. * @param scene The scene the result will construct the camera in
  26484. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26485. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26486. * @returns a factory method to construc the camera
  26487. */
  26488. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26489. /**
  26490. * Compute the world matrix of the camera.
  26491. * @returns the camera world matrix
  26492. */
  26493. computeWorldMatrix(): Matrix;
  26494. /**
  26495. * Parse a JSON and creates the camera from the parsed information
  26496. * @param parsedCamera The JSON to parse
  26497. * @param scene The scene to instantiate the camera in
  26498. * @returns the newly constructed camera
  26499. */
  26500. static Parse(parsedCamera: any, scene: Scene): Camera;
  26501. }
  26502. }
  26503. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26504. import { Nullable } from "babylonjs/types";
  26505. import { Scene } from "babylonjs/scene";
  26506. import { Vector4 } from "babylonjs/Maths/math.vector";
  26507. import { Mesh } from "babylonjs/Meshes/mesh";
  26508. /**
  26509. * Class containing static functions to help procedurally build meshes
  26510. */
  26511. export class DiscBuilder {
  26512. /**
  26513. * Creates a plane polygonal mesh. By default, this is a disc
  26514. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26515. * * 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
  26516. * * 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
  26517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26520. * @param name defines the name of the mesh
  26521. * @param options defines the options used to create the mesh
  26522. * @param scene defines the hosting scene
  26523. * @returns the plane polygonal mesh
  26524. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26525. */
  26526. static CreateDisc(name: string, options: {
  26527. radius?: number;
  26528. tessellation?: number;
  26529. arc?: number;
  26530. updatable?: boolean;
  26531. sideOrientation?: number;
  26532. frontUVs?: Vector4;
  26533. backUVs?: Vector4;
  26534. }, scene?: Nullable<Scene>): Mesh;
  26535. }
  26536. }
  26537. declare module "babylonjs/Materials/fresnelParameters" {
  26538. import { Color3 } from "babylonjs/Maths/math.color";
  26539. /**
  26540. * This represents all the required information to add a fresnel effect on a material:
  26541. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26542. */
  26543. export class FresnelParameters {
  26544. private _isEnabled;
  26545. /**
  26546. * Define if the fresnel effect is enable or not.
  26547. */
  26548. get isEnabled(): boolean;
  26549. set isEnabled(value: boolean);
  26550. /**
  26551. * Define the color used on edges (grazing angle)
  26552. */
  26553. leftColor: Color3;
  26554. /**
  26555. * Define the color used on center
  26556. */
  26557. rightColor: Color3;
  26558. /**
  26559. * Define bias applied to computed fresnel term
  26560. */
  26561. bias: number;
  26562. /**
  26563. * Defined the power exponent applied to fresnel term
  26564. */
  26565. power: number;
  26566. /**
  26567. * Clones the current fresnel and its valuues
  26568. * @returns a clone fresnel configuration
  26569. */
  26570. clone(): FresnelParameters;
  26571. /**
  26572. * Serializes the current fresnel parameters to a JSON representation.
  26573. * @return the JSON serialization
  26574. */
  26575. serialize(): any;
  26576. /**
  26577. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26578. * @param parsedFresnelParameters Define the JSON representation
  26579. * @returns the parsed parameters
  26580. */
  26581. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26582. }
  26583. }
  26584. declare module "babylonjs/Materials/pushMaterial" {
  26585. import { Nullable } from "babylonjs/types";
  26586. import { Scene } from "babylonjs/scene";
  26587. import { Matrix } from "babylonjs/Maths/math.vector";
  26588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26589. import { Mesh } from "babylonjs/Meshes/mesh";
  26590. import { Material } from "babylonjs/Materials/material";
  26591. import { Effect } from "babylonjs/Materials/effect";
  26592. /**
  26593. * Base class of materials working in push mode in babylon JS
  26594. * @hidden
  26595. */
  26596. export class PushMaterial extends Material {
  26597. protected _activeEffect: Effect;
  26598. protected _normalMatrix: Matrix;
  26599. /**
  26600. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26601. * This means that the material can keep using a previous shader while a new one is being compiled.
  26602. * This is mostly used when shader parallel compilation is supported (true by default)
  26603. */
  26604. allowShaderHotSwapping: boolean;
  26605. constructor(name: string, scene: Scene);
  26606. getEffect(): Effect;
  26607. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26608. /**
  26609. * Binds the given world matrix to the active effect
  26610. *
  26611. * @param world the matrix to bind
  26612. */
  26613. bindOnlyWorldMatrix(world: Matrix): void;
  26614. /**
  26615. * Binds the given normal matrix to the active effect
  26616. *
  26617. * @param normalMatrix the matrix to bind
  26618. */
  26619. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26620. bind(world: Matrix, mesh?: Mesh): void;
  26621. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26622. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26623. }
  26624. }
  26625. declare module "babylonjs/Materials/materialFlags" {
  26626. /**
  26627. * This groups all the flags used to control the materials channel.
  26628. */
  26629. export class MaterialFlags {
  26630. private static _DiffuseTextureEnabled;
  26631. /**
  26632. * Are diffuse textures enabled in the application.
  26633. */
  26634. static get DiffuseTextureEnabled(): boolean;
  26635. static set DiffuseTextureEnabled(value: boolean);
  26636. private static _AmbientTextureEnabled;
  26637. /**
  26638. * Are ambient textures enabled in the application.
  26639. */
  26640. static get AmbientTextureEnabled(): boolean;
  26641. static set AmbientTextureEnabled(value: boolean);
  26642. private static _OpacityTextureEnabled;
  26643. /**
  26644. * Are opacity textures enabled in the application.
  26645. */
  26646. static get OpacityTextureEnabled(): boolean;
  26647. static set OpacityTextureEnabled(value: boolean);
  26648. private static _ReflectionTextureEnabled;
  26649. /**
  26650. * Are reflection textures enabled in the application.
  26651. */
  26652. static get ReflectionTextureEnabled(): boolean;
  26653. static set ReflectionTextureEnabled(value: boolean);
  26654. private static _EmissiveTextureEnabled;
  26655. /**
  26656. * Are emissive textures enabled in the application.
  26657. */
  26658. static get EmissiveTextureEnabled(): boolean;
  26659. static set EmissiveTextureEnabled(value: boolean);
  26660. private static _SpecularTextureEnabled;
  26661. /**
  26662. * Are specular textures enabled in the application.
  26663. */
  26664. static get SpecularTextureEnabled(): boolean;
  26665. static set SpecularTextureEnabled(value: boolean);
  26666. private static _BumpTextureEnabled;
  26667. /**
  26668. * Are bump textures enabled in the application.
  26669. */
  26670. static get BumpTextureEnabled(): boolean;
  26671. static set BumpTextureEnabled(value: boolean);
  26672. private static _LightmapTextureEnabled;
  26673. /**
  26674. * Are lightmap textures enabled in the application.
  26675. */
  26676. static get LightmapTextureEnabled(): boolean;
  26677. static set LightmapTextureEnabled(value: boolean);
  26678. private static _RefractionTextureEnabled;
  26679. /**
  26680. * Are refraction textures enabled in the application.
  26681. */
  26682. static get RefractionTextureEnabled(): boolean;
  26683. static set RefractionTextureEnabled(value: boolean);
  26684. private static _ColorGradingTextureEnabled;
  26685. /**
  26686. * Are color grading textures enabled in the application.
  26687. */
  26688. static get ColorGradingTextureEnabled(): boolean;
  26689. static set ColorGradingTextureEnabled(value: boolean);
  26690. private static _FresnelEnabled;
  26691. /**
  26692. * Are fresnels enabled in the application.
  26693. */
  26694. static get FresnelEnabled(): boolean;
  26695. static set FresnelEnabled(value: boolean);
  26696. private static _ClearCoatTextureEnabled;
  26697. /**
  26698. * Are clear coat textures enabled in the application.
  26699. */
  26700. static get ClearCoatTextureEnabled(): boolean;
  26701. static set ClearCoatTextureEnabled(value: boolean);
  26702. private static _ClearCoatBumpTextureEnabled;
  26703. /**
  26704. * Are clear coat bump textures enabled in the application.
  26705. */
  26706. static get ClearCoatBumpTextureEnabled(): boolean;
  26707. static set ClearCoatBumpTextureEnabled(value: boolean);
  26708. private static _ClearCoatTintTextureEnabled;
  26709. /**
  26710. * Are clear coat tint textures enabled in the application.
  26711. */
  26712. static get ClearCoatTintTextureEnabled(): boolean;
  26713. static set ClearCoatTintTextureEnabled(value: boolean);
  26714. private static _SheenTextureEnabled;
  26715. /**
  26716. * Are sheen textures enabled in the application.
  26717. */
  26718. static get SheenTextureEnabled(): boolean;
  26719. static set SheenTextureEnabled(value: boolean);
  26720. private static _AnisotropicTextureEnabled;
  26721. /**
  26722. * Are anisotropic textures enabled in the application.
  26723. */
  26724. static get AnisotropicTextureEnabled(): boolean;
  26725. static set AnisotropicTextureEnabled(value: boolean);
  26726. private static _ThicknessTextureEnabled;
  26727. /**
  26728. * Are thickness textures enabled in the application.
  26729. */
  26730. static get ThicknessTextureEnabled(): boolean;
  26731. static set ThicknessTextureEnabled(value: boolean);
  26732. }
  26733. }
  26734. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26735. /** @hidden */
  26736. export var defaultFragmentDeclaration: {
  26737. name: string;
  26738. shader: string;
  26739. };
  26740. }
  26741. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26742. /** @hidden */
  26743. export var defaultUboDeclaration: {
  26744. name: string;
  26745. shader: string;
  26746. };
  26747. }
  26748. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26749. /** @hidden */
  26750. export var lightFragmentDeclaration: {
  26751. name: string;
  26752. shader: string;
  26753. };
  26754. }
  26755. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26756. /** @hidden */
  26757. export var lightUboDeclaration: {
  26758. name: string;
  26759. shader: string;
  26760. };
  26761. }
  26762. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26763. /** @hidden */
  26764. export var lightsFragmentFunctions: {
  26765. name: string;
  26766. shader: string;
  26767. };
  26768. }
  26769. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26770. /** @hidden */
  26771. export var shadowsFragmentFunctions: {
  26772. name: string;
  26773. shader: string;
  26774. };
  26775. }
  26776. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26777. /** @hidden */
  26778. export var fresnelFunction: {
  26779. name: string;
  26780. shader: string;
  26781. };
  26782. }
  26783. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26784. /** @hidden */
  26785. export var reflectionFunction: {
  26786. name: string;
  26787. shader: string;
  26788. };
  26789. }
  26790. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26791. /** @hidden */
  26792. export var bumpFragmentFunctions: {
  26793. name: string;
  26794. shader: string;
  26795. };
  26796. }
  26797. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26798. /** @hidden */
  26799. export var logDepthDeclaration: {
  26800. name: string;
  26801. shader: string;
  26802. };
  26803. }
  26804. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26805. /** @hidden */
  26806. export var bumpFragment: {
  26807. name: string;
  26808. shader: string;
  26809. };
  26810. }
  26811. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26812. /** @hidden */
  26813. export var depthPrePass: {
  26814. name: string;
  26815. shader: string;
  26816. };
  26817. }
  26818. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26819. /** @hidden */
  26820. export var lightFragment: {
  26821. name: string;
  26822. shader: string;
  26823. };
  26824. }
  26825. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26826. /** @hidden */
  26827. export var logDepthFragment: {
  26828. name: string;
  26829. shader: string;
  26830. };
  26831. }
  26832. declare module "babylonjs/Shaders/default.fragment" {
  26833. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26834. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26835. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26836. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26837. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26838. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26839. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26840. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26841. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26842. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26843. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26844. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26845. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26846. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26847. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26848. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26849. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26850. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26851. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26852. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26853. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26854. /** @hidden */
  26855. export var defaultPixelShader: {
  26856. name: string;
  26857. shader: string;
  26858. };
  26859. }
  26860. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26861. /** @hidden */
  26862. export var defaultVertexDeclaration: {
  26863. name: string;
  26864. shader: string;
  26865. };
  26866. }
  26867. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26868. /** @hidden */
  26869. export var bumpVertexDeclaration: {
  26870. name: string;
  26871. shader: string;
  26872. };
  26873. }
  26874. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26875. /** @hidden */
  26876. export var bumpVertex: {
  26877. name: string;
  26878. shader: string;
  26879. };
  26880. }
  26881. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26882. /** @hidden */
  26883. export var fogVertex: {
  26884. name: string;
  26885. shader: string;
  26886. };
  26887. }
  26888. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26889. /** @hidden */
  26890. export var shadowsVertex: {
  26891. name: string;
  26892. shader: string;
  26893. };
  26894. }
  26895. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26896. /** @hidden */
  26897. export var pointCloudVertex: {
  26898. name: string;
  26899. shader: string;
  26900. };
  26901. }
  26902. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26903. /** @hidden */
  26904. export var logDepthVertex: {
  26905. name: string;
  26906. shader: string;
  26907. };
  26908. }
  26909. declare module "babylonjs/Shaders/default.vertex" {
  26910. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26911. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26912. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26913. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26914. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26915. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26916. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26917. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26918. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26919. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26920. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26921. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26922. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26924. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26925. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26926. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26927. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26928. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26929. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26930. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26931. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26932. /** @hidden */
  26933. export var defaultVertexShader: {
  26934. name: string;
  26935. shader: string;
  26936. };
  26937. }
  26938. declare module "babylonjs/Materials/standardMaterial" {
  26939. import { SmartArray } from "babylonjs/Misc/smartArray";
  26940. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26941. import { Nullable } from "babylonjs/types";
  26942. import { Scene } from "babylonjs/scene";
  26943. import { Matrix } from "babylonjs/Maths/math.vector";
  26944. import { Color3 } from "babylonjs/Maths/math.color";
  26945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26947. import { Mesh } from "babylonjs/Meshes/mesh";
  26948. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26949. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26950. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26951. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26952. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26955. import "babylonjs/Shaders/default.fragment";
  26956. import "babylonjs/Shaders/default.vertex";
  26957. /** @hidden */
  26958. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26959. MAINUV1: boolean;
  26960. MAINUV2: boolean;
  26961. DIFFUSE: boolean;
  26962. DIFFUSEDIRECTUV: number;
  26963. AMBIENT: boolean;
  26964. AMBIENTDIRECTUV: number;
  26965. OPACITY: boolean;
  26966. OPACITYDIRECTUV: number;
  26967. OPACITYRGB: boolean;
  26968. REFLECTION: boolean;
  26969. EMISSIVE: boolean;
  26970. EMISSIVEDIRECTUV: number;
  26971. SPECULAR: boolean;
  26972. SPECULARDIRECTUV: number;
  26973. BUMP: boolean;
  26974. BUMPDIRECTUV: number;
  26975. PARALLAX: boolean;
  26976. PARALLAXOCCLUSION: boolean;
  26977. SPECULAROVERALPHA: boolean;
  26978. CLIPPLANE: boolean;
  26979. CLIPPLANE2: boolean;
  26980. CLIPPLANE3: boolean;
  26981. CLIPPLANE4: boolean;
  26982. CLIPPLANE5: boolean;
  26983. CLIPPLANE6: boolean;
  26984. ALPHATEST: boolean;
  26985. DEPTHPREPASS: boolean;
  26986. ALPHAFROMDIFFUSE: boolean;
  26987. POINTSIZE: boolean;
  26988. FOG: boolean;
  26989. SPECULARTERM: boolean;
  26990. DIFFUSEFRESNEL: boolean;
  26991. OPACITYFRESNEL: boolean;
  26992. REFLECTIONFRESNEL: boolean;
  26993. REFRACTIONFRESNEL: boolean;
  26994. EMISSIVEFRESNEL: boolean;
  26995. FRESNEL: boolean;
  26996. NORMAL: boolean;
  26997. UV1: boolean;
  26998. UV2: boolean;
  26999. VERTEXCOLOR: boolean;
  27000. VERTEXALPHA: boolean;
  27001. NUM_BONE_INFLUENCERS: number;
  27002. BonesPerMesh: number;
  27003. BONETEXTURE: boolean;
  27004. INSTANCES: boolean;
  27005. GLOSSINESS: boolean;
  27006. ROUGHNESS: boolean;
  27007. EMISSIVEASILLUMINATION: boolean;
  27008. LINKEMISSIVEWITHDIFFUSE: boolean;
  27009. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27010. LIGHTMAP: boolean;
  27011. LIGHTMAPDIRECTUV: number;
  27012. OBJECTSPACE_NORMALMAP: boolean;
  27013. USELIGHTMAPASSHADOWMAP: boolean;
  27014. REFLECTIONMAP_3D: boolean;
  27015. REFLECTIONMAP_SPHERICAL: boolean;
  27016. REFLECTIONMAP_PLANAR: boolean;
  27017. REFLECTIONMAP_CUBIC: boolean;
  27018. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27019. REFLECTIONMAP_PROJECTION: boolean;
  27020. REFLECTIONMAP_SKYBOX: boolean;
  27021. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27022. REFLECTIONMAP_EXPLICIT: boolean;
  27023. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27024. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27025. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27026. INVERTCUBICMAP: boolean;
  27027. LOGARITHMICDEPTH: boolean;
  27028. REFRACTION: boolean;
  27029. REFRACTIONMAP_3D: boolean;
  27030. REFLECTIONOVERALPHA: boolean;
  27031. TWOSIDEDLIGHTING: boolean;
  27032. SHADOWFLOAT: boolean;
  27033. MORPHTARGETS: boolean;
  27034. MORPHTARGETS_NORMAL: boolean;
  27035. MORPHTARGETS_TANGENT: boolean;
  27036. MORPHTARGETS_UV: boolean;
  27037. NUM_MORPH_INFLUENCERS: number;
  27038. NONUNIFORMSCALING: boolean;
  27039. PREMULTIPLYALPHA: boolean;
  27040. IMAGEPROCESSING: boolean;
  27041. VIGNETTE: boolean;
  27042. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27043. VIGNETTEBLENDMODEOPAQUE: boolean;
  27044. TONEMAPPING: boolean;
  27045. TONEMAPPING_ACES: boolean;
  27046. CONTRAST: boolean;
  27047. COLORCURVES: boolean;
  27048. COLORGRADING: boolean;
  27049. COLORGRADING3D: boolean;
  27050. SAMPLER3DGREENDEPTH: boolean;
  27051. SAMPLER3DBGRMAP: boolean;
  27052. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27053. MULTIVIEW: boolean;
  27054. /**
  27055. * If the reflection texture on this material is in linear color space
  27056. * @hidden
  27057. */
  27058. IS_REFLECTION_LINEAR: boolean;
  27059. /**
  27060. * If the refraction texture on this material is in linear color space
  27061. * @hidden
  27062. */
  27063. IS_REFRACTION_LINEAR: boolean;
  27064. EXPOSURE: boolean;
  27065. constructor();
  27066. setReflectionMode(modeToEnable: string): void;
  27067. }
  27068. /**
  27069. * This is the default material used in Babylon. It is the best trade off between quality
  27070. * and performances.
  27071. * @see http://doc.babylonjs.com/babylon101/materials
  27072. */
  27073. export class StandardMaterial extends PushMaterial {
  27074. private _diffuseTexture;
  27075. /**
  27076. * The basic texture of the material as viewed under a light.
  27077. */
  27078. diffuseTexture: Nullable<BaseTexture>;
  27079. private _ambientTexture;
  27080. /**
  27081. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27082. */
  27083. ambientTexture: Nullable<BaseTexture>;
  27084. private _opacityTexture;
  27085. /**
  27086. * Define the transparency of the material from a texture.
  27087. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27088. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27089. */
  27090. opacityTexture: Nullable<BaseTexture>;
  27091. private _reflectionTexture;
  27092. /**
  27093. * Define the texture used to display the reflection.
  27094. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27095. */
  27096. reflectionTexture: Nullable<BaseTexture>;
  27097. private _emissiveTexture;
  27098. /**
  27099. * Define texture of the material as if self lit.
  27100. * This will be mixed in the final result even in the absence of light.
  27101. */
  27102. emissiveTexture: Nullable<BaseTexture>;
  27103. private _specularTexture;
  27104. /**
  27105. * Define how the color and intensity of the highlight given by the light in the material.
  27106. */
  27107. specularTexture: Nullable<BaseTexture>;
  27108. private _bumpTexture;
  27109. /**
  27110. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27111. * 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.
  27112. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27113. */
  27114. bumpTexture: Nullable<BaseTexture>;
  27115. private _lightmapTexture;
  27116. /**
  27117. * Complex lighting can be computationally expensive to compute at runtime.
  27118. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27119. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27120. */
  27121. lightmapTexture: Nullable<BaseTexture>;
  27122. private _refractionTexture;
  27123. /**
  27124. * Define the texture used to display the refraction.
  27125. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27126. */
  27127. refractionTexture: Nullable<BaseTexture>;
  27128. /**
  27129. * The color of the material lit by the environmental background lighting.
  27130. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27131. */
  27132. ambientColor: Color3;
  27133. /**
  27134. * The basic color of the material as viewed under a light.
  27135. */
  27136. diffuseColor: Color3;
  27137. /**
  27138. * Define how the color and intensity of the highlight given by the light in the material.
  27139. */
  27140. specularColor: Color3;
  27141. /**
  27142. * Define the color of the material as if self lit.
  27143. * This will be mixed in the final result even in the absence of light.
  27144. */
  27145. emissiveColor: Color3;
  27146. /**
  27147. * Defines how sharp are the highlights in the material.
  27148. * The bigger the value the sharper giving a more glossy feeling to the result.
  27149. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27150. */
  27151. specularPower: number;
  27152. private _useAlphaFromDiffuseTexture;
  27153. /**
  27154. * Does the transparency come from the diffuse texture alpha channel.
  27155. */
  27156. useAlphaFromDiffuseTexture: boolean;
  27157. private _useEmissiveAsIllumination;
  27158. /**
  27159. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27160. */
  27161. useEmissiveAsIllumination: boolean;
  27162. private _linkEmissiveWithDiffuse;
  27163. /**
  27164. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27165. * the emissive level when the final color is close to one.
  27166. */
  27167. linkEmissiveWithDiffuse: boolean;
  27168. private _useSpecularOverAlpha;
  27169. /**
  27170. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27171. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27172. */
  27173. useSpecularOverAlpha: boolean;
  27174. private _useReflectionOverAlpha;
  27175. /**
  27176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27178. */
  27179. useReflectionOverAlpha: boolean;
  27180. private _disableLighting;
  27181. /**
  27182. * Does lights from the scene impacts this material.
  27183. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27184. */
  27185. disableLighting: boolean;
  27186. private _useObjectSpaceNormalMap;
  27187. /**
  27188. * Allows using an object space normal map (instead of tangent space).
  27189. */
  27190. useObjectSpaceNormalMap: boolean;
  27191. private _useParallax;
  27192. /**
  27193. * Is parallax enabled or not.
  27194. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27195. */
  27196. useParallax: boolean;
  27197. private _useParallaxOcclusion;
  27198. /**
  27199. * Is parallax occlusion enabled or not.
  27200. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27201. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27202. */
  27203. useParallaxOcclusion: boolean;
  27204. /**
  27205. * 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.
  27206. */
  27207. parallaxScaleBias: number;
  27208. private _roughness;
  27209. /**
  27210. * Helps to define how blurry the reflections should appears in the material.
  27211. */
  27212. roughness: number;
  27213. /**
  27214. * In case of refraction, define the value of the index of refraction.
  27215. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27216. */
  27217. indexOfRefraction: number;
  27218. /**
  27219. * Invert the refraction texture alongside the y axis.
  27220. * It can be useful with procedural textures or probe for instance.
  27221. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27222. */
  27223. invertRefractionY: boolean;
  27224. /**
  27225. * Defines the alpha limits in alpha test mode.
  27226. */
  27227. alphaCutOff: number;
  27228. private _useLightmapAsShadowmap;
  27229. /**
  27230. * In case of light mapping, define whether the map contains light or shadow informations.
  27231. */
  27232. useLightmapAsShadowmap: boolean;
  27233. private _diffuseFresnelParameters;
  27234. /**
  27235. * Define the diffuse fresnel parameters of the material.
  27236. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27237. */
  27238. diffuseFresnelParameters: FresnelParameters;
  27239. private _opacityFresnelParameters;
  27240. /**
  27241. * Define the opacity fresnel parameters of the material.
  27242. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27243. */
  27244. opacityFresnelParameters: FresnelParameters;
  27245. private _reflectionFresnelParameters;
  27246. /**
  27247. * Define the reflection fresnel parameters of the material.
  27248. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27249. */
  27250. reflectionFresnelParameters: FresnelParameters;
  27251. private _refractionFresnelParameters;
  27252. /**
  27253. * Define the refraction fresnel parameters of the material.
  27254. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27255. */
  27256. refractionFresnelParameters: FresnelParameters;
  27257. private _emissiveFresnelParameters;
  27258. /**
  27259. * Define the emissive fresnel parameters of the material.
  27260. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27261. */
  27262. emissiveFresnelParameters: FresnelParameters;
  27263. private _useReflectionFresnelFromSpecular;
  27264. /**
  27265. * If true automatically deducts the fresnels values from the material specularity.
  27266. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27267. */
  27268. useReflectionFresnelFromSpecular: boolean;
  27269. private _useGlossinessFromSpecularMapAlpha;
  27270. /**
  27271. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27272. */
  27273. useGlossinessFromSpecularMapAlpha: boolean;
  27274. private _maxSimultaneousLights;
  27275. /**
  27276. * Defines the maximum number of lights that can be used in the material
  27277. */
  27278. maxSimultaneousLights: number;
  27279. private _invertNormalMapX;
  27280. /**
  27281. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27282. */
  27283. invertNormalMapX: boolean;
  27284. private _invertNormalMapY;
  27285. /**
  27286. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27287. */
  27288. invertNormalMapY: boolean;
  27289. private _twoSidedLighting;
  27290. /**
  27291. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27292. */
  27293. twoSidedLighting: boolean;
  27294. /**
  27295. * Default configuration related to image processing available in the standard Material.
  27296. */
  27297. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27298. /**
  27299. * Gets the image processing configuration used either in this material.
  27300. */
  27301. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27302. /**
  27303. * Sets the Default image processing configuration used either in the this material.
  27304. *
  27305. * If sets to null, the scene one is in use.
  27306. */
  27307. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27308. /**
  27309. * Keep track of the image processing observer to allow dispose and replace.
  27310. */
  27311. private _imageProcessingObserver;
  27312. /**
  27313. * Attaches a new image processing configuration to the Standard Material.
  27314. * @param configuration
  27315. */
  27316. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27317. /**
  27318. * Gets wether the color curves effect is enabled.
  27319. */
  27320. get cameraColorCurvesEnabled(): boolean;
  27321. /**
  27322. * Sets wether the color curves effect is enabled.
  27323. */
  27324. set cameraColorCurvesEnabled(value: boolean);
  27325. /**
  27326. * Gets wether the color grading effect is enabled.
  27327. */
  27328. get cameraColorGradingEnabled(): boolean;
  27329. /**
  27330. * Gets wether the color grading effect is enabled.
  27331. */
  27332. set cameraColorGradingEnabled(value: boolean);
  27333. /**
  27334. * Gets wether tonemapping is enabled or not.
  27335. */
  27336. get cameraToneMappingEnabled(): boolean;
  27337. /**
  27338. * Sets wether tonemapping is enabled or not
  27339. */
  27340. set cameraToneMappingEnabled(value: boolean);
  27341. /**
  27342. * The camera exposure used on this material.
  27343. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27344. * This corresponds to a photographic exposure.
  27345. */
  27346. get cameraExposure(): number;
  27347. /**
  27348. * The camera exposure used on this material.
  27349. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27350. * This corresponds to a photographic exposure.
  27351. */
  27352. set cameraExposure(value: number);
  27353. /**
  27354. * Gets The camera contrast used on this material.
  27355. */
  27356. get cameraContrast(): number;
  27357. /**
  27358. * Sets The camera contrast used on this material.
  27359. */
  27360. set cameraContrast(value: number);
  27361. /**
  27362. * Gets the Color Grading 2D Lookup Texture.
  27363. */
  27364. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27365. /**
  27366. * Sets the Color Grading 2D Lookup Texture.
  27367. */
  27368. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27369. /**
  27370. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27371. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27372. * 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;
  27373. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27374. */
  27375. get cameraColorCurves(): Nullable<ColorCurves>;
  27376. /**
  27377. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27378. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27379. * 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;
  27380. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27381. */
  27382. set cameraColorCurves(value: Nullable<ColorCurves>);
  27383. /**
  27384. * Custom callback helping to override the default shader used in the material.
  27385. */
  27386. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27387. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27388. protected _worldViewProjectionMatrix: Matrix;
  27389. protected _globalAmbientColor: Color3;
  27390. protected _useLogarithmicDepth: boolean;
  27391. protected _rebuildInParallel: boolean;
  27392. /**
  27393. * Instantiates a new standard material.
  27394. * This is the default material used in Babylon. It is the best trade off between quality
  27395. * and performances.
  27396. * @see http://doc.babylonjs.com/babylon101/materials
  27397. * @param name Define the name of the material in the scene
  27398. * @param scene Define the scene the material belong to
  27399. */
  27400. constructor(name: string, scene: Scene);
  27401. /**
  27402. * Gets a boolean indicating that current material needs to register RTT
  27403. */
  27404. get hasRenderTargetTextures(): boolean;
  27405. /**
  27406. * Gets the current class name of the material e.g. "StandardMaterial"
  27407. * Mainly use in serialization.
  27408. * @returns the class name
  27409. */
  27410. getClassName(): string;
  27411. /**
  27412. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27413. * You can try switching to logarithmic depth.
  27414. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27415. */
  27416. get useLogarithmicDepth(): boolean;
  27417. set useLogarithmicDepth(value: boolean);
  27418. /**
  27419. * Specifies if the material will require alpha blending
  27420. * @returns a boolean specifying if alpha blending is needed
  27421. */
  27422. needAlphaBlending(): boolean;
  27423. /**
  27424. * Specifies if this material should be rendered in alpha test mode
  27425. * @returns a boolean specifying if an alpha test is needed.
  27426. */
  27427. needAlphaTesting(): boolean;
  27428. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27429. /**
  27430. * Get the texture used for alpha test purpose.
  27431. * @returns the diffuse texture in case of the standard material.
  27432. */
  27433. getAlphaTestTexture(): Nullable<BaseTexture>;
  27434. /**
  27435. * Get if the submesh is ready to be used and all its information available.
  27436. * Child classes can use it to update shaders
  27437. * @param mesh defines the mesh to check
  27438. * @param subMesh defines which submesh to check
  27439. * @param useInstances specifies that instances should be used
  27440. * @returns a boolean indicating that the submesh is ready or not
  27441. */
  27442. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27443. /**
  27444. * Builds the material UBO layouts.
  27445. * Used internally during the effect preparation.
  27446. */
  27447. buildUniformLayout(): void;
  27448. /**
  27449. * Unbinds the material from the mesh
  27450. */
  27451. unbind(): void;
  27452. /**
  27453. * Binds the submesh to this material by preparing the effect and shader to draw
  27454. * @param world defines the world transformation matrix
  27455. * @param mesh defines the mesh containing the submesh
  27456. * @param subMesh defines the submesh to bind the material to
  27457. */
  27458. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27459. /**
  27460. * Get the list of animatables in the material.
  27461. * @returns the list of animatables object used in the material
  27462. */
  27463. getAnimatables(): IAnimatable[];
  27464. /**
  27465. * Gets the active textures from the material
  27466. * @returns an array of textures
  27467. */
  27468. getActiveTextures(): BaseTexture[];
  27469. /**
  27470. * Specifies if the material uses a texture
  27471. * @param texture defines the texture to check against the material
  27472. * @returns a boolean specifying if the material uses the texture
  27473. */
  27474. hasTexture(texture: BaseTexture): boolean;
  27475. /**
  27476. * Disposes the material
  27477. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27478. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27479. */
  27480. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27481. /**
  27482. * Makes a duplicate of the material, and gives it a new name
  27483. * @param name defines the new name for the duplicated material
  27484. * @returns the cloned material
  27485. */
  27486. clone(name: string): StandardMaterial;
  27487. /**
  27488. * Serializes this material in a JSON representation
  27489. * @returns the serialized material object
  27490. */
  27491. serialize(): any;
  27492. /**
  27493. * Creates a standard material from parsed material data
  27494. * @param source defines the JSON representation of the material
  27495. * @param scene defines the hosting scene
  27496. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27497. * @returns a new standard material
  27498. */
  27499. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27500. /**
  27501. * Are diffuse textures enabled in the application.
  27502. */
  27503. static get DiffuseTextureEnabled(): boolean;
  27504. static set DiffuseTextureEnabled(value: boolean);
  27505. /**
  27506. * Are ambient textures enabled in the application.
  27507. */
  27508. static get AmbientTextureEnabled(): boolean;
  27509. static set AmbientTextureEnabled(value: boolean);
  27510. /**
  27511. * Are opacity textures enabled in the application.
  27512. */
  27513. static get OpacityTextureEnabled(): boolean;
  27514. static set OpacityTextureEnabled(value: boolean);
  27515. /**
  27516. * Are reflection textures enabled in the application.
  27517. */
  27518. static get ReflectionTextureEnabled(): boolean;
  27519. static set ReflectionTextureEnabled(value: boolean);
  27520. /**
  27521. * Are emissive textures enabled in the application.
  27522. */
  27523. static get EmissiveTextureEnabled(): boolean;
  27524. static set EmissiveTextureEnabled(value: boolean);
  27525. /**
  27526. * Are specular textures enabled in the application.
  27527. */
  27528. static get SpecularTextureEnabled(): boolean;
  27529. static set SpecularTextureEnabled(value: boolean);
  27530. /**
  27531. * Are bump textures enabled in the application.
  27532. */
  27533. static get BumpTextureEnabled(): boolean;
  27534. static set BumpTextureEnabled(value: boolean);
  27535. /**
  27536. * Are lightmap textures enabled in the application.
  27537. */
  27538. static get LightmapTextureEnabled(): boolean;
  27539. static set LightmapTextureEnabled(value: boolean);
  27540. /**
  27541. * Are refraction textures enabled in the application.
  27542. */
  27543. static get RefractionTextureEnabled(): boolean;
  27544. static set RefractionTextureEnabled(value: boolean);
  27545. /**
  27546. * Are color grading textures enabled in the application.
  27547. */
  27548. static get ColorGradingTextureEnabled(): boolean;
  27549. static set ColorGradingTextureEnabled(value: boolean);
  27550. /**
  27551. * Are fresnels enabled in the application.
  27552. */
  27553. static get FresnelEnabled(): boolean;
  27554. static set FresnelEnabled(value: boolean);
  27555. }
  27556. }
  27557. declare module "babylonjs/Particles/solidParticleSystem" {
  27558. import { Nullable } from "babylonjs/types";
  27559. import { Vector3 } from "babylonjs/Maths/math.vector";
  27560. import { Mesh } from "babylonjs/Meshes/mesh";
  27561. import { Scene, IDisposable } from "babylonjs/scene";
  27562. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27563. import { Material } from "babylonjs/Materials/material";
  27564. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27565. /**
  27566. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27567. *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.
  27568. * The SPS is also a particle system. It provides some methods to manage the particles.
  27569. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27570. *
  27571. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27572. */
  27573. export class SolidParticleSystem implements IDisposable {
  27574. /**
  27575. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27576. * Example : var p = SPS.particles[i];
  27577. */
  27578. particles: SolidParticle[];
  27579. /**
  27580. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27581. */
  27582. nbParticles: number;
  27583. /**
  27584. * If the particles must ever face the camera (default false). Useful for planar particles.
  27585. */
  27586. billboard: boolean;
  27587. /**
  27588. * Recompute normals when adding a shape
  27589. */
  27590. recomputeNormals: boolean;
  27591. /**
  27592. * This a counter ofr your own usage. It's not set by any SPS functions.
  27593. */
  27594. counter: number;
  27595. /**
  27596. * The SPS name. This name is also given to the underlying mesh.
  27597. */
  27598. name: string;
  27599. /**
  27600. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27601. */
  27602. mesh: Mesh;
  27603. /**
  27604. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27605. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27606. */
  27607. vars: any;
  27608. /**
  27609. * This array is populated when the SPS is set as 'pickable'.
  27610. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27611. * Each element of this array is an object `{idx: int, faceId: int}`.
  27612. * `idx` is the picked particle index in the `SPS.particles` array
  27613. * `faceId` is the picked face index counted within this particle.
  27614. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27615. */
  27616. pickedParticles: {
  27617. idx: number;
  27618. faceId: number;
  27619. }[];
  27620. /**
  27621. * This array is populated when `enableDepthSort` is set to true.
  27622. * Each element of this array is an instance of the class DepthSortedParticle.
  27623. */
  27624. depthSortedParticles: DepthSortedParticle[];
  27625. /**
  27626. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27627. * @hidden
  27628. */
  27629. _bSphereOnly: boolean;
  27630. /**
  27631. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27632. * @hidden
  27633. */
  27634. _bSphereRadiusFactor: number;
  27635. private _scene;
  27636. private _positions;
  27637. private _indices;
  27638. private _normals;
  27639. private _colors;
  27640. private _uvs;
  27641. private _indices32;
  27642. private _positions32;
  27643. private _normals32;
  27644. private _fixedNormal32;
  27645. private _colors32;
  27646. private _uvs32;
  27647. private _index;
  27648. private _updatable;
  27649. private _pickable;
  27650. private _isVisibilityBoxLocked;
  27651. private _alwaysVisible;
  27652. private _depthSort;
  27653. private _expandable;
  27654. private _shapeCounter;
  27655. private _copy;
  27656. private _color;
  27657. private _computeParticleColor;
  27658. private _computeParticleTexture;
  27659. private _computeParticleRotation;
  27660. private _computeParticleVertex;
  27661. private _computeBoundingBox;
  27662. private _depthSortParticles;
  27663. private _camera;
  27664. private _mustUnrotateFixedNormals;
  27665. private _particlesIntersect;
  27666. private _needs32Bits;
  27667. private _isNotBuilt;
  27668. private _lastParticleId;
  27669. private _idxOfId;
  27670. private _multimaterialEnabled;
  27671. private _useModelMaterial;
  27672. private _indicesByMaterial;
  27673. private _materialIndexes;
  27674. private _depthSortFunction;
  27675. private _materialSortFunction;
  27676. private _materials;
  27677. private _multimaterial;
  27678. private _materialIndexesById;
  27679. private _defaultMaterial;
  27680. private _autoUpdateSubMeshes;
  27681. /**
  27682. * Creates a SPS (Solid Particle System) object.
  27683. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27684. * @param scene (Scene) is the scene in which the SPS is added.
  27685. * @param options defines the options of the sps e.g.
  27686. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27687. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27688. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27689. * * 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.
  27690. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27691. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27692. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27693. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27694. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27695. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27696. */
  27697. constructor(name: string, scene: Scene, options?: {
  27698. updatable?: boolean;
  27699. isPickable?: boolean;
  27700. enableDepthSort?: boolean;
  27701. particleIntersection?: boolean;
  27702. boundingSphereOnly?: boolean;
  27703. bSphereRadiusFactor?: number;
  27704. expandable?: boolean;
  27705. useModelMaterial?: boolean;
  27706. enableMultiMaterial?: boolean;
  27707. });
  27708. /**
  27709. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27710. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27711. * @returns the created mesh
  27712. */
  27713. buildMesh(): Mesh;
  27714. /**
  27715. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27716. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27717. * Thus the particles generated from `digest()` have their property `position` set yet.
  27718. * @param mesh ( Mesh ) is the mesh to be digested
  27719. * @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
  27720. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27721. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27722. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27723. * @returns the current SPS
  27724. */
  27725. digest(mesh: Mesh, options?: {
  27726. facetNb?: number;
  27727. number?: number;
  27728. delta?: number;
  27729. storage?: [];
  27730. }): SolidParticleSystem;
  27731. /**
  27732. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27733. * @hidden
  27734. */
  27735. private _unrotateFixedNormals;
  27736. /**
  27737. * Resets the temporary working copy particle
  27738. * @hidden
  27739. */
  27740. private _resetCopy;
  27741. /**
  27742. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27743. * @param p the current index in the positions array to be updated
  27744. * @param ind the current index in the indices array
  27745. * @param shape a Vector3 array, the shape geometry
  27746. * @param positions the positions array to be updated
  27747. * @param meshInd the shape indices array
  27748. * @param indices the indices array to be updated
  27749. * @param meshUV the shape uv array
  27750. * @param uvs the uv array to be updated
  27751. * @param meshCol the shape color array
  27752. * @param colors the color array to be updated
  27753. * @param meshNor the shape normals array
  27754. * @param normals the normals array to be updated
  27755. * @param idx the particle index
  27756. * @param idxInShape the particle index in its shape
  27757. * @param options the addShape() method passed options
  27758. * @model the particle model
  27759. * @hidden
  27760. */
  27761. private _meshBuilder;
  27762. /**
  27763. * Returns a shape Vector3 array from positions float array
  27764. * @param positions float array
  27765. * @returns a vector3 array
  27766. * @hidden
  27767. */
  27768. private _posToShape;
  27769. /**
  27770. * Returns a shapeUV array from a float uvs (array deep copy)
  27771. * @param uvs as a float array
  27772. * @returns a shapeUV array
  27773. * @hidden
  27774. */
  27775. private _uvsToShapeUV;
  27776. /**
  27777. * Adds a new particle object in the particles array
  27778. * @param idx particle index in particles array
  27779. * @param id particle id
  27780. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27781. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27782. * @param model particle ModelShape object
  27783. * @param shapeId model shape identifier
  27784. * @param idxInShape index of the particle in the current model
  27785. * @param bInfo model bounding info object
  27786. * @param storage target storage array, if any
  27787. * @hidden
  27788. */
  27789. private _addParticle;
  27790. /**
  27791. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27792. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27793. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27794. * @param nb (positive integer) the number of particles to be created from this model
  27795. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27796. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27797. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27798. * @returns the number of shapes in the system
  27799. */
  27800. addShape(mesh: Mesh, nb: number, options?: {
  27801. positionFunction?: any;
  27802. vertexFunction?: any;
  27803. storage?: [];
  27804. }): number;
  27805. /**
  27806. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27807. * @hidden
  27808. */
  27809. private _rebuildParticle;
  27810. /**
  27811. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27812. * @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.
  27813. * @returns the SPS.
  27814. */
  27815. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27816. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27817. * Returns an array with the removed particles.
  27818. * 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.
  27819. * The SPS can't be empty so at least one particle needs to remain in place.
  27820. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27821. * @param start index of the first particle to remove
  27822. * @param end index of the last particle to remove (included)
  27823. * @returns an array populated with the removed particles
  27824. */
  27825. removeParticles(start: number, end: number): SolidParticle[];
  27826. /**
  27827. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27828. * @param solidParticleArray an array populated with Solid Particles objects
  27829. * @returns the SPS
  27830. */
  27831. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27832. /**
  27833. * Creates a new particle and modifies the SPS mesh geometry :
  27834. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27835. * - calls _addParticle() to populate the particle array
  27836. * factorized code from addShape() and insertParticlesFromArray()
  27837. * @param idx particle index in the particles array
  27838. * @param i particle index in its shape
  27839. * @param modelShape particle ModelShape object
  27840. * @param shape shape vertex array
  27841. * @param meshInd shape indices array
  27842. * @param meshUV shape uv array
  27843. * @param meshCol shape color array
  27844. * @param meshNor shape normals array
  27845. * @param bbInfo shape bounding info
  27846. * @param storage target particle storage
  27847. * @options addShape() passed options
  27848. * @hidden
  27849. */
  27850. private _insertNewParticle;
  27851. /**
  27852. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27853. * This method calls `updateParticle()` for each particle of the SPS.
  27854. * For an animated SPS, it is usually called within the render loop.
  27855. * 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.
  27856. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27857. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27858. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27859. * @returns the SPS.
  27860. */
  27861. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27862. /**
  27863. * Disposes the SPS.
  27864. */
  27865. dispose(): void;
  27866. /**
  27867. * Returns a SolidParticle object from its identifier : particle.id
  27868. * @param id (integer) the particle Id
  27869. * @returns the searched particle or null if not found in the SPS.
  27870. */
  27871. getParticleById(id: number): Nullable<SolidParticle>;
  27872. /**
  27873. * Returns a new array populated with the particles having the passed shapeId.
  27874. * @param shapeId (integer) the shape identifier
  27875. * @returns a new solid particle array
  27876. */
  27877. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27878. /**
  27879. * Populates the passed array "ref" with the particles having the passed shapeId.
  27880. * @param shapeId the shape identifier
  27881. * @returns the SPS
  27882. * @param ref
  27883. */
  27884. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27885. /**
  27886. * Computes the required SubMeshes according the materials assigned to the particles.
  27887. * @returns the solid particle system.
  27888. * Does nothing if called before the SPS mesh is built.
  27889. */
  27890. computeSubMeshes(): SolidParticleSystem;
  27891. /**
  27892. * Sorts the solid particles by material when MultiMaterial is enabled.
  27893. * Updates the indices32 array.
  27894. * Updates the indicesByMaterial array.
  27895. * Updates the mesh indices array.
  27896. * @returns the SPS
  27897. * @hidden
  27898. */
  27899. private _sortParticlesByMaterial;
  27900. /**
  27901. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27902. * @hidden
  27903. */
  27904. private _setMaterialIndexesById;
  27905. /**
  27906. * Returns an array with unique values of Materials from the passed array
  27907. * @param array the material array to be checked and filtered
  27908. * @hidden
  27909. */
  27910. private _filterUniqueMaterialId;
  27911. /**
  27912. * Sets a new Standard Material as _defaultMaterial if not already set.
  27913. * @hidden
  27914. */
  27915. private _setDefaultMaterial;
  27916. /**
  27917. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27918. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27919. * @returns the SPS.
  27920. */
  27921. refreshVisibleSize(): SolidParticleSystem;
  27922. /**
  27923. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27924. * @param size the size (float) of the visibility box
  27925. * note : this doesn't lock the SPS mesh bounding box.
  27926. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27927. */
  27928. setVisibilityBox(size: number): void;
  27929. /**
  27930. * Gets whether the SPS as always visible or not
  27931. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27932. */
  27933. get isAlwaysVisible(): boolean;
  27934. /**
  27935. * Sets the SPS as always visible or not
  27936. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27937. */
  27938. set isAlwaysVisible(val: boolean);
  27939. /**
  27940. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27941. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27942. */
  27943. set isVisibilityBoxLocked(val: boolean);
  27944. /**
  27945. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27946. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27947. */
  27948. get isVisibilityBoxLocked(): boolean;
  27949. /**
  27950. * Tells to `setParticles()` to compute the particle rotations or not.
  27951. * Default value : true. The SPS is faster when it's set to false.
  27952. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27953. */
  27954. set computeParticleRotation(val: boolean);
  27955. /**
  27956. * Tells to `setParticles()` to compute the particle colors or not.
  27957. * Default value : true. The SPS is faster when it's set to false.
  27958. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27959. */
  27960. set computeParticleColor(val: boolean);
  27961. set computeParticleTexture(val: boolean);
  27962. /**
  27963. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27964. * Default value : false. The SPS is faster when it's set to false.
  27965. * Note : the particle custom vertex positions aren't stored values.
  27966. */
  27967. set computeParticleVertex(val: boolean);
  27968. /**
  27969. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27970. */
  27971. set computeBoundingBox(val: boolean);
  27972. /**
  27973. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27974. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27975. * Default : `true`
  27976. */
  27977. set depthSortParticles(val: boolean);
  27978. /**
  27979. * Gets if `setParticles()` computes the particle rotations or not.
  27980. * Default value : true. The SPS is faster when it's set to false.
  27981. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27982. */
  27983. get computeParticleRotation(): boolean;
  27984. /**
  27985. * Gets if `setParticles()` computes the particle colors or not.
  27986. * Default value : true. The SPS is faster when it's set to false.
  27987. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27988. */
  27989. get computeParticleColor(): boolean;
  27990. /**
  27991. * Gets if `setParticles()` computes the particle textures or not.
  27992. * Default value : true. The SPS is faster when it's set to false.
  27993. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27994. */
  27995. get computeParticleTexture(): boolean;
  27996. /**
  27997. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27998. * Default value : false. The SPS is faster when it's set to false.
  27999. * Note : the particle custom vertex positions aren't stored values.
  28000. */
  28001. get computeParticleVertex(): boolean;
  28002. /**
  28003. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28004. */
  28005. get computeBoundingBox(): boolean;
  28006. /**
  28007. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28008. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28009. * Default : `true`
  28010. */
  28011. get depthSortParticles(): boolean;
  28012. /**
  28013. * Gets if the SPS is created as expandable at construction time.
  28014. * Default : `false`
  28015. */
  28016. get expandable(): boolean;
  28017. /**
  28018. * Gets if the SPS supports the Multi Materials
  28019. */
  28020. get multimaterialEnabled(): boolean;
  28021. /**
  28022. * Gets if the SPS uses the model materials for its own multimaterial.
  28023. */
  28024. get useModelMaterial(): boolean;
  28025. /**
  28026. * The SPS used material array.
  28027. */
  28028. get materials(): Material[];
  28029. /**
  28030. * Sets the SPS MultiMaterial from the passed materials.
  28031. * Note : the passed array is internally copied and not used then by reference.
  28032. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28033. */
  28034. setMultiMaterial(materials: Material[]): void;
  28035. /**
  28036. * The SPS computed multimaterial object
  28037. */
  28038. get multimaterial(): MultiMaterial;
  28039. set multimaterial(mm: MultiMaterial);
  28040. /**
  28041. * If the subMeshes must be updated on the next call to setParticles()
  28042. */
  28043. get autoUpdateSubMeshes(): boolean;
  28044. set autoUpdateSubMeshes(val: boolean);
  28045. /**
  28046. * This function does nothing. It may be overwritten to set all the particle first values.
  28047. * The SPS doesn't call this function, you may have to call it by your own.
  28048. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28049. */
  28050. initParticles(): void;
  28051. /**
  28052. * This function does nothing. It may be overwritten to recycle a particle.
  28053. * The SPS doesn't call this function, you may have to call it by your own.
  28054. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28055. * @param particle The particle to recycle
  28056. * @returns the recycled particle
  28057. */
  28058. recycleParticle(particle: SolidParticle): SolidParticle;
  28059. /**
  28060. * Updates a particle : this function should be overwritten by the user.
  28061. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28062. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28063. * @example : just set a particle position or velocity and recycle conditions
  28064. * @param particle The particle to update
  28065. * @returns the updated particle
  28066. */
  28067. updateParticle(particle: SolidParticle): SolidParticle;
  28068. /**
  28069. * Updates a vertex of a particle : it can be overwritten by the user.
  28070. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28071. * @param particle the current particle
  28072. * @param vertex the current index of the current particle
  28073. * @param pt the index of the current vertex in the particle shape
  28074. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28075. * @example : just set a vertex particle position
  28076. * @returns the updated vertex
  28077. */
  28078. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28079. /**
  28080. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28081. * This does nothing and may be overwritten by the user.
  28082. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28083. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28084. * @param update the boolean update value actually passed to setParticles()
  28085. */
  28086. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28087. /**
  28088. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28089. * This will be passed three parameters.
  28090. * This does nothing and may be overwritten by the user.
  28091. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28092. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28093. * @param update the boolean update value actually passed to setParticles()
  28094. */
  28095. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28096. }
  28097. }
  28098. declare module "babylonjs/Particles/solidParticle" {
  28099. import { Nullable } from "babylonjs/types";
  28100. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28101. import { Color4 } from "babylonjs/Maths/math.color";
  28102. import { Mesh } from "babylonjs/Meshes/mesh";
  28103. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28104. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28105. import { Plane } from "babylonjs/Maths/math.plane";
  28106. import { Material } from "babylonjs/Materials/material";
  28107. /**
  28108. * Represents one particle of a solid particle system.
  28109. */
  28110. export class SolidParticle {
  28111. /**
  28112. * particle global index
  28113. */
  28114. idx: number;
  28115. /**
  28116. * particle identifier
  28117. */
  28118. id: number;
  28119. /**
  28120. * The color of the particle
  28121. */
  28122. color: Nullable<Color4>;
  28123. /**
  28124. * The world space position of the particle.
  28125. */
  28126. position: Vector3;
  28127. /**
  28128. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28129. */
  28130. rotation: Vector3;
  28131. /**
  28132. * The world space rotation quaternion of the particle.
  28133. */
  28134. rotationQuaternion: Nullable<Quaternion>;
  28135. /**
  28136. * The scaling of the particle.
  28137. */
  28138. scaling: Vector3;
  28139. /**
  28140. * The uvs of the particle.
  28141. */
  28142. uvs: Vector4;
  28143. /**
  28144. * The current speed of the particle.
  28145. */
  28146. velocity: Vector3;
  28147. /**
  28148. * The pivot point in the particle local space.
  28149. */
  28150. pivot: Vector3;
  28151. /**
  28152. * Must the particle be translated from its pivot point in its local space ?
  28153. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28154. * Default : false
  28155. */
  28156. translateFromPivot: boolean;
  28157. /**
  28158. * Is the particle active or not ?
  28159. */
  28160. alive: boolean;
  28161. /**
  28162. * Is the particle visible or not ?
  28163. */
  28164. isVisible: boolean;
  28165. /**
  28166. * Index of this particle in the global "positions" array (Internal use)
  28167. * @hidden
  28168. */
  28169. _pos: number;
  28170. /**
  28171. * @hidden Index of this particle in the global "indices" array (Internal use)
  28172. */
  28173. _ind: number;
  28174. /**
  28175. * @hidden ModelShape of this particle (Internal use)
  28176. */
  28177. _model: ModelShape;
  28178. /**
  28179. * ModelShape id of this particle
  28180. */
  28181. shapeId: number;
  28182. /**
  28183. * Index of the particle in its shape id
  28184. */
  28185. idxInShape: number;
  28186. /**
  28187. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28188. */
  28189. _modelBoundingInfo: BoundingInfo;
  28190. /**
  28191. * @hidden Particle BoundingInfo object (Internal use)
  28192. */
  28193. _boundingInfo: BoundingInfo;
  28194. /**
  28195. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28196. */
  28197. _sps: SolidParticleSystem;
  28198. /**
  28199. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28200. */
  28201. _stillInvisible: boolean;
  28202. /**
  28203. * @hidden Last computed particle rotation matrix
  28204. */
  28205. _rotationMatrix: number[];
  28206. /**
  28207. * Parent particle Id, if any.
  28208. * Default null.
  28209. */
  28210. parentId: Nullable<number>;
  28211. /**
  28212. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28213. */
  28214. materialIndex: Nullable<number>;
  28215. /**
  28216. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28217. * The possible values are :
  28218. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28219. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28220. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28221. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28222. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28223. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28224. * */
  28225. cullingStrategy: number;
  28226. /**
  28227. * @hidden Internal global position in the SPS.
  28228. */
  28229. _globalPosition: Vector3;
  28230. /**
  28231. * Creates a Solid Particle object.
  28232. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28233. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28234. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28235. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28236. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28237. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28238. * @param shapeId (integer) is the model shape identifier in the SPS.
  28239. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28240. * @param sps defines the sps it is associated to
  28241. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28242. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28243. */
  28244. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28245. /**
  28246. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28247. * @param target the particle target
  28248. * @returns the current particle
  28249. */
  28250. copyToRef(target: SolidParticle): SolidParticle;
  28251. /**
  28252. * Legacy support, changed scale to scaling
  28253. */
  28254. get scale(): Vector3;
  28255. /**
  28256. * Legacy support, changed scale to scaling
  28257. */
  28258. set scale(scale: Vector3);
  28259. /**
  28260. * Legacy support, changed quaternion to rotationQuaternion
  28261. */
  28262. get quaternion(): Nullable<Quaternion>;
  28263. /**
  28264. * Legacy support, changed quaternion to rotationQuaternion
  28265. */
  28266. set quaternion(q: Nullable<Quaternion>);
  28267. /**
  28268. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28269. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28270. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28271. * @returns true if it intersects
  28272. */
  28273. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28274. /**
  28275. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28276. * A particle is in the frustum if its bounding box intersects the frustum
  28277. * @param frustumPlanes defines the frustum to test
  28278. * @returns true if the particle is in the frustum planes
  28279. */
  28280. isInFrustum(frustumPlanes: Plane[]): boolean;
  28281. /**
  28282. * get the rotation matrix of the particle
  28283. * @hidden
  28284. */
  28285. getRotationMatrix(m: Matrix): void;
  28286. }
  28287. /**
  28288. * Represents the shape of the model used by one particle of a solid particle system.
  28289. * SPS internal tool, don't use it manually.
  28290. */
  28291. export class ModelShape {
  28292. /**
  28293. * The shape id
  28294. * @hidden
  28295. */
  28296. shapeID: number;
  28297. /**
  28298. * flat array of model positions (internal use)
  28299. * @hidden
  28300. */
  28301. _shape: Vector3[];
  28302. /**
  28303. * flat array of model UVs (internal use)
  28304. * @hidden
  28305. */
  28306. _shapeUV: number[];
  28307. /**
  28308. * color array of the model
  28309. * @hidden
  28310. */
  28311. _shapeColors: number[];
  28312. /**
  28313. * indices array of the model
  28314. * @hidden
  28315. */
  28316. _indices: number[];
  28317. /**
  28318. * normals array of the model
  28319. * @hidden
  28320. */
  28321. _normals: number[];
  28322. /**
  28323. * length of the shape in the model indices array (internal use)
  28324. * @hidden
  28325. */
  28326. _indicesLength: number;
  28327. /**
  28328. * Custom position function (internal use)
  28329. * @hidden
  28330. */
  28331. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28332. /**
  28333. * Custom vertex function (internal use)
  28334. * @hidden
  28335. */
  28336. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28337. /**
  28338. * Model material (internal use)
  28339. * @hidden
  28340. */
  28341. _material: Nullable<Material>;
  28342. /**
  28343. * 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.
  28344. * SPS internal tool, don't use it manually.
  28345. * @hidden
  28346. */
  28347. 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>);
  28348. }
  28349. /**
  28350. * Represents a Depth Sorted Particle in the solid particle system.
  28351. * @hidden
  28352. */
  28353. export class DepthSortedParticle {
  28354. /**
  28355. * Index of the particle in the "indices" array
  28356. */
  28357. ind: number;
  28358. /**
  28359. * Length of the particle shape in the "indices" array
  28360. */
  28361. indicesLength: number;
  28362. /**
  28363. * Squared distance from the particle to the camera
  28364. */
  28365. sqDistance: number;
  28366. /**
  28367. * Material index when used with MultiMaterials
  28368. */
  28369. materialIndex: number;
  28370. /**
  28371. * Creates a new sorted particle
  28372. * @param materialIndex
  28373. */
  28374. constructor(ind: number, indLength: number, materialIndex: number);
  28375. }
  28376. }
  28377. declare module "babylonjs/Collisions/meshCollisionData" {
  28378. import { Collider } from "babylonjs/Collisions/collider";
  28379. import { Vector3 } from "babylonjs/Maths/math.vector";
  28380. import { Nullable } from "babylonjs/types";
  28381. import { Observer } from "babylonjs/Misc/observable";
  28382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28383. /**
  28384. * @hidden
  28385. */
  28386. export class _MeshCollisionData {
  28387. _checkCollisions: boolean;
  28388. _collisionMask: number;
  28389. _collisionGroup: number;
  28390. _collider: Nullable<Collider>;
  28391. _oldPositionForCollisions: Vector3;
  28392. _diffPositionForCollisions: Vector3;
  28393. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28394. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28395. }
  28396. }
  28397. declare module "babylonjs/Meshes/abstractMesh" {
  28398. import { Observable } from "babylonjs/Misc/observable";
  28399. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28400. import { Camera } from "babylonjs/Cameras/camera";
  28401. import { Scene, IDisposable } from "babylonjs/scene";
  28402. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28403. import { Node } from "babylonjs/node";
  28404. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28406. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28407. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28408. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28409. import { Material } from "babylonjs/Materials/material";
  28410. import { Light } from "babylonjs/Lights/light";
  28411. import { Skeleton } from "babylonjs/Bones/skeleton";
  28412. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28413. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28414. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28415. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28416. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28417. import { Plane } from "babylonjs/Maths/math.plane";
  28418. import { Ray } from "babylonjs/Culling/ray";
  28419. import { Collider } from "babylonjs/Collisions/collider";
  28420. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28421. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28422. /** @hidden */
  28423. class _FacetDataStorage {
  28424. facetPositions: Vector3[];
  28425. facetNormals: Vector3[];
  28426. facetPartitioning: number[][];
  28427. facetNb: number;
  28428. partitioningSubdivisions: number;
  28429. partitioningBBoxRatio: number;
  28430. facetDataEnabled: boolean;
  28431. facetParameters: any;
  28432. bbSize: Vector3;
  28433. subDiv: {
  28434. max: number;
  28435. X: number;
  28436. Y: number;
  28437. Z: number;
  28438. };
  28439. facetDepthSort: boolean;
  28440. facetDepthSortEnabled: boolean;
  28441. depthSortedIndices: IndicesArray;
  28442. depthSortedFacets: {
  28443. ind: number;
  28444. sqDistance: number;
  28445. }[];
  28446. facetDepthSortFunction: (f1: {
  28447. ind: number;
  28448. sqDistance: number;
  28449. }, f2: {
  28450. ind: number;
  28451. sqDistance: number;
  28452. }) => number;
  28453. facetDepthSortFrom: Vector3;
  28454. facetDepthSortOrigin: Vector3;
  28455. invertedMatrix: Matrix;
  28456. }
  28457. /**
  28458. * @hidden
  28459. **/
  28460. class _InternalAbstractMeshDataInfo {
  28461. _hasVertexAlpha: boolean;
  28462. _useVertexColors: boolean;
  28463. _numBoneInfluencers: number;
  28464. _applyFog: boolean;
  28465. _receiveShadows: boolean;
  28466. _facetData: _FacetDataStorage;
  28467. _visibility: number;
  28468. _skeleton: Nullable<Skeleton>;
  28469. _layerMask: number;
  28470. _computeBonesUsingShaders: boolean;
  28471. _isActive: boolean;
  28472. _onlyForInstances: boolean;
  28473. _isActiveIntermediate: boolean;
  28474. _onlyForInstancesIntermediate: boolean;
  28475. _actAsRegularMesh: boolean;
  28476. }
  28477. /**
  28478. * Class used to store all common mesh properties
  28479. */
  28480. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28481. /** No occlusion */
  28482. static OCCLUSION_TYPE_NONE: number;
  28483. /** Occlusion set to optimisitic */
  28484. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28485. /** Occlusion set to strict */
  28486. static OCCLUSION_TYPE_STRICT: number;
  28487. /** Use an accurante occlusion algorithm */
  28488. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28489. /** Use a conservative occlusion algorithm */
  28490. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28491. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28492. * Test order :
  28493. * Is the bounding sphere outside the frustum ?
  28494. * If not, are the bounding box vertices outside the frustum ?
  28495. * It not, then the cullable object is in the frustum.
  28496. */
  28497. static readonly CULLINGSTRATEGY_STANDARD: number;
  28498. /** Culling strategy : Bounding Sphere Only.
  28499. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28500. * It's also less accurate than the standard because some not visible objects can still be selected.
  28501. * Test : is the bounding sphere outside the frustum ?
  28502. * If not, then the cullable object is in the frustum.
  28503. */
  28504. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28505. /** Culling strategy : Optimistic Inclusion.
  28506. * This in an inclusion test first, then the standard exclusion test.
  28507. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28508. * 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.
  28509. * Anyway, it's as accurate as the standard strategy.
  28510. * Test :
  28511. * Is the cullable object bounding sphere center in the frustum ?
  28512. * If not, apply the default culling strategy.
  28513. */
  28514. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28515. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28516. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28517. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28518. * 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.
  28519. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28520. * Test :
  28521. * Is the cullable object bounding sphere center in the frustum ?
  28522. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28523. */
  28524. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28525. /**
  28526. * No billboard
  28527. */
  28528. static get BILLBOARDMODE_NONE(): number;
  28529. /** Billboard on X axis */
  28530. static get BILLBOARDMODE_X(): number;
  28531. /** Billboard on Y axis */
  28532. static get BILLBOARDMODE_Y(): number;
  28533. /** Billboard on Z axis */
  28534. static get BILLBOARDMODE_Z(): number;
  28535. /** Billboard on all axes */
  28536. static get BILLBOARDMODE_ALL(): number;
  28537. /** Billboard on using position instead of orientation */
  28538. static get BILLBOARDMODE_USE_POSITION(): number;
  28539. /** @hidden */
  28540. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28541. /**
  28542. * The culling strategy to use to check whether the mesh must be rendered or not.
  28543. * This value can be changed at any time and will be used on the next render mesh selection.
  28544. * The possible values are :
  28545. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28546. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28547. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28548. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28549. * Please read each static variable documentation to get details about the culling process.
  28550. * */
  28551. cullingStrategy: number;
  28552. /**
  28553. * Gets the number of facets in the mesh
  28554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28555. */
  28556. get facetNb(): number;
  28557. /**
  28558. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28560. */
  28561. get partitioningSubdivisions(): number;
  28562. set partitioningSubdivisions(nb: number);
  28563. /**
  28564. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28565. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28567. */
  28568. get partitioningBBoxRatio(): number;
  28569. set partitioningBBoxRatio(ratio: number);
  28570. /**
  28571. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28572. * Works only for updatable meshes.
  28573. * Doesn't work with multi-materials
  28574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28575. */
  28576. get mustDepthSortFacets(): boolean;
  28577. set mustDepthSortFacets(sort: boolean);
  28578. /**
  28579. * The location (Vector3) where the facet depth sort must be computed from.
  28580. * By default, the active camera position.
  28581. * Used only when facet depth sort is enabled
  28582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28583. */
  28584. get facetDepthSortFrom(): Vector3;
  28585. set facetDepthSortFrom(location: Vector3);
  28586. /**
  28587. * gets a boolean indicating if facetData is enabled
  28588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28589. */
  28590. get isFacetDataEnabled(): boolean;
  28591. /** @hidden */
  28592. _updateNonUniformScalingState(value: boolean): boolean;
  28593. /**
  28594. * An event triggered when this mesh collides with another one
  28595. */
  28596. onCollideObservable: Observable<AbstractMesh>;
  28597. /** Set a function to call when this mesh collides with another one */
  28598. set onCollide(callback: () => void);
  28599. /**
  28600. * An event triggered when the collision's position changes
  28601. */
  28602. onCollisionPositionChangeObservable: Observable<Vector3>;
  28603. /** Set a function to call when the collision's position changes */
  28604. set onCollisionPositionChange(callback: () => void);
  28605. /**
  28606. * An event triggered when material is changed
  28607. */
  28608. onMaterialChangedObservable: Observable<AbstractMesh>;
  28609. /**
  28610. * Gets or sets the orientation for POV movement & rotation
  28611. */
  28612. definedFacingForward: boolean;
  28613. /** @hidden */
  28614. _occlusionQuery: Nullable<WebGLQuery>;
  28615. /** @hidden */
  28616. _renderingGroup: Nullable<RenderingGroup>;
  28617. /**
  28618. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28619. */
  28620. get visibility(): number;
  28621. /**
  28622. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28623. */
  28624. set visibility(value: number);
  28625. /** Gets or sets the alpha index used to sort transparent meshes
  28626. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28627. */
  28628. alphaIndex: number;
  28629. /**
  28630. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28631. */
  28632. isVisible: boolean;
  28633. /**
  28634. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28635. */
  28636. isPickable: boolean;
  28637. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28638. showSubMeshesBoundingBox: boolean;
  28639. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28640. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28641. */
  28642. isBlocker: boolean;
  28643. /**
  28644. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28645. */
  28646. enablePointerMoveEvents: boolean;
  28647. /**
  28648. * Specifies the rendering group id for this mesh (0 by default)
  28649. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28650. */
  28651. renderingGroupId: number;
  28652. private _material;
  28653. /** Gets or sets current material */
  28654. get material(): Nullable<Material>;
  28655. set material(value: Nullable<Material>);
  28656. /**
  28657. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28658. * @see http://doc.babylonjs.com/babylon101/shadows
  28659. */
  28660. get receiveShadows(): boolean;
  28661. set receiveShadows(value: boolean);
  28662. /** Defines color to use when rendering outline */
  28663. outlineColor: Color3;
  28664. /** Define width to use when rendering outline */
  28665. outlineWidth: number;
  28666. /** Defines color to use when rendering overlay */
  28667. overlayColor: Color3;
  28668. /** Defines alpha to use when rendering overlay */
  28669. overlayAlpha: number;
  28670. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28671. get hasVertexAlpha(): boolean;
  28672. set hasVertexAlpha(value: boolean);
  28673. /** 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) */
  28674. get useVertexColors(): boolean;
  28675. set useVertexColors(value: boolean);
  28676. /**
  28677. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28678. */
  28679. get computeBonesUsingShaders(): boolean;
  28680. set computeBonesUsingShaders(value: boolean);
  28681. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28682. get numBoneInfluencers(): number;
  28683. set numBoneInfluencers(value: number);
  28684. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28685. get applyFog(): boolean;
  28686. set applyFog(value: boolean);
  28687. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28688. useOctreeForRenderingSelection: boolean;
  28689. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28690. useOctreeForPicking: boolean;
  28691. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28692. useOctreeForCollisions: boolean;
  28693. /**
  28694. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28695. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28696. */
  28697. get layerMask(): number;
  28698. set layerMask(value: number);
  28699. /**
  28700. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28701. */
  28702. alwaysSelectAsActiveMesh: boolean;
  28703. /**
  28704. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28705. */
  28706. doNotSyncBoundingInfo: boolean;
  28707. /**
  28708. * Gets or sets the current action manager
  28709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28710. */
  28711. actionManager: Nullable<AbstractActionManager>;
  28712. private _meshCollisionData;
  28713. /**
  28714. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28716. */
  28717. ellipsoid: Vector3;
  28718. /**
  28719. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28721. */
  28722. ellipsoidOffset: Vector3;
  28723. /**
  28724. * Gets or sets a collision mask used to mask collisions (default is -1).
  28725. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28726. */
  28727. get collisionMask(): number;
  28728. set collisionMask(mask: number);
  28729. /**
  28730. * Gets or sets the current collision group mask (-1 by default).
  28731. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28732. */
  28733. get collisionGroup(): number;
  28734. set collisionGroup(mask: number);
  28735. /**
  28736. * Defines edge width used when edgesRenderer is enabled
  28737. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28738. */
  28739. edgesWidth: number;
  28740. /**
  28741. * Defines edge color used when edgesRenderer is enabled
  28742. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28743. */
  28744. edgesColor: Color4;
  28745. /** @hidden */
  28746. _edgesRenderer: Nullable<IEdgesRenderer>;
  28747. /** @hidden */
  28748. _masterMesh: Nullable<AbstractMesh>;
  28749. /** @hidden */
  28750. _boundingInfo: Nullable<BoundingInfo>;
  28751. /** @hidden */
  28752. _renderId: number;
  28753. /**
  28754. * Gets or sets the list of subMeshes
  28755. * @see http://doc.babylonjs.com/how_to/multi_materials
  28756. */
  28757. subMeshes: SubMesh[];
  28758. /** @hidden */
  28759. _intersectionsInProgress: AbstractMesh[];
  28760. /** @hidden */
  28761. _unIndexed: boolean;
  28762. /** @hidden */
  28763. _lightSources: Light[];
  28764. /** Gets the list of lights affecting that mesh */
  28765. get lightSources(): Light[];
  28766. /** @hidden */
  28767. get _positions(): Nullable<Vector3[]>;
  28768. /** @hidden */
  28769. _waitingData: {
  28770. lods: Nullable<any>;
  28771. actions: Nullable<any>;
  28772. freezeWorldMatrix: Nullable<boolean>;
  28773. };
  28774. /** @hidden */
  28775. _bonesTransformMatrices: Nullable<Float32Array>;
  28776. /** @hidden */
  28777. _transformMatrixTexture: Nullable<RawTexture>;
  28778. /**
  28779. * Gets or sets a skeleton to apply skining transformations
  28780. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28781. */
  28782. set skeleton(value: Nullable<Skeleton>);
  28783. get skeleton(): Nullable<Skeleton>;
  28784. /**
  28785. * An event triggered when the mesh is rebuilt.
  28786. */
  28787. onRebuildObservable: Observable<AbstractMesh>;
  28788. /**
  28789. * Creates a new AbstractMesh
  28790. * @param name defines the name of the mesh
  28791. * @param scene defines the hosting scene
  28792. */
  28793. constructor(name: string, scene?: Nullable<Scene>);
  28794. /**
  28795. * Returns the string "AbstractMesh"
  28796. * @returns "AbstractMesh"
  28797. */
  28798. getClassName(): string;
  28799. /**
  28800. * Gets a string representation of the current mesh
  28801. * @param fullDetails defines a boolean indicating if full details must be included
  28802. * @returns a string representation of the current mesh
  28803. */
  28804. toString(fullDetails?: boolean): string;
  28805. /**
  28806. * @hidden
  28807. */
  28808. protected _getEffectiveParent(): Nullable<Node>;
  28809. /** @hidden */
  28810. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28811. /** @hidden */
  28812. _rebuild(): void;
  28813. /** @hidden */
  28814. _resyncLightSources(): void;
  28815. /** @hidden */
  28816. _resyncLightSource(light: Light): void;
  28817. /** @hidden */
  28818. _unBindEffect(): void;
  28819. /** @hidden */
  28820. _removeLightSource(light: Light, dispose: boolean): void;
  28821. private _markSubMeshesAsDirty;
  28822. /** @hidden */
  28823. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28824. /** @hidden */
  28825. _markSubMeshesAsAttributesDirty(): void;
  28826. /** @hidden */
  28827. _markSubMeshesAsMiscDirty(): void;
  28828. /**
  28829. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28830. */
  28831. get scaling(): Vector3;
  28832. set scaling(newScaling: Vector3);
  28833. /**
  28834. * Returns true if the mesh is blocked. Implemented by child classes
  28835. */
  28836. get isBlocked(): boolean;
  28837. /**
  28838. * Returns the mesh itself by default. Implemented by child classes
  28839. * @param camera defines the camera to use to pick the right LOD level
  28840. * @returns the currentAbstractMesh
  28841. */
  28842. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28843. /**
  28844. * Returns 0 by default. Implemented by child classes
  28845. * @returns an integer
  28846. */
  28847. getTotalVertices(): number;
  28848. /**
  28849. * Returns a positive integer : the total number of indices in this mesh geometry.
  28850. * @returns the numner of indices or zero if the mesh has no geometry.
  28851. */
  28852. getTotalIndices(): number;
  28853. /**
  28854. * Returns null by default. Implemented by child classes
  28855. * @returns null
  28856. */
  28857. getIndices(): Nullable<IndicesArray>;
  28858. /**
  28859. * Returns the array of the requested vertex data kind. Implemented by child classes
  28860. * @param kind defines the vertex data kind to use
  28861. * @returns null
  28862. */
  28863. getVerticesData(kind: string): Nullable<FloatArray>;
  28864. /**
  28865. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28866. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28867. * Note that a new underlying VertexBuffer object is created each call.
  28868. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28869. * @param kind defines vertex data kind:
  28870. * * VertexBuffer.PositionKind
  28871. * * VertexBuffer.UVKind
  28872. * * VertexBuffer.UV2Kind
  28873. * * VertexBuffer.UV3Kind
  28874. * * VertexBuffer.UV4Kind
  28875. * * VertexBuffer.UV5Kind
  28876. * * VertexBuffer.UV6Kind
  28877. * * VertexBuffer.ColorKind
  28878. * * VertexBuffer.MatricesIndicesKind
  28879. * * VertexBuffer.MatricesIndicesExtraKind
  28880. * * VertexBuffer.MatricesWeightsKind
  28881. * * VertexBuffer.MatricesWeightsExtraKind
  28882. * @param data defines the data source
  28883. * @param updatable defines if the data must be flagged as updatable (or static)
  28884. * @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
  28885. * @returns the current mesh
  28886. */
  28887. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28888. /**
  28889. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28890. * If the mesh has no geometry, it is simply returned as it is.
  28891. * @param kind defines vertex data kind:
  28892. * * VertexBuffer.PositionKind
  28893. * * VertexBuffer.UVKind
  28894. * * VertexBuffer.UV2Kind
  28895. * * VertexBuffer.UV3Kind
  28896. * * VertexBuffer.UV4Kind
  28897. * * VertexBuffer.UV5Kind
  28898. * * VertexBuffer.UV6Kind
  28899. * * VertexBuffer.ColorKind
  28900. * * VertexBuffer.MatricesIndicesKind
  28901. * * VertexBuffer.MatricesIndicesExtraKind
  28902. * * VertexBuffer.MatricesWeightsKind
  28903. * * VertexBuffer.MatricesWeightsExtraKind
  28904. * @param data defines the data source
  28905. * @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
  28906. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28907. * @returns the current mesh
  28908. */
  28909. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28910. /**
  28911. * Sets the mesh indices,
  28912. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28913. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28914. * @param totalVertices Defines the total number of vertices
  28915. * @returns the current mesh
  28916. */
  28917. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28918. /**
  28919. * Gets a boolean indicating if specific vertex data is present
  28920. * @param kind defines the vertex data kind to use
  28921. * @returns true is data kind is present
  28922. */
  28923. isVerticesDataPresent(kind: string): boolean;
  28924. /**
  28925. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28926. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28927. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28928. * @returns a BoundingInfo
  28929. */
  28930. getBoundingInfo(): BoundingInfo;
  28931. /**
  28932. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28933. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28934. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28935. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28936. * @returns the current mesh
  28937. */
  28938. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28939. /**
  28940. * Overwrite the current bounding info
  28941. * @param boundingInfo defines the new bounding info
  28942. * @returns the current mesh
  28943. */
  28944. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28945. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28946. get useBones(): boolean;
  28947. /** @hidden */
  28948. _preActivate(): void;
  28949. /** @hidden */
  28950. _preActivateForIntermediateRendering(renderId: number): void;
  28951. /** @hidden */
  28952. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28953. /** @hidden */
  28954. _postActivate(): void;
  28955. /** @hidden */
  28956. _freeze(): void;
  28957. /** @hidden */
  28958. _unFreeze(): void;
  28959. /**
  28960. * Gets the current world matrix
  28961. * @returns a Matrix
  28962. */
  28963. getWorldMatrix(): Matrix;
  28964. /** @hidden */
  28965. _getWorldMatrixDeterminant(): number;
  28966. /**
  28967. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28968. */
  28969. get isAnInstance(): boolean;
  28970. /**
  28971. * Gets a boolean indicating if this mesh has instances
  28972. */
  28973. get hasInstances(): boolean;
  28974. /**
  28975. * Perform relative position change from the point of view of behind the front of the mesh.
  28976. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28977. * Supports definition of mesh facing forward or backward
  28978. * @param amountRight defines the distance on the right axis
  28979. * @param amountUp defines the distance on the up axis
  28980. * @param amountForward defines the distance on the forward axis
  28981. * @returns the current mesh
  28982. */
  28983. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28984. /**
  28985. * Calculate relative position change from the point of view of behind the front of the mesh.
  28986. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28987. * Supports definition of mesh facing forward or backward
  28988. * @param amountRight defines the distance on the right axis
  28989. * @param amountUp defines the distance on the up axis
  28990. * @param amountForward defines the distance on the forward axis
  28991. * @returns the new displacement vector
  28992. */
  28993. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28994. /**
  28995. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28996. * Supports definition of mesh facing forward or backward
  28997. * @param flipBack defines the flip
  28998. * @param twirlClockwise defines the twirl
  28999. * @param tiltRight defines the tilt
  29000. * @returns the current mesh
  29001. */
  29002. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29003. /**
  29004. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29005. * Supports definition of mesh facing forward or backward.
  29006. * @param flipBack defines the flip
  29007. * @param twirlClockwise defines the twirl
  29008. * @param tiltRight defines the tilt
  29009. * @returns the new rotation vector
  29010. */
  29011. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29012. /**
  29013. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29014. * This means the mesh underlying bounding box and sphere are recomputed.
  29015. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29016. * @returns the current mesh
  29017. */
  29018. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29019. /** @hidden */
  29020. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29021. /** @hidden */
  29022. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29023. /** @hidden */
  29024. _updateBoundingInfo(): AbstractMesh;
  29025. /** @hidden */
  29026. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29027. /** @hidden */
  29028. protected _afterComputeWorldMatrix(): void;
  29029. /** @hidden */
  29030. get _effectiveMesh(): AbstractMesh;
  29031. /**
  29032. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29033. * A mesh is in the frustum if its bounding box intersects the frustum
  29034. * @param frustumPlanes defines the frustum to test
  29035. * @returns true if the mesh is in the frustum planes
  29036. */
  29037. isInFrustum(frustumPlanes: Plane[]): boolean;
  29038. /**
  29039. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29040. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29041. * @param frustumPlanes defines the frustum to test
  29042. * @returns true if the mesh is completely in the frustum planes
  29043. */
  29044. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29045. /**
  29046. * True if the mesh intersects another mesh or a SolidParticle object
  29047. * @param mesh defines a target mesh or SolidParticle to test
  29048. * @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)
  29049. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29050. * @returns true if there is an intersection
  29051. */
  29052. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29053. /**
  29054. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29055. * @param point defines the point to test
  29056. * @returns true if there is an intersection
  29057. */
  29058. intersectsPoint(point: Vector3): boolean;
  29059. /**
  29060. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29062. */
  29063. get checkCollisions(): boolean;
  29064. set checkCollisions(collisionEnabled: boolean);
  29065. /**
  29066. * Gets Collider object used to compute collisions (not physics)
  29067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29068. */
  29069. get collider(): Nullable<Collider>;
  29070. /**
  29071. * Move the mesh using collision engine
  29072. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29073. * @param displacement defines the requested displacement vector
  29074. * @returns the current mesh
  29075. */
  29076. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29077. private _onCollisionPositionChange;
  29078. /** @hidden */
  29079. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29080. /** @hidden */
  29081. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29082. /** @hidden */
  29083. _checkCollision(collider: Collider): AbstractMesh;
  29084. /** @hidden */
  29085. _generatePointsArray(): boolean;
  29086. /**
  29087. * Checks if the passed Ray intersects with the mesh
  29088. * @param ray defines the ray to use
  29089. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29090. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29091. * @returns the picking info
  29092. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29093. */
  29094. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29095. /**
  29096. * Clones the current mesh
  29097. * @param name defines the mesh name
  29098. * @param newParent defines the new mesh parent
  29099. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29100. * @returns the new mesh
  29101. */
  29102. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29103. /**
  29104. * Disposes all the submeshes of the current meshnp
  29105. * @returns the current mesh
  29106. */
  29107. releaseSubMeshes(): AbstractMesh;
  29108. /**
  29109. * Releases resources associated with this abstract mesh.
  29110. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29111. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29112. */
  29113. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29114. /**
  29115. * Adds the passed mesh as a child to the current mesh
  29116. * @param mesh defines the child mesh
  29117. * @returns the current mesh
  29118. */
  29119. addChild(mesh: AbstractMesh): AbstractMesh;
  29120. /**
  29121. * Removes the passed mesh from the current mesh children list
  29122. * @param mesh defines the child mesh
  29123. * @returns the current mesh
  29124. */
  29125. removeChild(mesh: AbstractMesh): AbstractMesh;
  29126. /** @hidden */
  29127. private _initFacetData;
  29128. /**
  29129. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29130. * This method can be called within the render loop.
  29131. * 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
  29132. * @returns the current mesh
  29133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29134. */
  29135. updateFacetData(): AbstractMesh;
  29136. /**
  29137. * Returns the facetLocalNormals array.
  29138. * The normals are expressed in the mesh local spac
  29139. * @returns an array of Vector3
  29140. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29141. */
  29142. getFacetLocalNormals(): Vector3[];
  29143. /**
  29144. * Returns the facetLocalPositions array.
  29145. * The facet positions are expressed in the mesh local space
  29146. * @returns an array of Vector3
  29147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29148. */
  29149. getFacetLocalPositions(): Vector3[];
  29150. /**
  29151. * Returns the facetLocalPartioning array
  29152. * @returns an array of array of numbers
  29153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29154. */
  29155. getFacetLocalPartitioning(): number[][];
  29156. /**
  29157. * Returns the i-th facet position in the world system.
  29158. * This method allocates a new Vector3 per call
  29159. * @param i defines the facet index
  29160. * @returns a new Vector3
  29161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29162. */
  29163. getFacetPosition(i: number): Vector3;
  29164. /**
  29165. * Sets the reference Vector3 with the i-th facet position in the world system
  29166. * @param i defines the facet index
  29167. * @param ref defines the target vector
  29168. * @returns the current mesh
  29169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29170. */
  29171. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29172. /**
  29173. * Returns the i-th facet normal in the world system.
  29174. * This method allocates a new Vector3 per call
  29175. * @param i defines the facet index
  29176. * @returns a new Vector3
  29177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29178. */
  29179. getFacetNormal(i: number): Vector3;
  29180. /**
  29181. * Sets the reference Vector3 with the i-th facet normal in the world system
  29182. * @param i defines the facet index
  29183. * @param ref defines the target vector
  29184. * @returns the current mesh
  29185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29186. */
  29187. getFacetNormalToRef(i: number, ref: Vector3): this;
  29188. /**
  29189. * 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)
  29190. * @param x defines x coordinate
  29191. * @param y defines y coordinate
  29192. * @param z defines z coordinate
  29193. * @returns the array of facet indexes
  29194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29195. */
  29196. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29197. /**
  29198. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29199. * @param projected sets as the (x,y,z) world projection on the facet
  29200. * @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
  29201. * @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
  29202. * @param x defines x coordinate
  29203. * @param y defines y coordinate
  29204. * @param z defines z coordinate
  29205. * @returns the face index if found (or null instead)
  29206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29207. */
  29208. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29209. /**
  29210. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29211. * @param projected sets as the (x,y,z) local projection on the facet
  29212. * @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
  29213. * @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
  29214. * @param x defines x coordinate
  29215. * @param y defines y coordinate
  29216. * @param z defines z coordinate
  29217. * @returns the face index if found (or null instead)
  29218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29219. */
  29220. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29221. /**
  29222. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29223. * @returns the parameters
  29224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29225. */
  29226. getFacetDataParameters(): any;
  29227. /**
  29228. * Disables the feature FacetData and frees the related memory
  29229. * @returns the current mesh
  29230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29231. */
  29232. disableFacetData(): AbstractMesh;
  29233. /**
  29234. * Updates the AbstractMesh indices array
  29235. * @param indices defines the data source
  29236. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29237. * @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)
  29238. * @returns the current mesh
  29239. */
  29240. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29241. /**
  29242. * Creates new normals data for the mesh
  29243. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29244. * @returns the current mesh
  29245. */
  29246. createNormals(updatable: boolean): AbstractMesh;
  29247. /**
  29248. * Align the mesh with a normal
  29249. * @param normal defines the normal to use
  29250. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29251. * @returns the current mesh
  29252. */
  29253. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29254. /** @hidden */
  29255. _checkOcclusionQuery(): boolean;
  29256. /**
  29257. * Disables the mesh edge rendering mode
  29258. * @returns the currentAbstractMesh
  29259. */
  29260. disableEdgesRendering(): AbstractMesh;
  29261. /**
  29262. * Enables the edge rendering mode on the mesh.
  29263. * This mode makes the mesh edges visible
  29264. * @param epsilon defines the maximal distance between two angles to detect a face
  29265. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29266. * @returns the currentAbstractMesh
  29267. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29268. */
  29269. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29270. }
  29271. }
  29272. declare module "babylonjs/Actions/actionEvent" {
  29273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29274. import { Nullable } from "babylonjs/types";
  29275. import { Sprite } from "babylonjs/Sprites/sprite";
  29276. import { Scene } from "babylonjs/scene";
  29277. import { Vector2 } from "babylonjs/Maths/math.vector";
  29278. /**
  29279. * Interface used to define ActionEvent
  29280. */
  29281. export interface IActionEvent {
  29282. /** The mesh or sprite that triggered the action */
  29283. source: any;
  29284. /** The X mouse cursor position at the time of the event */
  29285. pointerX: number;
  29286. /** The Y mouse cursor position at the time of the event */
  29287. pointerY: number;
  29288. /** The mesh that is currently pointed at (can be null) */
  29289. meshUnderPointer: Nullable<AbstractMesh>;
  29290. /** the original (browser) event that triggered the ActionEvent */
  29291. sourceEvent?: any;
  29292. /** additional data for the event */
  29293. additionalData?: any;
  29294. }
  29295. /**
  29296. * ActionEvent is the event being sent when an action is triggered.
  29297. */
  29298. export class ActionEvent implements IActionEvent {
  29299. /** The mesh or sprite that triggered the action */
  29300. source: any;
  29301. /** The X mouse cursor position at the time of the event */
  29302. pointerX: number;
  29303. /** The Y mouse cursor position at the time of the event */
  29304. pointerY: number;
  29305. /** The mesh that is currently pointed at (can be null) */
  29306. meshUnderPointer: Nullable<AbstractMesh>;
  29307. /** the original (browser) event that triggered the ActionEvent */
  29308. sourceEvent?: any;
  29309. /** additional data for the event */
  29310. additionalData?: any;
  29311. /**
  29312. * Creates a new ActionEvent
  29313. * @param source The mesh or sprite that triggered the action
  29314. * @param pointerX The X mouse cursor position at the time of the event
  29315. * @param pointerY The Y mouse cursor position at the time of the event
  29316. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29317. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29318. * @param additionalData additional data for the event
  29319. */
  29320. constructor(
  29321. /** The mesh or sprite that triggered the action */
  29322. source: any,
  29323. /** The X mouse cursor position at the time of the event */
  29324. pointerX: number,
  29325. /** The Y mouse cursor position at the time of the event */
  29326. pointerY: number,
  29327. /** The mesh that is currently pointed at (can be null) */
  29328. meshUnderPointer: Nullable<AbstractMesh>,
  29329. /** the original (browser) event that triggered the ActionEvent */
  29330. sourceEvent?: any,
  29331. /** additional data for the event */
  29332. additionalData?: any);
  29333. /**
  29334. * Helper function to auto-create an ActionEvent from a source mesh.
  29335. * @param source The source mesh that triggered the event
  29336. * @param evt The original (browser) event
  29337. * @param additionalData additional data for the event
  29338. * @returns the new ActionEvent
  29339. */
  29340. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29341. /**
  29342. * Helper function to auto-create an ActionEvent from a source sprite
  29343. * @param source The source sprite that triggered the event
  29344. * @param scene Scene associated with the sprite
  29345. * @param evt The original (browser) event
  29346. * @param additionalData additional data for the event
  29347. * @returns the new ActionEvent
  29348. */
  29349. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29350. /**
  29351. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29352. * @param scene the scene where the event occurred
  29353. * @param evt The original (browser) event
  29354. * @returns the new ActionEvent
  29355. */
  29356. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29357. /**
  29358. * Helper function to auto-create an ActionEvent from a primitive
  29359. * @param prim defines the target primitive
  29360. * @param pointerPos defines the pointer position
  29361. * @param evt The original (browser) event
  29362. * @param additionalData additional data for the event
  29363. * @returns the new ActionEvent
  29364. */
  29365. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29366. }
  29367. }
  29368. declare module "babylonjs/Actions/abstractActionManager" {
  29369. import { IDisposable } from "babylonjs/scene";
  29370. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29371. import { IAction } from "babylonjs/Actions/action";
  29372. import { Nullable } from "babylonjs/types";
  29373. /**
  29374. * Abstract class used to decouple action Manager from scene and meshes.
  29375. * Do not instantiate.
  29376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29377. */
  29378. export abstract class AbstractActionManager implements IDisposable {
  29379. /** Gets the list of active triggers */
  29380. static Triggers: {
  29381. [key: string]: number;
  29382. };
  29383. /** Gets the cursor to use when hovering items */
  29384. hoverCursor: string;
  29385. /** Gets the list of actions */
  29386. actions: IAction[];
  29387. /**
  29388. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29389. */
  29390. isRecursive: boolean;
  29391. /**
  29392. * Releases all associated resources
  29393. */
  29394. abstract dispose(): void;
  29395. /**
  29396. * Does this action manager has pointer triggers
  29397. */
  29398. abstract get hasPointerTriggers(): boolean;
  29399. /**
  29400. * Does this action manager has pick triggers
  29401. */
  29402. abstract get hasPickTriggers(): boolean;
  29403. /**
  29404. * Process a specific trigger
  29405. * @param trigger defines the trigger to process
  29406. * @param evt defines the event details to be processed
  29407. */
  29408. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29409. /**
  29410. * Does this action manager handles actions of any of the given triggers
  29411. * @param triggers defines the triggers to be tested
  29412. * @return a boolean indicating whether one (or more) of the triggers is handled
  29413. */
  29414. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29415. /**
  29416. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29417. * speed.
  29418. * @param triggerA defines the trigger to be tested
  29419. * @param triggerB defines the trigger to be tested
  29420. * @return a boolean indicating whether one (or more) of the triggers is handled
  29421. */
  29422. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29423. /**
  29424. * Does this action manager handles actions of a given trigger
  29425. * @param trigger defines the trigger to be tested
  29426. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29427. * @return whether the trigger is handled
  29428. */
  29429. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29430. /**
  29431. * Serialize this manager to a JSON object
  29432. * @param name defines the property name to store this manager
  29433. * @returns a JSON representation of this manager
  29434. */
  29435. abstract serialize(name: string): any;
  29436. /**
  29437. * Registers an action to this action manager
  29438. * @param action defines the action to be registered
  29439. * @return the action amended (prepared) after registration
  29440. */
  29441. abstract registerAction(action: IAction): Nullable<IAction>;
  29442. /**
  29443. * Unregisters an action to this action manager
  29444. * @param action defines the action to be unregistered
  29445. * @return a boolean indicating whether the action has been unregistered
  29446. */
  29447. abstract unregisterAction(action: IAction): Boolean;
  29448. /**
  29449. * Does exist one action manager with at least one trigger
  29450. **/
  29451. static get HasTriggers(): boolean;
  29452. /**
  29453. * Does exist one action manager with at least one pick trigger
  29454. **/
  29455. static get HasPickTriggers(): boolean;
  29456. /**
  29457. * Does exist one action manager that handles actions of a given trigger
  29458. * @param trigger defines the trigger to be tested
  29459. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29460. **/
  29461. static HasSpecificTrigger(trigger: number): boolean;
  29462. }
  29463. }
  29464. declare module "babylonjs/node" {
  29465. import { Scene } from "babylonjs/scene";
  29466. import { Nullable } from "babylonjs/types";
  29467. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29468. import { Engine } from "babylonjs/Engines/engine";
  29469. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29470. import { Observable } from "babylonjs/Misc/observable";
  29471. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29472. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29473. import { Animatable } from "babylonjs/Animations/animatable";
  29474. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29475. import { Animation } from "babylonjs/Animations/animation";
  29476. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29478. /**
  29479. * Defines how a node can be built from a string name.
  29480. */
  29481. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29482. /**
  29483. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29484. */
  29485. export class Node implements IBehaviorAware<Node> {
  29486. /** @hidden */
  29487. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29488. private static _NodeConstructors;
  29489. /**
  29490. * Add a new node constructor
  29491. * @param type defines the type name of the node to construct
  29492. * @param constructorFunc defines the constructor function
  29493. */
  29494. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29495. /**
  29496. * Returns a node constructor based on type name
  29497. * @param type defines the type name
  29498. * @param name defines the new node name
  29499. * @param scene defines the hosting scene
  29500. * @param options defines optional options to transmit to constructors
  29501. * @returns the new constructor or null
  29502. */
  29503. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29504. /**
  29505. * Gets or sets the name of the node
  29506. */
  29507. name: string;
  29508. /**
  29509. * Gets or sets the id of the node
  29510. */
  29511. id: string;
  29512. /**
  29513. * Gets or sets the unique id of the node
  29514. */
  29515. uniqueId: number;
  29516. /**
  29517. * Gets or sets a string used to store user defined state for the node
  29518. */
  29519. state: string;
  29520. /**
  29521. * Gets or sets an object used to store user defined information for the node
  29522. */
  29523. metadata: any;
  29524. /**
  29525. * For internal use only. Please do not use.
  29526. */
  29527. reservedDataStore: any;
  29528. /**
  29529. * List of inspectable custom properties (used by the Inspector)
  29530. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29531. */
  29532. inspectableCustomProperties: IInspectable[];
  29533. private _doNotSerialize;
  29534. /**
  29535. * Gets or sets a boolean used to define if the node must be serialized
  29536. */
  29537. get doNotSerialize(): boolean;
  29538. set doNotSerialize(value: boolean);
  29539. /** @hidden */
  29540. _isDisposed: boolean;
  29541. /**
  29542. * Gets a list of Animations associated with the node
  29543. */
  29544. animations: import("babylonjs/Animations/animation").Animation[];
  29545. protected _ranges: {
  29546. [name: string]: Nullable<AnimationRange>;
  29547. };
  29548. /**
  29549. * Callback raised when the node is ready to be used
  29550. */
  29551. onReady: Nullable<(node: Node) => void>;
  29552. private _isEnabled;
  29553. private _isParentEnabled;
  29554. private _isReady;
  29555. /** @hidden */
  29556. _currentRenderId: number;
  29557. private _parentUpdateId;
  29558. /** @hidden */
  29559. _childUpdateId: number;
  29560. /** @hidden */
  29561. _waitingParentId: Nullable<string>;
  29562. /** @hidden */
  29563. _scene: Scene;
  29564. /** @hidden */
  29565. _cache: any;
  29566. private _parentNode;
  29567. private _children;
  29568. /** @hidden */
  29569. _worldMatrix: Matrix;
  29570. /** @hidden */
  29571. _worldMatrixDeterminant: number;
  29572. /** @hidden */
  29573. _worldMatrixDeterminantIsDirty: boolean;
  29574. /** @hidden */
  29575. private _sceneRootNodesIndex;
  29576. /**
  29577. * Gets a boolean indicating if the node has been disposed
  29578. * @returns true if the node was disposed
  29579. */
  29580. isDisposed(): boolean;
  29581. /**
  29582. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29583. * @see https://doc.babylonjs.com/how_to/parenting
  29584. */
  29585. set parent(parent: Nullable<Node>);
  29586. get parent(): Nullable<Node>;
  29587. /** @hidden */
  29588. _addToSceneRootNodes(): void;
  29589. /** @hidden */
  29590. _removeFromSceneRootNodes(): void;
  29591. private _animationPropertiesOverride;
  29592. /**
  29593. * Gets or sets the animation properties override
  29594. */
  29595. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29596. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29597. /**
  29598. * Gets a string idenfifying the name of the class
  29599. * @returns "Node" string
  29600. */
  29601. getClassName(): string;
  29602. /** @hidden */
  29603. readonly _isNode: boolean;
  29604. /**
  29605. * An event triggered when the mesh is disposed
  29606. */
  29607. onDisposeObservable: Observable<Node>;
  29608. private _onDisposeObserver;
  29609. /**
  29610. * Sets a callback that will be raised when the node will be disposed
  29611. */
  29612. set onDispose(callback: () => void);
  29613. /**
  29614. * Creates a new Node
  29615. * @param name the name and id to be given to this node
  29616. * @param scene the scene this node will be added to
  29617. */
  29618. constructor(name: string, scene?: Nullable<Scene>);
  29619. /**
  29620. * Gets the scene of the node
  29621. * @returns a scene
  29622. */
  29623. getScene(): Scene;
  29624. /**
  29625. * Gets the engine of the node
  29626. * @returns a Engine
  29627. */
  29628. getEngine(): Engine;
  29629. private _behaviors;
  29630. /**
  29631. * Attach a behavior to the node
  29632. * @see http://doc.babylonjs.com/features/behaviour
  29633. * @param behavior defines the behavior to attach
  29634. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29635. * @returns the current Node
  29636. */
  29637. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29638. /**
  29639. * Remove an attached behavior
  29640. * @see http://doc.babylonjs.com/features/behaviour
  29641. * @param behavior defines the behavior to attach
  29642. * @returns the current Node
  29643. */
  29644. removeBehavior(behavior: Behavior<Node>): Node;
  29645. /**
  29646. * Gets the list of attached behaviors
  29647. * @see http://doc.babylonjs.com/features/behaviour
  29648. */
  29649. get behaviors(): Behavior<Node>[];
  29650. /**
  29651. * Gets an attached behavior by name
  29652. * @param name defines the name of the behavior to look for
  29653. * @see http://doc.babylonjs.com/features/behaviour
  29654. * @returns null if behavior was not found else the requested behavior
  29655. */
  29656. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29657. /**
  29658. * Returns the latest update of the World matrix
  29659. * @returns a Matrix
  29660. */
  29661. getWorldMatrix(): Matrix;
  29662. /** @hidden */
  29663. _getWorldMatrixDeterminant(): number;
  29664. /**
  29665. * Returns directly the latest state of the mesh World matrix.
  29666. * A Matrix is returned.
  29667. */
  29668. get worldMatrixFromCache(): Matrix;
  29669. /** @hidden */
  29670. _initCache(): void;
  29671. /** @hidden */
  29672. updateCache(force?: boolean): void;
  29673. /** @hidden */
  29674. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29675. /** @hidden */
  29676. _updateCache(ignoreParentClass?: boolean): void;
  29677. /** @hidden */
  29678. _isSynchronized(): boolean;
  29679. /** @hidden */
  29680. _markSyncedWithParent(): void;
  29681. /** @hidden */
  29682. isSynchronizedWithParent(): boolean;
  29683. /** @hidden */
  29684. isSynchronized(): boolean;
  29685. /**
  29686. * Is this node ready to be used/rendered
  29687. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29688. * @return true if the node is ready
  29689. */
  29690. isReady(completeCheck?: boolean): boolean;
  29691. /**
  29692. * Is this node enabled?
  29693. * 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
  29694. * @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
  29695. * @return whether this node (and its parent) is enabled
  29696. */
  29697. isEnabled(checkAncestors?: boolean): boolean;
  29698. /** @hidden */
  29699. protected _syncParentEnabledState(): void;
  29700. /**
  29701. * Set the enabled state of this node
  29702. * @param value defines the new enabled state
  29703. */
  29704. setEnabled(value: boolean): void;
  29705. /**
  29706. * Is this node a descendant of the given node?
  29707. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29708. * @param ancestor defines the parent node to inspect
  29709. * @returns a boolean indicating if this node is a descendant of the given node
  29710. */
  29711. isDescendantOf(ancestor: Node): boolean;
  29712. /** @hidden */
  29713. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29714. /**
  29715. * Will return all nodes that have this node as ascendant
  29716. * @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
  29717. * @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
  29718. * @return all children nodes of all types
  29719. */
  29720. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29721. /**
  29722. * Get all child-meshes of this node
  29723. * @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)
  29724. * @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
  29725. * @returns an array of AbstractMesh
  29726. */
  29727. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29728. /**
  29729. * Get all direct children of this node
  29730. * @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
  29731. * @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)
  29732. * @returns an array of Node
  29733. */
  29734. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29735. /** @hidden */
  29736. _setReady(state: boolean): void;
  29737. /**
  29738. * Get an animation by name
  29739. * @param name defines the name of the animation to look for
  29740. * @returns null if not found else the requested animation
  29741. */
  29742. getAnimationByName(name: string): Nullable<Animation>;
  29743. /**
  29744. * Creates an animation range for this node
  29745. * @param name defines the name of the range
  29746. * @param from defines the starting key
  29747. * @param to defines the end key
  29748. */
  29749. createAnimationRange(name: string, from: number, to: number): void;
  29750. /**
  29751. * Delete a specific animation range
  29752. * @param name defines the name of the range to delete
  29753. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29754. */
  29755. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29756. /**
  29757. * Get an animation range by name
  29758. * @param name defines the name of the animation range to look for
  29759. * @returns null if not found else the requested animation range
  29760. */
  29761. getAnimationRange(name: string): Nullable<AnimationRange>;
  29762. /**
  29763. * Gets the list of all animation ranges defined on this node
  29764. * @returns an array
  29765. */
  29766. getAnimationRanges(): Nullable<AnimationRange>[];
  29767. /**
  29768. * Will start the animation sequence
  29769. * @param name defines the range frames for animation sequence
  29770. * @param loop defines if the animation should loop (false by default)
  29771. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29772. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29773. * @returns the object created for this animation. If range does not exist, it will return null
  29774. */
  29775. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29776. /**
  29777. * Serialize animation ranges into a JSON compatible object
  29778. * @returns serialization object
  29779. */
  29780. serializeAnimationRanges(): any;
  29781. /**
  29782. * Computes the world matrix of the node
  29783. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29784. * @returns the world matrix
  29785. */
  29786. computeWorldMatrix(force?: boolean): Matrix;
  29787. /**
  29788. * Releases resources associated with this node.
  29789. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29790. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29791. */
  29792. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29793. /**
  29794. * Parse animation range data from a serialization object and store them into a given node
  29795. * @param node defines where to store the animation ranges
  29796. * @param parsedNode defines the serialization object to read data from
  29797. * @param scene defines the hosting scene
  29798. */
  29799. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29800. /**
  29801. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29802. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29803. * @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
  29804. * @returns the new bounding vectors
  29805. */
  29806. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29807. min: Vector3;
  29808. max: Vector3;
  29809. };
  29810. }
  29811. }
  29812. declare module "babylonjs/Animations/animation" {
  29813. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29814. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29815. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29816. import { Nullable } from "babylonjs/types";
  29817. import { Scene } from "babylonjs/scene";
  29818. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29819. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29820. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29821. import { Node } from "babylonjs/node";
  29822. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29823. import { Size } from "babylonjs/Maths/math.size";
  29824. import { Animatable } from "babylonjs/Animations/animatable";
  29825. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29826. /**
  29827. * @hidden
  29828. */
  29829. export class _IAnimationState {
  29830. key: number;
  29831. repeatCount: number;
  29832. workValue?: any;
  29833. loopMode?: number;
  29834. offsetValue?: any;
  29835. highLimitValue?: any;
  29836. }
  29837. /**
  29838. * Class used to store any kind of animation
  29839. */
  29840. export class Animation {
  29841. /**Name of the animation */
  29842. name: string;
  29843. /**Property to animate */
  29844. targetProperty: string;
  29845. /**The frames per second of the animation */
  29846. framePerSecond: number;
  29847. /**The data type of the animation */
  29848. dataType: number;
  29849. /**The loop mode of the animation */
  29850. loopMode?: number | undefined;
  29851. /**Specifies if blending should be enabled */
  29852. enableBlending?: boolean | undefined;
  29853. /**
  29854. * Use matrix interpolation instead of using direct key value when animating matrices
  29855. */
  29856. static AllowMatricesInterpolation: boolean;
  29857. /**
  29858. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29859. */
  29860. static AllowMatrixDecomposeForInterpolation: boolean;
  29861. /**
  29862. * Stores the key frames of the animation
  29863. */
  29864. private _keys;
  29865. /**
  29866. * Stores the easing function of the animation
  29867. */
  29868. private _easingFunction;
  29869. /**
  29870. * @hidden Internal use only
  29871. */
  29872. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29873. /**
  29874. * The set of event that will be linked to this animation
  29875. */
  29876. private _events;
  29877. /**
  29878. * Stores an array of target property paths
  29879. */
  29880. targetPropertyPath: string[];
  29881. /**
  29882. * Stores the blending speed of the animation
  29883. */
  29884. blendingSpeed: number;
  29885. /**
  29886. * Stores the animation ranges for the animation
  29887. */
  29888. private _ranges;
  29889. /**
  29890. * @hidden Internal use
  29891. */
  29892. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29893. /**
  29894. * Sets up an animation
  29895. * @param property The property to animate
  29896. * @param animationType The animation type to apply
  29897. * @param framePerSecond The frames per second of the animation
  29898. * @param easingFunction The easing function used in the animation
  29899. * @returns The created animation
  29900. */
  29901. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29902. /**
  29903. * Create and start an animation on a node
  29904. * @param name defines the name of the global animation that will be run on all nodes
  29905. * @param node defines the root node where the animation will take place
  29906. * @param targetProperty defines property to animate
  29907. * @param framePerSecond defines the number of frame per second yo use
  29908. * @param totalFrame defines the number of frames in total
  29909. * @param from defines the initial value
  29910. * @param to defines the final value
  29911. * @param loopMode defines which loop mode you want to use (off by default)
  29912. * @param easingFunction defines the easing function to use (linear by default)
  29913. * @param onAnimationEnd defines the callback to call when animation end
  29914. * @returns the animatable created for this animation
  29915. */
  29916. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29917. /**
  29918. * Create and start an animation on a node and its descendants
  29919. * @param name defines the name of the global animation that will be run on all nodes
  29920. * @param node defines the root node where the animation will take place
  29921. * @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
  29922. * @param targetProperty defines property to animate
  29923. * @param framePerSecond defines the number of frame per second to use
  29924. * @param totalFrame defines the number of frames in total
  29925. * @param from defines the initial value
  29926. * @param to defines the final value
  29927. * @param loopMode defines which loop mode you want to use (off by default)
  29928. * @param easingFunction defines the easing function to use (linear by default)
  29929. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29930. * @returns the list of animatables created for all nodes
  29931. * @example https://www.babylonjs-playground.com/#MH0VLI
  29932. */
  29933. 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[]>;
  29934. /**
  29935. * Creates a new animation, merges it with the existing animations and starts it
  29936. * @param name Name of the animation
  29937. * @param node Node which contains the scene that begins the animations
  29938. * @param targetProperty Specifies which property to animate
  29939. * @param framePerSecond The frames per second of the animation
  29940. * @param totalFrame The total number of frames
  29941. * @param from The frame at the beginning of the animation
  29942. * @param to The frame at the end of the animation
  29943. * @param loopMode Specifies the loop mode of the animation
  29944. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29945. * @param onAnimationEnd Callback to run once the animation is complete
  29946. * @returns Nullable animation
  29947. */
  29948. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29949. /**
  29950. * Transition property of an host to the target Value
  29951. * @param property The property to transition
  29952. * @param targetValue The target Value of the property
  29953. * @param host The object where the property to animate belongs
  29954. * @param scene Scene used to run the animation
  29955. * @param frameRate Framerate (in frame/s) to use
  29956. * @param transition The transition type we want to use
  29957. * @param duration The duration of the animation, in milliseconds
  29958. * @param onAnimationEnd Callback trigger at the end of the animation
  29959. * @returns Nullable animation
  29960. */
  29961. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29962. /**
  29963. * Return the array of runtime animations currently using this animation
  29964. */
  29965. get runtimeAnimations(): RuntimeAnimation[];
  29966. /**
  29967. * Specifies if any of the runtime animations are currently running
  29968. */
  29969. get hasRunningRuntimeAnimations(): boolean;
  29970. /**
  29971. * Initializes the animation
  29972. * @param name Name of the animation
  29973. * @param targetProperty Property to animate
  29974. * @param framePerSecond The frames per second of the animation
  29975. * @param dataType The data type of the animation
  29976. * @param loopMode The loop mode of the animation
  29977. * @param enableBlending Specifies if blending should be enabled
  29978. */
  29979. constructor(
  29980. /**Name of the animation */
  29981. name: string,
  29982. /**Property to animate */
  29983. targetProperty: string,
  29984. /**The frames per second of the animation */
  29985. framePerSecond: number,
  29986. /**The data type of the animation */
  29987. dataType: number,
  29988. /**The loop mode of the animation */
  29989. loopMode?: number | undefined,
  29990. /**Specifies if blending should be enabled */
  29991. enableBlending?: boolean | undefined);
  29992. /**
  29993. * Converts the animation to a string
  29994. * @param fullDetails support for multiple levels of logging within scene loading
  29995. * @returns String form of the animation
  29996. */
  29997. toString(fullDetails?: boolean): string;
  29998. /**
  29999. * Add an event to this animation
  30000. * @param event Event to add
  30001. */
  30002. addEvent(event: AnimationEvent): void;
  30003. /**
  30004. * Remove all events found at the given frame
  30005. * @param frame The frame to remove events from
  30006. */
  30007. removeEvents(frame: number): void;
  30008. /**
  30009. * Retrieves all the events from the animation
  30010. * @returns Events from the animation
  30011. */
  30012. getEvents(): AnimationEvent[];
  30013. /**
  30014. * Creates an animation range
  30015. * @param name Name of the animation range
  30016. * @param from Starting frame of the animation range
  30017. * @param to Ending frame of the animation
  30018. */
  30019. createRange(name: string, from: number, to: number): void;
  30020. /**
  30021. * Deletes an animation range by name
  30022. * @param name Name of the animation range to delete
  30023. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30024. */
  30025. deleteRange(name: string, deleteFrames?: boolean): void;
  30026. /**
  30027. * Gets the animation range by name, or null if not defined
  30028. * @param name Name of the animation range
  30029. * @returns Nullable animation range
  30030. */
  30031. getRange(name: string): Nullable<AnimationRange>;
  30032. /**
  30033. * Gets the key frames from the animation
  30034. * @returns The key frames of the animation
  30035. */
  30036. getKeys(): Array<IAnimationKey>;
  30037. /**
  30038. * Gets the highest frame rate of the animation
  30039. * @returns Highest frame rate of the animation
  30040. */
  30041. getHighestFrame(): number;
  30042. /**
  30043. * Gets the easing function of the animation
  30044. * @returns Easing function of the animation
  30045. */
  30046. getEasingFunction(): IEasingFunction;
  30047. /**
  30048. * Sets the easing function of the animation
  30049. * @param easingFunction A custom mathematical formula for animation
  30050. */
  30051. setEasingFunction(easingFunction: EasingFunction): void;
  30052. /**
  30053. * Interpolates a scalar linearly
  30054. * @param startValue Start value of the animation curve
  30055. * @param endValue End value of the animation curve
  30056. * @param gradient Scalar amount to interpolate
  30057. * @returns Interpolated scalar value
  30058. */
  30059. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30060. /**
  30061. * Interpolates a scalar cubically
  30062. * @param startValue Start value of the animation curve
  30063. * @param outTangent End tangent of the animation
  30064. * @param endValue End value of the animation curve
  30065. * @param inTangent Start tangent of the animation curve
  30066. * @param gradient Scalar amount to interpolate
  30067. * @returns Interpolated scalar value
  30068. */
  30069. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30070. /**
  30071. * Interpolates a quaternion using a spherical linear interpolation
  30072. * @param startValue Start value of the animation curve
  30073. * @param endValue End value of the animation curve
  30074. * @param gradient Scalar amount to interpolate
  30075. * @returns Interpolated quaternion value
  30076. */
  30077. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30078. /**
  30079. * Interpolates a quaternion cubically
  30080. * @param startValue Start value of the animation curve
  30081. * @param outTangent End tangent of the animation curve
  30082. * @param endValue End value of the animation curve
  30083. * @param inTangent Start tangent of the animation curve
  30084. * @param gradient Scalar amount to interpolate
  30085. * @returns Interpolated quaternion value
  30086. */
  30087. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30088. /**
  30089. * Interpolates a Vector3 linearl
  30090. * @param startValue Start value of the animation curve
  30091. * @param endValue End value of the animation curve
  30092. * @param gradient Scalar amount to interpolate
  30093. * @returns Interpolated scalar value
  30094. */
  30095. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30096. /**
  30097. * Interpolates a Vector3 cubically
  30098. * @param startValue Start value of the animation curve
  30099. * @param outTangent End tangent of the animation
  30100. * @param endValue End value of the animation curve
  30101. * @param inTangent Start tangent of the animation curve
  30102. * @param gradient Scalar amount to interpolate
  30103. * @returns InterpolatedVector3 value
  30104. */
  30105. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30106. /**
  30107. * Interpolates a Vector2 linearly
  30108. * @param startValue Start value of the animation curve
  30109. * @param endValue End value of the animation curve
  30110. * @param gradient Scalar amount to interpolate
  30111. * @returns Interpolated Vector2 value
  30112. */
  30113. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30114. /**
  30115. * Interpolates a Vector2 cubically
  30116. * @param startValue Start value of the animation curve
  30117. * @param outTangent End tangent of the animation
  30118. * @param endValue End value of the animation curve
  30119. * @param inTangent Start tangent of the animation curve
  30120. * @param gradient Scalar amount to interpolate
  30121. * @returns Interpolated Vector2 value
  30122. */
  30123. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30124. /**
  30125. * Interpolates a size linearly
  30126. * @param startValue Start value of the animation curve
  30127. * @param endValue End value of the animation curve
  30128. * @param gradient Scalar amount to interpolate
  30129. * @returns Interpolated Size value
  30130. */
  30131. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30132. /**
  30133. * Interpolates a Color3 linearly
  30134. * @param startValue Start value of the animation curve
  30135. * @param endValue End value of the animation curve
  30136. * @param gradient Scalar amount to interpolate
  30137. * @returns Interpolated Color3 value
  30138. */
  30139. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30140. /**
  30141. * Interpolates a Color4 linearly
  30142. * @param startValue Start value of the animation curve
  30143. * @param endValue End value of the animation curve
  30144. * @param gradient Scalar amount to interpolate
  30145. * @returns Interpolated Color3 value
  30146. */
  30147. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30148. /**
  30149. * @hidden Internal use only
  30150. */
  30151. _getKeyValue(value: any): any;
  30152. /**
  30153. * @hidden Internal use only
  30154. */
  30155. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30156. /**
  30157. * Defines the function to use to interpolate matrices
  30158. * @param startValue defines the start matrix
  30159. * @param endValue defines the end matrix
  30160. * @param gradient defines the gradient between both matrices
  30161. * @param result defines an optional target matrix where to store the interpolation
  30162. * @returns the interpolated matrix
  30163. */
  30164. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30165. /**
  30166. * Makes a copy of the animation
  30167. * @returns Cloned animation
  30168. */
  30169. clone(): Animation;
  30170. /**
  30171. * Sets the key frames of the animation
  30172. * @param values The animation key frames to set
  30173. */
  30174. setKeys(values: Array<IAnimationKey>): void;
  30175. /**
  30176. * Serializes the animation to an object
  30177. * @returns Serialized object
  30178. */
  30179. serialize(): any;
  30180. /**
  30181. * Float animation type
  30182. */
  30183. static readonly ANIMATIONTYPE_FLOAT: number;
  30184. /**
  30185. * Vector3 animation type
  30186. */
  30187. static readonly ANIMATIONTYPE_VECTOR3: number;
  30188. /**
  30189. * Quaternion animation type
  30190. */
  30191. static readonly ANIMATIONTYPE_QUATERNION: number;
  30192. /**
  30193. * Matrix animation type
  30194. */
  30195. static readonly ANIMATIONTYPE_MATRIX: number;
  30196. /**
  30197. * Color3 animation type
  30198. */
  30199. static readonly ANIMATIONTYPE_COLOR3: number;
  30200. /**
  30201. * Color3 animation type
  30202. */
  30203. static readonly ANIMATIONTYPE_COLOR4: number;
  30204. /**
  30205. * Vector2 animation type
  30206. */
  30207. static readonly ANIMATIONTYPE_VECTOR2: number;
  30208. /**
  30209. * Size animation type
  30210. */
  30211. static readonly ANIMATIONTYPE_SIZE: number;
  30212. /**
  30213. * Relative Loop Mode
  30214. */
  30215. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30216. /**
  30217. * Cycle Loop Mode
  30218. */
  30219. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30220. /**
  30221. * Constant Loop Mode
  30222. */
  30223. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30224. /** @hidden */
  30225. static _UniversalLerp(left: any, right: any, amount: number): any;
  30226. /**
  30227. * Parses an animation object and creates an animation
  30228. * @param parsedAnimation Parsed animation object
  30229. * @returns Animation object
  30230. */
  30231. static Parse(parsedAnimation: any): Animation;
  30232. /**
  30233. * Appends the serialized animations from the source animations
  30234. * @param source Source containing the animations
  30235. * @param destination Target to store the animations
  30236. */
  30237. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30238. }
  30239. }
  30240. declare module "babylonjs/Animations/animatable.interface" {
  30241. import { Nullable } from "babylonjs/types";
  30242. import { Animation } from "babylonjs/Animations/animation";
  30243. /**
  30244. * Interface containing an array of animations
  30245. */
  30246. export interface IAnimatable {
  30247. /**
  30248. * Array of animations
  30249. */
  30250. animations: Nullable<Array<Animation>>;
  30251. }
  30252. }
  30253. declare module "babylonjs/Misc/decorators" {
  30254. import { Nullable } from "babylonjs/types";
  30255. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30256. import { Scene } from "babylonjs/scene";
  30257. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30258. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30259. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30260. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30261. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30262. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30263. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30264. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30265. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30266. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30267. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30268. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30269. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30270. /**
  30271. * Decorator used to define property that can be serialized as reference to a camera
  30272. * @param sourceName defines the name of the property to decorate
  30273. */
  30274. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30275. /**
  30276. * Class used to help serialization objects
  30277. */
  30278. export class SerializationHelper {
  30279. /** @hidden */
  30280. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30281. /** @hidden */
  30282. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30283. /** @hidden */
  30284. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30285. /** @hidden */
  30286. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30287. /**
  30288. * Appends the serialized animations from the source animations
  30289. * @param source Source containing the animations
  30290. * @param destination Target to store the animations
  30291. */
  30292. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30293. /**
  30294. * Static function used to serialized a specific entity
  30295. * @param entity defines the entity to serialize
  30296. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30297. * @returns a JSON compatible object representing the serialization of the entity
  30298. */
  30299. static Serialize<T>(entity: T, serializationObject?: any): any;
  30300. /**
  30301. * Creates a new entity from a serialization data object
  30302. * @param creationFunction defines a function used to instanciated the new entity
  30303. * @param source defines the source serialization data
  30304. * @param scene defines the hosting scene
  30305. * @param rootUrl defines the root url for resources
  30306. * @returns a new entity
  30307. */
  30308. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30309. /**
  30310. * Clones an object
  30311. * @param creationFunction defines the function used to instanciate the new object
  30312. * @param source defines the source object
  30313. * @returns the cloned object
  30314. */
  30315. static Clone<T>(creationFunction: () => T, source: T): T;
  30316. /**
  30317. * Instanciates a new object based on a source one (some data will be shared between both object)
  30318. * @param creationFunction defines the function used to instanciate the new object
  30319. * @param source defines the source object
  30320. * @returns the new object
  30321. */
  30322. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30323. }
  30324. }
  30325. declare module "babylonjs/Misc/guid" {
  30326. /**
  30327. * Class used to manipulate GUIDs
  30328. */
  30329. export class GUID {
  30330. /**
  30331. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30332. * Be aware Math.random() could cause collisions, but:
  30333. * "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"
  30334. * @returns a pseudo random id
  30335. */
  30336. static RandomId(): string;
  30337. }
  30338. }
  30339. declare module "babylonjs/Materials/Textures/baseTexture" {
  30340. import { Observable } from "babylonjs/Misc/observable";
  30341. import { Nullable } from "babylonjs/types";
  30342. import { Scene } from "babylonjs/scene";
  30343. import { Matrix } from "babylonjs/Maths/math.vector";
  30344. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30345. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30346. import { ISize } from "babylonjs/Maths/math.size";
  30347. import "babylonjs/Misc/fileTools";
  30348. /**
  30349. * Base class of all the textures in babylon.
  30350. * It groups all the common properties the materials, post process, lights... might need
  30351. * in order to make a correct use of the texture.
  30352. */
  30353. export class BaseTexture implements IAnimatable {
  30354. /**
  30355. * Default anisotropic filtering level for the application.
  30356. * It is set to 4 as a good tradeoff between perf and quality.
  30357. */
  30358. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30359. /**
  30360. * Gets or sets the unique id of the texture
  30361. */
  30362. uniqueId: number;
  30363. /**
  30364. * Define the name of the texture.
  30365. */
  30366. name: string;
  30367. /**
  30368. * Gets or sets an object used to store user defined information.
  30369. */
  30370. metadata: any;
  30371. /**
  30372. * For internal use only. Please do not use.
  30373. */
  30374. reservedDataStore: any;
  30375. private _hasAlpha;
  30376. /**
  30377. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30378. */
  30379. set hasAlpha(value: boolean);
  30380. get hasAlpha(): boolean;
  30381. /**
  30382. * Defines if the alpha value should be determined via the rgb values.
  30383. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30384. */
  30385. getAlphaFromRGB: boolean;
  30386. /**
  30387. * Intensity or strength of the texture.
  30388. * It is commonly used by materials to fine tune the intensity of the texture
  30389. */
  30390. level: number;
  30391. /**
  30392. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30393. * This is part of the texture as textures usually maps to one uv set.
  30394. */
  30395. coordinatesIndex: number;
  30396. private _coordinatesMode;
  30397. /**
  30398. * How a texture is mapped.
  30399. *
  30400. * | Value | Type | Description |
  30401. * | ----- | ----------------------------------- | ----------- |
  30402. * | 0 | EXPLICIT_MODE | |
  30403. * | 1 | SPHERICAL_MODE | |
  30404. * | 2 | PLANAR_MODE | |
  30405. * | 3 | CUBIC_MODE | |
  30406. * | 4 | PROJECTION_MODE | |
  30407. * | 5 | SKYBOX_MODE | |
  30408. * | 6 | INVCUBIC_MODE | |
  30409. * | 7 | EQUIRECTANGULAR_MODE | |
  30410. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30411. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30412. */
  30413. set coordinatesMode(value: number);
  30414. get coordinatesMode(): number;
  30415. /**
  30416. * | Value | Type | Description |
  30417. * | ----- | ------------------ | ----------- |
  30418. * | 0 | CLAMP_ADDRESSMODE | |
  30419. * | 1 | WRAP_ADDRESSMODE | |
  30420. * | 2 | MIRROR_ADDRESSMODE | |
  30421. */
  30422. wrapU: number;
  30423. /**
  30424. * | Value | Type | Description |
  30425. * | ----- | ------------------ | ----------- |
  30426. * | 0 | CLAMP_ADDRESSMODE | |
  30427. * | 1 | WRAP_ADDRESSMODE | |
  30428. * | 2 | MIRROR_ADDRESSMODE | |
  30429. */
  30430. wrapV: number;
  30431. /**
  30432. * | Value | Type | Description |
  30433. * | ----- | ------------------ | ----------- |
  30434. * | 0 | CLAMP_ADDRESSMODE | |
  30435. * | 1 | WRAP_ADDRESSMODE | |
  30436. * | 2 | MIRROR_ADDRESSMODE | |
  30437. */
  30438. wrapR: number;
  30439. /**
  30440. * With compliant hardware and browser (supporting anisotropic filtering)
  30441. * this defines the level of anisotropic filtering in the texture.
  30442. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30443. */
  30444. anisotropicFilteringLevel: number;
  30445. /**
  30446. * Define if the texture is a cube texture or if false a 2d texture.
  30447. */
  30448. get isCube(): boolean;
  30449. set isCube(value: boolean);
  30450. /**
  30451. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30452. */
  30453. get is3D(): boolean;
  30454. set is3D(value: boolean);
  30455. /**
  30456. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30457. */
  30458. get is2DArray(): boolean;
  30459. set is2DArray(value: boolean);
  30460. /**
  30461. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30462. * HDR texture are usually stored in linear space.
  30463. * This only impacts the PBR and Background materials
  30464. */
  30465. gammaSpace: boolean;
  30466. /**
  30467. * Gets or sets whether or not the texture contains RGBD data.
  30468. */
  30469. get isRGBD(): boolean;
  30470. set isRGBD(value: boolean);
  30471. /**
  30472. * Is Z inverted in the texture (useful in a cube texture).
  30473. */
  30474. invertZ: boolean;
  30475. /**
  30476. * Are mip maps generated for this texture or not.
  30477. */
  30478. get noMipmap(): boolean;
  30479. /**
  30480. * @hidden
  30481. */
  30482. lodLevelInAlpha: boolean;
  30483. /**
  30484. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30485. */
  30486. get lodGenerationOffset(): number;
  30487. set lodGenerationOffset(value: number);
  30488. /**
  30489. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30490. */
  30491. get lodGenerationScale(): number;
  30492. set lodGenerationScale(value: number);
  30493. /**
  30494. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30495. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30496. * average roughness values.
  30497. */
  30498. get linearSpecularLOD(): boolean;
  30499. set linearSpecularLOD(value: boolean);
  30500. /**
  30501. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30502. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30503. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30504. */
  30505. get irradianceTexture(): Nullable<BaseTexture>;
  30506. set irradianceTexture(value: Nullable<BaseTexture>);
  30507. /**
  30508. * Define if the texture is a render target.
  30509. */
  30510. isRenderTarget: boolean;
  30511. /**
  30512. * Define the unique id of the texture in the scene.
  30513. */
  30514. get uid(): string;
  30515. /**
  30516. * Return a string representation of the texture.
  30517. * @returns the texture as a string
  30518. */
  30519. toString(): string;
  30520. /**
  30521. * Get the class name of the texture.
  30522. * @returns "BaseTexture"
  30523. */
  30524. getClassName(): string;
  30525. /**
  30526. * Define the list of animation attached to the texture.
  30527. */
  30528. animations: import("babylonjs/Animations/animation").Animation[];
  30529. /**
  30530. * An event triggered when the texture is disposed.
  30531. */
  30532. onDisposeObservable: Observable<BaseTexture>;
  30533. private _onDisposeObserver;
  30534. /**
  30535. * Callback triggered when the texture has been disposed.
  30536. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30537. */
  30538. set onDispose(callback: () => void);
  30539. /**
  30540. * Define the current state of the loading sequence when in delayed load mode.
  30541. */
  30542. delayLoadState: number;
  30543. private _scene;
  30544. /** @hidden */
  30545. _texture: Nullable<InternalTexture>;
  30546. private _uid;
  30547. /**
  30548. * Define if the texture is preventinga material to render or not.
  30549. * If not and the texture is not ready, the engine will use a default black texture instead.
  30550. */
  30551. get isBlocking(): boolean;
  30552. /**
  30553. * Instantiates a new BaseTexture.
  30554. * Base class of all the textures in babylon.
  30555. * It groups all the common properties the materials, post process, lights... might need
  30556. * in order to make a correct use of the texture.
  30557. * @param scene Define the scene the texture blongs to
  30558. */
  30559. constructor(scene: Nullable<Scene>);
  30560. /**
  30561. * Get the scene the texture belongs to.
  30562. * @returns the scene or null if undefined
  30563. */
  30564. getScene(): Nullable<Scene>;
  30565. /**
  30566. * Get the texture transform matrix used to offset tile the texture for istance.
  30567. * @returns the transformation matrix
  30568. */
  30569. getTextureMatrix(): Matrix;
  30570. /**
  30571. * Get the texture reflection matrix used to rotate/transform the reflection.
  30572. * @returns the reflection matrix
  30573. */
  30574. getReflectionTextureMatrix(): Matrix;
  30575. /**
  30576. * Get the underlying lower level texture from Babylon.
  30577. * @returns the insternal texture
  30578. */
  30579. getInternalTexture(): Nullable<InternalTexture>;
  30580. /**
  30581. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30582. * @returns true if ready or not blocking
  30583. */
  30584. isReadyOrNotBlocking(): boolean;
  30585. /**
  30586. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30587. * @returns true if fully ready
  30588. */
  30589. isReady(): boolean;
  30590. private _cachedSize;
  30591. /**
  30592. * Get the size of the texture.
  30593. * @returns the texture size.
  30594. */
  30595. getSize(): ISize;
  30596. /**
  30597. * Get the base size of the texture.
  30598. * It can be different from the size if the texture has been resized for POT for instance
  30599. * @returns the base size
  30600. */
  30601. getBaseSize(): ISize;
  30602. /**
  30603. * Update the sampling mode of the texture.
  30604. * Default is Trilinear mode.
  30605. *
  30606. * | Value | Type | Description |
  30607. * | ----- | ------------------ | ----------- |
  30608. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30609. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30610. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30611. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30612. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30613. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30614. * | 7 | NEAREST_LINEAR | |
  30615. * | 8 | NEAREST_NEAREST | |
  30616. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30617. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30618. * | 11 | LINEAR_LINEAR | |
  30619. * | 12 | LINEAR_NEAREST | |
  30620. *
  30621. * > _mag_: magnification filter (close to the viewer)
  30622. * > _min_: minification filter (far from the viewer)
  30623. * > _mip_: filter used between mip map levels
  30624. *@param samplingMode Define the new sampling mode of the texture
  30625. */
  30626. updateSamplingMode(samplingMode: number): void;
  30627. /**
  30628. * Scales the texture if is `canRescale()`
  30629. * @param ratio the resize factor we want to use to rescale
  30630. */
  30631. scale(ratio: number): void;
  30632. /**
  30633. * Get if the texture can rescale.
  30634. */
  30635. get canRescale(): boolean;
  30636. /** @hidden */
  30637. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30638. /** @hidden */
  30639. _rebuild(): void;
  30640. /**
  30641. * Triggers the load sequence in delayed load mode.
  30642. */
  30643. delayLoad(): void;
  30644. /**
  30645. * Clones the texture.
  30646. * @returns the cloned texture
  30647. */
  30648. clone(): Nullable<BaseTexture>;
  30649. /**
  30650. * Get the texture underlying type (INT, FLOAT...)
  30651. */
  30652. get textureType(): number;
  30653. /**
  30654. * Get the texture underlying format (RGB, RGBA...)
  30655. */
  30656. get textureFormat(): number;
  30657. /**
  30658. * Indicates that textures need to be re-calculated for all materials
  30659. */
  30660. protected _markAllSubMeshesAsTexturesDirty(): void;
  30661. /**
  30662. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30663. * This will returns an RGBA array buffer containing either in values (0-255) or
  30664. * float values (0-1) depending of the underlying buffer type.
  30665. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30666. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30667. * @param buffer defines a user defined buffer to fill with data (can be null)
  30668. * @returns The Array buffer containing the pixels data.
  30669. */
  30670. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30671. /**
  30672. * Release and destroy the underlying lower level texture aka internalTexture.
  30673. */
  30674. releaseInternalTexture(): void;
  30675. /** @hidden */
  30676. get _lodTextureHigh(): Nullable<BaseTexture>;
  30677. /** @hidden */
  30678. get _lodTextureMid(): Nullable<BaseTexture>;
  30679. /** @hidden */
  30680. get _lodTextureLow(): Nullable<BaseTexture>;
  30681. /**
  30682. * Dispose the texture and release its associated resources.
  30683. */
  30684. dispose(): void;
  30685. /**
  30686. * Serialize the texture into a JSON representation that can be parsed later on.
  30687. * @returns the JSON representation of the texture
  30688. */
  30689. serialize(): any;
  30690. /**
  30691. * Helper function to be called back once a list of texture contains only ready textures.
  30692. * @param textures Define the list of textures to wait for
  30693. * @param callback Define the callback triggered once the entire list will be ready
  30694. */
  30695. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30696. }
  30697. }
  30698. declare module "babylonjs/Materials/effect" {
  30699. import { Observable } from "babylonjs/Misc/observable";
  30700. import { Nullable } from "babylonjs/types";
  30701. import { IDisposable } from "babylonjs/scene";
  30702. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30703. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30704. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30705. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30706. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30707. import { Engine } from "babylonjs/Engines/engine";
  30708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30709. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30710. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30711. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30712. /**
  30713. * Options to be used when creating an effect.
  30714. */
  30715. export interface IEffectCreationOptions {
  30716. /**
  30717. * Atrributes that will be used in the shader.
  30718. */
  30719. attributes: string[];
  30720. /**
  30721. * Uniform varible names that will be set in the shader.
  30722. */
  30723. uniformsNames: string[];
  30724. /**
  30725. * Uniform buffer variable names that will be set in the shader.
  30726. */
  30727. uniformBuffersNames: string[];
  30728. /**
  30729. * Sampler texture variable names that will be set in the shader.
  30730. */
  30731. samplers: string[];
  30732. /**
  30733. * Define statements that will be set in the shader.
  30734. */
  30735. defines: any;
  30736. /**
  30737. * Possible fallbacks for this effect to improve performance when needed.
  30738. */
  30739. fallbacks: Nullable<IEffectFallbacks>;
  30740. /**
  30741. * Callback that will be called when the shader is compiled.
  30742. */
  30743. onCompiled: Nullable<(effect: Effect) => void>;
  30744. /**
  30745. * Callback that will be called if an error occurs during shader compilation.
  30746. */
  30747. onError: Nullable<(effect: Effect, errors: string) => void>;
  30748. /**
  30749. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30750. */
  30751. indexParameters?: any;
  30752. /**
  30753. * Max number of lights that can be used in the shader.
  30754. */
  30755. maxSimultaneousLights?: number;
  30756. /**
  30757. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30758. */
  30759. transformFeedbackVaryings?: Nullable<string[]>;
  30760. }
  30761. /**
  30762. * Effect containing vertex and fragment shader that can be executed on an object.
  30763. */
  30764. export class Effect implements IDisposable {
  30765. /**
  30766. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30767. */
  30768. static ShadersRepository: string;
  30769. /**
  30770. * Name of the effect.
  30771. */
  30772. name: any;
  30773. /**
  30774. * String container all the define statements that should be set on the shader.
  30775. */
  30776. defines: string;
  30777. /**
  30778. * Callback that will be called when the shader is compiled.
  30779. */
  30780. onCompiled: Nullable<(effect: Effect) => void>;
  30781. /**
  30782. * Callback that will be called if an error occurs during shader compilation.
  30783. */
  30784. onError: Nullable<(effect: Effect, errors: string) => void>;
  30785. /**
  30786. * Callback that will be called when effect is bound.
  30787. */
  30788. onBind: Nullable<(effect: Effect) => void>;
  30789. /**
  30790. * Unique ID of the effect.
  30791. */
  30792. uniqueId: number;
  30793. /**
  30794. * Observable that will be called when the shader is compiled.
  30795. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30796. */
  30797. onCompileObservable: Observable<Effect>;
  30798. /**
  30799. * Observable that will be called if an error occurs during shader compilation.
  30800. */
  30801. onErrorObservable: Observable<Effect>;
  30802. /** @hidden */
  30803. _onBindObservable: Nullable<Observable<Effect>>;
  30804. /**
  30805. * @hidden
  30806. * Specifies if the effect was previously ready
  30807. */
  30808. _wasPreviouslyReady: boolean;
  30809. /**
  30810. * Observable that will be called when effect is bound.
  30811. */
  30812. get onBindObservable(): Observable<Effect>;
  30813. /** @hidden */
  30814. _bonesComputationForcedToCPU: boolean;
  30815. private static _uniqueIdSeed;
  30816. private _engine;
  30817. private _uniformBuffersNames;
  30818. private _uniformsNames;
  30819. private _samplerList;
  30820. private _samplers;
  30821. private _isReady;
  30822. private _compilationError;
  30823. private _allFallbacksProcessed;
  30824. private _attributesNames;
  30825. private _attributes;
  30826. private _attributeLocationByName;
  30827. private _uniforms;
  30828. /**
  30829. * Key for the effect.
  30830. * @hidden
  30831. */
  30832. _key: string;
  30833. private _indexParameters;
  30834. private _fallbacks;
  30835. private _vertexSourceCode;
  30836. private _fragmentSourceCode;
  30837. private _vertexSourceCodeOverride;
  30838. private _fragmentSourceCodeOverride;
  30839. private _transformFeedbackVaryings;
  30840. /**
  30841. * Compiled shader to webGL program.
  30842. * @hidden
  30843. */
  30844. _pipelineContext: Nullable<IPipelineContext>;
  30845. private _valueCache;
  30846. private static _baseCache;
  30847. /**
  30848. * Instantiates an effect.
  30849. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30850. * @param baseName Name of the effect.
  30851. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30852. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30853. * @param samplers List of sampler variables that will be passed to the shader.
  30854. * @param engine Engine to be used to render the effect
  30855. * @param defines Define statements to be added to the shader.
  30856. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30857. * @param onCompiled Callback that will be called when the shader is compiled.
  30858. * @param onError Callback that will be called if an error occurs during shader compilation.
  30859. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30860. */
  30861. 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);
  30862. private _useFinalCode;
  30863. /**
  30864. * Unique key for this effect
  30865. */
  30866. get key(): string;
  30867. /**
  30868. * If the effect has been compiled and prepared.
  30869. * @returns if the effect is compiled and prepared.
  30870. */
  30871. isReady(): boolean;
  30872. private _isReadyInternal;
  30873. /**
  30874. * The engine the effect was initialized with.
  30875. * @returns the engine.
  30876. */
  30877. getEngine(): Engine;
  30878. /**
  30879. * The pipeline context for this effect
  30880. * @returns the associated pipeline context
  30881. */
  30882. getPipelineContext(): Nullable<IPipelineContext>;
  30883. /**
  30884. * The set of names of attribute variables for the shader.
  30885. * @returns An array of attribute names.
  30886. */
  30887. getAttributesNames(): string[];
  30888. /**
  30889. * Returns the attribute at the given index.
  30890. * @param index The index of the attribute.
  30891. * @returns The location of the attribute.
  30892. */
  30893. getAttributeLocation(index: number): number;
  30894. /**
  30895. * Returns the attribute based on the name of the variable.
  30896. * @param name of the attribute to look up.
  30897. * @returns the attribute location.
  30898. */
  30899. getAttributeLocationByName(name: string): number;
  30900. /**
  30901. * The number of attributes.
  30902. * @returns the numnber of attributes.
  30903. */
  30904. getAttributesCount(): number;
  30905. /**
  30906. * Gets the index of a uniform variable.
  30907. * @param uniformName of the uniform to look up.
  30908. * @returns the index.
  30909. */
  30910. getUniformIndex(uniformName: string): number;
  30911. /**
  30912. * Returns the attribute based on the name of the variable.
  30913. * @param uniformName of the uniform to look up.
  30914. * @returns the location of the uniform.
  30915. */
  30916. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30917. /**
  30918. * Returns an array of sampler variable names
  30919. * @returns The array of sampler variable neames.
  30920. */
  30921. getSamplers(): string[];
  30922. /**
  30923. * The error from the last compilation.
  30924. * @returns the error string.
  30925. */
  30926. getCompilationError(): string;
  30927. /**
  30928. * Gets a boolean indicating that all fallbacks were used during compilation
  30929. * @returns true if all fallbacks were used
  30930. */
  30931. allFallbacksProcessed(): boolean;
  30932. /**
  30933. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30934. * @param func The callback to be used.
  30935. */
  30936. executeWhenCompiled(func: (effect: Effect) => void): void;
  30937. private _checkIsReady;
  30938. private _loadShader;
  30939. /**
  30940. * Recompiles the webGL program
  30941. * @param vertexSourceCode The source code for the vertex shader.
  30942. * @param fragmentSourceCode The source code for the fragment shader.
  30943. * @param onCompiled Callback called when completed.
  30944. * @param onError Callback called on error.
  30945. * @hidden
  30946. */
  30947. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30948. /**
  30949. * Prepares the effect
  30950. * @hidden
  30951. */
  30952. _prepareEffect(): void;
  30953. private _processCompilationErrors;
  30954. /**
  30955. * Checks if the effect is supported. (Must be called after compilation)
  30956. */
  30957. get isSupported(): boolean;
  30958. /**
  30959. * Binds a texture to the engine to be used as output of the shader.
  30960. * @param channel Name of the output variable.
  30961. * @param texture Texture to bind.
  30962. * @hidden
  30963. */
  30964. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30965. /**
  30966. * Sets a texture on the engine to be used in the shader.
  30967. * @param channel Name of the sampler variable.
  30968. * @param texture Texture to set.
  30969. */
  30970. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30971. /**
  30972. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30973. * @param channel Name of the sampler variable.
  30974. * @param texture Texture to set.
  30975. */
  30976. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30977. /**
  30978. * Sets an array of textures on the engine to be used in the shader.
  30979. * @param channel Name of the variable.
  30980. * @param textures Textures to set.
  30981. */
  30982. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30983. /**
  30984. * 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)
  30985. * @param channel Name of the sampler variable.
  30986. * @param postProcess Post process to get the input texture from.
  30987. */
  30988. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30989. /**
  30990. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30991. * 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)
  30992. * @param channel Name of the sampler variable.
  30993. * @param postProcess Post process to get the output texture from.
  30994. */
  30995. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30996. /** @hidden */
  30997. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30998. /** @hidden */
  30999. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31000. /** @hidden */
  31001. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31002. /** @hidden */
  31003. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31004. /**
  31005. * Binds a buffer to a uniform.
  31006. * @param buffer Buffer to bind.
  31007. * @param name Name of the uniform variable to bind to.
  31008. */
  31009. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31010. /**
  31011. * Binds block to a uniform.
  31012. * @param blockName Name of the block to bind.
  31013. * @param index Index to bind.
  31014. */
  31015. bindUniformBlock(blockName: string, index: number): void;
  31016. /**
  31017. * Sets an interger value on a uniform variable.
  31018. * @param uniformName Name of the variable.
  31019. * @param value Value to be set.
  31020. * @returns this effect.
  31021. */
  31022. setInt(uniformName: string, value: number): Effect;
  31023. /**
  31024. * Sets an int array on a uniform variable.
  31025. * @param uniformName Name of the variable.
  31026. * @param array array to be set.
  31027. * @returns this effect.
  31028. */
  31029. setIntArray(uniformName: string, array: Int32Array): Effect;
  31030. /**
  31031. * 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)
  31032. * @param uniformName Name of the variable.
  31033. * @param array array to be set.
  31034. * @returns this effect.
  31035. */
  31036. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31037. /**
  31038. * 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)
  31039. * @param uniformName Name of the variable.
  31040. * @param array array to be set.
  31041. * @returns this effect.
  31042. */
  31043. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31044. /**
  31045. * 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)
  31046. * @param uniformName Name of the variable.
  31047. * @param array array to be set.
  31048. * @returns this effect.
  31049. */
  31050. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31051. /**
  31052. * Sets an float array on a uniform variable.
  31053. * @param uniformName Name of the variable.
  31054. * @param array array to be set.
  31055. * @returns this effect.
  31056. */
  31057. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31058. /**
  31059. * 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)
  31060. * @param uniformName Name of the variable.
  31061. * @param array array to be set.
  31062. * @returns this effect.
  31063. */
  31064. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31065. /**
  31066. * 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)
  31067. * @param uniformName Name of the variable.
  31068. * @param array array to be set.
  31069. * @returns this effect.
  31070. */
  31071. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31072. /**
  31073. * 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)
  31074. * @param uniformName Name of the variable.
  31075. * @param array array to be set.
  31076. * @returns this effect.
  31077. */
  31078. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31079. /**
  31080. * Sets an array on a uniform variable.
  31081. * @param uniformName Name of the variable.
  31082. * @param array array to be set.
  31083. * @returns this effect.
  31084. */
  31085. setArray(uniformName: string, array: number[]): Effect;
  31086. /**
  31087. * 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)
  31088. * @param uniformName Name of the variable.
  31089. * @param array array to be set.
  31090. * @returns this effect.
  31091. */
  31092. setArray2(uniformName: string, array: number[]): Effect;
  31093. /**
  31094. * 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)
  31095. * @param uniformName Name of the variable.
  31096. * @param array array to be set.
  31097. * @returns this effect.
  31098. */
  31099. setArray3(uniformName: string, array: number[]): Effect;
  31100. /**
  31101. * 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)
  31102. * @param uniformName Name of the variable.
  31103. * @param array array to be set.
  31104. * @returns this effect.
  31105. */
  31106. setArray4(uniformName: string, array: number[]): Effect;
  31107. /**
  31108. * Sets matrices on a uniform variable.
  31109. * @param uniformName Name of the variable.
  31110. * @param matrices matrices to be set.
  31111. * @returns this effect.
  31112. */
  31113. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31114. /**
  31115. * Sets matrix on a uniform variable.
  31116. * @param uniformName Name of the variable.
  31117. * @param matrix matrix to be set.
  31118. * @returns this effect.
  31119. */
  31120. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31121. /**
  31122. * 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)
  31123. * @param uniformName Name of the variable.
  31124. * @param matrix matrix to be set.
  31125. * @returns this effect.
  31126. */
  31127. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31128. /**
  31129. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31130. * @param uniformName Name of the variable.
  31131. * @param matrix matrix to be set.
  31132. * @returns this effect.
  31133. */
  31134. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31135. /**
  31136. * Sets a float on a uniform variable.
  31137. * @param uniformName Name of the variable.
  31138. * @param value value to be set.
  31139. * @returns this effect.
  31140. */
  31141. setFloat(uniformName: string, value: number): Effect;
  31142. /**
  31143. * Sets a boolean on a uniform variable.
  31144. * @param uniformName Name of the variable.
  31145. * @param bool value to be set.
  31146. * @returns this effect.
  31147. */
  31148. setBool(uniformName: string, bool: boolean): Effect;
  31149. /**
  31150. * Sets a Vector2 on a uniform variable.
  31151. * @param uniformName Name of the variable.
  31152. * @param vector2 vector2 to be set.
  31153. * @returns this effect.
  31154. */
  31155. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31156. /**
  31157. * Sets a float2 on a uniform variable.
  31158. * @param uniformName Name of the variable.
  31159. * @param x First float in float2.
  31160. * @param y Second float in float2.
  31161. * @returns this effect.
  31162. */
  31163. setFloat2(uniformName: string, x: number, y: number): Effect;
  31164. /**
  31165. * Sets a Vector3 on a uniform variable.
  31166. * @param uniformName Name of the variable.
  31167. * @param vector3 Value to be set.
  31168. * @returns this effect.
  31169. */
  31170. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31171. /**
  31172. * Sets a float3 on a uniform variable.
  31173. * @param uniformName Name of the variable.
  31174. * @param x First float in float3.
  31175. * @param y Second float in float3.
  31176. * @param z Third float in float3.
  31177. * @returns this effect.
  31178. */
  31179. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31180. /**
  31181. * Sets a Vector4 on a uniform variable.
  31182. * @param uniformName Name of the variable.
  31183. * @param vector4 Value to be set.
  31184. * @returns this effect.
  31185. */
  31186. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31187. /**
  31188. * Sets a float4 on a uniform variable.
  31189. * @param uniformName Name of the variable.
  31190. * @param x First float in float4.
  31191. * @param y Second float in float4.
  31192. * @param z Third float in float4.
  31193. * @param w Fourth float in float4.
  31194. * @returns this effect.
  31195. */
  31196. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31197. /**
  31198. * Sets a Color3 on a uniform variable.
  31199. * @param uniformName Name of the variable.
  31200. * @param color3 Value to be set.
  31201. * @returns this effect.
  31202. */
  31203. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31204. /**
  31205. * Sets a Color4 on a uniform variable.
  31206. * @param uniformName Name of the variable.
  31207. * @param color3 Value to be set.
  31208. * @param alpha Alpha value to be set.
  31209. * @returns this effect.
  31210. */
  31211. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31212. /**
  31213. * Sets a Color4 on a uniform variable
  31214. * @param uniformName defines the name of the variable
  31215. * @param color4 defines the value to be set
  31216. * @returns this effect.
  31217. */
  31218. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31219. /** Release all associated resources */
  31220. dispose(): void;
  31221. /**
  31222. * This function will add a new shader to the shader store
  31223. * @param name the name of the shader
  31224. * @param pixelShader optional pixel shader content
  31225. * @param vertexShader optional vertex shader content
  31226. */
  31227. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31228. /**
  31229. * Store of each shader (The can be looked up using effect.key)
  31230. */
  31231. static ShadersStore: {
  31232. [key: string]: string;
  31233. };
  31234. /**
  31235. * Store of each included file for a shader (The can be looked up using effect.key)
  31236. */
  31237. static IncludesShadersStore: {
  31238. [key: string]: string;
  31239. };
  31240. /**
  31241. * Resets the cache of effects.
  31242. */
  31243. static ResetCache(): void;
  31244. }
  31245. }
  31246. declare module "babylonjs/Engines/engineCapabilities" {
  31247. /**
  31248. * Interface used to describe the capabilities of the engine relatively to the current browser
  31249. */
  31250. export interface EngineCapabilities {
  31251. /** Maximum textures units per fragment shader */
  31252. maxTexturesImageUnits: number;
  31253. /** Maximum texture units per vertex shader */
  31254. maxVertexTextureImageUnits: number;
  31255. /** Maximum textures units in the entire pipeline */
  31256. maxCombinedTexturesImageUnits: number;
  31257. /** Maximum texture size */
  31258. maxTextureSize: number;
  31259. /** Maximum texture samples */
  31260. maxSamples?: number;
  31261. /** Maximum cube texture size */
  31262. maxCubemapTextureSize: number;
  31263. /** Maximum render texture size */
  31264. maxRenderTextureSize: number;
  31265. /** Maximum number of vertex attributes */
  31266. maxVertexAttribs: number;
  31267. /** Maximum number of varyings */
  31268. maxVaryingVectors: number;
  31269. /** Maximum number of uniforms per vertex shader */
  31270. maxVertexUniformVectors: number;
  31271. /** Maximum number of uniforms per fragment shader */
  31272. maxFragmentUniformVectors: number;
  31273. /** Defines if standard derivates (dx/dy) are supported */
  31274. standardDerivatives: boolean;
  31275. /** Defines if s3tc texture compression is supported */
  31276. s3tc?: WEBGL_compressed_texture_s3tc;
  31277. /** Defines if pvrtc texture compression is supported */
  31278. pvrtc: any;
  31279. /** Defines if etc1 texture compression is supported */
  31280. etc1: any;
  31281. /** Defines if etc2 texture compression is supported */
  31282. etc2: any;
  31283. /** Defines if astc texture compression is supported */
  31284. astc: any;
  31285. /** Defines if float textures are supported */
  31286. textureFloat: boolean;
  31287. /** Defines if vertex array objects are supported */
  31288. vertexArrayObject: boolean;
  31289. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31290. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31291. /** Gets the maximum level of anisotropy supported */
  31292. maxAnisotropy: number;
  31293. /** Defines if instancing is supported */
  31294. instancedArrays: boolean;
  31295. /** Defines if 32 bits indices are supported */
  31296. uintIndices: boolean;
  31297. /** Defines if high precision shaders are supported */
  31298. highPrecisionShaderSupported: boolean;
  31299. /** Defines if depth reading in the fragment shader is supported */
  31300. fragmentDepthSupported: boolean;
  31301. /** Defines if float texture linear filtering is supported*/
  31302. textureFloatLinearFiltering: boolean;
  31303. /** Defines if rendering to float textures is supported */
  31304. textureFloatRender: boolean;
  31305. /** Defines if half float textures are supported*/
  31306. textureHalfFloat: boolean;
  31307. /** Defines if half float texture linear filtering is supported*/
  31308. textureHalfFloatLinearFiltering: boolean;
  31309. /** Defines if rendering to half float textures is supported */
  31310. textureHalfFloatRender: boolean;
  31311. /** Defines if textureLOD shader command is supported */
  31312. textureLOD: boolean;
  31313. /** Defines if draw buffers extension is supported */
  31314. drawBuffersExtension: boolean;
  31315. /** Defines if depth textures are supported */
  31316. depthTextureExtension: boolean;
  31317. /** Defines if float color buffer are supported */
  31318. colorBufferFloat: boolean;
  31319. /** Gets disjoint timer query extension (null if not supported) */
  31320. timerQuery?: EXT_disjoint_timer_query;
  31321. /** Defines if timestamp can be used with timer query */
  31322. canUseTimestampForTimerQuery: boolean;
  31323. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31324. multiview?: any;
  31325. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31326. oculusMultiview?: any;
  31327. /** Function used to let the system compiles shaders in background */
  31328. parallelShaderCompile?: {
  31329. COMPLETION_STATUS_KHR: number;
  31330. };
  31331. /** Max number of texture samples for MSAA */
  31332. maxMSAASamples: number;
  31333. /** Defines if the blend min max extension is supported */
  31334. blendMinMax: boolean;
  31335. }
  31336. }
  31337. declare module "babylonjs/States/depthCullingState" {
  31338. import { Nullable } from "babylonjs/types";
  31339. /**
  31340. * @hidden
  31341. **/
  31342. export class DepthCullingState {
  31343. private _isDepthTestDirty;
  31344. private _isDepthMaskDirty;
  31345. private _isDepthFuncDirty;
  31346. private _isCullFaceDirty;
  31347. private _isCullDirty;
  31348. private _isZOffsetDirty;
  31349. private _isFrontFaceDirty;
  31350. private _depthTest;
  31351. private _depthMask;
  31352. private _depthFunc;
  31353. private _cull;
  31354. private _cullFace;
  31355. private _zOffset;
  31356. private _frontFace;
  31357. /**
  31358. * Initializes the state.
  31359. */
  31360. constructor();
  31361. get isDirty(): boolean;
  31362. get zOffset(): number;
  31363. set zOffset(value: number);
  31364. get cullFace(): Nullable<number>;
  31365. set cullFace(value: Nullable<number>);
  31366. get cull(): Nullable<boolean>;
  31367. set cull(value: Nullable<boolean>);
  31368. get depthFunc(): Nullable<number>;
  31369. set depthFunc(value: Nullable<number>);
  31370. get depthMask(): boolean;
  31371. set depthMask(value: boolean);
  31372. get depthTest(): boolean;
  31373. set depthTest(value: boolean);
  31374. get frontFace(): Nullable<number>;
  31375. set frontFace(value: Nullable<number>);
  31376. reset(): void;
  31377. apply(gl: WebGLRenderingContext): void;
  31378. }
  31379. }
  31380. declare module "babylonjs/States/stencilState" {
  31381. /**
  31382. * @hidden
  31383. **/
  31384. export class StencilState {
  31385. /** 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 */
  31386. static readonly ALWAYS: number;
  31387. /** Passed to stencilOperation to specify that stencil value must be kept */
  31388. static readonly KEEP: number;
  31389. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31390. static readonly REPLACE: number;
  31391. private _isStencilTestDirty;
  31392. private _isStencilMaskDirty;
  31393. private _isStencilFuncDirty;
  31394. private _isStencilOpDirty;
  31395. private _stencilTest;
  31396. private _stencilMask;
  31397. private _stencilFunc;
  31398. private _stencilFuncRef;
  31399. private _stencilFuncMask;
  31400. private _stencilOpStencilFail;
  31401. private _stencilOpDepthFail;
  31402. private _stencilOpStencilDepthPass;
  31403. get isDirty(): boolean;
  31404. get stencilFunc(): number;
  31405. set stencilFunc(value: number);
  31406. get stencilFuncRef(): number;
  31407. set stencilFuncRef(value: number);
  31408. get stencilFuncMask(): number;
  31409. set stencilFuncMask(value: number);
  31410. get stencilOpStencilFail(): number;
  31411. set stencilOpStencilFail(value: number);
  31412. get stencilOpDepthFail(): number;
  31413. set stencilOpDepthFail(value: number);
  31414. get stencilOpStencilDepthPass(): number;
  31415. set stencilOpStencilDepthPass(value: number);
  31416. get stencilMask(): number;
  31417. set stencilMask(value: number);
  31418. get stencilTest(): boolean;
  31419. set stencilTest(value: boolean);
  31420. constructor();
  31421. reset(): void;
  31422. apply(gl: WebGLRenderingContext): void;
  31423. }
  31424. }
  31425. declare module "babylonjs/States/alphaCullingState" {
  31426. /**
  31427. * @hidden
  31428. **/
  31429. export class AlphaState {
  31430. private _isAlphaBlendDirty;
  31431. private _isBlendFunctionParametersDirty;
  31432. private _isBlendEquationParametersDirty;
  31433. private _isBlendConstantsDirty;
  31434. private _alphaBlend;
  31435. private _blendFunctionParameters;
  31436. private _blendEquationParameters;
  31437. private _blendConstants;
  31438. /**
  31439. * Initializes the state.
  31440. */
  31441. constructor();
  31442. get isDirty(): boolean;
  31443. get alphaBlend(): boolean;
  31444. set alphaBlend(value: boolean);
  31445. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31446. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31447. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31448. reset(): void;
  31449. apply(gl: WebGLRenderingContext): void;
  31450. }
  31451. }
  31452. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31453. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31454. /** @hidden */
  31455. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31456. attributeProcessor(attribute: string): string;
  31457. varyingProcessor(varying: string, isFragment: boolean): string;
  31458. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31459. }
  31460. }
  31461. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31462. /**
  31463. * Interface for attribute information associated with buffer instanciation
  31464. */
  31465. export interface InstancingAttributeInfo {
  31466. /**
  31467. * Name of the GLSL attribute
  31468. * if attribute index is not specified, this is used to retrieve the index from the effect
  31469. */
  31470. attributeName: string;
  31471. /**
  31472. * Index/offset of the attribute in the vertex shader
  31473. * if not specified, this will be computes from the name.
  31474. */
  31475. index?: number;
  31476. /**
  31477. * size of the attribute, 1, 2, 3 or 4
  31478. */
  31479. attributeSize: number;
  31480. /**
  31481. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31482. */
  31483. offset: number;
  31484. /**
  31485. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31486. * default to 1
  31487. */
  31488. divisor?: number;
  31489. /**
  31490. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31491. * default is FLOAT
  31492. */
  31493. attributeType?: number;
  31494. /**
  31495. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31496. */
  31497. normalized?: boolean;
  31498. }
  31499. }
  31500. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31501. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31502. import { Nullable } from "babylonjs/types";
  31503. module "babylonjs/Engines/thinEngine" {
  31504. interface ThinEngine {
  31505. /**
  31506. * Update a video texture
  31507. * @param texture defines the texture to update
  31508. * @param video defines the video element to use
  31509. * @param invertY defines if data must be stored with Y axis inverted
  31510. */
  31511. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31512. }
  31513. }
  31514. }
  31515. declare module "babylonjs/Materials/Textures/videoTexture" {
  31516. import { Observable } from "babylonjs/Misc/observable";
  31517. import { Nullable } from "babylonjs/types";
  31518. import { Scene } from "babylonjs/scene";
  31519. import { Texture } from "babylonjs/Materials/Textures/texture";
  31520. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31521. /**
  31522. * Settings for finer control over video usage
  31523. */
  31524. export interface VideoTextureSettings {
  31525. /**
  31526. * Applies `autoplay` to video, if specified
  31527. */
  31528. autoPlay?: boolean;
  31529. /**
  31530. * Applies `loop` to video, if specified
  31531. */
  31532. loop?: boolean;
  31533. /**
  31534. * Automatically updates internal texture from video at every frame in the render loop
  31535. */
  31536. autoUpdateTexture: boolean;
  31537. /**
  31538. * Image src displayed during the video loading or until the user interacts with the video.
  31539. */
  31540. poster?: string;
  31541. }
  31542. /**
  31543. * If you want to display a video in your scene, this is the special texture for that.
  31544. * This special texture works similar to other textures, with the exception of a few parameters.
  31545. * @see https://doc.babylonjs.com/how_to/video_texture
  31546. */
  31547. export class VideoTexture extends Texture {
  31548. /**
  31549. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31550. */
  31551. readonly autoUpdateTexture: boolean;
  31552. /**
  31553. * The video instance used by the texture internally
  31554. */
  31555. readonly video: HTMLVideoElement;
  31556. private _onUserActionRequestedObservable;
  31557. /**
  31558. * Event triggerd when a dom action is required by the user to play the video.
  31559. * This happens due to recent changes in browser policies preventing video to auto start.
  31560. */
  31561. get onUserActionRequestedObservable(): Observable<Texture>;
  31562. private _generateMipMaps;
  31563. private _engine;
  31564. private _stillImageCaptured;
  31565. private _displayingPosterTexture;
  31566. private _settings;
  31567. private _createInternalTextureOnEvent;
  31568. private _frameId;
  31569. private _currentSrc;
  31570. /**
  31571. * Creates a video texture.
  31572. * If you want to display a video in your scene, this is the special texture for that.
  31573. * This special texture works similar to other textures, with the exception of a few parameters.
  31574. * @see https://doc.babylonjs.com/how_to/video_texture
  31575. * @param name optional name, will detect from video source, if not defined
  31576. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31577. * @param scene is obviously the current scene.
  31578. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31579. * @param invertY is false by default but can be used to invert video on Y axis
  31580. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31581. * @param settings allows finer control over video usage
  31582. */
  31583. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31584. private _getName;
  31585. private _getVideo;
  31586. private _createInternalTexture;
  31587. private reset;
  31588. /**
  31589. * @hidden Internal method to initiate `update`.
  31590. */
  31591. _rebuild(): void;
  31592. /**
  31593. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31594. */
  31595. update(): void;
  31596. /**
  31597. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31598. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31599. */
  31600. updateTexture(isVisible: boolean): void;
  31601. protected _updateInternalTexture: () => void;
  31602. /**
  31603. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31604. * @param url New url.
  31605. */
  31606. updateURL(url: string): void;
  31607. /**
  31608. * Clones the texture.
  31609. * @returns the cloned texture
  31610. */
  31611. clone(): VideoTexture;
  31612. /**
  31613. * Dispose the texture and release its associated resources.
  31614. */
  31615. dispose(): void;
  31616. /**
  31617. * Creates a video texture straight from a stream.
  31618. * @param scene Define the scene the texture should be created in
  31619. * @param stream Define the stream the texture should be created from
  31620. * @returns The created video texture as a promise
  31621. */
  31622. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31623. /**
  31624. * Creates a video texture straight from your WebCam video feed.
  31625. * @param scene Define the scene the texture should be created in
  31626. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31627. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31628. * @returns The created video texture as a promise
  31629. */
  31630. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31631. minWidth: number;
  31632. maxWidth: number;
  31633. minHeight: number;
  31634. maxHeight: number;
  31635. deviceId: string;
  31636. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31637. /**
  31638. * Creates a video texture straight from your WebCam video feed.
  31639. * @param scene Define the scene the texture should be created in
  31640. * @param onReady Define a callback to triggered once the texture will be ready
  31641. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31642. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31643. */
  31644. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31645. minWidth: number;
  31646. maxWidth: number;
  31647. minHeight: number;
  31648. maxHeight: number;
  31649. deviceId: string;
  31650. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31651. }
  31652. }
  31653. declare module "babylonjs/Engines/thinEngine" {
  31654. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31655. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31656. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31657. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31658. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31659. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31660. import { Observable } from "babylonjs/Misc/observable";
  31661. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31662. import { StencilState } from "babylonjs/States/stencilState";
  31663. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31665. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31666. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31667. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31668. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31669. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31670. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31671. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31672. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31673. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31674. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31675. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31676. import { WebRequest } from "babylonjs/Misc/webRequest";
  31677. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31678. /**
  31679. * Defines the interface used by objects working like Scene
  31680. * @hidden
  31681. */
  31682. interface ISceneLike {
  31683. _addPendingData(data: any): void;
  31684. _removePendingData(data: any): void;
  31685. offlineProvider: IOfflineProvider;
  31686. }
  31687. /** Interface defining initialization parameters for Engine class */
  31688. export interface EngineOptions extends WebGLContextAttributes {
  31689. /**
  31690. * Defines if the engine should no exceed a specified device ratio
  31691. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31692. */
  31693. limitDeviceRatio?: number;
  31694. /**
  31695. * Defines if webvr should be enabled automatically
  31696. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31697. */
  31698. autoEnableWebVR?: boolean;
  31699. /**
  31700. * Defines if webgl2 should be turned off even if supported
  31701. * @see http://doc.babylonjs.com/features/webgl2
  31702. */
  31703. disableWebGL2Support?: boolean;
  31704. /**
  31705. * Defines if webaudio should be initialized as well
  31706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31707. */
  31708. audioEngine?: boolean;
  31709. /**
  31710. * Defines if animations should run using a deterministic lock step
  31711. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31712. */
  31713. deterministicLockstep?: boolean;
  31714. /** Defines the maximum steps to use with deterministic lock step mode */
  31715. lockstepMaxSteps?: number;
  31716. /** Defines the seconds between each deterministic lock step */
  31717. timeStep?: number;
  31718. /**
  31719. * Defines that engine should ignore context lost events
  31720. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31721. */
  31722. doNotHandleContextLost?: boolean;
  31723. /**
  31724. * Defines that engine should ignore modifying touch action attribute and style
  31725. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31726. */
  31727. doNotHandleTouchAction?: boolean;
  31728. /**
  31729. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31730. */
  31731. useHighPrecisionFloats?: boolean;
  31732. }
  31733. /**
  31734. * The base engine class (root of all engines)
  31735. */
  31736. export class ThinEngine {
  31737. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31738. static ExceptionList: ({
  31739. key: string;
  31740. capture: string;
  31741. captureConstraint: number;
  31742. targets: string[];
  31743. } | {
  31744. key: string;
  31745. capture: null;
  31746. captureConstraint: null;
  31747. targets: string[];
  31748. })[];
  31749. /** @hidden */
  31750. static _TextureLoaders: IInternalTextureLoader[];
  31751. /**
  31752. * Returns the current npm package of the sdk
  31753. */
  31754. static get NpmPackage(): string;
  31755. /**
  31756. * Returns the current version of the framework
  31757. */
  31758. static get Version(): string;
  31759. /**
  31760. * Returns a string describing the current engine
  31761. */
  31762. get description(): string;
  31763. /**
  31764. * Gets or sets the epsilon value used by collision engine
  31765. */
  31766. static CollisionsEpsilon: number;
  31767. /**
  31768. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31769. */
  31770. static get ShadersRepository(): string;
  31771. static set ShadersRepository(value: string);
  31772. /**
  31773. * Gets or sets the textures that the engine should not attempt to load as compressed
  31774. */
  31775. protected _excludedCompressedTextures: string[];
  31776. /**
  31777. * Filters the compressed texture formats to only include
  31778. * files that are not included in the skippable list
  31779. *
  31780. * @param url the current extension
  31781. * @param textureFormatInUse the current compressed texture format
  31782. * @returns "format" string
  31783. */
  31784. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31785. /** @hidden */
  31786. _shaderProcessor: IShaderProcessor;
  31787. /**
  31788. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31789. */
  31790. forcePOTTextures: boolean;
  31791. /**
  31792. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31793. */
  31794. isFullscreen: boolean;
  31795. /**
  31796. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31797. */
  31798. cullBackFaces: boolean;
  31799. /**
  31800. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31801. */
  31802. renderEvenInBackground: boolean;
  31803. /**
  31804. * Gets or sets a boolean indicating that cache can be kept between frames
  31805. */
  31806. preventCacheWipeBetweenFrames: boolean;
  31807. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31808. validateShaderPrograms: boolean;
  31809. /**
  31810. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31811. * This can provide greater z depth for distant objects.
  31812. */
  31813. useReverseDepthBuffer: boolean;
  31814. /**
  31815. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31816. */
  31817. disableUniformBuffers: boolean;
  31818. /** @hidden */
  31819. _uniformBuffers: UniformBuffer[];
  31820. /**
  31821. * Gets a boolean indicating that the engine supports uniform buffers
  31822. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31823. */
  31824. get supportsUniformBuffers(): boolean;
  31825. /** @hidden */
  31826. _gl: WebGLRenderingContext;
  31827. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31828. protected _windowIsBackground: boolean;
  31829. protected _webGLVersion: number;
  31830. protected _creationOptions: EngineOptions;
  31831. protected _highPrecisionShadersAllowed: boolean;
  31832. /** @hidden */
  31833. get _shouldUseHighPrecisionShader(): boolean;
  31834. /**
  31835. * Gets a boolean indicating that only power of 2 textures are supported
  31836. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31837. */
  31838. get needPOTTextures(): boolean;
  31839. /** @hidden */
  31840. _badOS: boolean;
  31841. /** @hidden */
  31842. _badDesktopOS: boolean;
  31843. private _hardwareScalingLevel;
  31844. /** @hidden */
  31845. _caps: EngineCapabilities;
  31846. private _isStencilEnable;
  31847. private _glVersion;
  31848. private _glRenderer;
  31849. private _glVendor;
  31850. /** @hidden */
  31851. _videoTextureSupported: boolean;
  31852. protected _renderingQueueLaunched: boolean;
  31853. protected _activeRenderLoops: (() => void)[];
  31854. /**
  31855. * Observable signaled when a context lost event is raised
  31856. */
  31857. onContextLostObservable: Observable<ThinEngine>;
  31858. /**
  31859. * Observable signaled when a context restored event is raised
  31860. */
  31861. onContextRestoredObservable: Observable<ThinEngine>;
  31862. private _onContextLost;
  31863. private _onContextRestored;
  31864. protected _contextWasLost: boolean;
  31865. /** @hidden */
  31866. _doNotHandleContextLost: boolean;
  31867. /**
  31868. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31870. */
  31871. get doNotHandleContextLost(): boolean;
  31872. set doNotHandleContextLost(value: boolean);
  31873. /**
  31874. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31875. */
  31876. disableVertexArrayObjects: boolean;
  31877. /** @hidden */
  31878. protected _colorWrite: boolean;
  31879. /** @hidden */
  31880. protected _colorWriteChanged: boolean;
  31881. /** @hidden */
  31882. protected _depthCullingState: DepthCullingState;
  31883. /** @hidden */
  31884. protected _stencilState: StencilState;
  31885. /** @hidden */
  31886. _alphaState: AlphaState;
  31887. /** @hidden */
  31888. _alphaMode: number;
  31889. /** @hidden */
  31890. _alphaEquation: number;
  31891. /** @hidden */
  31892. _internalTexturesCache: InternalTexture[];
  31893. /** @hidden */
  31894. protected _activeChannel: number;
  31895. private _currentTextureChannel;
  31896. /** @hidden */
  31897. protected _boundTexturesCache: {
  31898. [key: string]: Nullable<InternalTexture>;
  31899. };
  31900. /** @hidden */
  31901. protected _currentEffect: Nullable<Effect>;
  31902. /** @hidden */
  31903. protected _currentProgram: Nullable<WebGLProgram>;
  31904. private _compiledEffects;
  31905. private _vertexAttribArraysEnabled;
  31906. /** @hidden */
  31907. protected _cachedViewport: Nullable<IViewportLike>;
  31908. private _cachedVertexArrayObject;
  31909. /** @hidden */
  31910. protected _cachedVertexBuffers: any;
  31911. /** @hidden */
  31912. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31913. /** @hidden */
  31914. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31915. /** @hidden */
  31916. _currentRenderTarget: Nullable<InternalTexture>;
  31917. private _uintIndicesCurrentlySet;
  31918. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31919. /** @hidden */
  31920. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31921. private _currentBufferPointers;
  31922. private _currentInstanceLocations;
  31923. private _currentInstanceBuffers;
  31924. private _textureUnits;
  31925. /** @hidden */
  31926. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31927. /** @hidden */
  31928. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31929. /** @hidden */
  31930. _boundRenderFunction: any;
  31931. private _vaoRecordInProgress;
  31932. private _mustWipeVertexAttributes;
  31933. private _emptyTexture;
  31934. private _emptyCubeTexture;
  31935. private _emptyTexture3D;
  31936. private _emptyTexture2DArray;
  31937. /** @hidden */
  31938. _frameHandler: number;
  31939. private _nextFreeTextureSlots;
  31940. private _maxSimultaneousTextures;
  31941. private _activeRequests;
  31942. protected _texturesSupported: string[];
  31943. /** @hidden */
  31944. _textureFormatInUse: Nullable<string>;
  31945. protected get _supportsHardwareTextureRescaling(): boolean;
  31946. /**
  31947. * Gets the list of texture formats supported
  31948. */
  31949. get texturesSupported(): Array<string>;
  31950. /**
  31951. * Gets the list of texture formats in use
  31952. */
  31953. get textureFormatInUse(): Nullable<string>;
  31954. /**
  31955. * Gets the current viewport
  31956. */
  31957. get currentViewport(): Nullable<IViewportLike>;
  31958. /**
  31959. * Gets the default empty texture
  31960. */
  31961. get emptyTexture(): InternalTexture;
  31962. /**
  31963. * Gets the default empty 3D texture
  31964. */
  31965. get emptyTexture3D(): InternalTexture;
  31966. /**
  31967. * Gets the default empty 2D array texture
  31968. */
  31969. get emptyTexture2DArray(): InternalTexture;
  31970. /**
  31971. * Gets the default empty cube texture
  31972. */
  31973. get emptyCubeTexture(): InternalTexture;
  31974. /**
  31975. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31976. */
  31977. readonly premultipliedAlpha: boolean;
  31978. /**
  31979. * Observable event triggered before each texture is initialized
  31980. */
  31981. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31982. /**
  31983. * Creates a new engine
  31984. * @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
  31985. * @param antialias defines enable antialiasing (default: false)
  31986. * @param options defines further options to be sent to the getContext() function
  31987. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31988. */
  31989. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31990. private _rebuildInternalTextures;
  31991. private _rebuildEffects;
  31992. /**
  31993. * Gets a boolean indicating if all created effects are ready
  31994. * @returns true if all effects are ready
  31995. */
  31996. areAllEffectsReady(): boolean;
  31997. protected _rebuildBuffers(): void;
  31998. private _initGLContext;
  31999. /**
  32000. * Gets version of the current webGL context
  32001. */
  32002. get webGLVersion(): number;
  32003. /**
  32004. * Gets a string idenfifying the name of the class
  32005. * @returns "Engine" string
  32006. */
  32007. getClassName(): string;
  32008. /**
  32009. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32010. */
  32011. get isStencilEnable(): boolean;
  32012. /** @hidden */
  32013. _prepareWorkingCanvas(): void;
  32014. /**
  32015. * Reset the texture cache to empty state
  32016. */
  32017. resetTextureCache(): void;
  32018. /**
  32019. * Gets an object containing information about the current webGL context
  32020. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32021. */
  32022. getGlInfo(): {
  32023. vendor: string;
  32024. renderer: string;
  32025. version: string;
  32026. };
  32027. /**
  32028. * Defines the hardware scaling level.
  32029. * By default the hardware scaling level is computed from the window device ratio.
  32030. * 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.
  32031. * @param level defines the level to use
  32032. */
  32033. setHardwareScalingLevel(level: number): void;
  32034. /**
  32035. * Gets the current hardware scaling level.
  32036. * By default the hardware scaling level is computed from the window device ratio.
  32037. * 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.
  32038. * @returns a number indicating the current hardware scaling level
  32039. */
  32040. getHardwareScalingLevel(): number;
  32041. /**
  32042. * Gets the list of loaded textures
  32043. * @returns an array containing all loaded textures
  32044. */
  32045. getLoadedTexturesCache(): InternalTexture[];
  32046. /**
  32047. * Gets the object containing all engine capabilities
  32048. * @returns the EngineCapabilities object
  32049. */
  32050. getCaps(): EngineCapabilities;
  32051. /**
  32052. * stop executing a render loop function and remove it from the execution array
  32053. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32054. */
  32055. stopRenderLoop(renderFunction?: () => void): void;
  32056. /** @hidden */
  32057. _renderLoop(): void;
  32058. /**
  32059. * Gets the HTML canvas attached with the current webGL context
  32060. * @returns a HTML canvas
  32061. */
  32062. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32063. /**
  32064. * Gets host window
  32065. * @returns the host window object
  32066. */
  32067. getHostWindow(): Nullable<Window>;
  32068. /**
  32069. * Gets the current render width
  32070. * @param useScreen defines if screen size must be used (or the current render target if any)
  32071. * @returns a number defining the current render width
  32072. */
  32073. getRenderWidth(useScreen?: boolean): number;
  32074. /**
  32075. * Gets the current render height
  32076. * @param useScreen defines if screen size must be used (or the current render target if any)
  32077. * @returns a number defining the current render height
  32078. */
  32079. getRenderHeight(useScreen?: boolean): number;
  32080. /**
  32081. * Can be used to override the current requestAnimationFrame requester.
  32082. * @hidden
  32083. */
  32084. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32085. /**
  32086. * Register and execute a render loop. The engine can have more than one render function
  32087. * @param renderFunction defines the function to continuously execute
  32088. */
  32089. runRenderLoop(renderFunction: () => void): void;
  32090. /**
  32091. * Clear the current render buffer or the current render target (if any is set up)
  32092. * @param color defines the color to use
  32093. * @param backBuffer defines if the back buffer must be cleared
  32094. * @param depth defines if the depth buffer must be cleared
  32095. * @param stencil defines if the stencil buffer must be cleared
  32096. */
  32097. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32098. private _viewportCached;
  32099. /** @hidden */
  32100. _viewport(x: number, y: number, width: number, height: number): void;
  32101. /**
  32102. * Set the WebGL's viewport
  32103. * @param viewport defines the viewport element to be used
  32104. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32105. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32106. */
  32107. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32108. /**
  32109. * Begin a new frame
  32110. */
  32111. beginFrame(): void;
  32112. /**
  32113. * Enf the current frame
  32114. */
  32115. endFrame(): void;
  32116. /**
  32117. * Resize the view according to the canvas' size
  32118. */
  32119. resize(): void;
  32120. /**
  32121. * Force a specific size of the canvas
  32122. * @param width defines the new canvas' width
  32123. * @param height defines the new canvas' height
  32124. */
  32125. setSize(width: number, height: number): void;
  32126. /**
  32127. * Binds the frame buffer to the specified texture.
  32128. * @param texture The texture to render to or null for the default canvas
  32129. * @param faceIndex The face of the texture to render to in case of cube texture
  32130. * @param requiredWidth The width of the target to render to
  32131. * @param requiredHeight The height of the target to render to
  32132. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32133. * @param lodLevel defines the lod level to bind to the frame buffer
  32134. * @param layer defines the 2d array index to bind to frame buffer to
  32135. */
  32136. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32137. /** @hidden */
  32138. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32139. /**
  32140. * Unbind the current render target texture from the webGL context
  32141. * @param texture defines the render target texture to unbind
  32142. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32143. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32144. */
  32145. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32146. /**
  32147. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32148. */
  32149. flushFramebuffer(): void;
  32150. /**
  32151. * Unbind the current render target and bind the default framebuffer
  32152. */
  32153. restoreDefaultFramebuffer(): void;
  32154. /** @hidden */
  32155. protected _resetVertexBufferBinding(): void;
  32156. /**
  32157. * Creates a vertex buffer
  32158. * @param data the data for the vertex buffer
  32159. * @returns the new WebGL static buffer
  32160. */
  32161. createVertexBuffer(data: DataArray): DataBuffer;
  32162. private _createVertexBuffer;
  32163. /**
  32164. * Creates a dynamic vertex buffer
  32165. * @param data the data for the dynamic vertex buffer
  32166. * @returns the new WebGL dynamic buffer
  32167. */
  32168. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32169. protected _resetIndexBufferBinding(): void;
  32170. /**
  32171. * Creates a new index buffer
  32172. * @param indices defines the content of the index buffer
  32173. * @param updatable defines if the index buffer must be updatable
  32174. * @returns a new webGL buffer
  32175. */
  32176. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32177. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32178. /**
  32179. * Bind a webGL buffer to the webGL context
  32180. * @param buffer defines the buffer to bind
  32181. */
  32182. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32183. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32184. private bindBuffer;
  32185. /**
  32186. * update the bound buffer with the given data
  32187. * @param data defines the data to update
  32188. */
  32189. updateArrayBuffer(data: Float32Array): void;
  32190. private _vertexAttribPointer;
  32191. private _bindIndexBufferWithCache;
  32192. private _bindVertexBuffersAttributes;
  32193. /**
  32194. * Records a vertex array object
  32195. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32196. * @param vertexBuffers defines the list of vertex buffers to store
  32197. * @param indexBuffer defines the index buffer to store
  32198. * @param effect defines the effect to store
  32199. * @returns the new vertex array object
  32200. */
  32201. recordVertexArrayObject(vertexBuffers: {
  32202. [key: string]: VertexBuffer;
  32203. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32204. /**
  32205. * Bind a specific vertex array object
  32206. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32207. * @param vertexArrayObject defines the vertex array object to bind
  32208. * @param indexBuffer defines the index buffer to bind
  32209. */
  32210. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32211. /**
  32212. * Bind webGl buffers directly to the webGL context
  32213. * @param vertexBuffer defines the vertex buffer to bind
  32214. * @param indexBuffer defines the index buffer to bind
  32215. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32216. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32217. * @param effect defines the effect associated with the vertex buffer
  32218. */
  32219. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32220. private _unbindVertexArrayObject;
  32221. /**
  32222. * Bind a list of vertex buffers to the webGL context
  32223. * @param vertexBuffers defines the list of vertex buffers to bind
  32224. * @param indexBuffer defines the index buffer to bind
  32225. * @param effect defines the effect associated with the vertex buffers
  32226. */
  32227. bindBuffers(vertexBuffers: {
  32228. [key: string]: Nullable<VertexBuffer>;
  32229. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32230. /**
  32231. * Unbind all instance attributes
  32232. */
  32233. unbindInstanceAttributes(): void;
  32234. /**
  32235. * Release and free the memory of a vertex array object
  32236. * @param vao defines the vertex array object to delete
  32237. */
  32238. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32239. /** @hidden */
  32240. _releaseBuffer(buffer: DataBuffer): boolean;
  32241. protected _deleteBuffer(buffer: DataBuffer): void;
  32242. /**
  32243. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32244. * @param instancesBuffer defines the webGL buffer to update and bind
  32245. * @param data defines the data to store in the buffer
  32246. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32247. */
  32248. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32249. /**
  32250. * Bind the content of a webGL buffer used with instanciation
  32251. * @param instancesBuffer defines the webGL buffer to bind
  32252. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32253. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32254. */
  32255. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32256. /**
  32257. * Disable the instance attribute corresponding to the name in parameter
  32258. * @param name defines the name of the attribute to disable
  32259. */
  32260. disableInstanceAttributeByName(name: string): void;
  32261. /**
  32262. * Disable the instance attribute corresponding to the location in parameter
  32263. * @param attributeLocation defines the attribute location of the attribute to disable
  32264. */
  32265. disableInstanceAttribute(attributeLocation: number): void;
  32266. /**
  32267. * Disable the attribute corresponding to the location in parameter
  32268. * @param attributeLocation defines the attribute location of the attribute to disable
  32269. */
  32270. disableAttributeByIndex(attributeLocation: number): void;
  32271. /**
  32272. * Send a draw order
  32273. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32274. * @param indexStart defines the starting index
  32275. * @param indexCount defines the number of index to draw
  32276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32277. */
  32278. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32279. /**
  32280. * Draw a list of points
  32281. * @param verticesStart defines the index of first vertex to draw
  32282. * @param verticesCount defines the count of vertices to draw
  32283. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32284. */
  32285. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32286. /**
  32287. * Draw a list of unindexed primitives
  32288. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32289. * @param verticesStart defines the index of first vertex to draw
  32290. * @param verticesCount defines the count of vertices to draw
  32291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32292. */
  32293. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32294. /**
  32295. * Draw a list of indexed primitives
  32296. * @param fillMode defines the primitive to use
  32297. * @param indexStart defines the starting index
  32298. * @param indexCount defines the number of index to draw
  32299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32300. */
  32301. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32302. /**
  32303. * Draw a list of unindexed primitives
  32304. * @param fillMode defines the primitive to use
  32305. * @param verticesStart defines the index of first vertex to draw
  32306. * @param verticesCount defines the count of vertices to draw
  32307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32308. */
  32309. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32310. private _drawMode;
  32311. /** @hidden */
  32312. protected _reportDrawCall(): void;
  32313. /** @hidden */
  32314. _releaseEffect(effect: Effect): void;
  32315. /** @hidden */
  32316. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32317. /**
  32318. * Create a new effect (used to store vertex/fragment shaders)
  32319. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32320. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32321. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32322. * @param samplers defines an array of string used to represent textures
  32323. * @param defines defines the string containing the defines to use to compile the shaders
  32324. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32325. * @param onCompiled defines a function to call when the effect creation is successful
  32326. * @param onError defines a function to call when the effect creation has failed
  32327. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32328. * @returns the new Effect
  32329. */
  32330. 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;
  32331. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32332. private _compileShader;
  32333. private _compileRawShader;
  32334. /**
  32335. * Directly creates a webGL program
  32336. * @param pipelineContext defines the pipeline context to attach to
  32337. * @param vertexCode defines the vertex shader code to use
  32338. * @param fragmentCode defines the fragment shader code to use
  32339. * @param context defines the webGL context to use (if not set, the current one will be used)
  32340. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32341. * @returns the new webGL program
  32342. */
  32343. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32344. /**
  32345. * Creates a webGL program
  32346. * @param pipelineContext defines the pipeline context to attach to
  32347. * @param vertexCode defines the vertex shader code to use
  32348. * @param fragmentCode defines the fragment shader code to use
  32349. * @param defines defines the string containing the defines to use to compile the shaders
  32350. * @param context defines the webGL context to use (if not set, the current one will be used)
  32351. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32352. * @returns the new webGL program
  32353. */
  32354. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32355. /**
  32356. * Creates a new pipeline context
  32357. * @returns the new pipeline
  32358. */
  32359. createPipelineContext(): IPipelineContext;
  32360. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32361. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32362. /** @hidden */
  32363. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32364. /** @hidden */
  32365. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32366. /** @hidden */
  32367. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32368. /**
  32369. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32370. * @param pipelineContext defines the pipeline context to use
  32371. * @param uniformsNames defines the list of uniform names
  32372. * @returns an array of webGL uniform locations
  32373. */
  32374. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32375. /**
  32376. * Gets the lsit of active attributes for a given webGL program
  32377. * @param pipelineContext defines the pipeline context to use
  32378. * @param attributesNames defines the list of attribute names to get
  32379. * @returns an array of indices indicating the offset of each attribute
  32380. */
  32381. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32382. /**
  32383. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32384. * @param effect defines the effect to activate
  32385. */
  32386. enableEffect(effect: Nullable<Effect>): void;
  32387. /**
  32388. * Set the value of an uniform to a number (int)
  32389. * @param uniform defines the webGL uniform location where to store the value
  32390. * @param value defines the int number to store
  32391. */
  32392. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32393. /**
  32394. * Set the value of an uniform to an array of int32
  32395. * @param uniform defines the webGL uniform location where to store the value
  32396. * @param array defines the array of int32 to store
  32397. */
  32398. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32399. /**
  32400. * Set the value of an uniform to an array of int32 (stored as vec2)
  32401. * @param uniform defines the webGL uniform location where to store the value
  32402. * @param array defines the array of int32 to store
  32403. */
  32404. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32405. /**
  32406. * Set the value of an uniform to an array of int32 (stored as vec3)
  32407. * @param uniform defines the webGL uniform location where to store the value
  32408. * @param array defines the array of int32 to store
  32409. */
  32410. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32411. /**
  32412. * Set the value of an uniform to an array of int32 (stored as vec4)
  32413. * @param uniform defines the webGL uniform location where to store the value
  32414. * @param array defines the array of int32 to store
  32415. */
  32416. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32417. /**
  32418. * Set the value of an uniform to an array of number
  32419. * @param uniform defines the webGL uniform location where to store the value
  32420. * @param array defines the array of number to store
  32421. */
  32422. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32423. /**
  32424. * Set the value of an uniform to an array of number (stored as vec2)
  32425. * @param uniform defines the webGL uniform location where to store the value
  32426. * @param array defines the array of number to store
  32427. */
  32428. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32429. /**
  32430. * Set the value of an uniform to an array of number (stored as vec3)
  32431. * @param uniform defines the webGL uniform location where to store the value
  32432. * @param array defines the array of number to store
  32433. */
  32434. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32435. /**
  32436. * Set the value of an uniform to an array of number (stored as vec4)
  32437. * @param uniform defines the webGL uniform location where to store the value
  32438. * @param array defines the array of number to store
  32439. */
  32440. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32441. /**
  32442. * Set the value of an uniform to an array of float32 (stored as matrices)
  32443. * @param uniform defines the webGL uniform location where to store the value
  32444. * @param matrices defines the array of float32 to store
  32445. */
  32446. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32447. /**
  32448. * Set the value of an uniform to a matrix (3x3)
  32449. * @param uniform defines the webGL uniform location where to store the value
  32450. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32451. */
  32452. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32453. /**
  32454. * Set the value of an uniform to a matrix (2x2)
  32455. * @param uniform defines the webGL uniform location where to store the value
  32456. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32457. */
  32458. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32459. /**
  32460. * Set the value of an uniform to a number (float)
  32461. * @param uniform defines the webGL uniform location where to store the value
  32462. * @param value defines the float number to store
  32463. */
  32464. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32465. /**
  32466. * Set the value of an uniform to a vec2
  32467. * @param uniform defines the webGL uniform location where to store the value
  32468. * @param x defines the 1st component of the value
  32469. * @param y defines the 2nd component of the value
  32470. */
  32471. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32472. /**
  32473. * Set the value of an uniform to a vec3
  32474. * @param uniform defines the webGL uniform location where to store the value
  32475. * @param x defines the 1st component of the value
  32476. * @param y defines the 2nd component of the value
  32477. * @param z defines the 3rd component of the value
  32478. */
  32479. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32480. /**
  32481. * Set the value of an uniform to a vec4
  32482. * @param uniform defines the webGL uniform location where to store the value
  32483. * @param x defines the 1st component of the value
  32484. * @param y defines the 2nd component of the value
  32485. * @param z defines the 3rd component of the value
  32486. * @param w defines the 4th component of the value
  32487. */
  32488. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32489. /**
  32490. * Apply all cached states (depth, culling, stencil and alpha)
  32491. */
  32492. applyStates(): void;
  32493. /**
  32494. * Enable or disable color writing
  32495. * @param enable defines the state to set
  32496. */
  32497. setColorWrite(enable: boolean): void;
  32498. /**
  32499. * Gets a boolean indicating if color writing is enabled
  32500. * @returns the current color writing state
  32501. */
  32502. getColorWrite(): boolean;
  32503. /**
  32504. * Gets the depth culling state manager
  32505. */
  32506. get depthCullingState(): DepthCullingState;
  32507. /**
  32508. * Gets the alpha state manager
  32509. */
  32510. get alphaState(): AlphaState;
  32511. /**
  32512. * Gets the stencil state manager
  32513. */
  32514. get stencilState(): StencilState;
  32515. /**
  32516. * Clears the list of texture accessible through engine.
  32517. * This can help preventing texture load conflict due to name collision.
  32518. */
  32519. clearInternalTexturesCache(): void;
  32520. /**
  32521. * Force the entire cache to be cleared
  32522. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32523. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32524. */
  32525. wipeCaches(bruteForce?: boolean): void;
  32526. /** @hidden */
  32527. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32528. min: number;
  32529. mag: number;
  32530. };
  32531. /** @hidden */
  32532. _createTexture(): WebGLTexture;
  32533. /**
  32534. * Usually called from Texture.ts.
  32535. * Passed information to create a WebGLTexture
  32536. * @param urlArg defines a value which contains one of the following:
  32537. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32538. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32539. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32540. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32541. * @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)
  32542. * @param scene needed for loading to the correct scene
  32543. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32544. * @param onLoad optional callback to be called upon successful completion
  32545. * @param onError optional callback to be called upon failure
  32546. * @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
  32547. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32548. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32549. * @param forcedExtension defines the extension to use to pick the right loader
  32550. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32551. * @param mimeType defines an optional mime type
  32552. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32553. */
  32554. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32555. /**
  32556. * Loads an image as an HTMLImageElement.
  32557. * @param input url string, ArrayBuffer, or Blob to load
  32558. * @param onLoad callback called when the image successfully loads
  32559. * @param onError callback called when the image fails to load
  32560. * @param offlineProvider offline provider for caching
  32561. * @param mimeType optional mime type
  32562. * @returns the HTMLImageElement of the loaded image
  32563. * @hidden
  32564. */
  32565. 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>;
  32566. /**
  32567. * @hidden
  32568. */
  32569. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32570. /**
  32571. * Creates a raw texture
  32572. * @param data defines the data to store in the texture
  32573. * @param width defines the width of the texture
  32574. * @param height defines the height of the texture
  32575. * @param format defines the format of the data
  32576. * @param generateMipMaps defines if the engine should generate the mip levels
  32577. * @param invertY defines if data must be stored with Y axis inverted
  32578. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32579. * @param compression defines the compression used (null by default)
  32580. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32581. * @returns the raw texture inside an InternalTexture
  32582. */
  32583. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32584. /**
  32585. * Creates a new raw cube texture
  32586. * @param data defines the array of data to use to create each face
  32587. * @param size defines the size of the textures
  32588. * @param format defines the format of the data
  32589. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32590. * @param generateMipMaps defines if the engine should generate the mip levels
  32591. * @param invertY defines if data must be stored with Y axis inverted
  32592. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32593. * @param compression defines the compression used (null by default)
  32594. * @returns the cube texture as an InternalTexture
  32595. */
  32596. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32597. /**
  32598. * Creates a new raw 3D texture
  32599. * @param data defines the data used to create the texture
  32600. * @param width defines the width of the texture
  32601. * @param height defines the height of the texture
  32602. * @param depth defines the depth of the texture
  32603. * @param format defines the format of the texture
  32604. * @param generateMipMaps defines if the engine must generate mip levels
  32605. * @param invertY defines if data must be stored with Y axis inverted
  32606. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32607. * @param compression defines the compressed used (can be null)
  32608. * @param textureType defines the compressed used (can be null)
  32609. * @returns a new raw 3D texture (stored in an InternalTexture)
  32610. */
  32611. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32612. /**
  32613. * Creates a new raw 2D array texture
  32614. * @param data defines the data used to create the texture
  32615. * @param width defines the width of the texture
  32616. * @param height defines the height of the texture
  32617. * @param depth defines the number of layers of the texture
  32618. * @param format defines the format of the texture
  32619. * @param generateMipMaps defines if the engine must generate mip levels
  32620. * @param invertY defines if data must be stored with Y axis inverted
  32621. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32622. * @param compression defines the compressed used (can be null)
  32623. * @param textureType defines the compressed used (can be null)
  32624. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32625. */
  32626. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32627. private _unpackFlipYCached;
  32628. /**
  32629. * In case you are sharing the context with other applications, it might
  32630. * be interested to not cache the unpack flip y state to ensure a consistent
  32631. * value would be set.
  32632. */
  32633. enableUnpackFlipYCached: boolean;
  32634. /** @hidden */
  32635. _unpackFlipY(value: boolean): void;
  32636. /** @hidden */
  32637. _getUnpackAlignement(): number;
  32638. private _getTextureTarget;
  32639. /**
  32640. * Update the sampling mode of a given texture
  32641. * @param samplingMode defines the required sampling mode
  32642. * @param texture defines the texture to update
  32643. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32644. */
  32645. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32646. /**
  32647. * Update the sampling mode of a given texture
  32648. * @param texture defines the texture to update
  32649. * @param wrapU defines the texture wrap mode of the u coordinates
  32650. * @param wrapV defines the texture wrap mode of the v coordinates
  32651. * @param wrapR defines the texture wrap mode of the r coordinates
  32652. */
  32653. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32654. /** @hidden */
  32655. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32656. width: number;
  32657. height: number;
  32658. layers?: number;
  32659. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32660. /** @hidden */
  32661. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32662. /** @hidden */
  32663. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32664. /**
  32665. * Update a portion of an internal texture
  32666. * @param texture defines the texture to update
  32667. * @param imageData defines the data to store into the texture
  32668. * @param xOffset defines the x coordinates of the update rectangle
  32669. * @param yOffset defines the y coordinates of the update rectangle
  32670. * @param width defines the width of the update rectangle
  32671. * @param height defines the height of the update rectangle
  32672. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32673. * @param lod defines the lod level to update (0 by default)
  32674. */
  32675. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32676. /** @hidden */
  32677. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32678. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32679. private _prepareWebGLTexture;
  32680. /** @hidden */
  32681. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32682. private _getDepthStencilBuffer;
  32683. /** @hidden */
  32684. _releaseFramebufferObjects(texture: InternalTexture): void;
  32685. /** @hidden */
  32686. _releaseTexture(texture: InternalTexture): void;
  32687. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32688. protected _setProgram(program: WebGLProgram): void;
  32689. protected _boundUniforms: {
  32690. [key: number]: WebGLUniformLocation;
  32691. };
  32692. /**
  32693. * Binds an effect to the webGL context
  32694. * @param effect defines the effect to bind
  32695. */
  32696. bindSamplers(effect: Effect): void;
  32697. private _activateCurrentTexture;
  32698. /** @hidden */
  32699. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32700. /** @hidden */
  32701. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32702. /**
  32703. * Unbind all textures from the webGL context
  32704. */
  32705. unbindAllTextures(): void;
  32706. /**
  32707. * Sets a texture to the according uniform.
  32708. * @param channel The texture channel
  32709. * @param uniform The uniform to set
  32710. * @param texture The texture to apply
  32711. */
  32712. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32713. private _bindSamplerUniformToChannel;
  32714. private _getTextureWrapMode;
  32715. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32716. /**
  32717. * Sets an array of texture to the webGL context
  32718. * @param channel defines the channel where the texture array must be set
  32719. * @param uniform defines the associated uniform location
  32720. * @param textures defines the array of textures to bind
  32721. */
  32722. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32723. /** @hidden */
  32724. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32725. private _setTextureParameterFloat;
  32726. private _setTextureParameterInteger;
  32727. /**
  32728. * Unbind all vertex attributes from the webGL context
  32729. */
  32730. unbindAllAttributes(): void;
  32731. /**
  32732. * 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
  32733. */
  32734. releaseEffects(): void;
  32735. /**
  32736. * Dispose and release all associated resources
  32737. */
  32738. dispose(): void;
  32739. /**
  32740. * Attach a new callback raised when context lost event is fired
  32741. * @param callback defines the callback to call
  32742. */
  32743. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32744. /**
  32745. * Attach a new callback raised when context restored event is fired
  32746. * @param callback defines the callback to call
  32747. */
  32748. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32749. /**
  32750. * Get the current error code of the webGL context
  32751. * @returns the error code
  32752. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32753. */
  32754. getError(): number;
  32755. private _canRenderToFloatFramebuffer;
  32756. private _canRenderToHalfFloatFramebuffer;
  32757. private _canRenderToFramebuffer;
  32758. /** @hidden */
  32759. _getWebGLTextureType(type: number): number;
  32760. /** @hidden */
  32761. _getInternalFormat(format: number): number;
  32762. /** @hidden */
  32763. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32764. /** @hidden */
  32765. _getRGBAMultiSampleBufferFormat(type: number): number;
  32766. /** @hidden */
  32767. _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;
  32768. /**
  32769. * Loads a file from a url
  32770. * @param url url to load
  32771. * @param onSuccess callback called when the file successfully loads
  32772. * @param onProgress callback called while file is loading (if the server supports this mode)
  32773. * @param offlineProvider defines the offline provider for caching
  32774. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32775. * @param onError callback called when the file fails to load
  32776. * @returns a file request object
  32777. * @hidden
  32778. */
  32779. 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;
  32780. /**
  32781. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32782. * @param x defines the x coordinate of the rectangle where pixels must be read
  32783. * @param y defines the y coordinate of the rectangle where pixels must be read
  32784. * @param width defines the width of the rectangle where pixels must be read
  32785. * @param height defines the height of the rectangle where pixels must be read
  32786. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32787. * @returns a Uint8Array containing RGBA colors
  32788. */
  32789. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32790. private static _isSupported;
  32791. /**
  32792. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32793. * @returns true if the engine can be created
  32794. * @ignorenaming
  32795. */
  32796. static isSupported(): boolean;
  32797. /**
  32798. * Find the next highest power of two.
  32799. * @param x Number to start search from.
  32800. * @return Next highest power of two.
  32801. */
  32802. static CeilingPOT(x: number): number;
  32803. /**
  32804. * Find the next lowest power of two.
  32805. * @param x Number to start search from.
  32806. * @return Next lowest power of two.
  32807. */
  32808. static FloorPOT(x: number): number;
  32809. /**
  32810. * Find the nearest power of two.
  32811. * @param x Number to start search from.
  32812. * @return Next nearest power of two.
  32813. */
  32814. static NearestPOT(x: number): number;
  32815. /**
  32816. * Get the closest exponent of two
  32817. * @param value defines the value to approximate
  32818. * @param max defines the maximum value to return
  32819. * @param mode defines how to define the closest value
  32820. * @returns closest exponent of two of the given value
  32821. */
  32822. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32823. /**
  32824. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32825. * @param func - the function to be called
  32826. * @param requester - the object that will request the next frame. Falls back to window.
  32827. * @returns frame number
  32828. */
  32829. static QueueNewFrame(func: () => void, requester?: any): number;
  32830. /**
  32831. * Gets host document
  32832. * @returns the host document object
  32833. */
  32834. getHostDocument(): Nullable<Document>;
  32835. }
  32836. }
  32837. declare module "babylonjs/Maths/sphericalPolynomial" {
  32838. import { Vector3 } from "babylonjs/Maths/math.vector";
  32839. import { Color3 } from "babylonjs/Maths/math.color";
  32840. /**
  32841. * Class representing spherical harmonics coefficients to the 3rd degree
  32842. */
  32843. export class SphericalHarmonics {
  32844. /**
  32845. * Defines whether or not the harmonics have been prescaled for rendering.
  32846. */
  32847. preScaled: boolean;
  32848. /**
  32849. * The l0,0 coefficients of the spherical harmonics
  32850. */
  32851. l00: Vector3;
  32852. /**
  32853. * The l1,-1 coefficients of the spherical harmonics
  32854. */
  32855. l1_1: Vector3;
  32856. /**
  32857. * The l1,0 coefficients of the spherical harmonics
  32858. */
  32859. l10: Vector3;
  32860. /**
  32861. * The l1,1 coefficients of the spherical harmonics
  32862. */
  32863. l11: Vector3;
  32864. /**
  32865. * The l2,-2 coefficients of the spherical harmonics
  32866. */
  32867. l2_2: Vector3;
  32868. /**
  32869. * The l2,-1 coefficients of the spherical harmonics
  32870. */
  32871. l2_1: Vector3;
  32872. /**
  32873. * The l2,0 coefficients of the spherical harmonics
  32874. */
  32875. l20: Vector3;
  32876. /**
  32877. * The l2,1 coefficients of the spherical harmonics
  32878. */
  32879. l21: Vector3;
  32880. /**
  32881. * The l2,2 coefficients of the spherical harmonics
  32882. */
  32883. l22: Vector3;
  32884. /**
  32885. * Adds a light to the spherical harmonics
  32886. * @param direction the direction of the light
  32887. * @param color the color of the light
  32888. * @param deltaSolidAngle the delta solid angle of the light
  32889. */
  32890. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32891. /**
  32892. * Scales the spherical harmonics by the given amount
  32893. * @param scale the amount to scale
  32894. */
  32895. scaleInPlace(scale: number): void;
  32896. /**
  32897. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32898. *
  32899. * ```
  32900. * E_lm = A_l * L_lm
  32901. * ```
  32902. *
  32903. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32904. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32905. * the scaling factors are given in equation 9.
  32906. */
  32907. convertIncidentRadianceToIrradiance(): void;
  32908. /**
  32909. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32910. *
  32911. * ```
  32912. * L = (1/pi) * E * rho
  32913. * ```
  32914. *
  32915. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32916. */
  32917. convertIrradianceToLambertianRadiance(): void;
  32918. /**
  32919. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32920. * required operations at run time.
  32921. *
  32922. * This is simply done by scaling back the SH with Ylm constants parameter.
  32923. * The trigonometric part being applied by the shader at run time.
  32924. */
  32925. preScaleForRendering(): void;
  32926. /**
  32927. * Constructs a spherical harmonics from an array.
  32928. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32929. * @returns the spherical harmonics
  32930. */
  32931. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32932. /**
  32933. * Gets the spherical harmonics from polynomial
  32934. * @param polynomial the spherical polynomial
  32935. * @returns the spherical harmonics
  32936. */
  32937. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32938. }
  32939. /**
  32940. * Class representing spherical polynomial coefficients to the 3rd degree
  32941. */
  32942. export class SphericalPolynomial {
  32943. private _harmonics;
  32944. /**
  32945. * The spherical harmonics used to create the polynomials.
  32946. */
  32947. get preScaledHarmonics(): SphericalHarmonics;
  32948. /**
  32949. * The x coefficients of the spherical polynomial
  32950. */
  32951. x: Vector3;
  32952. /**
  32953. * The y coefficients of the spherical polynomial
  32954. */
  32955. y: Vector3;
  32956. /**
  32957. * The z coefficients of the spherical polynomial
  32958. */
  32959. z: Vector3;
  32960. /**
  32961. * The xx coefficients of the spherical polynomial
  32962. */
  32963. xx: Vector3;
  32964. /**
  32965. * The yy coefficients of the spherical polynomial
  32966. */
  32967. yy: Vector3;
  32968. /**
  32969. * The zz coefficients of the spherical polynomial
  32970. */
  32971. zz: Vector3;
  32972. /**
  32973. * The xy coefficients of the spherical polynomial
  32974. */
  32975. xy: Vector3;
  32976. /**
  32977. * The yz coefficients of the spherical polynomial
  32978. */
  32979. yz: Vector3;
  32980. /**
  32981. * The zx coefficients of the spherical polynomial
  32982. */
  32983. zx: Vector3;
  32984. /**
  32985. * Adds an ambient color to the spherical polynomial
  32986. * @param color the color to add
  32987. */
  32988. addAmbient(color: Color3): void;
  32989. /**
  32990. * Scales the spherical polynomial by the given amount
  32991. * @param scale the amount to scale
  32992. */
  32993. scaleInPlace(scale: number): void;
  32994. /**
  32995. * Gets the spherical polynomial from harmonics
  32996. * @param harmonics the spherical harmonics
  32997. * @returns the spherical polynomial
  32998. */
  32999. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33000. /**
  33001. * Constructs a spherical polynomial from an array.
  33002. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33003. * @returns the spherical polynomial
  33004. */
  33005. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33006. }
  33007. }
  33008. declare module "babylonjs/Materials/Textures/internalTexture" {
  33009. import { Observable } from "babylonjs/Misc/observable";
  33010. import { Nullable, int } from "babylonjs/types";
  33011. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33013. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33014. /**
  33015. * Defines the source of the internal texture
  33016. */
  33017. export enum InternalTextureSource {
  33018. /**
  33019. * The source of the texture data is unknown
  33020. */
  33021. Unknown = 0,
  33022. /**
  33023. * Texture data comes from an URL
  33024. */
  33025. Url = 1,
  33026. /**
  33027. * Texture data is only used for temporary storage
  33028. */
  33029. Temp = 2,
  33030. /**
  33031. * Texture data comes from raw data (ArrayBuffer)
  33032. */
  33033. Raw = 3,
  33034. /**
  33035. * Texture content is dynamic (video or dynamic texture)
  33036. */
  33037. Dynamic = 4,
  33038. /**
  33039. * Texture content is generated by rendering to it
  33040. */
  33041. RenderTarget = 5,
  33042. /**
  33043. * Texture content is part of a multi render target process
  33044. */
  33045. MultiRenderTarget = 6,
  33046. /**
  33047. * Texture data comes from a cube data file
  33048. */
  33049. Cube = 7,
  33050. /**
  33051. * Texture data comes from a raw cube data
  33052. */
  33053. CubeRaw = 8,
  33054. /**
  33055. * Texture data come from a prefiltered cube data file
  33056. */
  33057. CubePrefiltered = 9,
  33058. /**
  33059. * Texture content is raw 3D data
  33060. */
  33061. Raw3D = 10,
  33062. /**
  33063. * Texture content is raw 2D array data
  33064. */
  33065. Raw2DArray = 11,
  33066. /**
  33067. * Texture content is a depth texture
  33068. */
  33069. Depth = 12,
  33070. /**
  33071. * Texture data comes from a raw cube data encoded with RGBD
  33072. */
  33073. CubeRawRGBD = 13
  33074. }
  33075. /**
  33076. * Class used to store data associated with WebGL texture data for the engine
  33077. * This class should not be used directly
  33078. */
  33079. export class InternalTexture {
  33080. /** @hidden */
  33081. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33082. /**
  33083. * Defines if the texture is ready
  33084. */
  33085. isReady: boolean;
  33086. /**
  33087. * Defines if the texture is a cube texture
  33088. */
  33089. isCube: boolean;
  33090. /**
  33091. * Defines if the texture contains 3D data
  33092. */
  33093. is3D: boolean;
  33094. /**
  33095. * Defines if the texture contains 2D array data
  33096. */
  33097. is2DArray: boolean;
  33098. /**
  33099. * Defines if the texture contains multiview data
  33100. */
  33101. isMultiview: boolean;
  33102. /**
  33103. * Gets the URL used to load this texture
  33104. */
  33105. url: string;
  33106. /**
  33107. * Gets the sampling mode of the texture
  33108. */
  33109. samplingMode: number;
  33110. /**
  33111. * Gets a boolean indicating if the texture needs mipmaps generation
  33112. */
  33113. generateMipMaps: boolean;
  33114. /**
  33115. * Gets the number of samples used by the texture (WebGL2+ only)
  33116. */
  33117. samples: number;
  33118. /**
  33119. * Gets the type of the texture (int, float...)
  33120. */
  33121. type: number;
  33122. /**
  33123. * Gets the format of the texture (RGB, RGBA...)
  33124. */
  33125. format: number;
  33126. /**
  33127. * Observable called when the texture is loaded
  33128. */
  33129. onLoadedObservable: Observable<InternalTexture>;
  33130. /**
  33131. * Gets the width of the texture
  33132. */
  33133. width: number;
  33134. /**
  33135. * Gets the height of the texture
  33136. */
  33137. height: number;
  33138. /**
  33139. * Gets the depth of the texture
  33140. */
  33141. depth: number;
  33142. /**
  33143. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33144. */
  33145. baseWidth: number;
  33146. /**
  33147. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33148. */
  33149. baseHeight: number;
  33150. /**
  33151. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33152. */
  33153. baseDepth: number;
  33154. /**
  33155. * Gets a boolean indicating if the texture is inverted on Y axis
  33156. */
  33157. invertY: boolean;
  33158. /** @hidden */
  33159. _invertVScale: boolean;
  33160. /** @hidden */
  33161. _associatedChannel: number;
  33162. /** @hidden */
  33163. _source: InternalTextureSource;
  33164. /** @hidden */
  33165. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33166. /** @hidden */
  33167. _bufferView: Nullable<ArrayBufferView>;
  33168. /** @hidden */
  33169. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33170. /** @hidden */
  33171. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33172. /** @hidden */
  33173. _size: number;
  33174. /** @hidden */
  33175. _extension: string;
  33176. /** @hidden */
  33177. _files: Nullable<string[]>;
  33178. /** @hidden */
  33179. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33180. /** @hidden */
  33181. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33182. /** @hidden */
  33183. _framebuffer: Nullable<WebGLFramebuffer>;
  33184. /** @hidden */
  33185. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33186. /** @hidden */
  33187. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33188. /** @hidden */
  33189. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33190. /** @hidden */
  33191. _attachments: Nullable<number[]>;
  33192. /** @hidden */
  33193. _cachedCoordinatesMode: Nullable<number>;
  33194. /** @hidden */
  33195. _cachedWrapU: Nullable<number>;
  33196. /** @hidden */
  33197. _cachedWrapV: Nullable<number>;
  33198. /** @hidden */
  33199. _cachedWrapR: Nullable<number>;
  33200. /** @hidden */
  33201. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33202. /** @hidden */
  33203. _isDisabled: boolean;
  33204. /** @hidden */
  33205. _compression: Nullable<string>;
  33206. /** @hidden */
  33207. _generateStencilBuffer: boolean;
  33208. /** @hidden */
  33209. _generateDepthBuffer: boolean;
  33210. /** @hidden */
  33211. _comparisonFunction: number;
  33212. /** @hidden */
  33213. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33214. /** @hidden */
  33215. _lodGenerationScale: number;
  33216. /** @hidden */
  33217. _lodGenerationOffset: number;
  33218. /** @hidden */
  33219. _depthStencilTexture: Nullable<InternalTexture>;
  33220. /** @hidden */
  33221. _colorTextureArray: Nullable<WebGLTexture>;
  33222. /** @hidden */
  33223. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33224. /** @hidden */
  33225. _lodTextureHigh: Nullable<BaseTexture>;
  33226. /** @hidden */
  33227. _lodTextureMid: Nullable<BaseTexture>;
  33228. /** @hidden */
  33229. _lodTextureLow: Nullable<BaseTexture>;
  33230. /** @hidden */
  33231. _isRGBD: boolean;
  33232. /** @hidden */
  33233. _linearSpecularLOD: boolean;
  33234. /** @hidden */
  33235. _irradianceTexture: Nullable<BaseTexture>;
  33236. /** @hidden */
  33237. _webGLTexture: Nullable<WebGLTexture>;
  33238. /** @hidden */
  33239. _references: number;
  33240. private _engine;
  33241. /**
  33242. * Gets the Engine the texture belongs to.
  33243. * @returns The babylon engine
  33244. */
  33245. getEngine(): ThinEngine;
  33246. /**
  33247. * Gets the data source type of the texture
  33248. */
  33249. get source(): InternalTextureSource;
  33250. /**
  33251. * Creates a new InternalTexture
  33252. * @param engine defines the engine to use
  33253. * @param source defines the type of data that will be used
  33254. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33255. */
  33256. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33257. /**
  33258. * Increments the number of references (ie. the number of Texture that point to it)
  33259. */
  33260. incrementReferences(): void;
  33261. /**
  33262. * Change the size of the texture (not the size of the content)
  33263. * @param width defines the new width
  33264. * @param height defines the new height
  33265. * @param depth defines the new depth (1 by default)
  33266. */
  33267. updateSize(width: int, height: int, depth?: int): void;
  33268. /** @hidden */
  33269. _rebuild(): void;
  33270. /** @hidden */
  33271. _swapAndDie(target: InternalTexture): void;
  33272. /**
  33273. * Dispose the current allocated resources
  33274. */
  33275. dispose(): void;
  33276. }
  33277. }
  33278. declare module "babylonjs/Audio/analyser" {
  33279. import { Scene } from "babylonjs/scene";
  33280. /**
  33281. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33283. */
  33284. export class Analyser {
  33285. /**
  33286. * Gets or sets the smoothing
  33287. * @ignorenaming
  33288. */
  33289. SMOOTHING: number;
  33290. /**
  33291. * Gets or sets the FFT table size
  33292. * @ignorenaming
  33293. */
  33294. FFT_SIZE: number;
  33295. /**
  33296. * Gets or sets the bar graph amplitude
  33297. * @ignorenaming
  33298. */
  33299. BARGRAPHAMPLITUDE: number;
  33300. /**
  33301. * Gets or sets the position of the debug canvas
  33302. * @ignorenaming
  33303. */
  33304. DEBUGCANVASPOS: {
  33305. x: number;
  33306. y: number;
  33307. };
  33308. /**
  33309. * Gets or sets the debug canvas size
  33310. * @ignorenaming
  33311. */
  33312. DEBUGCANVASSIZE: {
  33313. width: number;
  33314. height: number;
  33315. };
  33316. private _byteFreqs;
  33317. private _byteTime;
  33318. private _floatFreqs;
  33319. private _webAudioAnalyser;
  33320. private _debugCanvas;
  33321. private _debugCanvasContext;
  33322. private _scene;
  33323. private _registerFunc;
  33324. private _audioEngine;
  33325. /**
  33326. * Creates a new analyser
  33327. * @param scene defines hosting scene
  33328. */
  33329. constructor(scene: Scene);
  33330. /**
  33331. * Get the number of data values you will have to play with for the visualization
  33332. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33333. * @returns a number
  33334. */
  33335. getFrequencyBinCount(): number;
  33336. /**
  33337. * Gets the current frequency data as a byte array
  33338. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33339. * @returns a Uint8Array
  33340. */
  33341. getByteFrequencyData(): Uint8Array;
  33342. /**
  33343. * Gets the current waveform as a byte array
  33344. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33345. * @returns a Uint8Array
  33346. */
  33347. getByteTimeDomainData(): Uint8Array;
  33348. /**
  33349. * Gets the current frequency data as a float array
  33350. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33351. * @returns a Float32Array
  33352. */
  33353. getFloatFrequencyData(): Float32Array;
  33354. /**
  33355. * Renders the debug canvas
  33356. */
  33357. drawDebugCanvas(): void;
  33358. /**
  33359. * Stops rendering the debug canvas and removes it
  33360. */
  33361. stopDebugCanvas(): void;
  33362. /**
  33363. * Connects two audio nodes
  33364. * @param inputAudioNode defines first node to connect
  33365. * @param outputAudioNode defines second node to connect
  33366. */
  33367. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33368. /**
  33369. * Releases all associated resources
  33370. */
  33371. dispose(): void;
  33372. }
  33373. }
  33374. declare module "babylonjs/Audio/audioEngine" {
  33375. import { IDisposable } from "babylonjs/scene";
  33376. import { Analyser } from "babylonjs/Audio/analyser";
  33377. import { Nullable } from "babylonjs/types";
  33378. import { Observable } from "babylonjs/Misc/observable";
  33379. /**
  33380. * This represents an audio engine and it is responsible
  33381. * to play, synchronize and analyse sounds throughout the application.
  33382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33383. */
  33384. export interface IAudioEngine extends IDisposable {
  33385. /**
  33386. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33387. */
  33388. readonly canUseWebAudio: boolean;
  33389. /**
  33390. * Gets the current AudioContext if available.
  33391. */
  33392. readonly audioContext: Nullable<AudioContext>;
  33393. /**
  33394. * The master gain node defines the global audio volume of your audio engine.
  33395. */
  33396. readonly masterGain: GainNode;
  33397. /**
  33398. * Gets whether or not mp3 are supported by your browser.
  33399. */
  33400. readonly isMP3supported: boolean;
  33401. /**
  33402. * Gets whether or not ogg are supported by your browser.
  33403. */
  33404. readonly isOGGsupported: boolean;
  33405. /**
  33406. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33407. * @ignoreNaming
  33408. */
  33409. WarnedWebAudioUnsupported: boolean;
  33410. /**
  33411. * Defines if the audio engine relies on a custom unlocked button.
  33412. * In this case, the embedded button will not be displayed.
  33413. */
  33414. useCustomUnlockedButton: boolean;
  33415. /**
  33416. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33417. */
  33418. readonly unlocked: boolean;
  33419. /**
  33420. * Event raised when audio has been unlocked on the browser.
  33421. */
  33422. onAudioUnlockedObservable: Observable<AudioEngine>;
  33423. /**
  33424. * Event raised when audio has been locked on the browser.
  33425. */
  33426. onAudioLockedObservable: Observable<AudioEngine>;
  33427. /**
  33428. * Flags the audio engine in Locked state.
  33429. * This happens due to new browser policies preventing audio to autoplay.
  33430. */
  33431. lock(): void;
  33432. /**
  33433. * Unlocks the audio engine once a user action has been done on the dom.
  33434. * This is helpful to resume play once browser policies have been satisfied.
  33435. */
  33436. unlock(): void;
  33437. }
  33438. /**
  33439. * This represents the default audio engine used in babylon.
  33440. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33442. */
  33443. export class AudioEngine implements IAudioEngine {
  33444. private _audioContext;
  33445. private _audioContextInitialized;
  33446. private _muteButton;
  33447. private _hostElement;
  33448. /**
  33449. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33450. */
  33451. canUseWebAudio: boolean;
  33452. /**
  33453. * The master gain node defines the global audio volume of your audio engine.
  33454. */
  33455. masterGain: GainNode;
  33456. /**
  33457. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33458. * @ignoreNaming
  33459. */
  33460. WarnedWebAudioUnsupported: boolean;
  33461. /**
  33462. * Gets whether or not mp3 are supported by your browser.
  33463. */
  33464. isMP3supported: boolean;
  33465. /**
  33466. * Gets whether or not ogg are supported by your browser.
  33467. */
  33468. isOGGsupported: boolean;
  33469. /**
  33470. * Gets whether audio has been unlocked on the device.
  33471. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33472. * a user interaction has happened.
  33473. */
  33474. unlocked: boolean;
  33475. /**
  33476. * Defines if the audio engine relies on a custom unlocked button.
  33477. * In this case, the embedded button will not be displayed.
  33478. */
  33479. useCustomUnlockedButton: boolean;
  33480. /**
  33481. * Event raised when audio has been unlocked on the browser.
  33482. */
  33483. onAudioUnlockedObservable: Observable<AudioEngine>;
  33484. /**
  33485. * Event raised when audio has been locked on the browser.
  33486. */
  33487. onAudioLockedObservable: Observable<AudioEngine>;
  33488. /**
  33489. * Gets the current AudioContext if available.
  33490. */
  33491. get audioContext(): Nullable<AudioContext>;
  33492. private _connectedAnalyser;
  33493. /**
  33494. * Instantiates a new audio engine.
  33495. *
  33496. * There should be only one per page as some browsers restrict the number
  33497. * of audio contexts you can create.
  33498. * @param hostElement defines the host element where to display the mute icon if necessary
  33499. */
  33500. constructor(hostElement?: Nullable<HTMLElement>);
  33501. /**
  33502. * Flags the audio engine in Locked state.
  33503. * This happens due to new browser policies preventing audio to autoplay.
  33504. */
  33505. lock(): void;
  33506. /**
  33507. * Unlocks the audio engine once a user action has been done on the dom.
  33508. * This is helpful to resume play once browser policies have been satisfied.
  33509. */
  33510. unlock(): void;
  33511. private _resumeAudioContext;
  33512. private _initializeAudioContext;
  33513. private _tryToRun;
  33514. private _triggerRunningState;
  33515. private _triggerSuspendedState;
  33516. private _displayMuteButton;
  33517. private _moveButtonToTopLeft;
  33518. private _onResize;
  33519. private _hideMuteButton;
  33520. /**
  33521. * Destroy and release the resources associated with the audio ccontext.
  33522. */
  33523. dispose(): void;
  33524. /**
  33525. * Gets the global volume sets on the master gain.
  33526. * @returns the global volume if set or -1 otherwise
  33527. */
  33528. getGlobalVolume(): number;
  33529. /**
  33530. * Sets the global volume of your experience (sets on the master gain).
  33531. * @param newVolume Defines the new global volume of the application
  33532. */
  33533. setGlobalVolume(newVolume: number): void;
  33534. /**
  33535. * Connect the audio engine to an audio analyser allowing some amazing
  33536. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33538. * @param analyser The analyser to connect to the engine
  33539. */
  33540. connectToAnalyser(analyser: Analyser): void;
  33541. }
  33542. }
  33543. declare module "babylonjs/Loading/loadingScreen" {
  33544. /**
  33545. * Interface used to present a loading screen while loading a scene
  33546. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33547. */
  33548. export interface ILoadingScreen {
  33549. /**
  33550. * Function called to display the loading screen
  33551. */
  33552. displayLoadingUI: () => void;
  33553. /**
  33554. * Function called to hide the loading screen
  33555. */
  33556. hideLoadingUI: () => void;
  33557. /**
  33558. * Gets or sets the color to use for the background
  33559. */
  33560. loadingUIBackgroundColor: string;
  33561. /**
  33562. * Gets or sets the text to display while loading
  33563. */
  33564. loadingUIText: string;
  33565. }
  33566. /**
  33567. * Class used for the default loading screen
  33568. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33569. */
  33570. export class DefaultLoadingScreen implements ILoadingScreen {
  33571. private _renderingCanvas;
  33572. private _loadingText;
  33573. private _loadingDivBackgroundColor;
  33574. private _loadingDiv;
  33575. private _loadingTextDiv;
  33576. /** Gets or sets the logo url to use for the default loading screen */
  33577. static DefaultLogoUrl: string;
  33578. /** Gets or sets the spinner url to use for the default loading screen */
  33579. static DefaultSpinnerUrl: string;
  33580. /**
  33581. * Creates a new default loading screen
  33582. * @param _renderingCanvas defines the canvas used to render the scene
  33583. * @param _loadingText defines the default text to display
  33584. * @param _loadingDivBackgroundColor defines the default background color
  33585. */
  33586. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33587. /**
  33588. * Function called to display the loading screen
  33589. */
  33590. displayLoadingUI(): void;
  33591. /**
  33592. * Function called to hide the loading screen
  33593. */
  33594. hideLoadingUI(): void;
  33595. /**
  33596. * Gets or sets the text to display while loading
  33597. */
  33598. set loadingUIText(text: string);
  33599. get loadingUIText(): string;
  33600. /**
  33601. * Gets or sets the color to use for the background
  33602. */
  33603. get loadingUIBackgroundColor(): string;
  33604. set loadingUIBackgroundColor(color: string);
  33605. private _resizeLoadingUI;
  33606. }
  33607. }
  33608. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33609. /**
  33610. * Interface for any object that can request an animation frame
  33611. */
  33612. export interface ICustomAnimationFrameRequester {
  33613. /**
  33614. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33615. */
  33616. renderFunction?: Function;
  33617. /**
  33618. * Called to request the next frame to render to
  33619. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33620. */
  33621. requestAnimationFrame: Function;
  33622. /**
  33623. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33624. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33625. */
  33626. requestID?: number;
  33627. }
  33628. }
  33629. declare module "babylonjs/Misc/performanceMonitor" {
  33630. /**
  33631. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33632. */
  33633. export class PerformanceMonitor {
  33634. private _enabled;
  33635. private _rollingFrameTime;
  33636. private _lastFrameTimeMs;
  33637. /**
  33638. * constructor
  33639. * @param frameSampleSize The number of samples required to saturate the sliding window
  33640. */
  33641. constructor(frameSampleSize?: number);
  33642. /**
  33643. * Samples current frame
  33644. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33645. */
  33646. sampleFrame(timeMs?: number): void;
  33647. /**
  33648. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33649. */
  33650. get averageFrameTime(): number;
  33651. /**
  33652. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33653. */
  33654. get averageFrameTimeVariance(): number;
  33655. /**
  33656. * Returns the frame time of the most recent frame
  33657. */
  33658. get instantaneousFrameTime(): number;
  33659. /**
  33660. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33661. */
  33662. get averageFPS(): number;
  33663. /**
  33664. * Returns the average framerate in frames per second using the most recent frame time
  33665. */
  33666. get instantaneousFPS(): number;
  33667. /**
  33668. * Returns true if enough samples have been taken to completely fill the sliding window
  33669. */
  33670. get isSaturated(): boolean;
  33671. /**
  33672. * Enables contributions to the sliding window sample set
  33673. */
  33674. enable(): void;
  33675. /**
  33676. * Disables contributions to the sliding window sample set
  33677. * Samples will not be interpolated over the disabled period
  33678. */
  33679. disable(): void;
  33680. /**
  33681. * Returns true if sampling is enabled
  33682. */
  33683. get isEnabled(): boolean;
  33684. /**
  33685. * Resets performance monitor
  33686. */
  33687. reset(): void;
  33688. }
  33689. /**
  33690. * RollingAverage
  33691. *
  33692. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33693. */
  33694. export class RollingAverage {
  33695. /**
  33696. * Current average
  33697. */
  33698. average: number;
  33699. /**
  33700. * Current variance
  33701. */
  33702. variance: number;
  33703. protected _samples: Array<number>;
  33704. protected _sampleCount: number;
  33705. protected _pos: number;
  33706. protected _m2: number;
  33707. /**
  33708. * constructor
  33709. * @param length The number of samples required to saturate the sliding window
  33710. */
  33711. constructor(length: number);
  33712. /**
  33713. * Adds a sample to the sample set
  33714. * @param v The sample value
  33715. */
  33716. add(v: number): void;
  33717. /**
  33718. * Returns previously added values or null if outside of history or outside the sliding window domain
  33719. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33720. * @return Value previously recorded with add() or null if outside of range
  33721. */
  33722. history(i: number): number;
  33723. /**
  33724. * Returns true if enough samples have been taken to completely fill the sliding window
  33725. * @return true if sample-set saturated
  33726. */
  33727. isSaturated(): boolean;
  33728. /**
  33729. * Resets the rolling average (equivalent to 0 samples taken so far)
  33730. */
  33731. reset(): void;
  33732. /**
  33733. * Wraps a value around the sample range boundaries
  33734. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33735. * @return Wrapped position in sample range
  33736. */
  33737. protected _wrapPosition(i: number): number;
  33738. }
  33739. }
  33740. declare module "babylonjs/Misc/perfCounter" {
  33741. /**
  33742. * This class is used to track a performance counter which is number based.
  33743. * The user has access to many properties which give statistics of different nature.
  33744. *
  33745. * The implementer can track two kinds of Performance Counter: time and count.
  33746. * 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.
  33747. * 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.
  33748. */
  33749. export class PerfCounter {
  33750. /**
  33751. * Gets or sets a global boolean to turn on and off all the counters
  33752. */
  33753. static Enabled: boolean;
  33754. /**
  33755. * Returns the smallest value ever
  33756. */
  33757. get min(): number;
  33758. /**
  33759. * Returns the biggest value ever
  33760. */
  33761. get max(): number;
  33762. /**
  33763. * Returns the average value since the performance counter is running
  33764. */
  33765. get average(): number;
  33766. /**
  33767. * Returns the average value of the last second the counter was monitored
  33768. */
  33769. get lastSecAverage(): number;
  33770. /**
  33771. * Returns the current value
  33772. */
  33773. get current(): number;
  33774. /**
  33775. * Gets the accumulated total
  33776. */
  33777. get total(): number;
  33778. /**
  33779. * Gets the total value count
  33780. */
  33781. get count(): number;
  33782. /**
  33783. * Creates a new counter
  33784. */
  33785. constructor();
  33786. /**
  33787. * Call this method to start monitoring a new frame.
  33788. * 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.
  33789. */
  33790. fetchNewFrame(): void;
  33791. /**
  33792. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33793. * @param newCount the count value to add to the monitored count
  33794. * @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.
  33795. */
  33796. addCount(newCount: number, fetchResult: boolean): void;
  33797. /**
  33798. * Start monitoring this performance counter
  33799. */
  33800. beginMonitoring(): void;
  33801. /**
  33802. * Compute the time lapsed since the previous beginMonitoring() call.
  33803. * @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
  33804. */
  33805. endMonitoring(newFrame?: boolean): void;
  33806. private _fetchResult;
  33807. private _startMonitoringTime;
  33808. private _min;
  33809. private _max;
  33810. private _average;
  33811. private _current;
  33812. private _totalValueCount;
  33813. private _totalAccumulated;
  33814. private _lastSecAverage;
  33815. private _lastSecAccumulated;
  33816. private _lastSecTime;
  33817. private _lastSecValueCount;
  33818. }
  33819. }
  33820. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33821. module "babylonjs/Engines/thinEngine" {
  33822. interface ThinEngine {
  33823. /**
  33824. * Sets alpha constants used by some alpha blending modes
  33825. * @param r defines the red component
  33826. * @param g defines the green component
  33827. * @param b defines the blue component
  33828. * @param a defines the alpha component
  33829. */
  33830. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33831. /**
  33832. * Sets the current alpha mode
  33833. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33834. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33835. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33836. */
  33837. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33838. /**
  33839. * Gets the current alpha mode
  33840. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33841. * @returns the current alpha mode
  33842. */
  33843. getAlphaMode(): number;
  33844. /**
  33845. * Sets the current alpha equation
  33846. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33847. */
  33848. setAlphaEquation(equation: number): void;
  33849. /**
  33850. * Gets the current alpha equation.
  33851. * @returns the current alpha equation
  33852. */
  33853. getAlphaEquation(): number;
  33854. }
  33855. }
  33856. }
  33857. declare module "babylonjs/Engines/engine" {
  33858. import { Observable } from "babylonjs/Misc/observable";
  33859. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33860. import { Scene } from "babylonjs/scene";
  33861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33862. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33863. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33864. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33865. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33866. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33867. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33868. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33869. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33870. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33871. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33872. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33873. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33874. import "babylonjs/Engines/Extensions/engine.alpha";
  33875. import { Material } from "babylonjs/Materials/material";
  33876. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33877. /**
  33878. * Defines the interface used by display changed events
  33879. */
  33880. export interface IDisplayChangedEventArgs {
  33881. /** Gets the vrDisplay object (if any) */
  33882. vrDisplay: Nullable<any>;
  33883. /** Gets a boolean indicating if webVR is supported */
  33884. vrSupported: boolean;
  33885. }
  33886. /**
  33887. * Defines the interface used by objects containing a viewport (like a camera)
  33888. */
  33889. interface IViewportOwnerLike {
  33890. /**
  33891. * Gets or sets the viewport
  33892. */
  33893. viewport: IViewportLike;
  33894. }
  33895. /**
  33896. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33897. */
  33898. export class Engine extends ThinEngine {
  33899. /** Defines that alpha blending is disabled */
  33900. static readonly ALPHA_DISABLE: number;
  33901. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33902. static readonly ALPHA_ADD: number;
  33903. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33904. static readonly ALPHA_COMBINE: number;
  33905. /** Defines that alpha blending to DEST - SRC * DEST */
  33906. static readonly ALPHA_SUBTRACT: number;
  33907. /** Defines that alpha blending to SRC * DEST */
  33908. static readonly ALPHA_MULTIPLY: number;
  33909. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33910. static readonly ALPHA_MAXIMIZED: number;
  33911. /** Defines that alpha blending to SRC + DEST */
  33912. static readonly ALPHA_ONEONE: number;
  33913. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33914. static readonly ALPHA_PREMULTIPLIED: number;
  33915. /**
  33916. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33917. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33918. */
  33919. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33920. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33921. static readonly ALPHA_INTERPOLATE: number;
  33922. /**
  33923. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33924. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33925. */
  33926. static readonly ALPHA_SCREENMODE: number;
  33927. /** Defines that the ressource is not delayed*/
  33928. static readonly DELAYLOADSTATE_NONE: number;
  33929. /** Defines that the ressource was successfully delay loaded */
  33930. static readonly DELAYLOADSTATE_LOADED: number;
  33931. /** Defines that the ressource is currently delay loading */
  33932. static readonly DELAYLOADSTATE_LOADING: number;
  33933. /** Defines that the ressource is delayed and has not started loading */
  33934. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33935. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33936. static readonly NEVER: number;
  33937. /** 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 */
  33938. static readonly ALWAYS: number;
  33939. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33940. static readonly LESS: number;
  33941. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33942. static readonly EQUAL: number;
  33943. /** 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 */
  33944. static readonly LEQUAL: number;
  33945. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33946. static readonly GREATER: number;
  33947. /** 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 */
  33948. static readonly GEQUAL: number;
  33949. /** 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 */
  33950. static readonly NOTEQUAL: number;
  33951. /** Passed to stencilOperation to specify that stencil value must be kept */
  33952. static readonly KEEP: number;
  33953. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33954. static readonly REPLACE: number;
  33955. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33956. static readonly INCR: number;
  33957. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33958. static readonly DECR: number;
  33959. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33960. static readonly INVERT: number;
  33961. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33962. static readonly INCR_WRAP: number;
  33963. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33964. static readonly DECR_WRAP: number;
  33965. /** Texture is not repeating outside of 0..1 UVs */
  33966. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33967. /** Texture is repeating outside of 0..1 UVs */
  33968. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33969. /** Texture is repeating and mirrored */
  33970. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33971. /** ALPHA */
  33972. static readonly TEXTUREFORMAT_ALPHA: number;
  33973. /** LUMINANCE */
  33974. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33975. /** LUMINANCE_ALPHA */
  33976. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33977. /** RGB */
  33978. static readonly TEXTUREFORMAT_RGB: number;
  33979. /** RGBA */
  33980. static readonly TEXTUREFORMAT_RGBA: number;
  33981. /** RED */
  33982. static readonly TEXTUREFORMAT_RED: number;
  33983. /** RED (2nd reference) */
  33984. static readonly TEXTUREFORMAT_R: number;
  33985. /** RG */
  33986. static readonly TEXTUREFORMAT_RG: number;
  33987. /** RED_INTEGER */
  33988. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33989. /** RED_INTEGER (2nd reference) */
  33990. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33991. /** RG_INTEGER */
  33992. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33993. /** RGB_INTEGER */
  33994. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33995. /** RGBA_INTEGER */
  33996. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33997. /** UNSIGNED_BYTE */
  33998. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33999. /** UNSIGNED_BYTE (2nd reference) */
  34000. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34001. /** FLOAT */
  34002. static readonly TEXTURETYPE_FLOAT: number;
  34003. /** HALF_FLOAT */
  34004. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34005. /** BYTE */
  34006. static readonly TEXTURETYPE_BYTE: number;
  34007. /** SHORT */
  34008. static readonly TEXTURETYPE_SHORT: number;
  34009. /** UNSIGNED_SHORT */
  34010. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34011. /** INT */
  34012. static readonly TEXTURETYPE_INT: number;
  34013. /** UNSIGNED_INT */
  34014. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34015. /** UNSIGNED_SHORT_4_4_4_4 */
  34016. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34017. /** UNSIGNED_SHORT_5_5_5_1 */
  34018. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34019. /** UNSIGNED_SHORT_5_6_5 */
  34020. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34021. /** UNSIGNED_INT_2_10_10_10_REV */
  34022. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34023. /** UNSIGNED_INT_24_8 */
  34024. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34025. /** UNSIGNED_INT_10F_11F_11F_REV */
  34026. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34027. /** UNSIGNED_INT_5_9_9_9_REV */
  34028. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34029. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34030. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34031. /** nearest is mag = nearest and min = nearest and mip = linear */
  34032. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34033. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34034. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34035. /** Trilinear is mag = linear and min = linear and mip = linear */
  34036. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34037. /** nearest is mag = nearest and min = nearest and mip = linear */
  34038. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34039. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34040. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34041. /** Trilinear is mag = linear and min = linear and mip = linear */
  34042. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34043. /** mag = nearest and min = nearest and mip = nearest */
  34044. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34045. /** mag = nearest and min = linear and mip = nearest */
  34046. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34047. /** mag = nearest and min = linear and mip = linear */
  34048. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34049. /** mag = nearest and min = linear and mip = none */
  34050. static readonly TEXTURE_NEAREST_LINEAR: number;
  34051. /** mag = nearest and min = nearest and mip = none */
  34052. static readonly TEXTURE_NEAREST_NEAREST: number;
  34053. /** mag = linear and min = nearest and mip = nearest */
  34054. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34055. /** mag = linear and min = nearest and mip = linear */
  34056. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34057. /** mag = linear and min = linear and mip = none */
  34058. static readonly TEXTURE_LINEAR_LINEAR: number;
  34059. /** mag = linear and min = nearest and mip = none */
  34060. static readonly TEXTURE_LINEAR_NEAREST: number;
  34061. /** Explicit coordinates mode */
  34062. static readonly TEXTURE_EXPLICIT_MODE: number;
  34063. /** Spherical coordinates mode */
  34064. static readonly TEXTURE_SPHERICAL_MODE: number;
  34065. /** Planar coordinates mode */
  34066. static readonly TEXTURE_PLANAR_MODE: number;
  34067. /** Cubic coordinates mode */
  34068. static readonly TEXTURE_CUBIC_MODE: number;
  34069. /** Projection coordinates mode */
  34070. static readonly TEXTURE_PROJECTION_MODE: number;
  34071. /** Skybox coordinates mode */
  34072. static readonly TEXTURE_SKYBOX_MODE: number;
  34073. /** Inverse Cubic coordinates mode */
  34074. static readonly TEXTURE_INVCUBIC_MODE: number;
  34075. /** Equirectangular coordinates mode */
  34076. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34077. /** Equirectangular Fixed coordinates mode */
  34078. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34079. /** Equirectangular Fixed Mirrored coordinates mode */
  34080. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34081. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34082. static readonly SCALEMODE_FLOOR: number;
  34083. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34084. static readonly SCALEMODE_NEAREST: number;
  34085. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34086. static readonly SCALEMODE_CEILING: number;
  34087. /**
  34088. * Returns the current npm package of the sdk
  34089. */
  34090. static get NpmPackage(): string;
  34091. /**
  34092. * Returns the current version of the framework
  34093. */
  34094. static get Version(): string;
  34095. /** Gets the list of created engines */
  34096. static get Instances(): Engine[];
  34097. /**
  34098. * Gets the latest created engine
  34099. */
  34100. static get LastCreatedEngine(): Nullable<Engine>;
  34101. /**
  34102. * Gets the latest created scene
  34103. */
  34104. static get LastCreatedScene(): Nullable<Scene>;
  34105. /**
  34106. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34107. * @param flag defines which part of the materials must be marked as dirty
  34108. * @param predicate defines a predicate used to filter which materials should be affected
  34109. */
  34110. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34111. /**
  34112. * Method called to create the default loading screen.
  34113. * This can be overriden in your own app.
  34114. * @param canvas The rendering canvas element
  34115. * @returns The loading screen
  34116. */
  34117. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34118. /**
  34119. * Method called to create the default rescale post process on each engine.
  34120. */
  34121. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34122. /**
  34123. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34124. **/
  34125. enableOfflineSupport: boolean;
  34126. /**
  34127. * 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)
  34128. **/
  34129. disableManifestCheck: boolean;
  34130. /**
  34131. * Gets the list of created scenes
  34132. */
  34133. scenes: Scene[];
  34134. /**
  34135. * Event raised when a new scene is created
  34136. */
  34137. onNewSceneAddedObservable: Observable<Scene>;
  34138. /**
  34139. * Gets the list of created postprocesses
  34140. */
  34141. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34142. /**
  34143. * Gets a boolean indicating if the pointer is currently locked
  34144. */
  34145. isPointerLock: boolean;
  34146. /**
  34147. * Observable event triggered each time the rendering canvas is resized
  34148. */
  34149. onResizeObservable: Observable<Engine>;
  34150. /**
  34151. * Observable event triggered each time the canvas loses focus
  34152. */
  34153. onCanvasBlurObservable: Observable<Engine>;
  34154. /**
  34155. * Observable event triggered each time the canvas gains focus
  34156. */
  34157. onCanvasFocusObservable: Observable<Engine>;
  34158. /**
  34159. * Observable event triggered each time the canvas receives pointerout event
  34160. */
  34161. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34162. /**
  34163. * Observable raised when the engine begins a new frame
  34164. */
  34165. onBeginFrameObservable: Observable<Engine>;
  34166. /**
  34167. * If set, will be used to request the next animation frame for the render loop
  34168. */
  34169. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34170. /**
  34171. * Observable raised when the engine ends the current frame
  34172. */
  34173. onEndFrameObservable: Observable<Engine>;
  34174. /**
  34175. * Observable raised when the engine is about to compile a shader
  34176. */
  34177. onBeforeShaderCompilationObservable: Observable<Engine>;
  34178. /**
  34179. * Observable raised when the engine has jsut compiled a shader
  34180. */
  34181. onAfterShaderCompilationObservable: Observable<Engine>;
  34182. /**
  34183. * Gets the audio engine
  34184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34185. * @ignorenaming
  34186. */
  34187. static audioEngine: IAudioEngine;
  34188. /**
  34189. * Default AudioEngine factory responsible of creating the Audio Engine.
  34190. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34191. */
  34192. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34193. /**
  34194. * Default offline support factory responsible of creating a tool used to store data locally.
  34195. * By default, this will create a Database object if the workload has been embedded.
  34196. */
  34197. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34198. private _loadingScreen;
  34199. private _pointerLockRequested;
  34200. private _dummyFramebuffer;
  34201. private _rescalePostProcess;
  34202. private _deterministicLockstep;
  34203. private _lockstepMaxSteps;
  34204. private _timeStep;
  34205. protected get _supportsHardwareTextureRescaling(): boolean;
  34206. private _fps;
  34207. private _deltaTime;
  34208. /** @hidden */
  34209. _drawCalls: PerfCounter;
  34210. /**
  34211. * Turn this value on if you want to pause FPS computation when in background
  34212. */
  34213. disablePerformanceMonitorInBackground: boolean;
  34214. private _performanceMonitor;
  34215. /**
  34216. * Gets the performance monitor attached to this engine
  34217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34218. */
  34219. get performanceMonitor(): PerformanceMonitor;
  34220. private _onFocus;
  34221. private _onBlur;
  34222. private _onCanvasPointerOut;
  34223. private _onCanvasBlur;
  34224. private _onCanvasFocus;
  34225. private _onFullscreenChange;
  34226. private _onPointerLockChange;
  34227. /**
  34228. * Gets the HTML element used to attach event listeners
  34229. * @returns a HTML element
  34230. */
  34231. getInputElement(): Nullable<HTMLElement>;
  34232. /**
  34233. * Creates a new engine
  34234. * @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
  34235. * @param antialias defines enable antialiasing (default: false)
  34236. * @param options defines further options to be sent to the getContext() function
  34237. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34238. */
  34239. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34240. /**
  34241. * Gets current aspect ratio
  34242. * @param viewportOwner defines the camera to use to get the aspect ratio
  34243. * @param useScreen defines if screen size must be used (or the current render target if any)
  34244. * @returns a number defining the aspect ratio
  34245. */
  34246. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34247. /**
  34248. * Gets current screen aspect ratio
  34249. * @returns a number defining the aspect ratio
  34250. */
  34251. getScreenAspectRatio(): number;
  34252. /**
  34253. * Gets the client rect of the HTML canvas attached with the current webGL context
  34254. * @returns a client rectanglee
  34255. */
  34256. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34257. /**
  34258. * Gets the client rect of the HTML element used for events
  34259. * @returns a client rectanglee
  34260. */
  34261. getInputElementClientRect(): Nullable<ClientRect>;
  34262. /**
  34263. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34264. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34265. * @returns true if engine is in deterministic lock step mode
  34266. */
  34267. isDeterministicLockStep(): boolean;
  34268. /**
  34269. * Gets the max steps when engine is running in deterministic lock step
  34270. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34271. * @returns the max steps
  34272. */
  34273. getLockstepMaxSteps(): number;
  34274. /**
  34275. * Returns the time in ms between steps when using deterministic lock step.
  34276. * @returns time step in (ms)
  34277. */
  34278. getTimeStep(): number;
  34279. /**
  34280. * Force the mipmap generation for the given render target texture
  34281. * @param texture defines the render target texture to use
  34282. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34283. */
  34284. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34285. /** States */
  34286. /**
  34287. * Set various states to the webGL context
  34288. * @param culling defines backface culling state
  34289. * @param zOffset defines the value to apply to zOffset (0 by default)
  34290. * @param force defines if states must be applied even if cache is up to date
  34291. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34292. */
  34293. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34294. /**
  34295. * Set the z offset to apply to current rendering
  34296. * @param value defines the offset to apply
  34297. */
  34298. setZOffset(value: number): void;
  34299. /**
  34300. * Gets the current value of the zOffset
  34301. * @returns the current zOffset state
  34302. */
  34303. getZOffset(): number;
  34304. /**
  34305. * Enable or disable depth buffering
  34306. * @param enable defines the state to set
  34307. */
  34308. setDepthBuffer(enable: boolean): void;
  34309. /**
  34310. * Gets a boolean indicating if depth writing is enabled
  34311. * @returns the current depth writing state
  34312. */
  34313. getDepthWrite(): boolean;
  34314. /**
  34315. * Enable or disable depth writing
  34316. * @param enable defines the state to set
  34317. */
  34318. setDepthWrite(enable: boolean): void;
  34319. /**
  34320. * Gets a boolean indicating if stencil buffer is enabled
  34321. * @returns the current stencil buffer state
  34322. */
  34323. getStencilBuffer(): boolean;
  34324. /**
  34325. * Enable or disable the stencil buffer
  34326. * @param enable defines if the stencil buffer must be enabled or disabled
  34327. */
  34328. setStencilBuffer(enable: boolean): void;
  34329. /**
  34330. * Gets the current stencil mask
  34331. * @returns a number defining the new stencil mask to use
  34332. */
  34333. getStencilMask(): number;
  34334. /**
  34335. * Sets the current stencil mask
  34336. * @param mask defines the new stencil mask to use
  34337. */
  34338. setStencilMask(mask: number): void;
  34339. /**
  34340. * Gets the current stencil function
  34341. * @returns a number defining the stencil function to use
  34342. */
  34343. getStencilFunction(): number;
  34344. /**
  34345. * Gets the current stencil reference value
  34346. * @returns a number defining the stencil reference value to use
  34347. */
  34348. getStencilFunctionReference(): number;
  34349. /**
  34350. * Gets the current stencil mask
  34351. * @returns a number defining the stencil mask to use
  34352. */
  34353. getStencilFunctionMask(): number;
  34354. /**
  34355. * Sets the current stencil function
  34356. * @param stencilFunc defines the new stencil function to use
  34357. */
  34358. setStencilFunction(stencilFunc: number): void;
  34359. /**
  34360. * Sets the current stencil reference
  34361. * @param reference defines the new stencil reference to use
  34362. */
  34363. setStencilFunctionReference(reference: number): void;
  34364. /**
  34365. * Sets the current stencil mask
  34366. * @param mask defines the new stencil mask to use
  34367. */
  34368. setStencilFunctionMask(mask: number): void;
  34369. /**
  34370. * Gets the current stencil operation when stencil fails
  34371. * @returns a number defining stencil operation to use when stencil fails
  34372. */
  34373. getStencilOperationFail(): number;
  34374. /**
  34375. * Gets the current stencil operation when depth fails
  34376. * @returns a number defining stencil operation to use when depth fails
  34377. */
  34378. getStencilOperationDepthFail(): number;
  34379. /**
  34380. * Gets the current stencil operation when stencil passes
  34381. * @returns a number defining stencil operation to use when stencil passes
  34382. */
  34383. getStencilOperationPass(): number;
  34384. /**
  34385. * Sets the stencil operation to use when stencil fails
  34386. * @param operation defines the stencil operation to use when stencil fails
  34387. */
  34388. setStencilOperationFail(operation: number): void;
  34389. /**
  34390. * Sets the stencil operation to use when depth fails
  34391. * @param operation defines the stencil operation to use when depth fails
  34392. */
  34393. setStencilOperationDepthFail(operation: number): void;
  34394. /**
  34395. * Sets the stencil operation to use when stencil passes
  34396. * @param operation defines the stencil operation to use when stencil passes
  34397. */
  34398. setStencilOperationPass(operation: number): void;
  34399. /**
  34400. * Sets a boolean indicating if the dithering state is enabled or disabled
  34401. * @param value defines the dithering state
  34402. */
  34403. setDitheringState(value: boolean): void;
  34404. /**
  34405. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34406. * @param value defines the rasterizer state
  34407. */
  34408. setRasterizerState(value: boolean): void;
  34409. /**
  34410. * Gets the current depth function
  34411. * @returns a number defining the depth function
  34412. */
  34413. getDepthFunction(): Nullable<number>;
  34414. /**
  34415. * Sets the current depth function
  34416. * @param depthFunc defines the function to use
  34417. */
  34418. setDepthFunction(depthFunc: number): void;
  34419. /**
  34420. * Sets the current depth function to GREATER
  34421. */
  34422. setDepthFunctionToGreater(): void;
  34423. /**
  34424. * Sets the current depth function to GEQUAL
  34425. */
  34426. setDepthFunctionToGreaterOrEqual(): void;
  34427. /**
  34428. * Sets the current depth function to LESS
  34429. */
  34430. setDepthFunctionToLess(): void;
  34431. /**
  34432. * Sets the current depth function to LEQUAL
  34433. */
  34434. setDepthFunctionToLessOrEqual(): void;
  34435. private _cachedStencilBuffer;
  34436. private _cachedStencilFunction;
  34437. private _cachedStencilMask;
  34438. private _cachedStencilOperationPass;
  34439. private _cachedStencilOperationFail;
  34440. private _cachedStencilOperationDepthFail;
  34441. private _cachedStencilReference;
  34442. /**
  34443. * Caches the the state of the stencil buffer
  34444. */
  34445. cacheStencilState(): void;
  34446. /**
  34447. * Restores the state of the stencil buffer
  34448. */
  34449. restoreStencilState(): void;
  34450. /**
  34451. * Directly set the WebGL Viewport
  34452. * @param x defines the x coordinate of the viewport (in screen space)
  34453. * @param y defines the y coordinate of the viewport (in screen space)
  34454. * @param width defines the width of the viewport (in screen space)
  34455. * @param height defines the height of the viewport (in screen space)
  34456. * @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
  34457. */
  34458. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34459. /**
  34460. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34461. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34462. * @param y defines the y-coordinate of the corner of the clear rectangle
  34463. * @param width defines the width of the clear rectangle
  34464. * @param height defines the height of the clear rectangle
  34465. * @param clearColor defines the clear color
  34466. */
  34467. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34468. /**
  34469. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34470. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34471. * @param y defines the y-coordinate of the corner of the clear rectangle
  34472. * @param width defines the width of the clear rectangle
  34473. * @param height defines the height of the clear rectangle
  34474. */
  34475. enableScissor(x: number, y: number, width: number, height: number): void;
  34476. /**
  34477. * Disable previously set scissor test rectangle
  34478. */
  34479. disableScissor(): void;
  34480. protected _reportDrawCall(): void;
  34481. /**
  34482. * Initializes a webVR display and starts listening to display change events
  34483. * The onVRDisplayChangedObservable will be notified upon these changes
  34484. * @returns The onVRDisplayChangedObservable
  34485. */
  34486. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34487. /** @hidden */
  34488. _prepareVRComponent(): void;
  34489. /** @hidden */
  34490. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34491. /** @hidden */
  34492. _submitVRFrame(): void;
  34493. /**
  34494. * Call this function to leave webVR mode
  34495. * Will do nothing if webVR is not supported or if there is no webVR device
  34496. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34497. */
  34498. disableVR(): void;
  34499. /**
  34500. * Gets a boolean indicating that the system is in VR mode and is presenting
  34501. * @returns true if VR mode is engaged
  34502. */
  34503. isVRPresenting(): boolean;
  34504. /** @hidden */
  34505. _requestVRFrame(): void;
  34506. /** @hidden */
  34507. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34508. /**
  34509. * Gets the source code of the vertex shader associated with a specific webGL program
  34510. * @param program defines the program to use
  34511. * @returns a string containing the source code of the vertex shader associated with the program
  34512. */
  34513. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34514. /**
  34515. * Gets the source code of the fragment shader associated with a specific webGL program
  34516. * @param program defines the program to use
  34517. * @returns a string containing the source code of the fragment shader associated with the program
  34518. */
  34519. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34520. /**
  34521. * Sets a depth stencil texture from a render target to the according uniform.
  34522. * @param channel The texture channel
  34523. * @param uniform The uniform to set
  34524. * @param texture The render target texture containing the depth stencil texture to apply
  34525. */
  34526. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34527. /**
  34528. * Sets a texture to the webGL context from a postprocess
  34529. * @param channel defines the channel to use
  34530. * @param postProcess defines the source postprocess
  34531. */
  34532. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34533. /**
  34534. * Binds the output of the passed in post process to the texture channel specified
  34535. * @param channel The channel the texture should be bound to
  34536. * @param postProcess The post process which's output should be bound
  34537. */
  34538. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34539. /** @hidden */
  34540. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34541. protected _rebuildBuffers(): void;
  34542. /** @hidden */
  34543. _renderFrame(): void;
  34544. _renderLoop(): void;
  34545. /** @hidden */
  34546. _renderViews(): boolean;
  34547. /**
  34548. * Toggle full screen mode
  34549. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34550. */
  34551. switchFullscreen(requestPointerLock: boolean): void;
  34552. /**
  34553. * Enters full screen mode
  34554. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34555. */
  34556. enterFullscreen(requestPointerLock: boolean): void;
  34557. /**
  34558. * Exits full screen mode
  34559. */
  34560. exitFullscreen(): void;
  34561. /**
  34562. * Enters Pointerlock mode
  34563. */
  34564. enterPointerlock(): void;
  34565. /**
  34566. * Exits Pointerlock mode
  34567. */
  34568. exitPointerlock(): void;
  34569. /**
  34570. * Begin a new frame
  34571. */
  34572. beginFrame(): void;
  34573. /**
  34574. * Enf the current frame
  34575. */
  34576. endFrame(): void;
  34577. resize(): void;
  34578. /**
  34579. * Set the compressed texture format to use, based on the formats you have, and the formats
  34580. * supported by the hardware / browser.
  34581. *
  34582. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34583. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34584. * to API arguments needed to compressed textures. This puts the burden on the container
  34585. * generator to house the arcane code for determining these for current & future formats.
  34586. *
  34587. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34588. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34589. *
  34590. * Note: The result of this call is not taken into account when a texture is base64.
  34591. *
  34592. * @param formatsAvailable defines the list of those format families you have created
  34593. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34594. *
  34595. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34596. * @returns The extension selected.
  34597. */
  34598. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34599. /**
  34600. * Set the compressed texture extensions or file names to skip.
  34601. *
  34602. * @param skippedFiles defines the list of those texture files you want to skip
  34603. * Example: [".dds", ".env", "myfile.png"]
  34604. */
  34605. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34606. /**
  34607. * Force a specific size of the canvas
  34608. * @param width defines the new canvas' width
  34609. * @param height defines the new canvas' height
  34610. */
  34611. setSize(width: number, height: number): void;
  34612. /**
  34613. * Updates a dynamic vertex buffer.
  34614. * @param vertexBuffer the vertex buffer to update
  34615. * @param data the data used to update the vertex buffer
  34616. * @param byteOffset the byte offset of the data
  34617. * @param byteLength the byte length of the data
  34618. */
  34619. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34620. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34621. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34622. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34623. _releaseTexture(texture: InternalTexture): void;
  34624. /**
  34625. * @hidden
  34626. * Rescales a texture
  34627. * @param source input texutre
  34628. * @param destination destination texture
  34629. * @param scene scene to use to render the resize
  34630. * @param internalFormat format to use when resizing
  34631. * @param onComplete callback to be called when resize has completed
  34632. */
  34633. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34634. /**
  34635. * Gets the current framerate
  34636. * @returns a number representing the framerate
  34637. */
  34638. getFps(): number;
  34639. /**
  34640. * Gets the time spent between current and previous frame
  34641. * @returns a number representing the delta time in ms
  34642. */
  34643. getDeltaTime(): number;
  34644. private _measureFps;
  34645. /** @hidden */
  34646. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34647. /**
  34648. * Update a dynamic index buffer
  34649. * @param indexBuffer defines the target index buffer
  34650. * @param indices defines the data to update
  34651. * @param offset defines the offset in the target index buffer where update should start
  34652. */
  34653. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34654. /**
  34655. * Updates the sample count of a render target texture
  34656. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34657. * @param texture defines the texture to update
  34658. * @param samples defines the sample count to set
  34659. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34660. */
  34661. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34662. /**
  34663. * Updates a depth texture Comparison Mode and Function.
  34664. * If the comparison Function is equal to 0, the mode will be set to none.
  34665. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34666. * @param texture The texture to set the comparison function for
  34667. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34668. */
  34669. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34670. /**
  34671. * Creates a webGL buffer to use with instanciation
  34672. * @param capacity defines the size of the buffer
  34673. * @returns the webGL buffer
  34674. */
  34675. createInstancesBuffer(capacity: number): DataBuffer;
  34676. /**
  34677. * Delete a webGL buffer used with instanciation
  34678. * @param buffer defines the webGL buffer to delete
  34679. */
  34680. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34681. /** @hidden */
  34682. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34683. dispose(): void;
  34684. private _disableTouchAction;
  34685. /**
  34686. * Display the loading screen
  34687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34688. */
  34689. displayLoadingUI(): void;
  34690. /**
  34691. * Hide the loading screen
  34692. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34693. */
  34694. hideLoadingUI(): void;
  34695. /**
  34696. * Gets the current loading screen object
  34697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34698. */
  34699. get loadingScreen(): ILoadingScreen;
  34700. /**
  34701. * Sets the current loading screen object
  34702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34703. */
  34704. set loadingScreen(loadingScreen: ILoadingScreen);
  34705. /**
  34706. * Sets the current loading screen text
  34707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34708. */
  34709. set loadingUIText(text: string);
  34710. /**
  34711. * Sets the current loading screen background color
  34712. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34713. */
  34714. set loadingUIBackgroundColor(color: string);
  34715. /** Pointerlock and fullscreen */
  34716. /**
  34717. * Ask the browser to promote the current element to pointerlock mode
  34718. * @param element defines the DOM element to promote
  34719. */
  34720. static _RequestPointerlock(element: HTMLElement): void;
  34721. /**
  34722. * Asks the browser to exit pointerlock mode
  34723. */
  34724. static _ExitPointerlock(): void;
  34725. /**
  34726. * Ask the browser to promote the current element to fullscreen rendering mode
  34727. * @param element defines the DOM element to promote
  34728. */
  34729. static _RequestFullscreen(element: HTMLElement): void;
  34730. /**
  34731. * Asks the browser to exit fullscreen mode
  34732. */
  34733. static _ExitFullscreen(): void;
  34734. }
  34735. }
  34736. declare module "babylonjs/Engines/engineStore" {
  34737. import { Nullable } from "babylonjs/types";
  34738. import { Engine } from "babylonjs/Engines/engine";
  34739. import { Scene } from "babylonjs/scene";
  34740. /**
  34741. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34742. * during the life time of the application.
  34743. */
  34744. export class EngineStore {
  34745. /** Gets the list of created engines */
  34746. static Instances: import("babylonjs/Engines/engine").Engine[];
  34747. /** @hidden */
  34748. static _LastCreatedScene: Nullable<Scene>;
  34749. /**
  34750. * Gets the latest created engine
  34751. */
  34752. static get LastCreatedEngine(): Nullable<Engine>;
  34753. /**
  34754. * Gets the latest created scene
  34755. */
  34756. static get LastCreatedScene(): Nullable<Scene>;
  34757. /**
  34758. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34759. * @ignorenaming
  34760. */
  34761. static UseFallbackTexture: boolean;
  34762. /**
  34763. * Texture content used if a texture cannot loaded
  34764. * @ignorenaming
  34765. */
  34766. static FallbackTexture: string;
  34767. }
  34768. }
  34769. declare module "babylonjs/Misc/promise" {
  34770. /**
  34771. * Helper class that provides a small promise polyfill
  34772. */
  34773. export class PromisePolyfill {
  34774. /**
  34775. * Static function used to check if the polyfill is required
  34776. * If this is the case then the function will inject the polyfill to window.Promise
  34777. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34778. */
  34779. static Apply(force?: boolean): void;
  34780. }
  34781. }
  34782. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34783. /**
  34784. * Interface for screenshot methods with describe argument called `size` as object with options
  34785. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34786. */
  34787. export interface IScreenshotSize {
  34788. /**
  34789. * number in pixels for canvas height
  34790. */
  34791. height?: number;
  34792. /**
  34793. * multiplier allowing render at a higher or lower resolution
  34794. * If value is defined then height and width will be ignored and taken from camera
  34795. */
  34796. precision?: number;
  34797. /**
  34798. * number in pixels for canvas width
  34799. */
  34800. width?: number;
  34801. }
  34802. }
  34803. declare module "babylonjs/Misc/tools" {
  34804. import { Nullable, float } from "babylonjs/types";
  34805. import { DomManagement } from "babylonjs/Misc/domManagement";
  34806. import { WebRequest } from "babylonjs/Misc/webRequest";
  34807. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34808. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34809. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34810. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34811. import { Camera } from "babylonjs/Cameras/camera";
  34812. import { Engine } from "babylonjs/Engines/engine";
  34813. interface IColor4Like {
  34814. r: float;
  34815. g: float;
  34816. b: float;
  34817. a: float;
  34818. }
  34819. /**
  34820. * Class containing a set of static utilities functions
  34821. */
  34822. export class Tools {
  34823. /**
  34824. * Gets or sets the base URL to use to load assets
  34825. */
  34826. static get BaseUrl(): string;
  34827. static set BaseUrl(value: string);
  34828. /**
  34829. * Enable/Disable Custom HTTP Request Headers globally.
  34830. * default = false
  34831. * @see CustomRequestHeaders
  34832. */
  34833. static UseCustomRequestHeaders: boolean;
  34834. /**
  34835. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34836. * i.e. when loading files, where the server/service expects an Authorization header
  34837. */
  34838. static CustomRequestHeaders: {
  34839. [key: string]: string;
  34840. };
  34841. /**
  34842. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34843. */
  34844. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34845. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34846. /**
  34847. * Default behaviour for cors in the application.
  34848. * It can be a string if the expected behavior is identical in the entire app.
  34849. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34850. */
  34851. static CorsBehavior: string | ((url: string | string[]) => string);
  34852. /**
  34853. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34854. * @ignorenaming
  34855. */
  34856. static get UseFallbackTexture(): boolean;
  34857. static set UseFallbackTexture(value: boolean);
  34858. /**
  34859. * Use this object to register external classes like custom textures or material
  34860. * to allow the laoders to instantiate them
  34861. */
  34862. static get RegisteredExternalClasses(): {
  34863. [key: string]: Object;
  34864. };
  34865. static set RegisteredExternalClasses(classes: {
  34866. [key: string]: Object;
  34867. });
  34868. /**
  34869. * Texture content used if a texture cannot loaded
  34870. * @ignorenaming
  34871. */
  34872. static get fallbackTexture(): string;
  34873. static set fallbackTexture(value: string);
  34874. /**
  34875. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34876. * @param u defines the coordinate on X axis
  34877. * @param v defines the coordinate on Y axis
  34878. * @param width defines the width of the source data
  34879. * @param height defines the height of the source data
  34880. * @param pixels defines the source byte array
  34881. * @param color defines the output color
  34882. */
  34883. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34884. /**
  34885. * Interpolates between a and b via alpha
  34886. * @param a The lower value (returned when alpha = 0)
  34887. * @param b The upper value (returned when alpha = 1)
  34888. * @param alpha The interpolation-factor
  34889. * @return The mixed value
  34890. */
  34891. static Mix(a: number, b: number, alpha: number): number;
  34892. /**
  34893. * Tries to instantiate a new object from a given class name
  34894. * @param className defines the class name to instantiate
  34895. * @returns the new object or null if the system was not able to do the instantiation
  34896. */
  34897. static Instantiate(className: string): any;
  34898. /**
  34899. * Provides a slice function that will work even on IE
  34900. * @param data defines the array to slice
  34901. * @param start defines the start of the data (optional)
  34902. * @param end defines the end of the data (optional)
  34903. * @returns the new sliced array
  34904. */
  34905. static Slice<T>(data: T, start?: number, end?: number): T;
  34906. /**
  34907. * Polyfill for setImmediate
  34908. * @param action defines the action to execute after the current execution block
  34909. */
  34910. static SetImmediate(action: () => void): void;
  34911. /**
  34912. * Function indicating if a number is an exponent of 2
  34913. * @param value defines the value to test
  34914. * @returns true if the value is an exponent of 2
  34915. */
  34916. static IsExponentOfTwo(value: number): boolean;
  34917. private static _tmpFloatArray;
  34918. /**
  34919. * Returns the nearest 32-bit single precision float representation of a Number
  34920. * @param value A Number. If the parameter is of a different type, it will get converted
  34921. * to a number or to NaN if it cannot be converted
  34922. * @returns number
  34923. */
  34924. static FloatRound(value: number): number;
  34925. /**
  34926. * Extracts the filename from a path
  34927. * @param path defines the path to use
  34928. * @returns the filename
  34929. */
  34930. static GetFilename(path: string): string;
  34931. /**
  34932. * Extracts the "folder" part of a path (everything before the filename).
  34933. * @param uri The URI to extract the info from
  34934. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34935. * @returns The "folder" part of the path
  34936. */
  34937. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34938. /**
  34939. * Extracts text content from a DOM element hierarchy
  34940. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34941. */
  34942. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34943. /**
  34944. * Convert an angle in radians to degrees
  34945. * @param angle defines the angle to convert
  34946. * @returns the angle in degrees
  34947. */
  34948. static ToDegrees(angle: number): number;
  34949. /**
  34950. * Convert an angle in degrees to radians
  34951. * @param angle defines the angle to convert
  34952. * @returns the angle in radians
  34953. */
  34954. static ToRadians(angle: number): number;
  34955. /**
  34956. * Returns an array if obj is not an array
  34957. * @param obj defines the object to evaluate as an array
  34958. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34959. * @returns either obj directly if obj is an array or a new array containing obj
  34960. */
  34961. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34962. /**
  34963. * Gets the pointer prefix to use
  34964. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34965. */
  34966. static GetPointerPrefix(): string;
  34967. /**
  34968. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34969. * @param url define the url we are trying
  34970. * @param element define the dom element where to configure the cors policy
  34971. */
  34972. static SetCorsBehavior(url: string | string[], element: {
  34973. crossOrigin: string | null;
  34974. }): void;
  34975. /**
  34976. * Removes unwanted characters from an url
  34977. * @param url defines the url to clean
  34978. * @returns the cleaned url
  34979. */
  34980. static CleanUrl(url: string): string;
  34981. /**
  34982. * Gets or sets a function used to pre-process url before using them to load assets
  34983. */
  34984. static get PreprocessUrl(): (url: string) => string;
  34985. static set PreprocessUrl(processor: (url: string) => string);
  34986. /**
  34987. * Loads an image as an HTMLImageElement.
  34988. * @param input url string, ArrayBuffer, or Blob to load
  34989. * @param onLoad callback called when the image successfully loads
  34990. * @param onError callback called when the image fails to load
  34991. * @param offlineProvider offline provider for caching
  34992. * @param mimeType optional mime type
  34993. * @returns the HTMLImageElement of the loaded image
  34994. */
  34995. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34996. /**
  34997. * Loads a file from a url
  34998. * @param url url string, ArrayBuffer, or Blob to load
  34999. * @param onSuccess callback called when the file successfully loads
  35000. * @param onProgress callback called while file is loading (if the server supports this mode)
  35001. * @param offlineProvider defines the offline provider for caching
  35002. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35003. * @param onError callback called when the file fails to load
  35004. * @returns a file request object
  35005. */
  35006. 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;
  35007. /**
  35008. * Loads a file from a url
  35009. * @param url the file url to load
  35010. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  35011. */
  35012. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  35013. /**
  35014. * Load a script (identified by an url). When the url returns, the
  35015. * content of this file is added into a new script element, attached to the DOM (body element)
  35016. * @param scriptUrl defines the url of the script to laod
  35017. * @param onSuccess defines the callback called when the script is loaded
  35018. * @param onError defines the callback to call if an error occurs
  35019. * @param scriptId defines the id of the script element
  35020. */
  35021. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35022. /**
  35023. * Load an asynchronous script (identified by an url). When the url returns, the
  35024. * content of this file is added into a new script element, attached to the DOM (body element)
  35025. * @param scriptUrl defines the url of the script to laod
  35026. * @param scriptId defines the id of the script element
  35027. * @returns a promise request object
  35028. */
  35029. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35030. /**
  35031. * Loads a file from a blob
  35032. * @param fileToLoad defines the blob to use
  35033. * @param callback defines the callback to call when data is loaded
  35034. * @param progressCallback defines the callback to call during loading process
  35035. * @returns a file request object
  35036. */
  35037. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35038. /**
  35039. * Reads a file from a File object
  35040. * @param file defines the file to load
  35041. * @param onSuccess defines the callback to call when data is loaded
  35042. * @param onProgress defines the callback to call during loading process
  35043. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35044. * @param onError defines the callback to call when an error occurs
  35045. * @returns a file request object
  35046. */
  35047. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35048. /**
  35049. * Creates a data url from a given string content
  35050. * @param content defines the content to convert
  35051. * @returns the new data url link
  35052. */
  35053. static FileAsURL(content: string): string;
  35054. /**
  35055. * Format the given number to a specific decimal format
  35056. * @param value defines the number to format
  35057. * @param decimals defines the number of decimals to use
  35058. * @returns the formatted string
  35059. */
  35060. static Format(value: number, decimals?: number): string;
  35061. /**
  35062. * Tries to copy an object by duplicating every property
  35063. * @param source defines the source object
  35064. * @param destination defines the target object
  35065. * @param doNotCopyList defines a list of properties to avoid
  35066. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35067. */
  35068. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35069. /**
  35070. * Gets a boolean indicating if the given object has no own property
  35071. * @param obj defines the object to test
  35072. * @returns true if object has no own property
  35073. */
  35074. static IsEmpty(obj: any): boolean;
  35075. /**
  35076. * Function used to register events at window level
  35077. * @param windowElement defines the Window object to use
  35078. * @param events defines the events to register
  35079. */
  35080. static RegisterTopRootEvents(windowElement: Window, events: {
  35081. name: string;
  35082. handler: Nullable<(e: FocusEvent) => any>;
  35083. }[]): void;
  35084. /**
  35085. * Function used to unregister events from window level
  35086. * @param windowElement defines the Window object to use
  35087. * @param events defines the events to unregister
  35088. */
  35089. static UnregisterTopRootEvents(windowElement: Window, events: {
  35090. name: string;
  35091. handler: Nullable<(e: FocusEvent) => any>;
  35092. }[]): void;
  35093. /**
  35094. * @ignore
  35095. */
  35096. static _ScreenshotCanvas: HTMLCanvasElement;
  35097. /**
  35098. * Dumps the current bound framebuffer
  35099. * @param width defines the rendering width
  35100. * @param height defines the rendering height
  35101. * @param engine defines the hosting engine
  35102. * @param successCallback defines the callback triggered once the data are available
  35103. * @param mimeType defines the mime type of the result
  35104. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35105. */
  35106. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35107. /**
  35108. * Converts the canvas data to blob.
  35109. * This acts as a polyfill for browsers not supporting the to blob function.
  35110. * @param canvas Defines the canvas to extract the data from
  35111. * @param successCallback Defines the callback triggered once the data are available
  35112. * @param mimeType Defines the mime type of the result
  35113. */
  35114. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35115. /**
  35116. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35117. * @param successCallback defines the callback triggered once the data are available
  35118. * @param mimeType defines the mime type of the result
  35119. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35120. */
  35121. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35122. /**
  35123. * Downloads a blob in the browser
  35124. * @param blob defines the blob to download
  35125. * @param fileName defines the name of the downloaded file
  35126. */
  35127. static Download(blob: Blob, fileName: string): void;
  35128. /**
  35129. * Captures a screenshot of the current rendering
  35130. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35131. * @param engine defines the rendering engine
  35132. * @param camera defines the source camera
  35133. * @param size This parameter can be set to a single number or to an object with the
  35134. * following (optional) properties: precision, width, height. If a single number is passed,
  35135. * it will be used for both width and height. If an object is passed, the screenshot size
  35136. * will be derived from the parameters. The precision property is a multiplier allowing
  35137. * rendering at a higher or lower resolution
  35138. * @param successCallback defines the callback receives a single parameter which contains the
  35139. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35140. * src parameter of an <img> to display it
  35141. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35142. * Check your browser for supported MIME types
  35143. */
  35144. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35145. /**
  35146. * Captures a screenshot of the current rendering
  35147. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35148. * @param engine defines the rendering engine
  35149. * @param camera defines the source camera
  35150. * @param size This parameter can be set to a single number or to an object with the
  35151. * following (optional) properties: precision, width, height. If a single number is passed,
  35152. * it will be used for both width and height. If an object is passed, the screenshot size
  35153. * will be derived from the parameters. The precision property is a multiplier allowing
  35154. * rendering at a higher or lower resolution
  35155. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35156. * Check your browser for supported MIME types
  35157. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35158. * to the src parameter of an <img> to display it
  35159. */
  35160. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35161. /**
  35162. * Generates an image screenshot from the specified camera.
  35163. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35164. * @param engine The engine to use for rendering
  35165. * @param camera The camera to use for rendering
  35166. * @param size This parameter can be set to a single number or to an object with the
  35167. * following (optional) properties: precision, width, height. If a single number is passed,
  35168. * it will be used for both width and height. If an object is passed, the screenshot size
  35169. * will be derived from the parameters. The precision property is a multiplier allowing
  35170. * rendering at a higher or lower resolution
  35171. * @param successCallback The callback receives a single parameter which contains the
  35172. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35173. * src parameter of an <img> to display it
  35174. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35175. * Check your browser for supported MIME types
  35176. * @param samples Texture samples (default: 1)
  35177. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35178. * @param fileName A name for for the downloaded file.
  35179. */
  35180. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35181. /**
  35182. * Generates an image screenshot from the specified camera.
  35183. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35184. * @param engine The engine to use for rendering
  35185. * @param camera The camera to use for rendering
  35186. * @param size This parameter can be set to a single number or to an object with the
  35187. * following (optional) properties: precision, width, height. If a single number is passed,
  35188. * it will be used for both width and height. If an object is passed, the screenshot size
  35189. * will be derived from the parameters. The precision property is a multiplier allowing
  35190. * rendering at a higher or lower resolution
  35191. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35192. * Check your browser for supported MIME types
  35193. * @param samples Texture samples (default: 1)
  35194. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35195. * @param fileName A name for for the downloaded file.
  35196. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35197. * to the src parameter of an <img> to display it
  35198. */
  35199. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35200. /**
  35201. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35202. * Be aware Math.random() could cause collisions, but:
  35203. * "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"
  35204. * @returns a pseudo random id
  35205. */
  35206. static RandomId(): string;
  35207. /**
  35208. * Test if the given uri is a base64 string
  35209. * @param uri The uri to test
  35210. * @return True if the uri is a base64 string or false otherwise
  35211. */
  35212. static IsBase64(uri: string): boolean;
  35213. /**
  35214. * Decode the given base64 uri.
  35215. * @param uri The uri to decode
  35216. * @return The decoded base64 data.
  35217. */
  35218. static DecodeBase64(uri: string): ArrayBuffer;
  35219. /**
  35220. * Gets the absolute url.
  35221. * @param url the input url
  35222. * @return the absolute url
  35223. */
  35224. static GetAbsoluteUrl(url: string): string;
  35225. /**
  35226. * No log
  35227. */
  35228. static readonly NoneLogLevel: number;
  35229. /**
  35230. * Only message logs
  35231. */
  35232. static readonly MessageLogLevel: number;
  35233. /**
  35234. * Only warning logs
  35235. */
  35236. static readonly WarningLogLevel: number;
  35237. /**
  35238. * Only error logs
  35239. */
  35240. static readonly ErrorLogLevel: number;
  35241. /**
  35242. * All logs
  35243. */
  35244. static readonly AllLogLevel: number;
  35245. /**
  35246. * Gets a value indicating the number of loading errors
  35247. * @ignorenaming
  35248. */
  35249. static get errorsCount(): number;
  35250. /**
  35251. * Callback called when a new log is added
  35252. */
  35253. static OnNewCacheEntry: (entry: string) => void;
  35254. /**
  35255. * Log a message to the console
  35256. * @param message defines the message to log
  35257. */
  35258. static Log(message: string): void;
  35259. /**
  35260. * Write a warning message to the console
  35261. * @param message defines the message to log
  35262. */
  35263. static Warn(message: string): void;
  35264. /**
  35265. * Write an error message to the console
  35266. * @param message defines the message to log
  35267. */
  35268. static Error(message: string): void;
  35269. /**
  35270. * Gets current log cache (list of logs)
  35271. */
  35272. static get LogCache(): string;
  35273. /**
  35274. * Clears the log cache
  35275. */
  35276. static ClearLogCache(): void;
  35277. /**
  35278. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35279. */
  35280. static set LogLevels(level: number);
  35281. /**
  35282. * Checks if the window object exists
  35283. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35284. */
  35285. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35286. /**
  35287. * No performance log
  35288. */
  35289. static readonly PerformanceNoneLogLevel: number;
  35290. /**
  35291. * Use user marks to log performance
  35292. */
  35293. static readonly PerformanceUserMarkLogLevel: number;
  35294. /**
  35295. * Log performance to the console
  35296. */
  35297. static readonly PerformanceConsoleLogLevel: number;
  35298. private static _performance;
  35299. /**
  35300. * Sets the current performance log level
  35301. */
  35302. static set PerformanceLogLevel(level: number);
  35303. private static _StartPerformanceCounterDisabled;
  35304. private static _EndPerformanceCounterDisabled;
  35305. private static _StartUserMark;
  35306. private static _EndUserMark;
  35307. private static _StartPerformanceConsole;
  35308. private static _EndPerformanceConsole;
  35309. /**
  35310. * Starts a performance counter
  35311. */
  35312. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35313. /**
  35314. * Ends a specific performance coutner
  35315. */
  35316. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35317. /**
  35318. * Gets either window.performance.now() if supported or Date.now() else
  35319. */
  35320. static get Now(): number;
  35321. /**
  35322. * This method will return the name of the class used to create the instance of the given object.
  35323. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35324. * @param object the object to get the class name from
  35325. * @param isType defines if the object is actually a type
  35326. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35327. */
  35328. static GetClassName(object: any, isType?: boolean): string;
  35329. /**
  35330. * Gets the first element of an array satisfying a given predicate
  35331. * @param array defines the array to browse
  35332. * @param predicate defines the predicate to use
  35333. * @returns null if not found or the element
  35334. */
  35335. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35336. /**
  35337. * This method will return the name of the full name of the class, including its owning module (if any).
  35338. * 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).
  35339. * @param object the object to get the class name from
  35340. * @param isType defines if the object is actually a type
  35341. * @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.
  35342. * @ignorenaming
  35343. */
  35344. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35345. /**
  35346. * Returns a promise that resolves after the given amount of time.
  35347. * @param delay Number of milliseconds to delay
  35348. * @returns Promise that resolves after the given amount of time
  35349. */
  35350. static DelayAsync(delay: number): Promise<void>;
  35351. /**
  35352. * Utility function to detect if the current user agent is Safari
  35353. * @returns whether or not the current user agent is safari
  35354. */
  35355. static IsSafari(): boolean;
  35356. }
  35357. /**
  35358. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35359. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35360. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35361. * @param name The name of the class, case should be preserved
  35362. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35363. */
  35364. export function className(name: string, module?: string): (target: Object) => void;
  35365. /**
  35366. * An implementation of a loop for asynchronous functions.
  35367. */
  35368. export class AsyncLoop {
  35369. /**
  35370. * Defines the number of iterations for the loop
  35371. */
  35372. iterations: number;
  35373. /**
  35374. * Defines the current index of the loop.
  35375. */
  35376. index: number;
  35377. private _done;
  35378. private _fn;
  35379. private _successCallback;
  35380. /**
  35381. * Constructor.
  35382. * @param iterations the number of iterations.
  35383. * @param func the function to run each iteration
  35384. * @param successCallback the callback that will be called upon succesful execution
  35385. * @param offset starting offset.
  35386. */
  35387. constructor(
  35388. /**
  35389. * Defines the number of iterations for the loop
  35390. */
  35391. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35392. /**
  35393. * Execute the next iteration. Must be called after the last iteration was finished.
  35394. */
  35395. executeNext(): void;
  35396. /**
  35397. * Break the loop and run the success callback.
  35398. */
  35399. breakLoop(): void;
  35400. /**
  35401. * Create and run an async loop.
  35402. * @param iterations the number of iterations.
  35403. * @param fn the function to run each iteration
  35404. * @param successCallback the callback that will be called upon succesful execution
  35405. * @param offset starting offset.
  35406. * @returns the created async loop object
  35407. */
  35408. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35409. /**
  35410. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35411. * @param iterations total number of iterations
  35412. * @param syncedIterations number of synchronous iterations in each async iteration.
  35413. * @param fn the function to call each iteration.
  35414. * @param callback a success call back that will be called when iterating stops.
  35415. * @param breakFunction a break condition (optional)
  35416. * @param timeout timeout settings for the setTimeout function. default - 0.
  35417. * @returns the created async loop object
  35418. */
  35419. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35420. }
  35421. }
  35422. declare module "babylonjs/Misc/stringDictionary" {
  35423. import { Nullable } from "babylonjs/types";
  35424. /**
  35425. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35426. * The underlying implementation relies on an associative array to ensure the best performances.
  35427. * The value can be anything including 'null' but except 'undefined'
  35428. */
  35429. export class StringDictionary<T> {
  35430. /**
  35431. * This will clear this dictionary and copy the content from the 'source' one.
  35432. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35433. * @param source the dictionary to take the content from and copy to this dictionary
  35434. */
  35435. copyFrom(source: StringDictionary<T>): void;
  35436. /**
  35437. * Get a value based from its key
  35438. * @param key the given key to get the matching value from
  35439. * @return the value if found, otherwise undefined is returned
  35440. */
  35441. get(key: string): T | undefined;
  35442. /**
  35443. * Get a value from its key or add it if it doesn't exist.
  35444. * This method will ensure you that a given key/data will be present in the dictionary.
  35445. * @param key the given key to get the matching value from
  35446. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35447. * The factory will only be invoked if there's no data for the given key.
  35448. * @return the value corresponding to the key.
  35449. */
  35450. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35451. /**
  35452. * Get a value from its key if present in the dictionary otherwise add it
  35453. * @param key the key to get the value from
  35454. * @param val if there's no such key/value pair in the dictionary add it with this value
  35455. * @return the value corresponding to the key
  35456. */
  35457. getOrAdd(key: string, val: T): T;
  35458. /**
  35459. * Check if there's a given key in the dictionary
  35460. * @param key the key to check for
  35461. * @return true if the key is present, false otherwise
  35462. */
  35463. contains(key: string): boolean;
  35464. /**
  35465. * Add a new key and its corresponding value
  35466. * @param key the key to add
  35467. * @param value the value corresponding to the key
  35468. * @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
  35469. */
  35470. add(key: string, value: T): boolean;
  35471. /**
  35472. * Update a specific value associated to a key
  35473. * @param key defines the key to use
  35474. * @param value defines the value to store
  35475. * @returns true if the value was updated (or false if the key was not found)
  35476. */
  35477. set(key: string, value: T): boolean;
  35478. /**
  35479. * Get the element of the given key and remove it from the dictionary
  35480. * @param key defines the key to search
  35481. * @returns the value associated with the key or null if not found
  35482. */
  35483. getAndRemove(key: string): Nullable<T>;
  35484. /**
  35485. * Remove a key/value from the dictionary.
  35486. * @param key the key to remove
  35487. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35488. */
  35489. remove(key: string): boolean;
  35490. /**
  35491. * Clear the whole content of the dictionary
  35492. */
  35493. clear(): void;
  35494. /**
  35495. * Gets the current count
  35496. */
  35497. get count(): number;
  35498. /**
  35499. * Execute a callback on each key/val of the dictionary.
  35500. * Note that you can remove any element in this dictionary in the callback implementation
  35501. * @param callback the callback to execute on a given key/value pair
  35502. */
  35503. forEach(callback: (key: string, val: T) => void): void;
  35504. /**
  35505. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35506. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35507. * Note that you can remove any element in this dictionary in the callback implementation
  35508. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35509. * @returns the first item
  35510. */
  35511. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35512. private _count;
  35513. private _data;
  35514. }
  35515. }
  35516. declare module "babylonjs/Collisions/collisionCoordinator" {
  35517. import { Nullable } from "babylonjs/types";
  35518. import { Scene } from "babylonjs/scene";
  35519. import { Vector3 } from "babylonjs/Maths/math.vector";
  35520. import { Collider } from "babylonjs/Collisions/collider";
  35521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35522. /** @hidden */
  35523. export interface ICollisionCoordinator {
  35524. createCollider(): Collider;
  35525. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35526. init(scene: Scene): void;
  35527. }
  35528. /** @hidden */
  35529. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35530. private _scene;
  35531. private _scaledPosition;
  35532. private _scaledVelocity;
  35533. private _finalPosition;
  35534. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35535. createCollider(): Collider;
  35536. init(scene: Scene): void;
  35537. private _collideWithWorld;
  35538. }
  35539. }
  35540. declare module "babylonjs/Inputs/scene.inputManager" {
  35541. import { Nullable } from "babylonjs/types";
  35542. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35543. import { Vector2 } from "babylonjs/Maths/math.vector";
  35544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35545. import { Scene } from "babylonjs/scene";
  35546. /**
  35547. * Class used to manage all inputs for the scene.
  35548. */
  35549. export class InputManager {
  35550. /** The distance in pixel that you have to move to prevent some events */
  35551. static DragMovementThreshold: number;
  35552. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35553. static LongPressDelay: number;
  35554. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35555. static DoubleClickDelay: number;
  35556. /** If you need to check double click without raising a single click at first click, enable this flag */
  35557. static ExclusiveDoubleClickMode: boolean;
  35558. private _wheelEventName;
  35559. private _onPointerMove;
  35560. private _onPointerDown;
  35561. private _onPointerUp;
  35562. private _initClickEvent;
  35563. private _initActionManager;
  35564. private _delayedSimpleClick;
  35565. private _delayedSimpleClickTimeout;
  35566. private _previousDelayedSimpleClickTimeout;
  35567. private _meshPickProceed;
  35568. private _previousButtonPressed;
  35569. private _currentPickResult;
  35570. private _previousPickResult;
  35571. private _totalPointersPressed;
  35572. private _doubleClickOccured;
  35573. private _pointerOverMesh;
  35574. private _pickedDownMesh;
  35575. private _pickedUpMesh;
  35576. private _pointerX;
  35577. private _pointerY;
  35578. private _unTranslatedPointerX;
  35579. private _unTranslatedPointerY;
  35580. private _startingPointerPosition;
  35581. private _previousStartingPointerPosition;
  35582. private _startingPointerTime;
  35583. private _previousStartingPointerTime;
  35584. private _pointerCaptures;
  35585. private _onKeyDown;
  35586. private _onKeyUp;
  35587. private _onCanvasFocusObserver;
  35588. private _onCanvasBlurObserver;
  35589. private _scene;
  35590. /**
  35591. * Creates a new InputManager
  35592. * @param scene defines the hosting scene
  35593. */
  35594. constructor(scene: Scene);
  35595. /**
  35596. * Gets the mesh that is currently under the pointer
  35597. */
  35598. get meshUnderPointer(): Nullable<AbstractMesh>;
  35599. /**
  35600. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35601. */
  35602. get unTranslatedPointer(): Vector2;
  35603. /**
  35604. * Gets or sets the current on-screen X position of the pointer
  35605. */
  35606. get pointerX(): number;
  35607. set pointerX(value: number);
  35608. /**
  35609. * Gets or sets the current on-screen Y position of the pointer
  35610. */
  35611. get pointerY(): number;
  35612. set pointerY(value: number);
  35613. private _updatePointerPosition;
  35614. private _processPointerMove;
  35615. private _setRayOnPointerInfo;
  35616. private _checkPrePointerObservable;
  35617. /**
  35618. * Use this method to simulate a pointer move on a mesh
  35619. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35620. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35621. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35622. */
  35623. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35624. /**
  35625. * Use this method to simulate a pointer down on a mesh
  35626. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35627. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35628. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35629. */
  35630. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35631. private _processPointerDown;
  35632. /** @hidden */
  35633. _isPointerSwiping(): boolean;
  35634. /**
  35635. * Use this method to simulate a pointer up on a mesh
  35636. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35637. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35638. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35639. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35640. */
  35641. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35642. private _processPointerUp;
  35643. /**
  35644. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35645. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35646. * @returns true if the pointer was captured
  35647. */
  35648. isPointerCaptured(pointerId?: number): boolean;
  35649. /**
  35650. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35651. * @param attachUp defines if you want to attach events to pointerup
  35652. * @param attachDown defines if you want to attach events to pointerdown
  35653. * @param attachMove defines if you want to attach events to pointermove
  35654. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35655. */
  35656. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35657. /**
  35658. * Detaches all event handlers
  35659. */
  35660. detachControl(): void;
  35661. /**
  35662. * Force the value of meshUnderPointer
  35663. * @param mesh defines the mesh to use
  35664. */
  35665. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35666. /**
  35667. * Gets the mesh under the pointer
  35668. * @returns a Mesh or null if no mesh is under the pointer
  35669. */
  35670. getPointerOverMesh(): Nullable<AbstractMesh>;
  35671. }
  35672. }
  35673. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35674. /**
  35675. * Helper class used to generate session unique ID
  35676. */
  35677. export class UniqueIdGenerator {
  35678. private static _UniqueIdCounter;
  35679. /**
  35680. * Gets an unique (relatively to the current scene) Id
  35681. */
  35682. static get UniqueId(): number;
  35683. }
  35684. }
  35685. declare module "babylonjs/Animations/animationGroup" {
  35686. import { Animatable } from "babylonjs/Animations/animatable";
  35687. import { Animation } from "babylonjs/Animations/animation";
  35688. import { Scene, IDisposable } from "babylonjs/scene";
  35689. import { Observable } from "babylonjs/Misc/observable";
  35690. import { Nullable } from "babylonjs/types";
  35691. import "babylonjs/Animations/animatable";
  35692. /**
  35693. * This class defines the direct association between an animation and a target
  35694. */
  35695. export class TargetedAnimation {
  35696. /**
  35697. * Animation to perform
  35698. */
  35699. animation: Animation;
  35700. /**
  35701. * Target to animate
  35702. */
  35703. target: any;
  35704. /**
  35705. * Serialize the object
  35706. * @returns the JSON object representing the current entity
  35707. */
  35708. serialize(): any;
  35709. }
  35710. /**
  35711. * Use this class to create coordinated animations on multiple targets
  35712. */
  35713. export class AnimationGroup implements IDisposable {
  35714. /** The name of the animation group */
  35715. name: string;
  35716. private _scene;
  35717. private _targetedAnimations;
  35718. private _animatables;
  35719. private _from;
  35720. private _to;
  35721. private _isStarted;
  35722. private _isPaused;
  35723. private _speedRatio;
  35724. private _loopAnimation;
  35725. /**
  35726. * Gets or sets the unique id of the node
  35727. */
  35728. uniqueId: number;
  35729. /**
  35730. * This observable will notify when one animation have ended
  35731. */
  35732. onAnimationEndObservable: Observable<TargetedAnimation>;
  35733. /**
  35734. * Observer raised when one animation loops
  35735. */
  35736. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35737. /**
  35738. * Observer raised when all animations have looped
  35739. */
  35740. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35741. /**
  35742. * This observable will notify when all animations have ended.
  35743. */
  35744. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35745. /**
  35746. * This observable will notify when all animations have paused.
  35747. */
  35748. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35749. /**
  35750. * This observable will notify when all animations are playing.
  35751. */
  35752. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35753. /**
  35754. * Gets the first frame
  35755. */
  35756. get from(): number;
  35757. /**
  35758. * Gets the last frame
  35759. */
  35760. get to(): number;
  35761. /**
  35762. * Define if the animations are started
  35763. */
  35764. get isStarted(): boolean;
  35765. /**
  35766. * Gets a value indicating that the current group is playing
  35767. */
  35768. get isPlaying(): boolean;
  35769. /**
  35770. * Gets or sets the speed ratio to use for all animations
  35771. */
  35772. get speedRatio(): number;
  35773. /**
  35774. * Gets or sets the speed ratio to use for all animations
  35775. */
  35776. set speedRatio(value: number);
  35777. /**
  35778. * Gets or sets if all animations should loop or not
  35779. */
  35780. get loopAnimation(): boolean;
  35781. set loopAnimation(value: boolean);
  35782. /**
  35783. * Gets the targeted animations for this animation group
  35784. */
  35785. get targetedAnimations(): Array<TargetedAnimation>;
  35786. /**
  35787. * returning the list of animatables controlled by this animation group.
  35788. */
  35789. get animatables(): Array<Animatable>;
  35790. /**
  35791. * Instantiates a new Animation Group.
  35792. * This helps managing several animations at once.
  35793. * @see http://doc.babylonjs.com/how_to/group
  35794. * @param name Defines the name of the group
  35795. * @param scene Defines the scene the group belongs to
  35796. */
  35797. constructor(
  35798. /** The name of the animation group */
  35799. name: string, scene?: Nullable<Scene>);
  35800. /**
  35801. * Add an animation (with its target) in the group
  35802. * @param animation defines the animation we want to add
  35803. * @param target defines the target of the animation
  35804. * @returns the TargetedAnimation object
  35805. */
  35806. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35807. /**
  35808. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35809. * It can add constant keys at begin or end
  35810. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35811. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35812. * @returns the animation group
  35813. */
  35814. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35815. private _animationLoopCount;
  35816. private _animationLoopFlags;
  35817. private _processLoop;
  35818. /**
  35819. * Start all animations on given targets
  35820. * @param loop defines if animations must loop
  35821. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35822. * @param from defines the from key (optional)
  35823. * @param to defines the to key (optional)
  35824. * @returns the current animation group
  35825. */
  35826. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35827. /**
  35828. * Pause all animations
  35829. * @returns the animation group
  35830. */
  35831. pause(): AnimationGroup;
  35832. /**
  35833. * Play all animations to initial state
  35834. * This function will start() the animations if they were not started or will restart() them if they were paused
  35835. * @param loop defines if animations must loop
  35836. * @returns the animation group
  35837. */
  35838. play(loop?: boolean): AnimationGroup;
  35839. /**
  35840. * Reset all animations to initial state
  35841. * @returns the animation group
  35842. */
  35843. reset(): AnimationGroup;
  35844. /**
  35845. * Restart animations from key 0
  35846. * @returns the animation group
  35847. */
  35848. restart(): AnimationGroup;
  35849. /**
  35850. * Stop all animations
  35851. * @returns the animation group
  35852. */
  35853. stop(): AnimationGroup;
  35854. /**
  35855. * Set animation weight for all animatables
  35856. * @param weight defines the weight to use
  35857. * @return the animationGroup
  35858. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35859. */
  35860. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35861. /**
  35862. * Synchronize and normalize all animatables with a source animatable
  35863. * @param root defines the root animatable to synchronize with
  35864. * @return the animationGroup
  35865. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35866. */
  35867. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35868. /**
  35869. * Goes to a specific frame in this animation group
  35870. * @param frame the frame number to go to
  35871. * @return the animationGroup
  35872. */
  35873. goToFrame(frame: number): AnimationGroup;
  35874. /**
  35875. * Dispose all associated resources
  35876. */
  35877. dispose(): void;
  35878. private _checkAnimationGroupEnded;
  35879. /**
  35880. * Clone the current animation group and returns a copy
  35881. * @param newName defines the name of the new group
  35882. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35883. * @returns the new aniamtion group
  35884. */
  35885. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35886. /**
  35887. * Serializes the animationGroup to an object
  35888. * @returns Serialized object
  35889. */
  35890. serialize(): any;
  35891. /**
  35892. * Returns a new AnimationGroup object parsed from the source provided.
  35893. * @param parsedAnimationGroup defines the source
  35894. * @param scene defines the scene that will receive the animationGroup
  35895. * @returns a new AnimationGroup
  35896. */
  35897. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35898. /**
  35899. * Returns the string "AnimationGroup"
  35900. * @returns "AnimationGroup"
  35901. */
  35902. getClassName(): string;
  35903. /**
  35904. * Creates a detailled string about the object
  35905. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35906. * @returns a string representing the object
  35907. */
  35908. toString(fullDetails?: boolean): string;
  35909. }
  35910. }
  35911. declare module "babylonjs/scene" {
  35912. import { Nullable } from "babylonjs/types";
  35913. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35914. import { Observable } from "babylonjs/Misc/observable";
  35915. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35916. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35917. import { Geometry } from "babylonjs/Meshes/geometry";
  35918. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35919. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35921. import { Mesh } from "babylonjs/Meshes/mesh";
  35922. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35923. import { Bone } from "babylonjs/Bones/bone";
  35924. import { Skeleton } from "babylonjs/Bones/skeleton";
  35925. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35926. import { Camera } from "babylonjs/Cameras/camera";
  35927. import { AbstractScene } from "babylonjs/abstractScene";
  35928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35930. import { Material } from "babylonjs/Materials/material";
  35931. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35932. import { Effect } from "babylonjs/Materials/effect";
  35933. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35934. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35935. import { Light } from "babylonjs/Lights/light";
  35936. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35937. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35938. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35939. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35940. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35941. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35942. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35943. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35944. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35945. import { Engine } from "babylonjs/Engines/engine";
  35946. import { Node } from "babylonjs/node";
  35947. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35948. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35949. import { WebRequest } from "babylonjs/Misc/webRequest";
  35950. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35951. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35952. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35953. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35954. import { Plane } from "babylonjs/Maths/math.plane";
  35955. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35956. import { Ray } from "babylonjs/Culling/ray";
  35957. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35958. import { Animation } from "babylonjs/Animations/animation";
  35959. import { Animatable } from "babylonjs/Animations/animatable";
  35960. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35961. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35962. import { Collider } from "babylonjs/Collisions/collider";
  35963. /**
  35964. * Define an interface for all classes that will hold resources
  35965. */
  35966. export interface IDisposable {
  35967. /**
  35968. * Releases all held resources
  35969. */
  35970. dispose(): void;
  35971. }
  35972. /** Interface defining initialization parameters for Scene class */
  35973. export interface SceneOptions {
  35974. /**
  35975. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35976. * It will improve performance when the number of geometries becomes important.
  35977. */
  35978. useGeometryUniqueIdsMap?: boolean;
  35979. /**
  35980. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35981. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35982. */
  35983. useMaterialMeshMap?: boolean;
  35984. /**
  35985. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35986. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35987. */
  35988. useClonedMeshMap?: boolean;
  35989. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35990. virtual?: boolean;
  35991. }
  35992. /**
  35993. * Represents a scene to be rendered by the engine.
  35994. * @see http://doc.babylonjs.com/features/scene
  35995. */
  35996. export class Scene extends AbstractScene implements IAnimatable {
  35997. /** The fog is deactivated */
  35998. static readonly FOGMODE_NONE: number;
  35999. /** The fog density is following an exponential function */
  36000. static readonly FOGMODE_EXP: number;
  36001. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36002. static readonly FOGMODE_EXP2: number;
  36003. /** The fog density is following a linear function. */
  36004. static readonly FOGMODE_LINEAR: number;
  36005. /**
  36006. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36007. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36008. */
  36009. static MinDeltaTime: number;
  36010. /**
  36011. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36013. */
  36014. static MaxDeltaTime: number;
  36015. /**
  36016. * Factory used to create the default material.
  36017. * @param name The name of the material to create
  36018. * @param scene The scene to create the material for
  36019. * @returns The default material
  36020. */
  36021. static DefaultMaterialFactory(scene: Scene): Material;
  36022. /**
  36023. * Factory used to create the a collision coordinator.
  36024. * @returns The collision coordinator
  36025. */
  36026. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36027. /** @hidden */
  36028. _inputManager: InputManager;
  36029. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36030. cameraToUseForPointers: Nullable<Camera>;
  36031. /** @hidden */
  36032. readonly _isScene: boolean;
  36033. /**
  36034. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36035. */
  36036. autoClear: boolean;
  36037. /**
  36038. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36039. */
  36040. autoClearDepthAndStencil: boolean;
  36041. /**
  36042. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36043. */
  36044. clearColor: Color4;
  36045. /**
  36046. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36047. */
  36048. ambientColor: Color3;
  36049. /**
  36050. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36051. * It should only be one of the following (if not the default embedded one):
  36052. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36053. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36054. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36055. * The material properties need to be setup according to the type of texture in use.
  36056. */
  36057. environmentBRDFTexture: BaseTexture;
  36058. /** @hidden */
  36059. protected _environmentTexture: Nullable<BaseTexture>;
  36060. /**
  36061. * Texture used in all pbr material as the reflection texture.
  36062. * As in the majority of the scene they are the same (exception for multi room and so on),
  36063. * this is easier to reference from here than from all the materials.
  36064. */
  36065. get environmentTexture(): Nullable<BaseTexture>;
  36066. /**
  36067. * Texture used in all pbr material as the reflection texture.
  36068. * As in the majority of the scene they are the same (exception for multi room and so on),
  36069. * this is easier to set here than in all the materials.
  36070. */
  36071. set environmentTexture(value: Nullable<BaseTexture>);
  36072. /** @hidden */
  36073. protected _environmentIntensity: number;
  36074. /**
  36075. * Intensity of the environment in all pbr material.
  36076. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36077. * As in the majority of the scene they are the same (exception for multi room and so on),
  36078. * this is easier to reference from here than from all the materials.
  36079. */
  36080. get environmentIntensity(): number;
  36081. /**
  36082. * Intensity of the environment in all pbr material.
  36083. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36084. * As in the majority of the scene they are the same (exception for multi room and so on),
  36085. * this is easier to set here than in all the materials.
  36086. */
  36087. set environmentIntensity(value: number);
  36088. /** @hidden */
  36089. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36090. /**
  36091. * Default image processing configuration used either in the rendering
  36092. * Forward main pass or through the imageProcessingPostProcess if present.
  36093. * As in the majority of the scene they are the same (exception for multi camera),
  36094. * this is easier to reference from here than from all the materials and post process.
  36095. *
  36096. * No setter as we it is a shared configuration, you can set the values instead.
  36097. */
  36098. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36099. private _forceWireframe;
  36100. /**
  36101. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36102. */
  36103. set forceWireframe(value: boolean);
  36104. get forceWireframe(): boolean;
  36105. private _skipFrustumClipping;
  36106. /**
  36107. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36108. */
  36109. set skipFrustumClipping(value: boolean);
  36110. get skipFrustumClipping(): boolean;
  36111. private _forcePointsCloud;
  36112. /**
  36113. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36114. */
  36115. set forcePointsCloud(value: boolean);
  36116. get forcePointsCloud(): boolean;
  36117. /**
  36118. * Gets or sets the active clipplane 1
  36119. */
  36120. clipPlane: Nullable<Plane>;
  36121. /**
  36122. * Gets or sets the active clipplane 2
  36123. */
  36124. clipPlane2: Nullable<Plane>;
  36125. /**
  36126. * Gets or sets the active clipplane 3
  36127. */
  36128. clipPlane3: Nullable<Plane>;
  36129. /**
  36130. * Gets or sets the active clipplane 4
  36131. */
  36132. clipPlane4: Nullable<Plane>;
  36133. /**
  36134. * Gets or sets the active clipplane 5
  36135. */
  36136. clipPlane5: Nullable<Plane>;
  36137. /**
  36138. * Gets or sets the active clipplane 6
  36139. */
  36140. clipPlane6: Nullable<Plane>;
  36141. /**
  36142. * Gets or sets a boolean indicating if animations are enabled
  36143. */
  36144. animationsEnabled: boolean;
  36145. private _animationPropertiesOverride;
  36146. /**
  36147. * Gets or sets the animation properties override
  36148. */
  36149. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36150. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36151. /**
  36152. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36153. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36154. */
  36155. useConstantAnimationDeltaTime: boolean;
  36156. /**
  36157. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36158. * Please note that it requires to run a ray cast through the scene on every frame
  36159. */
  36160. constantlyUpdateMeshUnderPointer: boolean;
  36161. /**
  36162. * Defines the HTML cursor to use when hovering over interactive elements
  36163. */
  36164. hoverCursor: string;
  36165. /**
  36166. * Defines the HTML default cursor to use (empty by default)
  36167. */
  36168. defaultCursor: string;
  36169. /**
  36170. * Defines wether cursors are handled by the scene.
  36171. */
  36172. doNotHandleCursors: boolean;
  36173. /**
  36174. * This is used to call preventDefault() on pointer down
  36175. * in order to block unwanted artifacts like system double clicks
  36176. */
  36177. preventDefaultOnPointerDown: boolean;
  36178. /**
  36179. * This is used to call preventDefault() on pointer up
  36180. * in order to block unwanted artifacts like system double clicks
  36181. */
  36182. preventDefaultOnPointerUp: boolean;
  36183. /**
  36184. * Gets or sets user defined metadata
  36185. */
  36186. metadata: any;
  36187. /**
  36188. * For internal use only. Please do not use.
  36189. */
  36190. reservedDataStore: any;
  36191. /**
  36192. * Gets the name of the plugin used to load this scene (null by default)
  36193. */
  36194. loadingPluginName: string;
  36195. /**
  36196. * Use this array to add regular expressions used to disable offline support for specific urls
  36197. */
  36198. disableOfflineSupportExceptionRules: RegExp[];
  36199. /**
  36200. * An event triggered when the scene is disposed.
  36201. */
  36202. onDisposeObservable: Observable<Scene>;
  36203. private _onDisposeObserver;
  36204. /** Sets a function to be executed when this scene is disposed. */
  36205. set onDispose(callback: () => void);
  36206. /**
  36207. * An event triggered before rendering the scene (right after animations and physics)
  36208. */
  36209. onBeforeRenderObservable: Observable<Scene>;
  36210. private _onBeforeRenderObserver;
  36211. /** Sets a function to be executed before rendering this scene */
  36212. set beforeRender(callback: Nullable<() => void>);
  36213. /**
  36214. * An event triggered after rendering the scene
  36215. */
  36216. onAfterRenderObservable: Observable<Scene>;
  36217. /**
  36218. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36219. */
  36220. onAfterRenderCameraObservable: Observable<Camera>;
  36221. private _onAfterRenderObserver;
  36222. /** Sets a function to be executed after rendering this scene */
  36223. set afterRender(callback: Nullable<() => void>);
  36224. /**
  36225. * An event triggered before animating the scene
  36226. */
  36227. onBeforeAnimationsObservable: Observable<Scene>;
  36228. /**
  36229. * An event triggered after animations processing
  36230. */
  36231. onAfterAnimationsObservable: Observable<Scene>;
  36232. /**
  36233. * An event triggered before draw calls are ready to be sent
  36234. */
  36235. onBeforeDrawPhaseObservable: Observable<Scene>;
  36236. /**
  36237. * An event triggered after draw calls have been sent
  36238. */
  36239. onAfterDrawPhaseObservable: Observable<Scene>;
  36240. /**
  36241. * An event triggered when the scene is ready
  36242. */
  36243. onReadyObservable: Observable<Scene>;
  36244. /**
  36245. * An event triggered before rendering a camera
  36246. */
  36247. onBeforeCameraRenderObservable: Observable<Camera>;
  36248. private _onBeforeCameraRenderObserver;
  36249. /** Sets a function to be executed before rendering a camera*/
  36250. set beforeCameraRender(callback: () => void);
  36251. /**
  36252. * An event triggered after rendering a camera
  36253. */
  36254. onAfterCameraRenderObservable: Observable<Camera>;
  36255. private _onAfterCameraRenderObserver;
  36256. /** Sets a function to be executed after rendering a camera*/
  36257. set afterCameraRender(callback: () => void);
  36258. /**
  36259. * An event triggered when active meshes evaluation is about to start
  36260. */
  36261. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36262. /**
  36263. * An event triggered when active meshes evaluation is done
  36264. */
  36265. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36266. /**
  36267. * An event triggered when particles rendering is about to start
  36268. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36269. */
  36270. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36271. /**
  36272. * An event triggered when particles rendering is done
  36273. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36274. */
  36275. onAfterParticlesRenderingObservable: Observable<Scene>;
  36276. /**
  36277. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36278. */
  36279. onDataLoadedObservable: Observable<Scene>;
  36280. /**
  36281. * An event triggered when a camera is created
  36282. */
  36283. onNewCameraAddedObservable: Observable<Camera>;
  36284. /**
  36285. * An event triggered when a camera is removed
  36286. */
  36287. onCameraRemovedObservable: Observable<Camera>;
  36288. /**
  36289. * An event triggered when a light is created
  36290. */
  36291. onNewLightAddedObservable: Observable<Light>;
  36292. /**
  36293. * An event triggered when a light is removed
  36294. */
  36295. onLightRemovedObservable: Observable<Light>;
  36296. /**
  36297. * An event triggered when a geometry is created
  36298. */
  36299. onNewGeometryAddedObservable: Observable<Geometry>;
  36300. /**
  36301. * An event triggered when a geometry is removed
  36302. */
  36303. onGeometryRemovedObservable: Observable<Geometry>;
  36304. /**
  36305. * An event triggered when a transform node is created
  36306. */
  36307. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36308. /**
  36309. * An event triggered when a transform node is removed
  36310. */
  36311. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36312. /**
  36313. * An event triggered when a mesh is created
  36314. */
  36315. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36316. /**
  36317. * An event triggered when a mesh is removed
  36318. */
  36319. onMeshRemovedObservable: Observable<AbstractMesh>;
  36320. /**
  36321. * An event triggered when a skeleton is created
  36322. */
  36323. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36324. /**
  36325. * An event triggered when a skeleton is removed
  36326. */
  36327. onSkeletonRemovedObservable: Observable<Skeleton>;
  36328. /**
  36329. * An event triggered when a material is created
  36330. */
  36331. onNewMaterialAddedObservable: Observable<Material>;
  36332. /**
  36333. * An event triggered when a material is removed
  36334. */
  36335. onMaterialRemovedObservable: Observable<Material>;
  36336. /**
  36337. * An event triggered when a texture is created
  36338. */
  36339. onNewTextureAddedObservable: Observable<BaseTexture>;
  36340. /**
  36341. * An event triggered when a texture is removed
  36342. */
  36343. onTextureRemovedObservable: Observable<BaseTexture>;
  36344. /**
  36345. * An event triggered when render targets are about to be rendered
  36346. * Can happen multiple times per frame.
  36347. */
  36348. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36349. /**
  36350. * An event triggered when render targets were rendered.
  36351. * Can happen multiple times per frame.
  36352. */
  36353. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36354. /**
  36355. * An event triggered before calculating deterministic simulation step
  36356. */
  36357. onBeforeStepObservable: Observable<Scene>;
  36358. /**
  36359. * An event triggered after calculating deterministic simulation step
  36360. */
  36361. onAfterStepObservable: Observable<Scene>;
  36362. /**
  36363. * An event triggered when the activeCamera property is updated
  36364. */
  36365. onActiveCameraChanged: Observable<Scene>;
  36366. /**
  36367. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36368. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36369. * 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)
  36370. */
  36371. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36372. /**
  36373. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36374. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36375. * 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)
  36376. */
  36377. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36378. /**
  36379. * This Observable will when a mesh has been imported into the scene.
  36380. */
  36381. onMeshImportedObservable: Observable<AbstractMesh>;
  36382. /**
  36383. * This Observable will when an animation file has been imported into the scene.
  36384. */
  36385. onAnimationFileImportedObservable: Observable<Scene>;
  36386. /**
  36387. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36388. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36389. */
  36390. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36391. /** @hidden */
  36392. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36393. /**
  36394. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36395. */
  36396. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36397. /**
  36398. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36399. */
  36400. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36401. /**
  36402. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36403. */
  36404. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36405. /** Callback called when a pointer move is detected */
  36406. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36407. /** Callback called when a pointer down is detected */
  36408. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36409. /** Callback called when a pointer up is detected */
  36410. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36411. /** Callback called when a pointer pick is detected */
  36412. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36413. /**
  36414. * 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).
  36415. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36416. */
  36417. onPrePointerObservable: Observable<PointerInfoPre>;
  36418. /**
  36419. * Observable event triggered each time an input event is received from the rendering canvas
  36420. */
  36421. onPointerObservable: Observable<PointerInfo>;
  36422. /**
  36423. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36424. */
  36425. get unTranslatedPointer(): Vector2;
  36426. /**
  36427. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36428. */
  36429. static get DragMovementThreshold(): number;
  36430. static set DragMovementThreshold(value: number);
  36431. /**
  36432. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36433. */
  36434. static get LongPressDelay(): number;
  36435. static set LongPressDelay(value: number);
  36436. /**
  36437. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36438. */
  36439. static get DoubleClickDelay(): number;
  36440. static set DoubleClickDelay(value: number);
  36441. /** If you need to check double click without raising a single click at first click, enable this flag */
  36442. static get ExclusiveDoubleClickMode(): boolean;
  36443. static set ExclusiveDoubleClickMode(value: boolean);
  36444. /** @hidden */
  36445. _mirroredCameraPosition: Nullable<Vector3>;
  36446. /**
  36447. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36448. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36449. */
  36450. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36451. /**
  36452. * Observable event triggered each time an keyboard event is received from the hosting window
  36453. */
  36454. onKeyboardObservable: Observable<KeyboardInfo>;
  36455. private _useRightHandedSystem;
  36456. /**
  36457. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36458. */
  36459. set useRightHandedSystem(value: boolean);
  36460. get useRightHandedSystem(): boolean;
  36461. private _timeAccumulator;
  36462. private _currentStepId;
  36463. private _currentInternalStep;
  36464. /**
  36465. * Sets the step Id used by deterministic lock step
  36466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36467. * @param newStepId defines the step Id
  36468. */
  36469. setStepId(newStepId: number): void;
  36470. /**
  36471. * Gets the step Id used by deterministic lock step
  36472. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36473. * @returns the step Id
  36474. */
  36475. getStepId(): number;
  36476. /**
  36477. * Gets the internal step used by deterministic lock step
  36478. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36479. * @returns the internal step
  36480. */
  36481. getInternalStep(): number;
  36482. private _fogEnabled;
  36483. /**
  36484. * Gets or sets a boolean indicating if fog is enabled on this scene
  36485. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36486. * (Default is true)
  36487. */
  36488. set fogEnabled(value: boolean);
  36489. get fogEnabled(): boolean;
  36490. private _fogMode;
  36491. /**
  36492. * Gets or sets the fog mode to use
  36493. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36494. * | mode | value |
  36495. * | --- | --- |
  36496. * | FOGMODE_NONE | 0 |
  36497. * | FOGMODE_EXP | 1 |
  36498. * | FOGMODE_EXP2 | 2 |
  36499. * | FOGMODE_LINEAR | 3 |
  36500. */
  36501. set fogMode(value: number);
  36502. get fogMode(): number;
  36503. /**
  36504. * Gets or sets the fog color to use
  36505. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36506. * (Default is Color3(0.2, 0.2, 0.3))
  36507. */
  36508. fogColor: Color3;
  36509. /**
  36510. * Gets or sets the fog density to use
  36511. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36512. * (Default is 0.1)
  36513. */
  36514. fogDensity: number;
  36515. /**
  36516. * Gets or sets the fog start distance to use
  36517. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36518. * (Default is 0)
  36519. */
  36520. fogStart: number;
  36521. /**
  36522. * Gets or sets the fog end distance to use
  36523. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36524. * (Default is 1000)
  36525. */
  36526. fogEnd: number;
  36527. private _shadowsEnabled;
  36528. /**
  36529. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36530. */
  36531. set shadowsEnabled(value: boolean);
  36532. get shadowsEnabled(): boolean;
  36533. private _lightsEnabled;
  36534. /**
  36535. * Gets or sets a boolean indicating if lights are enabled on this scene
  36536. */
  36537. set lightsEnabled(value: boolean);
  36538. get lightsEnabled(): boolean;
  36539. /** All of the active cameras added to this scene. */
  36540. activeCameras: Camera[];
  36541. /** @hidden */
  36542. _activeCamera: Nullable<Camera>;
  36543. /** Gets or sets the current active camera */
  36544. get activeCamera(): Nullable<Camera>;
  36545. set activeCamera(value: Nullable<Camera>);
  36546. private _defaultMaterial;
  36547. /** The default material used on meshes when no material is affected */
  36548. get defaultMaterial(): Material;
  36549. /** The default material used on meshes when no material is affected */
  36550. set defaultMaterial(value: Material);
  36551. private _texturesEnabled;
  36552. /**
  36553. * Gets or sets a boolean indicating if textures are enabled on this scene
  36554. */
  36555. set texturesEnabled(value: boolean);
  36556. get texturesEnabled(): boolean;
  36557. /**
  36558. * Gets or sets a boolean indicating if particles are enabled on this scene
  36559. */
  36560. particlesEnabled: boolean;
  36561. /**
  36562. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36563. */
  36564. spritesEnabled: boolean;
  36565. private _skeletonsEnabled;
  36566. /**
  36567. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36568. */
  36569. set skeletonsEnabled(value: boolean);
  36570. get skeletonsEnabled(): boolean;
  36571. /**
  36572. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36573. */
  36574. lensFlaresEnabled: boolean;
  36575. /**
  36576. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36578. */
  36579. collisionsEnabled: boolean;
  36580. private _collisionCoordinator;
  36581. /** @hidden */
  36582. get collisionCoordinator(): ICollisionCoordinator;
  36583. /**
  36584. * Defines the gravity applied to this scene (used only for collisions)
  36585. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36586. */
  36587. gravity: Vector3;
  36588. /**
  36589. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36590. */
  36591. postProcessesEnabled: boolean;
  36592. /**
  36593. * The list of postprocesses added to the scene
  36594. */
  36595. postProcesses: PostProcess[];
  36596. /**
  36597. * Gets the current postprocess manager
  36598. */
  36599. postProcessManager: PostProcessManager;
  36600. /**
  36601. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36602. */
  36603. renderTargetsEnabled: boolean;
  36604. /**
  36605. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36606. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36607. */
  36608. dumpNextRenderTargets: boolean;
  36609. /**
  36610. * The list of user defined render targets added to the scene
  36611. */
  36612. customRenderTargets: RenderTargetTexture[];
  36613. /**
  36614. * Defines if texture loading must be delayed
  36615. * If true, textures will only be loaded when they need to be rendered
  36616. */
  36617. useDelayedTextureLoading: boolean;
  36618. /**
  36619. * Gets the list of meshes imported to the scene through SceneLoader
  36620. */
  36621. importedMeshesFiles: String[];
  36622. /**
  36623. * Gets or sets a boolean indicating if probes are enabled on this scene
  36624. */
  36625. probesEnabled: boolean;
  36626. /**
  36627. * Gets or sets the current offline provider to use to store scene data
  36628. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36629. */
  36630. offlineProvider: IOfflineProvider;
  36631. /**
  36632. * Gets or sets the action manager associated with the scene
  36633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36634. */
  36635. actionManager: AbstractActionManager;
  36636. private _meshesForIntersections;
  36637. /**
  36638. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36639. */
  36640. proceduralTexturesEnabled: boolean;
  36641. private _engine;
  36642. private _totalVertices;
  36643. /** @hidden */
  36644. _activeIndices: PerfCounter;
  36645. /** @hidden */
  36646. _activeParticles: PerfCounter;
  36647. /** @hidden */
  36648. _activeBones: PerfCounter;
  36649. private _animationRatio;
  36650. /** @hidden */
  36651. _animationTimeLast: number;
  36652. /** @hidden */
  36653. _animationTime: number;
  36654. /**
  36655. * Gets or sets a general scale for animation speed
  36656. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36657. */
  36658. animationTimeScale: number;
  36659. /** @hidden */
  36660. _cachedMaterial: Nullable<Material>;
  36661. /** @hidden */
  36662. _cachedEffect: Nullable<Effect>;
  36663. /** @hidden */
  36664. _cachedVisibility: Nullable<number>;
  36665. private _renderId;
  36666. private _frameId;
  36667. private _executeWhenReadyTimeoutId;
  36668. private _intermediateRendering;
  36669. private _viewUpdateFlag;
  36670. private _projectionUpdateFlag;
  36671. /** @hidden */
  36672. _toBeDisposed: Nullable<IDisposable>[];
  36673. private _activeRequests;
  36674. /** @hidden */
  36675. _pendingData: any[];
  36676. private _isDisposed;
  36677. /**
  36678. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36679. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36680. */
  36681. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36682. private _activeMeshes;
  36683. private _processedMaterials;
  36684. private _renderTargets;
  36685. /** @hidden */
  36686. _activeParticleSystems: SmartArray<IParticleSystem>;
  36687. private _activeSkeletons;
  36688. private _softwareSkinnedMeshes;
  36689. private _renderingManager;
  36690. /** @hidden */
  36691. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36692. private _transformMatrix;
  36693. private _sceneUbo;
  36694. /** @hidden */
  36695. _viewMatrix: Matrix;
  36696. private _projectionMatrix;
  36697. /** @hidden */
  36698. _forcedViewPosition: Nullable<Vector3>;
  36699. /** @hidden */
  36700. _frustumPlanes: Plane[];
  36701. /**
  36702. * Gets the list of frustum planes (built from the active camera)
  36703. */
  36704. get frustumPlanes(): Plane[];
  36705. /**
  36706. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36707. * This is useful if there are more lights that the maximum simulteanous authorized
  36708. */
  36709. requireLightSorting: boolean;
  36710. /** @hidden */
  36711. readonly useMaterialMeshMap: boolean;
  36712. /** @hidden */
  36713. readonly useClonedMeshMap: boolean;
  36714. private _externalData;
  36715. private _uid;
  36716. /**
  36717. * @hidden
  36718. * Backing store of defined scene components.
  36719. */
  36720. _components: ISceneComponent[];
  36721. /**
  36722. * @hidden
  36723. * Backing store of defined scene components.
  36724. */
  36725. _serializableComponents: ISceneSerializableComponent[];
  36726. /**
  36727. * List of components to register on the next registration step.
  36728. */
  36729. private _transientComponents;
  36730. /**
  36731. * Registers the transient components if needed.
  36732. */
  36733. private _registerTransientComponents;
  36734. /**
  36735. * @hidden
  36736. * Add a component to the scene.
  36737. * Note that the ccomponent could be registered on th next frame if this is called after
  36738. * the register component stage.
  36739. * @param component Defines the component to add to the scene
  36740. */
  36741. _addComponent(component: ISceneComponent): void;
  36742. /**
  36743. * @hidden
  36744. * Gets a component from the scene.
  36745. * @param name defines the name of the component to retrieve
  36746. * @returns the component or null if not present
  36747. */
  36748. _getComponent(name: string): Nullable<ISceneComponent>;
  36749. /**
  36750. * @hidden
  36751. * Defines the actions happening before camera updates.
  36752. */
  36753. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36754. /**
  36755. * @hidden
  36756. * Defines the actions happening before clear the canvas.
  36757. */
  36758. _beforeClearStage: Stage<SimpleStageAction>;
  36759. /**
  36760. * @hidden
  36761. * Defines the actions when collecting render targets for the frame.
  36762. */
  36763. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36764. /**
  36765. * @hidden
  36766. * Defines the actions happening for one camera in the frame.
  36767. */
  36768. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36769. /**
  36770. * @hidden
  36771. * Defines the actions happening during the per mesh ready checks.
  36772. */
  36773. _isReadyForMeshStage: Stage<MeshStageAction>;
  36774. /**
  36775. * @hidden
  36776. * Defines the actions happening before evaluate active mesh checks.
  36777. */
  36778. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36779. /**
  36780. * @hidden
  36781. * Defines the actions happening during the evaluate sub mesh checks.
  36782. */
  36783. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36784. /**
  36785. * @hidden
  36786. * Defines the actions happening during the active mesh stage.
  36787. */
  36788. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36789. /**
  36790. * @hidden
  36791. * Defines the actions happening during the per camera render target step.
  36792. */
  36793. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36794. /**
  36795. * @hidden
  36796. * Defines the actions happening just before the active camera is drawing.
  36797. */
  36798. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36799. /**
  36800. * @hidden
  36801. * Defines the actions happening just before a render target is drawing.
  36802. */
  36803. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36804. /**
  36805. * @hidden
  36806. * Defines the actions happening just before a rendering group is drawing.
  36807. */
  36808. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36809. /**
  36810. * @hidden
  36811. * Defines the actions happening just before a mesh is drawing.
  36812. */
  36813. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36814. /**
  36815. * @hidden
  36816. * Defines the actions happening just after a mesh has been drawn.
  36817. */
  36818. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36819. /**
  36820. * @hidden
  36821. * Defines the actions happening just after a rendering group has been drawn.
  36822. */
  36823. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36824. /**
  36825. * @hidden
  36826. * Defines the actions happening just after the active camera has been drawn.
  36827. */
  36828. _afterCameraDrawStage: Stage<CameraStageAction>;
  36829. /**
  36830. * @hidden
  36831. * Defines the actions happening just after a render target has been drawn.
  36832. */
  36833. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36834. /**
  36835. * @hidden
  36836. * Defines the actions happening just after rendering all cameras and computing intersections.
  36837. */
  36838. _afterRenderStage: Stage<SimpleStageAction>;
  36839. /**
  36840. * @hidden
  36841. * Defines the actions happening when a pointer move event happens.
  36842. */
  36843. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36844. /**
  36845. * @hidden
  36846. * Defines the actions happening when a pointer down event happens.
  36847. */
  36848. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36849. /**
  36850. * @hidden
  36851. * Defines the actions happening when a pointer up event happens.
  36852. */
  36853. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36854. /**
  36855. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36856. */
  36857. private geometriesByUniqueId;
  36858. /**
  36859. * Creates a new Scene
  36860. * @param engine defines the engine to use to render this scene
  36861. * @param options defines the scene options
  36862. */
  36863. constructor(engine: Engine, options?: SceneOptions);
  36864. /**
  36865. * Gets a string idenfifying the name of the class
  36866. * @returns "Scene" string
  36867. */
  36868. getClassName(): string;
  36869. private _defaultMeshCandidates;
  36870. /**
  36871. * @hidden
  36872. */
  36873. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36874. private _defaultSubMeshCandidates;
  36875. /**
  36876. * @hidden
  36877. */
  36878. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36879. /**
  36880. * Sets the default candidate providers for the scene.
  36881. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36882. * and getCollidingSubMeshCandidates to their default function
  36883. */
  36884. setDefaultCandidateProviders(): void;
  36885. /**
  36886. * Gets the mesh that is currently under the pointer
  36887. */
  36888. get meshUnderPointer(): Nullable<AbstractMesh>;
  36889. /**
  36890. * Gets or sets the current on-screen X position of the pointer
  36891. */
  36892. get pointerX(): number;
  36893. set pointerX(value: number);
  36894. /**
  36895. * Gets or sets the current on-screen Y position of the pointer
  36896. */
  36897. get pointerY(): number;
  36898. set pointerY(value: number);
  36899. /**
  36900. * Gets the cached material (ie. the latest rendered one)
  36901. * @returns the cached material
  36902. */
  36903. getCachedMaterial(): Nullable<Material>;
  36904. /**
  36905. * Gets the cached effect (ie. the latest rendered one)
  36906. * @returns the cached effect
  36907. */
  36908. getCachedEffect(): Nullable<Effect>;
  36909. /**
  36910. * Gets the cached visibility state (ie. the latest rendered one)
  36911. * @returns the cached visibility state
  36912. */
  36913. getCachedVisibility(): Nullable<number>;
  36914. /**
  36915. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36916. * @param material defines the current material
  36917. * @param effect defines the current effect
  36918. * @param visibility defines the current visibility state
  36919. * @returns true if one parameter is not cached
  36920. */
  36921. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36922. /**
  36923. * Gets the engine associated with the scene
  36924. * @returns an Engine
  36925. */
  36926. getEngine(): Engine;
  36927. /**
  36928. * Gets the total number of vertices rendered per frame
  36929. * @returns the total number of vertices rendered per frame
  36930. */
  36931. getTotalVertices(): number;
  36932. /**
  36933. * Gets the performance counter for total vertices
  36934. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36935. */
  36936. get totalVerticesPerfCounter(): PerfCounter;
  36937. /**
  36938. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36939. * @returns the total number of active indices rendered per frame
  36940. */
  36941. getActiveIndices(): number;
  36942. /**
  36943. * Gets the performance counter for active indices
  36944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36945. */
  36946. get totalActiveIndicesPerfCounter(): PerfCounter;
  36947. /**
  36948. * Gets the total number of active particles rendered per frame
  36949. * @returns the total number of active particles rendered per frame
  36950. */
  36951. getActiveParticles(): number;
  36952. /**
  36953. * Gets the performance counter for active particles
  36954. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36955. */
  36956. get activeParticlesPerfCounter(): PerfCounter;
  36957. /**
  36958. * Gets the total number of active bones rendered per frame
  36959. * @returns the total number of active bones rendered per frame
  36960. */
  36961. getActiveBones(): number;
  36962. /**
  36963. * Gets the performance counter for active bones
  36964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36965. */
  36966. get activeBonesPerfCounter(): PerfCounter;
  36967. /**
  36968. * Gets the array of active meshes
  36969. * @returns an array of AbstractMesh
  36970. */
  36971. getActiveMeshes(): SmartArray<AbstractMesh>;
  36972. /**
  36973. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36974. * @returns a number
  36975. */
  36976. getAnimationRatio(): number;
  36977. /**
  36978. * Gets an unique Id for the current render phase
  36979. * @returns a number
  36980. */
  36981. getRenderId(): number;
  36982. /**
  36983. * Gets an unique Id for the current frame
  36984. * @returns a number
  36985. */
  36986. getFrameId(): number;
  36987. /** Call this function if you want to manually increment the render Id*/
  36988. incrementRenderId(): void;
  36989. private _createUbo;
  36990. /**
  36991. * Use this method to simulate a pointer move on a mesh
  36992. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36993. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36994. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36995. * @returns the current scene
  36996. */
  36997. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36998. /**
  36999. * Use this method to simulate a pointer down on a mesh
  37000. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37001. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37002. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37003. * @returns the current scene
  37004. */
  37005. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37006. /**
  37007. * Use this method to simulate a pointer up on a mesh
  37008. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37009. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37010. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37011. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37012. * @returns the current scene
  37013. */
  37014. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37015. /**
  37016. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37017. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37018. * @returns true if the pointer was captured
  37019. */
  37020. isPointerCaptured(pointerId?: number): boolean;
  37021. /**
  37022. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37023. * @param attachUp defines if you want to attach events to pointerup
  37024. * @param attachDown defines if you want to attach events to pointerdown
  37025. * @param attachMove defines if you want to attach events to pointermove
  37026. */
  37027. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37028. /** Detaches all event handlers*/
  37029. detachControl(): void;
  37030. /**
  37031. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37032. * Delay loaded resources are not taking in account
  37033. * @return true if all required resources are ready
  37034. */
  37035. isReady(): boolean;
  37036. /** Resets all cached information relative to material (including effect and visibility) */
  37037. resetCachedMaterial(): void;
  37038. /**
  37039. * Registers a function to be called before every frame render
  37040. * @param func defines the function to register
  37041. */
  37042. registerBeforeRender(func: () => void): void;
  37043. /**
  37044. * Unregisters a function called before every frame render
  37045. * @param func defines the function to unregister
  37046. */
  37047. unregisterBeforeRender(func: () => void): void;
  37048. /**
  37049. * Registers a function to be called after every frame render
  37050. * @param func defines the function to register
  37051. */
  37052. registerAfterRender(func: () => void): void;
  37053. /**
  37054. * Unregisters a function called after every frame render
  37055. * @param func defines the function to unregister
  37056. */
  37057. unregisterAfterRender(func: () => void): void;
  37058. private _executeOnceBeforeRender;
  37059. /**
  37060. * The provided function will run before render once and will be disposed afterwards.
  37061. * A timeout delay can be provided so that the function will be executed in N ms.
  37062. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37063. * @param func The function to be executed.
  37064. * @param timeout optional delay in ms
  37065. */
  37066. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37067. /** @hidden */
  37068. _addPendingData(data: any): void;
  37069. /** @hidden */
  37070. _removePendingData(data: any): void;
  37071. /**
  37072. * Returns the number of items waiting to be loaded
  37073. * @returns the number of items waiting to be loaded
  37074. */
  37075. getWaitingItemsCount(): number;
  37076. /**
  37077. * Returns a boolean indicating if the scene is still loading data
  37078. */
  37079. get isLoading(): boolean;
  37080. /**
  37081. * Registers a function to be executed when the scene is ready
  37082. * @param {Function} func - the function to be executed
  37083. */
  37084. executeWhenReady(func: () => void): void;
  37085. /**
  37086. * Returns a promise that resolves when the scene is ready
  37087. * @returns A promise that resolves when the scene is ready
  37088. */
  37089. whenReadyAsync(): Promise<void>;
  37090. /** @hidden */
  37091. _checkIsReady(): void;
  37092. /**
  37093. * Gets all animatable attached to the scene
  37094. */
  37095. get animatables(): Animatable[];
  37096. /**
  37097. * Resets the last animation time frame.
  37098. * Useful to override when animations start running when loading a scene for the first time.
  37099. */
  37100. resetLastAnimationTimeFrame(): void;
  37101. /**
  37102. * Gets the current view matrix
  37103. * @returns a Matrix
  37104. */
  37105. getViewMatrix(): Matrix;
  37106. /**
  37107. * Gets the current projection matrix
  37108. * @returns a Matrix
  37109. */
  37110. getProjectionMatrix(): Matrix;
  37111. /**
  37112. * Gets the current transform matrix
  37113. * @returns a Matrix made of View * Projection
  37114. */
  37115. getTransformMatrix(): Matrix;
  37116. /**
  37117. * Sets the current transform matrix
  37118. * @param viewL defines the View matrix to use
  37119. * @param projectionL defines the Projection matrix to use
  37120. * @param viewR defines the right View matrix to use (if provided)
  37121. * @param projectionR defines the right Projection matrix to use (if provided)
  37122. */
  37123. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37124. /**
  37125. * Gets the uniform buffer used to store scene data
  37126. * @returns a UniformBuffer
  37127. */
  37128. getSceneUniformBuffer(): UniformBuffer;
  37129. /**
  37130. * Gets an unique (relatively to the current scene) Id
  37131. * @returns an unique number for the scene
  37132. */
  37133. getUniqueId(): number;
  37134. /**
  37135. * Add a mesh to the list of scene's meshes
  37136. * @param newMesh defines the mesh to add
  37137. * @param recursive if all child meshes should also be added to the scene
  37138. */
  37139. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37140. /**
  37141. * Remove a mesh for the list of scene's meshes
  37142. * @param toRemove defines the mesh to remove
  37143. * @param recursive if all child meshes should also be removed from the scene
  37144. * @returns the index where the mesh was in the mesh list
  37145. */
  37146. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37147. /**
  37148. * Add a transform node to the list of scene's transform nodes
  37149. * @param newTransformNode defines the transform node to add
  37150. */
  37151. addTransformNode(newTransformNode: TransformNode): void;
  37152. /**
  37153. * Remove a transform node for the list of scene's transform nodes
  37154. * @param toRemove defines the transform node to remove
  37155. * @returns the index where the transform node was in the transform node list
  37156. */
  37157. removeTransformNode(toRemove: TransformNode): number;
  37158. /**
  37159. * Remove a skeleton for the list of scene's skeletons
  37160. * @param toRemove defines the skeleton to remove
  37161. * @returns the index where the skeleton was in the skeleton list
  37162. */
  37163. removeSkeleton(toRemove: Skeleton): number;
  37164. /**
  37165. * Remove a morph target for the list of scene's morph targets
  37166. * @param toRemove defines the morph target to remove
  37167. * @returns the index where the morph target was in the morph target list
  37168. */
  37169. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37170. /**
  37171. * Remove a light for the list of scene's lights
  37172. * @param toRemove defines the light to remove
  37173. * @returns the index where the light was in the light list
  37174. */
  37175. removeLight(toRemove: Light): number;
  37176. /**
  37177. * Remove a camera for the list of scene's cameras
  37178. * @param toRemove defines the camera to remove
  37179. * @returns the index where the camera was in the camera list
  37180. */
  37181. removeCamera(toRemove: Camera): number;
  37182. /**
  37183. * Remove a particle system for the list of scene's particle systems
  37184. * @param toRemove defines the particle system to remove
  37185. * @returns the index where the particle system was in the particle system list
  37186. */
  37187. removeParticleSystem(toRemove: IParticleSystem): number;
  37188. /**
  37189. * Remove a animation for the list of scene's animations
  37190. * @param toRemove defines the animation to remove
  37191. * @returns the index where the animation was in the animation list
  37192. */
  37193. removeAnimation(toRemove: Animation): number;
  37194. /**
  37195. * Will stop the animation of the given target
  37196. * @param target - the target
  37197. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37198. * @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)
  37199. */
  37200. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37201. /**
  37202. * Removes the given animation group from this scene.
  37203. * @param toRemove The animation group to remove
  37204. * @returns The index of the removed animation group
  37205. */
  37206. removeAnimationGroup(toRemove: AnimationGroup): number;
  37207. /**
  37208. * Removes the given multi-material from this scene.
  37209. * @param toRemove The multi-material to remove
  37210. * @returns The index of the removed multi-material
  37211. */
  37212. removeMultiMaterial(toRemove: MultiMaterial): number;
  37213. /**
  37214. * Removes the given material from this scene.
  37215. * @param toRemove The material to remove
  37216. * @returns The index of the removed material
  37217. */
  37218. removeMaterial(toRemove: Material): number;
  37219. /**
  37220. * Removes the given action manager from this scene.
  37221. * @param toRemove The action manager to remove
  37222. * @returns The index of the removed action manager
  37223. */
  37224. removeActionManager(toRemove: AbstractActionManager): number;
  37225. /**
  37226. * Removes the given texture from this scene.
  37227. * @param toRemove The texture to remove
  37228. * @returns The index of the removed texture
  37229. */
  37230. removeTexture(toRemove: BaseTexture): number;
  37231. /**
  37232. * Adds the given light to this scene
  37233. * @param newLight The light to add
  37234. */
  37235. addLight(newLight: Light): void;
  37236. /**
  37237. * Sorts the list list based on light priorities
  37238. */
  37239. sortLightsByPriority(): void;
  37240. /**
  37241. * Adds the given camera to this scene
  37242. * @param newCamera The camera to add
  37243. */
  37244. addCamera(newCamera: Camera): void;
  37245. /**
  37246. * Adds the given skeleton to this scene
  37247. * @param newSkeleton The skeleton to add
  37248. */
  37249. addSkeleton(newSkeleton: Skeleton): void;
  37250. /**
  37251. * Adds the given particle system to this scene
  37252. * @param newParticleSystem The particle system to add
  37253. */
  37254. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37255. /**
  37256. * Adds the given animation to this scene
  37257. * @param newAnimation The animation to add
  37258. */
  37259. addAnimation(newAnimation: Animation): void;
  37260. /**
  37261. * Adds the given animation group to this scene.
  37262. * @param newAnimationGroup The animation group to add
  37263. */
  37264. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37265. /**
  37266. * Adds the given multi-material to this scene
  37267. * @param newMultiMaterial The multi-material to add
  37268. */
  37269. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37270. /**
  37271. * Adds the given material to this scene
  37272. * @param newMaterial The material to add
  37273. */
  37274. addMaterial(newMaterial: Material): void;
  37275. /**
  37276. * Adds the given morph target to this scene
  37277. * @param newMorphTargetManager The morph target to add
  37278. */
  37279. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37280. /**
  37281. * Adds the given geometry to this scene
  37282. * @param newGeometry The geometry to add
  37283. */
  37284. addGeometry(newGeometry: Geometry): void;
  37285. /**
  37286. * Adds the given action manager to this scene
  37287. * @param newActionManager The action manager to add
  37288. */
  37289. addActionManager(newActionManager: AbstractActionManager): void;
  37290. /**
  37291. * Adds the given texture to this scene.
  37292. * @param newTexture The texture to add
  37293. */
  37294. addTexture(newTexture: BaseTexture): void;
  37295. /**
  37296. * Switch active camera
  37297. * @param newCamera defines the new active camera
  37298. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37299. */
  37300. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37301. /**
  37302. * sets the active camera of the scene using its ID
  37303. * @param id defines the camera's ID
  37304. * @return the new active camera or null if none found.
  37305. */
  37306. setActiveCameraByID(id: string): Nullable<Camera>;
  37307. /**
  37308. * sets the active camera of the scene using its name
  37309. * @param name defines the camera's name
  37310. * @returns the new active camera or null if none found.
  37311. */
  37312. setActiveCameraByName(name: string): Nullable<Camera>;
  37313. /**
  37314. * get an animation group using its name
  37315. * @param name defines the material's name
  37316. * @return the animation group or null if none found.
  37317. */
  37318. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37319. /**
  37320. * Get a material using its unique id
  37321. * @param uniqueId defines the material's unique id
  37322. * @return the material or null if none found.
  37323. */
  37324. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37325. /**
  37326. * get a material using its id
  37327. * @param id defines the material's ID
  37328. * @return the material or null if none found.
  37329. */
  37330. getMaterialByID(id: string): Nullable<Material>;
  37331. /**
  37332. * Gets a the last added material using a given id
  37333. * @param id defines the material's ID
  37334. * @return the last material with the given id or null if none found.
  37335. */
  37336. getLastMaterialByID(id: string): Nullable<Material>;
  37337. /**
  37338. * Gets a material using its name
  37339. * @param name defines the material's name
  37340. * @return the material or null if none found.
  37341. */
  37342. getMaterialByName(name: string): Nullable<Material>;
  37343. /**
  37344. * Get a texture using its unique id
  37345. * @param uniqueId defines the texture's unique id
  37346. * @return the texture or null if none found.
  37347. */
  37348. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37349. /**
  37350. * Gets a camera using its id
  37351. * @param id defines the id to look for
  37352. * @returns the camera or null if not found
  37353. */
  37354. getCameraByID(id: string): Nullable<Camera>;
  37355. /**
  37356. * Gets a camera using its unique id
  37357. * @param uniqueId defines the unique id to look for
  37358. * @returns the camera or null if not found
  37359. */
  37360. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37361. /**
  37362. * Gets a camera using its name
  37363. * @param name defines the camera's name
  37364. * @return the camera or null if none found.
  37365. */
  37366. getCameraByName(name: string): Nullable<Camera>;
  37367. /**
  37368. * Gets a bone using its id
  37369. * @param id defines the bone's id
  37370. * @return the bone or null if not found
  37371. */
  37372. getBoneByID(id: string): Nullable<Bone>;
  37373. /**
  37374. * Gets a bone using its id
  37375. * @param name defines the bone's name
  37376. * @return the bone or null if not found
  37377. */
  37378. getBoneByName(name: string): Nullable<Bone>;
  37379. /**
  37380. * Gets a light node using its name
  37381. * @param name defines the the light's name
  37382. * @return the light or null if none found.
  37383. */
  37384. getLightByName(name: string): Nullable<Light>;
  37385. /**
  37386. * Gets a light node using its id
  37387. * @param id defines the light's id
  37388. * @return the light or null if none found.
  37389. */
  37390. getLightByID(id: string): Nullable<Light>;
  37391. /**
  37392. * Gets a light node using its scene-generated unique ID
  37393. * @param uniqueId defines the light's unique id
  37394. * @return the light or null if none found.
  37395. */
  37396. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37397. /**
  37398. * Gets a particle system by id
  37399. * @param id defines the particle system id
  37400. * @return the corresponding system or null if none found
  37401. */
  37402. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37403. /**
  37404. * Gets a geometry using its ID
  37405. * @param id defines the geometry's id
  37406. * @return the geometry or null if none found.
  37407. */
  37408. getGeometryByID(id: string): Nullable<Geometry>;
  37409. private _getGeometryByUniqueID;
  37410. /**
  37411. * Add a new geometry to this scene
  37412. * @param geometry defines the geometry to be added to the scene.
  37413. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37414. * @return a boolean defining if the geometry was added or not
  37415. */
  37416. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37417. /**
  37418. * Removes an existing geometry
  37419. * @param geometry defines the geometry to be removed from the scene
  37420. * @return a boolean defining if the geometry was removed or not
  37421. */
  37422. removeGeometry(geometry: Geometry): boolean;
  37423. /**
  37424. * Gets the list of geometries attached to the scene
  37425. * @returns an array of Geometry
  37426. */
  37427. getGeometries(): Geometry[];
  37428. /**
  37429. * Gets the first added mesh found of a given ID
  37430. * @param id defines the id to search for
  37431. * @return the mesh found or null if not found at all
  37432. */
  37433. getMeshByID(id: string): Nullable<AbstractMesh>;
  37434. /**
  37435. * Gets a list of meshes using their id
  37436. * @param id defines the id to search for
  37437. * @returns a list of meshes
  37438. */
  37439. getMeshesByID(id: string): Array<AbstractMesh>;
  37440. /**
  37441. * Gets the first added transform node found of a given ID
  37442. * @param id defines the id to search for
  37443. * @return the found transform node or null if not found at all.
  37444. */
  37445. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37446. /**
  37447. * Gets a transform node with its auto-generated unique id
  37448. * @param uniqueId efines the unique id to search for
  37449. * @return the found transform node or null if not found at all.
  37450. */
  37451. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37452. /**
  37453. * Gets a list of transform nodes using their id
  37454. * @param id defines the id to search for
  37455. * @returns a list of transform nodes
  37456. */
  37457. getTransformNodesByID(id: string): Array<TransformNode>;
  37458. /**
  37459. * Gets a mesh with its auto-generated unique id
  37460. * @param uniqueId defines the unique id to search for
  37461. * @return the found mesh or null if not found at all.
  37462. */
  37463. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37464. /**
  37465. * Gets a the last added mesh using a given id
  37466. * @param id defines the id to search for
  37467. * @return the found mesh or null if not found at all.
  37468. */
  37469. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37470. /**
  37471. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37472. * @param id defines the id to search for
  37473. * @return the found node or null if not found at all
  37474. */
  37475. getLastEntryByID(id: string): Nullable<Node>;
  37476. /**
  37477. * Gets a node (Mesh, Camera, Light) using a given id
  37478. * @param id defines the id to search for
  37479. * @return the found node or null if not found at all
  37480. */
  37481. getNodeByID(id: string): Nullable<Node>;
  37482. /**
  37483. * Gets a node (Mesh, Camera, Light) using a given name
  37484. * @param name defines the name to search for
  37485. * @return the found node or null if not found at all.
  37486. */
  37487. getNodeByName(name: string): Nullable<Node>;
  37488. /**
  37489. * Gets a mesh using a given name
  37490. * @param name defines the name to search for
  37491. * @return the found mesh or null if not found at all.
  37492. */
  37493. getMeshByName(name: string): Nullable<AbstractMesh>;
  37494. /**
  37495. * Gets a transform node using a given name
  37496. * @param name defines the name to search for
  37497. * @return the found transform node or null if not found at all.
  37498. */
  37499. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37500. /**
  37501. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37502. * @param id defines the id to search for
  37503. * @return the found skeleton or null if not found at all.
  37504. */
  37505. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37506. /**
  37507. * Gets a skeleton using a given auto generated unique id
  37508. * @param uniqueId defines the unique id to search for
  37509. * @return the found skeleton or null if not found at all.
  37510. */
  37511. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37512. /**
  37513. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37514. * @param id defines the id to search for
  37515. * @return the found skeleton or null if not found at all.
  37516. */
  37517. getSkeletonById(id: string): Nullable<Skeleton>;
  37518. /**
  37519. * Gets a skeleton using a given name
  37520. * @param name defines the name to search for
  37521. * @return the found skeleton or null if not found at all.
  37522. */
  37523. getSkeletonByName(name: string): Nullable<Skeleton>;
  37524. /**
  37525. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37526. * @param id defines the id to search for
  37527. * @return the found morph target manager or null if not found at all.
  37528. */
  37529. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37530. /**
  37531. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37532. * @param id defines the id to search for
  37533. * @return the found morph target or null if not found at all.
  37534. */
  37535. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37536. /**
  37537. * Gets a boolean indicating if the given mesh is active
  37538. * @param mesh defines the mesh to look for
  37539. * @returns true if the mesh is in the active list
  37540. */
  37541. isActiveMesh(mesh: AbstractMesh): boolean;
  37542. /**
  37543. * Return a unique id as a string which can serve as an identifier for the scene
  37544. */
  37545. get uid(): string;
  37546. /**
  37547. * Add an externaly attached data from its key.
  37548. * This method call will fail and return false, if such key already exists.
  37549. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37550. * @param key the unique key that identifies the data
  37551. * @param data the data object to associate to the key for this Engine instance
  37552. * @return true if no such key were already present and the data was added successfully, false otherwise
  37553. */
  37554. addExternalData<T>(key: string, data: T): boolean;
  37555. /**
  37556. * Get an externaly attached data from its key
  37557. * @param key the unique key that identifies the data
  37558. * @return the associated data, if present (can be null), or undefined if not present
  37559. */
  37560. getExternalData<T>(key: string): Nullable<T>;
  37561. /**
  37562. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37563. * @param key the unique key that identifies the data
  37564. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37565. * @return the associated data, can be null if the factory returned null.
  37566. */
  37567. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37568. /**
  37569. * Remove an externaly attached data from the Engine instance
  37570. * @param key the unique key that identifies the data
  37571. * @return true if the data was successfully removed, false if it doesn't exist
  37572. */
  37573. removeExternalData(key: string): boolean;
  37574. private _evaluateSubMesh;
  37575. /**
  37576. * Clear the processed materials smart array preventing retention point in material dispose.
  37577. */
  37578. freeProcessedMaterials(): void;
  37579. private _preventFreeActiveMeshesAndRenderingGroups;
  37580. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37581. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37582. * when disposing several meshes in a row or a hierarchy of meshes.
  37583. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37584. */
  37585. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37586. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37587. /**
  37588. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37589. */
  37590. freeActiveMeshes(): void;
  37591. /**
  37592. * Clear the info related to rendering groups preventing retention points during dispose.
  37593. */
  37594. freeRenderingGroups(): void;
  37595. /** @hidden */
  37596. _isInIntermediateRendering(): boolean;
  37597. /**
  37598. * Lambda returning the list of potentially active meshes.
  37599. */
  37600. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37601. /**
  37602. * Lambda returning the list of potentially active sub meshes.
  37603. */
  37604. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37605. /**
  37606. * Lambda returning the list of potentially intersecting sub meshes.
  37607. */
  37608. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37609. /**
  37610. * Lambda returning the list of potentially colliding sub meshes.
  37611. */
  37612. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37613. private _activeMeshesFrozen;
  37614. private _skipEvaluateActiveMeshesCompletely;
  37615. /**
  37616. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37617. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37618. * @returns the current scene
  37619. */
  37620. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37621. /**
  37622. * Use this function to restart evaluating active meshes on every frame
  37623. * @returns the current scene
  37624. */
  37625. unfreezeActiveMeshes(): Scene;
  37626. private _evaluateActiveMeshes;
  37627. private _activeMesh;
  37628. /**
  37629. * Update the transform matrix to update from the current active camera
  37630. * @param force defines a boolean used to force the update even if cache is up to date
  37631. */
  37632. updateTransformMatrix(force?: boolean): void;
  37633. private _bindFrameBuffer;
  37634. /** @hidden */
  37635. _allowPostProcessClearColor: boolean;
  37636. /** @hidden */
  37637. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37638. private _processSubCameras;
  37639. private _checkIntersections;
  37640. /** @hidden */
  37641. _advancePhysicsEngineStep(step: number): void;
  37642. /**
  37643. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37644. */
  37645. getDeterministicFrameTime: () => number;
  37646. /** @hidden */
  37647. _animate(): void;
  37648. /** Execute all animations (for a frame) */
  37649. animate(): void;
  37650. /**
  37651. * Render the scene
  37652. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37653. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37654. */
  37655. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37656. /**
  37657. * Freeze all materials
  37658. * A frozen material will not be updatable but should be faster to render
  37659. */
  37660. freezeMaterials(): void;
  37661. /**
  37662. * Unfreeze all materials
  37663. * A frozen material will not be updatable but should be faster to render
  37664. */
  37665. unfreezeMaterials(): void;
  37666. /**
  37667. * Releases all held ressources
  37668. */
  37669. dispose(): void;
  37670. /**
  37671. * Gets if the scene is already disposed
  37672. */
  37673. get isDisposed(): boolean;
  37674. /**
  37675. * Call this function to reduce memory footprint of the scene.
  37676. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37677. */
  37678. clearCachedVertexData(): void;
  37679. /**
  37680. * This function will remove the local cached buffer data from texture.
  37681. * It will save memory but will prevent the texture from being rebuilt
  37682. */
  37683. cleanCachedTextureBuffer(): void;
  37684. /**
  37685. * Get the world extend vectors with an optional filter
  37686. *
  37687. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37688. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37689. */
  37690. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37691. min: Vector3;
  37692. max: Vector3;
  37693. };
  37694. /**
  37695. * Creates a ray that can be used to pick in the scene
  37696. * @param x defines the x coordinate of the origin (on-screen)
  37697. * @param y defines the y coordinate of the origin (on-screen)
  37698. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37699. * @param camera defines the camera to use for the picking
  37700. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37701. * @returns a Ray
  37702. */
  37703. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37704. /**
  37705. * Creates a ray that can be used to pick in the scene
  37706. * @param x defines the x coordinate of the origin (on-screen)
  37707. * @param y defines the y coordinate of the origin (on-screen)
  37708. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37709. * @param result defines the ray where to store the picking ray
  37710. * @param camera defines the camera to use for the picking
  37711. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37712. * @returns the current scene
  37713. */
  37714. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37715. /**
  37716. * Creates a ray that can be used to pick in the scene
  37717. * @param x defines the x coordinate of the origin (on-screen)
  37718. * @param y defines the y coordinate of the origin (on-screen)
  37719. * @param camera defines the camera to use for the picking
  37720. * @returns a Ray
  37721. */
  37722. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37723. /**
  37724. * Creates a ray that can be used to pick in the scene
  37725. * @param x defines the x coordinate of the origin (on-screen)
  37726. * @param y defines the y coordinate of the origin (on-screen)
  37727. * @param result defines the ray where to store the picking ray
  37728. * @param camera defines the camera to use for the picking
  37729. * @returns the current scene
  37730. */
  37731. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37732. /** Launch a ray to try to pick a mesh in the scene
  37733. * @param x position on screen
  37734. * @param y position on screen
  37735. * @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
  37736. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37737. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37738. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37739. * @returns a PickingInfo
  37740. */
  37741. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37742. /** Use the given ray to pick a mesh in the scene
  37743. * @param ray The ray to use to pick meshes
  37744. * @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
  37745. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37746. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37747. * @returns a PickingInfo
  37748. */
  37749. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37750. /**
  37751. * Launch a ray to try to pick a mesh in the scene
  37752. * @param x X position on screen
  37753. * @param y Y position on screen
  37754. * @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
  37755. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37756. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37757. * @returns an array of PickingInfo
  37758. */
  37759. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37760. /**
  37761. * Launch a ray to try to pick a mesh in the scene
  37762. * @param ray Ray to use
  37763. * @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
  37764. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37765. * @returns an array of PickingInfo
  37766. */
  37767. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37768. /**
  37769. * Force the value of meshUnderPointer
  37770. * @param mesh defines the mesh to use
  37771. */
  37772. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37773. /**
  37774. * Gets the mesh under the pointer
  37775. * @returns a Mesh or null if no mesh is under the pointer
  37776. */
  37777. getPointerOverMesh(): Nullable<AbstractMesh>;
  37778. /** @hidden */
  37779. _rebuildGeometries(): void;
  37780. /** @hidden */
  37781. _rebuildTextures(): void;
  37782. private _getByTags;
  37783. /**
  37784. * Get a list of meshes by tags
  37785. * @param tagsQuery defines the tags query to use
  37786. * @param forEach defines a predicate used to filter results
  37787. * @returns an array of Mesh
  37788. */
  37789. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37790. /**
  37791. * Get a list of cameras by tags
  37792. * @param tagsQuery defines the tags query to use
  37793. * @param forEach defines a predicate used to filter results
  37794. * @returns an array of Camera
  37795. */
  37796. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37797. /**
  37798. * Get a list of lights by tags
  37799. * @param tagsQuery defines the tags query to use
  37800. * @param forEach defines a predicate used to filter results
  37801. * @returns an array of Light
  37802. */
  37803. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37804. /**
  37805. * Get a list of materials by tags
  37806. * @param tagsQuery defines the tags query to use
  37807. * @param forEach defines a predicate used to filter results
  37808. * @returns an array of Material
  37809. */
  37810. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37811. /**
  37812. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37813. * This allowed control for front to back rendering or reversly depending of the special needs.
  37814. *
  37815. * @param renderingGroupId The rendering group id corresponding to its index
  37816. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37817. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37818. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37819. */
  37820. 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;
  37821. /**
  37822. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37823. *
  37824. * @param renderingGroupId The rendering group id corresponding to its index
  37825. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37826. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37827. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37828. */
  37829. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37830. /**
  37831. * Gets the current auto clear configuration for one rendering group of the rendering
  37832. * manager.
  37833. * @param index the rendering group index to get the information for
  37834. * @returns The auto clear setup for the requested rendering group
  37835. */
  37836. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37837. private _blockMaterialDirtyMechanism;
  37838. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37839. get blockMaterialDirtyMechanism(): boolean;
  37840. set blockMaterialDirtyMechanism(value: boolean);
  37841. /**
  37842. * Will flag all materials as dirty to trigger new shader compilation
  37843. * @param flag defines the flag used to specify which material part must be marked as dirty
  37844. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37845. */
  37846. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37847. /** @hidden */
  37848. _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;
  37849. /** @hidden */
  37850. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37851. /** @hidden */
  37852. _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;
  37853. /** @hidden */
  37854. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37855. /** @hidden */
  37856. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37857. /** @hidden */
  37858. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37859. }
  37860. }
  37861. declare module "babylonjs/assetContainer" {
  37862. import { AbstractScene } from "babylonjs/abstractScene";
  37863. import { Scene } from "babylonjs/scene";
  37864. import { Mesh } from "babylonjs/Meshes/mesh";
  37865. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37866. import { Skeleton } from "babylonjs/Bones/skeleton";
  37867. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37868. import { Animatable } from "babylonjs/Animations/animatable";
  37869. import { Nullable } from "babylonjs/types";
  37870. import { Node } from "babylonjs/node";
  37871. /**
  37872. * Set of assets to keep when moving a scene into an asset container.
  37873. */
  37874. export class KeepAssets extends AbstractScene {
  37875. }
  37876. /**
  37877. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37878. */
  37879. export class InstantiatedEntries {
  37880. /**
  37881. * List of new root nodes (eg. nodes with no parent)
  37882. */
  37883. rootNodes: TransformNode[];
  37884. /**
  37885. * List of new skeletons
  37886. */
  37887. skeletons: Skeleton[];
  37888. /**
  37889. * List of new animation groups
  37890. */
  37891. animationGroups: AnimationGroup[];
  37892. }
  37893. /**
  37894. * Container with a set of assets that can be added or removed from a scene.
  37895. */
  37896. export class AssetContainer extends AbstractScene {
  37897. /**
  37898. * The scene the AssetContainer belongs to.
  37899. */
  37900. scene: Scene;
  37901. /**
  37902. * Instantiates an AssetContainer.
  37903. * @param scene The scene the AssetContainer belongs to.
  37904. */
  37905. constructor(scene: Scene);
  37906. /**
  37907. * Instantiate or clone all meshes and add the new ones to the scene.
  37908. * Skeletons and animation groups will all be cloned
  37909. * @param nameFunction defines an optional function used to get new names for clones
  37910. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37911. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37912. */
  37913. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37914. /**
  37915. * Adds all the assets from the container to the scene.
  37916. */
  37917. addAllToScene(): void;
  37918. /**
  37919. * Removes all the assets in the container from the scene
  37920. */
  37921. removeAllFromScene(): void;
  37922. /**
  37923. * Disposes all the assets in the container
  37924. */
  37925. dispose(): void;
  37926. private _moveAssets;
  37927. /**
  37928. * Removes all the assets contained in the scene and adds them to the container.
  37929. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37930. */
  37931. moveAllFromScene(keepAssets?: KeepAssets): void;
  37932. /**
  37933. * 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.
  37934. * @returns the root mesh
  37935. */
  37936. createRootMesh(): Mesh;
  37937. /**
  37938. * Merge animations from this asset container into a scene
  37939. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37940. * @param animatables set of animatables to retarget to a node from the scene
  37941. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37942. */
  37943. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37944. }
  37945. }
  37946. declare module "babylonjs/abstractScene" {
  37947. import { Scene } from "babylonjs/scene";
  37948. import { Nullable } from "babylonjs/types";
  37949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37950. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37951. import { Geometry } from "babylonjs/Meshes/geometry";
  37952. import { Skeleton } from "babylonjs/Bones/skeleton";
  37953. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37954. import { AssetContainer } from "babylonjs/assetContainer";
  37955. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37956. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37957. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37958. import { Material } from "babylonjs/Materials/material";
  37959. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37960. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37961. import { Camera } from "babylonjs/Cameras/camera";
  37962. import { Light } from "babylonjs/Lights/light";
  37963. import { Node } from "babylonjs/node";
  37964. import { Animation } from "babylonjs/Animations/animation";
  37965. /**
  37966. * Defines how the parser contract is defined.
  37967. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37968. */
  37969. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37970. /**
  37971. * Defines how the individual parser contract is defined.
  37972. * These parser can parse an individual asset
  37973. */
  37974. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37975. /**
  37976. * Base class of the scene acting as a container for the different elements composing a scene.
  37977. * This class is dynamically extended by the different components of the scene increasing
  37978. * flexibility and reducing coupling
  37979. */
  37980. export abstract class AbstractScene {
  37981. /**
  37982. * Stores the list of available parsers in the application.
  37983. */
  37984. private static _BabylonFileParsers;
  37985. /**
  37986. * Stores the list of available individual parsers in the application.
  37987. */
  37988. private static _IndividualBabylonFileParsers;
  37989. /**
  37990. * Adds a parser in the list of available ones
  37991. * @param name Defines the name of the parser
  37992. * @param parser Defines the parser to add
  37993. */
  37994. static AddParser(name: string, parser: BabylonFileParser): void;
  37995. /**
  37996. * Gets a general parser from the list of avaialble ones
  37997. * @param name Defines the name of the parser
  37998. * @returns the requested parser or null
  37999. */
  38000. static GetParser(name: string): Nullable<BabylonFileParser>;
  38001. /**
  38002. * Adds n individual parser in the list of available ones
  38003. * @param name Defines the name of the parser
  38004. * @param parser Defines the parser to add
  38005. */
  38006. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38007. /**
  38008. * Gets an individual parser from the list of avaialble ones
  38009. * @param name Defines the name of the parser
  38010. * @returns the requested parser or null
  38011. */
  38012. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38013. /**
  38014. * Parser json data and populate both a scene and its associated container object
  38015. * @param jsonData Defines the data to parse
  38016. * @param scene Defines the scene to parse the data for
  38017. * @param container Defines the container attached to the parsing sequence
  38018. * @param rootUrl Defines the root url of the data
  38019. */
  38020. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38021. /**
  38022. * Gets the list of root nodes (ie. nodes with no parent)
  38023. */
  38024. rootNodes: Node[];
  38025. /** All of the cameras added to this scene
  38026. * @see http://doc.babylonjs.com/babylon101/cameras
  38027. */
  38028. cameras: Camera[];
  38029. /**
  38030. * All of the lights added to this scene
  38031. * @see http://doc.babylonjs.com/babylon101/lights
  38032. */
  38033. lights: Light[];
  38034. /**
  38035. * All of the (abstract) meshes added to this scene
  38036. */
  38037. meshes: AbstractMesh[];
  38038. /**
  38039. * The list of skeletons added to the scene
  38040. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38041. */
  38042. skeletons: Skeleton[];
  38043. /**
  38044. * All of the particle systems added to this scene
  38045. * @see http://doc.babylonjs.com/babylon101/particles
  38046. */
  38047. particleSystems: IParticleSystem[];
  38048. /**
  38049. * Gets a list of Animations associated with the scene
  38050. */
  38051. animations: Animation[];
  38052. /**
  38053. * All of the animation groups added to this scene
  38054. * @see http://doc.babylonjs.com/how_to/group
  38055. */
  38056. animationGroups: AnimationGroup[];
  38057. /**
  38058. * All of the multi-materials added to this scene
  38059. * @see http://doc.babylonjs.com/how_to/multi_materials
  38060. */
  38061. multiMaterials: MultiMaterial[];
  38062. /**
  38063. * All of the materials added to this scene
  38064. * In the context of a Scene, it is not supposed to be modified manually.
  38065. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38066. * Note also that the order of the Material within the array is not significant and might change.
  38067. * @see http://doc.babylonjs.com/babylon101/materials
  38068. */
  38069. materials: Material[];
  38070. /**
  38071. * The list of morph target managers added to the scene
  38072. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38073. */
  38074. morphTargetManagers: MorphTargetManager[];
  38075. /**
  38076. * The list of geometries used in the scene.
  38077. */
  38078. geometries: Geometry[];
  38079. /**
  38080. * All of the tranform nodes added to this scene
  38081. * In the context of a Scene, it is not supposed to be modified manually.
  38082. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38083. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38084. * @see http://doc.babylonjs.com/how_to/transformnode
  38085. */
  38086. transformNodes: TransformNode[];
  38087. /**
  38088. * ActionManagers available on the scene.
  38089. */
  38090. actionManagers: AbstractActionManager[];
  38091. /**
  38092. * Textures to keep.
  38093. */
  38094. textures: BaseTexture[];
  38095. /**
  38096. * Environment texture for the scene
  38097. */
  38098. environmentTexture: Nullable<BaseTexture>;
  38099. /**
  38100. * @returns all meshes, lights, cameras, transformNodes and bones
  38101. */
  38102. getNodes(): Array<Node>;
  38103. }
  38104. }
  38105. declare module "babylonjs/Audio/sound" {
  38106. import { Observable } from "babylonjs/Misc/observable";
  38107. import { Vector3 } from "babylonjs/Maths/math.vector";
  38108. import { Nullable } from "babylonjs/types";
  38109. import { Scene } from "babylonjs/scene";
  38110. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38111. /**
  38112. * Interface used to define options for Sound class
  38113. */
  38114. export interface ISoundOptions {
  38115. /**
  38116. * Does the sound autoplay once loaded.
  38117. */
  38118. autoplay?: boolean;
  38119. /**
  38120. * Does the sound loop after it finishes playing once.
  38121. */
  38122. loop?: boolean;
  38123. /**
  38124. * Sound's volume
  38125. */
  38126. volume?: number;
  38127. /**
  38128. * Is it a spatial sound?
  38129. */
  38130. spatialSound?: boolean;
  38131. /**
  38132. * Maximum distance to hear that sound
  38133. */
  38134. maxDistance?: number;
  38135. /**
  38136. * Uses user defined attenuation function
  38137. */
  38138. useCustomAttenuation?: boolean;
  38139. /**
  38140. * Define the roll off factor of spatial sounds.
  38141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38142. */
  38143. rolloffFactor?: number;
  38144. /**
  38145. * Define the reference distance the sound should be heard perfectly.
  38146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38147. */
  38148. refDistance?: number;
  38149. /**
  38150. * Define the distance attenuation model the sound will follow.
  38151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38152. */
  38153. distanceModel?: string;
  38154. /**
  38155. * Defines the playback speed (1 by default)
  38156. */
  38157. playbackRate?: number;
  38158. /**
  38159. * Defines if the sound is from a streaming source
  38160. */
  38161. streaming?: boolean;
  38162. /**
  38163. * Defines an optional length (in seconds) inside the sound file
  38164. */
  38165. length?: number;
  38166. /**
  38167. * Defines an optional offset (in seconds) inside the sound file
  38168. */
  38169. offset?: number;
  38170. /**
  38171. * If true, URLs will not be required to state the audio file codec to use.
  38172. */
  38173. skipCodecCheck?: boolean;
  38174. }
  38175. /**
  38176. * Defines a sound that can be played in the application.
  38177. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38179. */
  38180. export class Sound {
  38181. /**
  38182. * The name of the sound in the scene.
  38183. */
  38184. name: string;
  38185. /**
  38186. * Does the sound autoplay once loaded.
  38187. */
  38188. autoplay: boolean;
  38189. /**
  38190. * Does the sound loop after it finishes playing once.
  38191. */
  38192. loop: boolean;
  38193. /**
  38194. * Does the sound use a custom attenuation curve to simulate the falloff
  38195. * happening when the source gets further away from the camera.
  38196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38197. */
  38198. useCustomAttenuation: boolean;
  38199. /**
  38200. * The sound track id this sound belongs to.
  38201. */
  38202. soundTrackId: number;
  38203. /**
  38204. * Is this sound currently played.
  38205. */
  38206. isPlaying: boolean;
  38207. /**
  38208. * Is this sound currently paused.
  38209. */
  38210. isPaused: boolean;
  38211. /**
  38212. * Does this sound enables spatial sound.
  38213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38214. */
  38215. spatialSound: boolean;
  38216. /**
  38217. * Define the reference distance the sound should be heard perfectly.
  38218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38219. */
  38220. refDistance: number;
  38221. /**
  38222. * Define the roll off factor of spatial sounds.
  38223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38224. */
  38225. rolloffFactor: number;
  38226. /**
  38227. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38229. */
  38230. maxDistance: number;
  38231. /**
  38232. * Define the distance attenuation model the sound will follow.
  38233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38234. */
  38235. distanceModel: string;
  38236. /**
  38237. * @hidden
  38238. * Back Compat
  38239. **/
  38240. onended: () => any;
  38241. /**
  38242. * Observable event when the current playing sound finishes.
  38243. */
  38244. onEndedObservable: Observable<Sound>;
  38245. private _panningModel;
  38246. private _playbackRate;
  38247. private _streaming;
  38248. private _startTime;
  38249. private _startOffset;
  38250. private _position;
  38251. /** @hidden */
  38252. _positionInEmitterSpace: boolean;
  38253. private _localDirection;
  38254. private _volume;
  38255. private _isReadyToPlay;
  38256. private _isDirectional;
  38257. private _readyToPlayCallback;
  38258. private _audioBuffer;
  38259. private _soundSource;
  38260. private _streamingSource;
  38261. private _soundPanner;
  38262. private _soundGain;
  38263. private _inputAudioNode;
  38264. private _outputAudioNode;
  38265. private _coneInnerAngle;
  38266. private _coneOuterAngle;
  38267. private _coneOuterGain;
  38268. private _scene;
  38269. private _connectedTransformNode;
  38270. private _customAttenuationFunction;
  38271. private _registerFunc;
  38272. private _isOutputConnected;
  38273. private _htmlAudioElement;
  38274. private _urlType;
  38275. private _length?;
  38276. private _offset?;
  38277. /** @hidden */
  38278. static _SceneComponentInitialization: (scene: Scene) => void;
  38279. /**
  38280. * Create a sound and attach it to a scene
  38281. * @param name Name of your sound
  38282. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38283. * @param scene defines the scene the sound belongs to
  38284. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38285. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38286. */
  38287. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38288. /**
  38289. * Release the sound and its associated resources
  38290. */
  38291. dispose(): void;
  38292. /**
  38293. * Gets if the sounds is ready to be played or not.
  38294. * @returns true if ready, otherwise false
  38295. */
  38296. isReady(): boolean;
  38297. private _soundLoaded;
  38298. /**
  38299. * Sets the data of the sound from an audiobuffer
  38300. * @param audioBuffer The audioBuffer containing the data
  38301. */
  38302. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38303. /**
  38304. * Updates the current sounds options such as maxdistance, loop...
  38305. * @param options A JSON object containing values named as the object properties
  38306. */
  38307. updateOptions(options: ISoundOptions): void;
  38308. private _createSpatialParameters;
  38309. private _updateSpatialParameters;
  38310. /**
  38311. * Switch the panning model to HRTF:
  38312. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38314. */
  38315. switchPanningModelToHRTF(): void;
  38316. /**
  38317. * Switch the panning model to Equal Power:
  38318. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38320. */
  38321. switchPanningModelToEqualPower(): void;
  38322. private _switchPanningModel;
  38323. /**
  38324. * Connect this sound to a sound track audio node like gain...
  38325. * @param soundTrackAudioNode the sound track audio node to connect to
  38326. */
  38327. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38328. /**
  38329. * Transform this sound into a directional source
  38330. * @param coneInnerAngle Size of the inner cone in degree
  38331. * @param coneOuterAngle Size of the outer cone in degree
  38332. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38333. */
  38334. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38335. /**
  38336. * Gets or sets the inner angle for the directional cone.
  38337. */
  38338. get directionalConeInnerAngle(): number;
  38339. /**
  38340. * Gets or sets the inner angle for the directional cone.
  38341. */
  38342. set directionalConeInnerAngle(value: number);
  38343. /**
  38344. * Gets or sets the outer angle for the directional cone.
  38345. */
  38346. get directionalConeOuterAngle(): number;
  38347. /**
  38348. * Gets or sets the outer angle for the directional cone.
  38349. */
  38350. set directionalConeOuterAngle(value: number);
  38351. /**
  38352. * Sets the position of the emitter if spatial sound is enabled
  38353. * @param newPosition Defines the new posisiton
  38354. */
  38355. setPosition(newPosition: Vector3): void;
  38356. /**
  38357. * Sets the local direction of the emitter if spatial sound is enabled
  38358. * @param newLocalDirection Defines the new local direction
  38359. */
  38360. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38361. private _updateDirection;
  38362. /** @hidden */
  38363. updateDistanceFromListener(): void;
  38364. /**
  38365. * Sets a new custom attenuation function for the sound.
  38366. * @param callback Defines the function used for the attenuation
  38367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38368. */
  38369. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38370. /**
  38371. * Play the sound
  38372. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38373. * @param offset (optional) Start the sound at a specific time in seconds
  38374. * @param length (optional) Sound duration (in seconds)
  38375. */
  38376. play(time?: number, offset?: number, length?: number): void;
  38377. private _onended;
  38378. /**
  38379. * Stop the sound
  38380. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38381. */
  38382. stop(time?: number): void;
  38383. /**
  38384. * Put the sound in pause
  38385. */
  38386. pause(): void;
  38387. /**
  38388. * Sets a dedicated volume for this sounds
  38389. * @param newVolume Define the new volume of the sound
  38390. * @param time Define time for gradual change to new volume
  38391. */
  38392. setVolume(newVolume: number, time?: number): void;
  38393. /**
  38394. * Set the sound play back rate
  38395. * @param newPlaybackRate Define the playback rate the sound should be played at
  38396. */
  38397. setPlaybackRate(newPlaybackRate: number): void;
  38398. /**
  38399. * Gets the volume of the sound.
  38400. * @returns the volume of the sound
  38401. */
  38402. getVolume(): number;
  38403. /**
  38404. * Attach the sound to a dedicated mesh
  38405. * @param transformNode The transform node to connect the sound with
  38406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38407. */
  38408. attachToMesh(transformNode: TransformNode): void;
  38409. /**
  38410. * Detach the sound from the previously attached mesh
  38411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38412. */
  38413. detachFromMesh(): void;
  38414. private _onRegisterAfterWorldMatrixUpdate;
  38415. /**
  38416. * Clone the current sound in the scene.
  38417. * @returns the new sound clone
  38418. */
  38419. clone(): Nullable<Sound>;
  38420. /**
  38421. * Gets the current underlying audio buffer containing the data
  38422. * @returns the audio buffer
  38423. */
  38424. getAudioBuffer(): Nullable<AudioBuffer>;
  38425. /**
  38426. * Serializes the Sound in a JSON representation
  38427. * @returns the JSON representation of the sound
  38428. */
  38429. serialize(): any;
  38430. /**
  38431. * Parse a JSON representation of a sound to innstantiate in a given scene
  38432. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38433. * @param scene Define the scene the new parsed sound should be created in
  38434. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38435. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38436. * @returns the newly parsed sound
  38437. */
  38438. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38439. }
  38440. }
  38441. declare module "babylonjs/Actions/directAudioActions" {
  38442. import { Action } from "babylonjs/Actions/action";
  38443. import { Condition } from "babylonjs/Actions/condition";
  38444. import { Sound } from "babylonjs/Audio/sound";
  38445. /**
  38446. * This defines an action helpful to play a defined sound on a triggered action.
  38447. */
  38448. export class PlaySoundAction extends Action {
  38449. private _sound;
  38450. /**
  38451. * Instantiate the action
  38452. * @param triggerOptions defines the trigger options
  38453. * @param sound defines the sound to play
  38454. * @param condition defines the trigger related conditions
  38455. */
  38456. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38457. /** @hidden */
  38458. _prepare(): void;
  38459. /**
  38460. * Execute the action and play the sound.
  38461. */
  38462. execute(): void;
  38463. /**
  38464. * Serializes the actions and its related information.
  38465. * @param parent defines the object to serialize in
  38466. * @returns the serialized object
  38467. */
  38468. serialize(parent: any): any;
  38469. }
  38470. /**
  38471. * This defines an action helpful to stop a defined sound on a triggered action.
  38472. */
  38473. export class StopSoundAction extends Action {
  38474. private _sound;
  38475. /**
  38476. * Instantiate the action
  38477. * @param triggerOptions defines the trigger options
  38478. * @param sound defines the sound to stop
  38479. * @param condition defines the trigger related conditions
  38480. */
  38481. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38482. /** @hidden */
  38483. _prepare(): void;
  38484. /**
  38485. * Execute the action and stop the sound.
  38486. */
  38487. execute(): void;
  38488. /**
  38489. * Serializes the actions and its related information.
  38490. * @param parent defines the object to serialize in
  38491. * @returns the serialized object
  38492. */
  38493. serialize(parent: any): any;
  38494. }
  38495. }
  38496. declare module "babylonjs/Actions/interpolateValueAction" {
  38497. import { Action } from "babylonjs/Actions/action";
  38498. import { Condition } from "babylonjs/Actions/condition";
  38499. import { Observable } from "babylonjs/Misc/observable";
  38500. /**
  38501. * This defines an action responsible to change the value of a property
  38502. * by interpolating between its current value and the newly set one once triggered.
  38503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38504. */
  38505. export class InterpolateValueAction extends Action {
  38506. /**
  38507. * Defines the path of the property where the value should be interpolated
  38508. */
  38509. propertyPath: string;
  38510. /**
  38511. * Defines the target value at the end of the interpolation.
  38512. */
  38513. value: any;
  38514. /**
  38515. * Defines the time it will take for the property to interpolate to the value.
  38516. */
  38517. duration: number;
  38518. /**
  38519. * Defines if the other scene animations should be stopped when the action has been triggered
  38520. */
  38521. stopOtherAnimations?: boolean;
  38522. /**
  38523. * Defines a callback raised once the interpolation animation has been done.
  38524. */
  38525. onInterpolationDone?: () => void;
  38526. /**
  38527. * Observable triggered once the interpolation animation has been done.
  38528. */
  38529. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38530. private _target;
  38531. private _effectiveTarget;
  38532. private _property;
  38533. /**
  38534. * Instantiate the action
  38535. * @param triggerOptions defines the trigger options
  38536. * @param target defines the object containing the value to interpolate
  38537. * @param propertyPath defines the path to the property in the target object
  38538. * @param value defines the target value at the end of the interpolation
  38539. * @param duration deines the time it will take for the property to interpolate to the value.
  38540. * @param condition defines the trigger related conditions
  38541. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38542. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38543. */
  38544. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38545. /** @hidden */
  38546. _prepare(): void;
  38547. /**
  38548. * Execute the action starts the value interpolation.
  38549. */
  38550. execute(): void;
  38551. /**
  38552. * Serializes the actions and its related information.
  38553. * @param parent defines the object to serialize in
  38554. * @returns the serialized object
  38555. */
  38556. serialize(parent: any): any;
  38557. }
  38558. }
  38559. declare module "babylonjs/Actions/index" {
  38560. export * from "babylonjs/Actions/abstractActionManager";
  38561. export * from "babylonjs/Actions/action";
  38562. export * from "babylonjs/Actions/actionEvent";
  38563. export * from "babylonjs/Actions/actionManager";
  38564. export * from "babylonjs/Actions/condition";
  38565. export * from "babylonjs/Actions/directActions";
  38566. export * from "babylonjs/Actions/directAudioActions";
  38567. export * from "babylonjs/Actions/interpolateValueAction";
  38568. }
  38569. declare module "babylonjs/Animations/index" {
  38570. export * from "babylonjs/Animations/animatable";
  38571. export * from "babylonjs/Animations/animation";
  38572. export * from "babylonjs/Animations/animationGroup";
  38573. export * from "babylonjs/Animations/animationPropertiesOverride";
  38574. export * from "babylonjs/Animations/easing";
  38575. export * from "babylonjs/Animations/runtimeAnimation";
  38576. export * from "babylonjs/Animations/animationEvent";
  38577. export * from "babylonjs/Animations/animationGroup";
  38578. export * from "babylonjs/Animations/animationKey";
  38579. export * from "babylonjs/Animations/animationRange";
  38580. export * from "babylonjs/Animations/animatable.interface";
  38581. }
  38582. declare module "babylonjs/Audio/soundTrack" {
  38583. import { Sound } from "babylonjs/Audio/sound";
  38584. import { Analyser } from "babylonjs/Audio/analyser";
  38585. import { Scene } from "babylonjs/scene";
  38586. /**
  38587. * Options allowed during the creation of a sound track.
  38588. */
  38589. export interface ISoundTrackOptions {
  38590. /**
  38591. * The volume the sound track should take during creation
  38592. */
  38593. volume?: number;
  38594. /**
  38595. * Define if the sound track is the main sound track of the scene
  38596. */
  38597. mainTrack?: boolean;
  38598. }
  38599. /**
  38600. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38601. * It will be also used in a future release to apply effects on a specific track.
  38602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38603. */
  38604. export class SoundTrack {
  38605. /**
  38606. * The unique identifier of the sound track in the scene.
  38607. */
  38608. id: number;
  38609. /**
  38610. * The list of sounds included in the sound track.
  38611. */
  38612. soundCollection: Array<Sound>;
  38613. private _outputAudioNode;
  38614. private _scene;
  38615. private _connectedAnalyser;
  38616. private _options;
  38617. private _isInitialized;
  38618. /**
  38619. * Creates a new sound track.
  38620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38621. * @param scene Define the scene the sound track belongs to
  38622. * @param options
  38623. */
  38624. constructor(scene: Scene, options?: ISoundTrackOptions);
  38625. private _initializeSoundTrackAudioGraph;
  38626. /**
  38627. * Release the sound track and its associated resources
  38628. */
  38629. dispose(): void;
  38630. /**
  38631. * Adds a sound to this sound track
  38632. * @param sound define the cound to add
  38633. * @ignoreNaming
  38634. */
  38635. AddSound(sound: Sound): void;
  38636. /**
  38637. * Removes a sound to this sound track
  38638. * @param sound define the cound to remove
  38639. * @ignoreNaming
  38640. */
  38641. RemoveSound(sound: Sound): void;
  38642. /**
  38643. * Set a global volume for the full sound track.
  38644. * @param newVolume Define the new volume of the sound track
  38645. */
  38646. setVolume(newVolume: number): void;
  38647. /**
  38648. * Switch the panning model to HRTF:
  38649. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38651. */
  38652. switchPanningModelToHRTF(): void;
  38653. /**
  38654. * Switch the panning model to Equal Power:
  38655. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38657. */
  38658. switchPanningModelToEqualPower(): void;
  38659. /**
  38660. * Connect the sound track to an audio analyser allowing some amazing
  38661. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38663. * @param analyser The analyser to connect to the engine
  38664. */
  38665. connectToAnalyser(analyser: Analyser): void;
  38666. }
  38667. }
  38668. declare module "babylonjs/Audio/audioSceneComponent" {
  38669. import { Sound } from "babylonjs/Audio/sound";
  38670. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38671. import { Nullable } from "babylonjs/types";
  38672. import { Vector3 } from "babylonjs/Maths/math.vector";
  38673. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38674. import { Scene } from "babylonjs/scene";
  38675. import { AbstractScene } from "babylonjs/abstractScene";
  38676. import "babylonjs/Audio/audioEngine";
  38677. module "babylonjs/abstractScene" {
  38678. interface AbstractScene {
  38679. /**
  38680. * The list of sounds used in the scene.
  38681. */
  38682. sounds: Nullable<Array<Sound>>;
  38683. }
  38684. }
  38685. module "babylonjs/scene" {
  38686. interface Scene {
  38687. /**
  38688. * @hidden
  38689. * Backing field
  38690. */
  38691. _mainSoundTrack: SoundTrack;
  38692. /**
  38693. * The main sound track played by the scene.
  38694. * It cotains your primary collection of sounds.
  38695. */
  38696. mainSoundTrack: SoundTrack;
  38697. /**
  38698. * The list of sound tracks added to the scene
  38699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38700. */
  38701. soundTracks: Nullable<Array<SoundTrack>>;
  38702. /**
  38703. * Gets a sound using a given name
  38704. * @param name defines the name to search for
  38705. * @return the found sound or null if not found at all.
  38706. */
  38707. getSoundByName(name: string): Nullable<Sound>;
  38708. /**
  38709. * Gets or sets if audio support is enabled
  38710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38711. */
  38712. audioEnabled: boolean;
  38713. /**
  38714. * Gets or sets if audio will be output to headphones
  38715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38716. */
  38717. headphone: boolean;
  38718. /**
  38719. * Gets or sets custom audio listener position provider
  38720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38721. */
  38722. audioListenerPositionProvider: Nullable<() => Vector3>;
  38723. /**
  38724. * Gets or sets a refresh rate when using 3D audio positioning
  38725. */
  38726. audioPositioningRefreshRate: number;
  38727. }
  38728. }
  38729. /**
  38730. * Defines the sound scene component responsible to manage any sounds
  38731. * in a given scene.
  38732. */
  38733. export class AudioSceneComponent implements ISceneSerializableComponent {
  38734. /**
  38735. * The component name helpfull to identify the component in the list of scene components.
  38736. */
  38737. readonly name: string;
  38738. /**
  38739. * The scene the component belongs to.
  38740. */
  38741. scene: Scene;
  38742. private _audioEnabled;
  38743. /**
  38744. * Gets whether audio is enabled or not.
  38745. * Please use related enable/disable method to switch state.
  38746. */
  38747. get audioEnabled(): boolean;
  38748. private _headphone;
  38749. /**
  38750. * Gets whether audio is outputing to headphone or not.
  38751. * Please use the according Switch methods to change output.
  38752. */
  38753. get headphone(): boolean;
  38754. /**
  38755. * Gets or sets a refresh rate when using 3D audio positioning
  38756. */
  38757. audioPositioningRefreshRate: number;
  38758. private _audioListenerPositionProvider;
  38759. /**
  38760. * Gets the current audio listener position provider
  38761. */
  38762. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38763. /**
  38764. * Sets a custom listener position for all sounds in the scene
  38765. * By default, this is the position of the first active camera
  38766. */
  38767. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38768. /**
  38769. * Creates a new instance of the component for the given scene
  38770. * @param scene Defines the scene to register the component in
  38771. */
  38772. constructor(scene: Scene);
  38773. /**
  38774. * Registers the component in a given scene
  38775. */
  38776. register(): void;
  38777. /**
  38778. * Rebuilds the elements related to this component in case of
  38779. * context lost for instance.
  38780. */
  38781. rebuild(): void;
  38782. /**
  38783. * Serializes the component data to the specified json object
  38784. * @param serializationObject The object to serialize to
  38785. */
  38786. serialize(serializationObject: any): void;
  38787. /**
  38788. * Adds all the elements from the container to the scene
  38789. * @param container the container holding the elements
  38790. */
  38791. addFromContainer(container: AbstractScene): void;
  38792. /**
  38793. * Removes all the elements in the container from the scene
  38794. * @param container contains the elements to remove
  38795. * @param dispose if the removed element should be disposed (default: false)
  38796. */
  38797. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38798. /**
  38799. * Disposes the component and the associated ressources.
  38800. */
  38801. dispose(): void;
  38802. /**
  38803. * Disables audio in the associated scene.
  38804. */
  38805. disableAudio(): void;
  38806. /**
  38807. * Enables audio in the associated scene.
  38808. */
  38809. enableAudio(): void;
  38810. /**
  38811. * Switch audio to headphone output.
  38812. */
  38813. switchAudioModeForHeadphones(): void;
  38814. /**
  38815. * Switch audio to normal speakers.
  38816. */
  38817. switchAudioModeForNormalSpeakers(): void;
  38818. private _cachedCameraDirection;
  38819. private _cachedCameraPosition;
  38820. private _lastCheck;
  38821. private _afterRender;
  38822. }
  38823. }
  38824. declare module "babylonjs/Audio/weightedsound" {
  38825. import { Sound } from "babylonjs/Audio/sound";
  38826. /**
  38827. * Wraps one or more Sound objects and selects one with random weight for playback.
  38828. */
  38829. export class WeightedSound {
  38830. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38831. loop: boolean;
  38832. private _coneInnerAngle;
  38833. private _coneOuterAngle;
  38834. private _volume;
  38835. /** A Sound is currently playing. */
  38836. isPlaying: boolean;
  38837. /** A Sound is currently paused. */
  38838. isPaused: boolean;
  38839. private _sounds;
  38840. private _weights;
  38841. private _currentIndex?;
  38842. /**
  38843. * Creates a new WeightedSound from the list of sounds given.
  38844. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38845. * @param sounds Array of Sounds that will be selected from.
  38846. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38847. */
  38848. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38849. /**
  38850. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38851. */
  38852. get directionalConeInnerAngle(): number;
  38853. /**
  38854. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38855. */
  38856. set directionalConeInnerAngle(value: number);
  38857. /**
  38858. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38859. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38860. */
  38861. get directionalConeOuterAngle(): number;
  38862. /**
  38863. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38864. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38865. */
  38866. set directionalConeOuterAngle(value: number);
  38867. /**
  38868. * Playback volume.
  38869. */
  38870. get volume(): number;
  38871. /**
  38872. * Playback volume.
  38873. */
  38874. set volume(value: number);
  38875. private _onended;
  38876. /**
  38877. * Suspend playback
  38878. */
  38879. pause(): void;
  38880. /**
  38881. * Stop playback
  38882. */
  38883. stop(): void;
  38884. /**
  38885. * Start playback.
  38886. * @param startOffset Position the clip head at a specific time in seconds.
  38887. */
  38888. play(startOffset?: number): void;
  38889. }
  38890. }
  38891. declare module "babylonjs/Audio/index" {
  38892. export * from "babylonjs/Audio/analyser";
  38893. export * from "babylonjs/Audio/audioEngine";
  38894. export * from "babylonjs/Audio/audioSceneComponent";
  38895. export * from "babylonjs/Audio/sound";
  38896. export * from "babylonjs/Audio/soundTrack";
  38897. export * from "babylonjs/Audio/weightedsound";
  38898. }
  38899. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38900. import { Behavior } from "babylonjs/Behaviors/behavior";
  38901. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38902. import { BackEase } from "babylonjs/Animations/easing";
  38903. /**
  38904. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38905. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38906. */
  38907. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38908. /**
  38909. * Gets the name of the behavior.
  38910. */
  38911. get name(): string;
  38912. /**
  38913. * The easing function used by animations
  38914. */
  38915. static EasingFunction: BackEase;
  38916. /**
  38917. * The easing mode used by animations
  38918. */
  38919. static EasingMode: number;
  38920. /**
  38921. * The duration of the animation, in milliseconds
  38922. */
  38923. transitionDuration: number;
  38924. /**
  38925. * Length of the distance animated by the transition when lower radius is reached
  38926. */
  38927. lowerRadiusTransitionRange: number;
  38928. /**
  38929. * Length of the distance animated by the transition when upper radius is reached
  38930. */
  38931. upperRadiusTransitionRange: number;
  38932. private _autoTransitionRange;
  38933. /**
  38934. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38935. */
  38936. get autoTransitionRange(): boolean;
  38937. /**
  38938. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38939. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38940. */
  38941. set autoTransitionRange(value: boolean);
  38942. private _attachedCamera;
  38943. private _onAfterCheckInputsObserver;
  38944. private _onMeshTargetChangedObserver;
  38945. /**
  38946. * Initializes the behavior.
  38947. */
  38948. init(): void;
  38949. /**
  38950. * Attaches the behavior to its arc rotate camera.
  38951. * @param camera Defines the camera to attach the behavior to
  38952. */
  38953. attach(camera: ArcRotateCamera): void;
  38954. /**
  38955. * Detaches the behavior from its current arc rotate camera.
  38956. */
  38957. detach(): void;
  38958. private _radiusIsAnimating;
  38959. private _radiusBounceTransition;
  38960. private _animatables;
  38961. private _cachedWheelPrecision;
  38962. /**
  38963. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38964. * @param radiusLimit The limit to check against.
  38965. * @return Bool to indicate if at limit.
  38966. */
  38967. private _isRadiusAtLimit;
  38968. /**
  38969. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38970. * @param radiusDelta The delta by which to animate to. Can be negative.
  38971. */
  38972. private _applyBoundRadiusAnimation;
  38973. /**
  38974. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38975. */
  38976. protected _clearAnimationLocks(): void;
  38977. /**
  38978. * Stops and removes all animations that have been applied to the camera
  38979. */
  38980. stopAllAnimations(): void;
  38981. }
  38982. }
  38983. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38984. import { Behavior } from "babylonjs/Behaviors/behavior";
  38985. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38986. import { ExponentialEase } from "babylonjs/Animations/easing";
  38987. import { Nullable } from "babylonjs/types";
  38988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38989. import { Vector3 } from "babylonjs/Maths/math.vector";
  38990. /**
  38991. * 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.
  38992. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38993. */
  38994. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38995. /**
  38996. * Gets the name of the behavior.
  38997. */
  38998. get name(): string;
  38999. private _mode;
  39000. private _radiusScale;
  39001. private _positionScale;
  39002. private _defaultElevation;
  39003. private _elevationReturnTime;
  39004. private _elevationReturnWaitTime;
  39005. private _zoomStopsAnimation;
  39006. private _framingTime;
  39007. /**
  39008. * The easing function used by animations
  39009. */
  39010. static EasingFunction: ExponentialEase;
  39011. /**
  39012. * The easing mode used by animations
  39013. */
  39014. static EasingMode: number;
  39015. /**
  39016. * Sets the current mode used by the behavior
  39017. */
  39018. set mode(mode: number);
  39019. /**
  39020. * Gets current mode used by the behavior.
  39021. */
  39022. get mode(): number;
  39023. /**
  39024. * Sets the scale applied to the radius (1 by default)
  39025. */
  39026. set radiusScale(radius: number);
  39027. /**
  39028. * Gets the scale applied to the radius
  39029. */
  39030. get radiusScale(): number;
  39031. /**
  39032. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39033. */
  39034. set positionScale(scale: number);
  39035. /**
  39036. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39037. */
  39038. get positionScale(): number;
  39039. /**
  39040. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39041. * behaviour is triggered, in radians.
  39042. */
  39043. set defaultElevation(elevation: number);
  39044. /**
  39045. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39046. * behaviour is triggered, in radians.
  39047. */
  39048. get defaultElevation(): number;
  39049. /**
  39050. * Sets the time (in milliseconds) taken to return to the default beta position.
  39051. * Negative value indicates camera should not return to default.
  39052. */
  39053. set elevationReturnTime(speed: number);
  39054. /**
  39055. * Gets the time (in milliseconds) taken to return to the default beta position.
  39056. * Negative value indicates camera should not return to default.
  39057. */
  39058. get elevationReturnTime(): number;
  39059. /**
  39060. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39061. */
  39062. set elevationReturnWaitTime(time: number);
  39063. /**
  39064. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39065. */
  39066. get elevationReturnWaitTime(): number;
  39067. /**
  39068. * Sets the flag that indicates if user zooming should stop animation.
  39069. */
  39070. set zoomStopsAnimation(flag: boolean);
  39071. /**
  39072. * Gets the flag that indicates if user zooming should stop animation.
  39073. */
  39074. get zoomStopsAnimation(): boolean;
  39075. /**
  39076. * Sets the transition time when framing the mesh, in milliseconds
  39077. */
  39078. set framingTime(time: number);
  39079. /**
  39080. * Gets the transition time when framing the mesh, in milliseconds
  39081. */
  39082. get framingTime(): number;
  39083. /**
  39084. * Define if the behavior should automatically change the configured
  39085. * camera limits and sensibilities.
  39086. */
  39087. autoCorrectCameraLimitsAndSensibility: boolean;
  39088. private _onPrePointerObservableObserver;
  39089. private _onAfterCheckInputsObserver;
  39090. private _onMeshTargetChangedObserver;
  39091. private _attachedCamera;
  39092. private _isPointerDown;
  39093. private _lastInteractionTime;
  39094. /**
  39095. * Initializes the behavior.
  39096. */
  39097. init(): void;
  39098. /**
  39099. * Attaches the behavior to its arc rotate camera.
  39100. * @param camera Defines the camera to attach the behavior to
  39101. */
  39102. attach(camera: ArcRotateCamera): void;
  39103. /**
  39104. * Detaches the behavior from its current arc rotate camera.
  39105. */
  39106. detach(): void;
  39107. private _animatables;
  39108. private _betaIsAnimating;
  39109. private _betaTransition;
  39110. private _radiusTransition;
  39111. private _vectorTransition;
  39112. /**
  39113. * Targets the given mesh and updates zoom level accordingly.
  39114. * @param mesh The mesh to target.
  39115. * @param radius Optional. If a cached radius position already exists, overrides default.
  39116. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39117. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39118. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39119. */
  39120. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39121. /**
  39122. * Targets the given mesh with its children and updates zoom level accordingly.
  39123. * @param mesh The mesh to target.
  39124. * @param radius Optional. If a cached radius position already exists, overrides default.
  39125. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39126. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39127. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39128. */
  39129. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39130. /**
  39131. * Targets the given meshes with their children and updates zoom level accordingly.
  39132. * @param meshes The mesh to target.
  39133. * @param radius Optional. If a cached radius position already exists, overrides default.
  39134. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39135. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39136. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39137. */
  39138. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39139. /**
  39140. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39141. * @param minimumWorld Determines the smaller position of the bounding box extend
  39142. * @param maximumWorld Determines the bigger position of the bounding box extend
  39143. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39144. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39145. */
  39146. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39147. /**
  39148. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39149. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39150. * frustum width.
  39151. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39152. * to fully enclose the mesh in the viewing frustum.
  39153. */
  39154. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39155. /**
  39156. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39157. * is automatically returned to its default position (expected to be above ground plane).
  39158. */
  39159. private _maintainCameraAboveGround;
  39160. /**
  39161. * Returns the frustum slope based on the canvas ratio and camera FOV
  39162. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39163. */
  39164. private _getFrustumSlope;
  39165. /**
  39166. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39167. */
  39168. private _clearAnimationLocks;
  39169. /**
  39170. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39171. */
  39172. private _applyUserInteraction;
  39173. /**
  39174. * Stops and removes all animations that have been applied to the camera
  39175. */
  39176. stopAllAnimations(): void;
  39177. /**
  39178. * Gets a value indicating if the user is moving the camera
  39179. */
  39180. get isUserIsMoving(): boolean;
  39181. /**
  39182. * The camera can move all the way towards the mesh.
  39183. */
  39184. static IgnoreBoundsSizeMode: number;
  39185. /**
  39186. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39187. */
  39188. static FitFrustumSidesMode: number;
  39189. }
  39190. }
  39191. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39192. import { Nullable } from "babylonjs/types";
  39193. import { Camera } from "babylonjs/Cameras/camera";
  39194. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39195. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39196. /**
  39197. * Base class for Camera Pointer Inputs.
  39198. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39199. * for example usage.
  39200. */
  39201. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39202. /**
  39203. * Defines the camera the input is attached to.
  39204. */
  39205. abstract camera: Camera;
  39206. /**
  39207. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39208. */
  39209. protected _altKey: boolean;
  39210. protected _ctrlKey: boolean;
  39211. protected _metaKey: boolean;
  39212. protected _shiftKey: boolean;
  39213. /**
  39214. * Which mouse buttons were pressed at time of last mouse event.
  39215. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39216. */
  39217. protected _buttonsPressed: number;
  39218. /**
  39219. * Defines the buttons associated with the input to handle camera move.
  39220. */
  39221. buttons: number[];
  39222. /**
  39223. * Attach the input controls to a specific dom element to get the input from.
  39224. * @param element Defines the element the controls should be listened from
  39225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39226. */
  39227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39228. /**
  39229. * Detach the current controls from the specified dom element.
  39230. * @param element Defines the element to stop listening the inputs from
  39231. */
  39232. detachControl(element: Nullable<HTMLElement>): void;
  39233. /**
  39234. * Gets the class name of the current input.
  39235. * @returns the class name
  39236. */
  39237. getClassName(): string;
  39238. /**
  39239. * Get the friendly name associated with the input class.
  39240. * @returns the input friendly name
  39241. */
  39242. getSimpleName(): string;
  39243. /**
  39244. * Called on pointer POINTERDOUBLETAP event.
  39245. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39246. */
  39247. protected onDoubleTap(type: string): void;
  39248. /**
  39249. * Called on pointer POINTERMOVE event if only a single touch is active.
  39250. * Override this method to provide functionality.
  39251. */
  39252. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39253. /**
  39254. * Called on pointer POINTERMOVE event if multiple touches are active.
  39255. * Override this method to provide functionality.
  39256. */
  39257. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39258. /**
  39259. * Called on JS contextmenu event.
  39260. * Override this method to provide functionality.
  39261. */
  39262. protected onContextMenu(evt: PointerEvent): void;
  39263. /**
  39264. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39265. * press.
  39266. * Override this method to provide functionality.
  39267. */
  39268. protected onButtonDown(evt: PointerEvent): void;
  39269. /**
  39270. * Called each time a new POINTERUP event occurs. Ie, for each button
  39271. * release.
  39272. * Override this method to provide functionality.
  39273. */
  39274. protected onButtonUp(evt: PointerEvent): void;
  39275. /**
  39276. * Called when window becomes inactive.
  39277. * Override this method to provide functionality.
  39278. */
  39279. protected onLostFocus(): void;
  39280. private _pointerInput;
  39281. private _observer;
  39282. private _onLostFocus;
  39283. private pointA;
  39284. private pointB;
  39285. }
  39286. }
  39287. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39288. import { Nullable } from "babylonjs/types";
  39289. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39290. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39291. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39292. /**
  39293. * Manage the pointers inputs to control an arc rotate camera.
  39294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39295. */
  39296. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39297. /**
  39298. * Defines the camera the input is attached to.
  39299. */
  39300. camera: ArcRotateCamera;
  39301. /**
  39302. * Gets the class name of the current input.
  39303. * @returns the class name
  39304. */
  39305. getClassName(): string;
  39306. /**
  39307. * Defines the buttons associated with the input to handle camera move.
  39308. */
  39309. buttons: number[];
  39310. /**
  39311. * Defines the pointer angular sensibility along the X axis or how fast is
  39312. * the camera rotating.
  39313. */
  39314. angularSensibilityX: number;
  39315. /**
  39316. * Defines the pointer angular sensibility along the Y axis or how fast is
  39317. * the camera rotating.
  39318. */
  39319. angularSensibilityY: number;
  39320. /**
  39321. * Defines the pointer pinch precision or how fast is the camera zooming.
  39322. */
  39323. pinchPrecision: number;
  39324. /**
  39325. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39326. * from 0.
  39327. * It defines the percentage of current camera.radius to use as delta when
  39328. * pinch zoom is used.
  39329. */
  39330. pinchDeltaPercentage: number;
  39331. /**
  39332. * Defines the pointer panning sensibility or how fast is the camera moving.
  39333. */
  39334. panningSensibility: number;
  39335. /**
  39336. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39337. */
  39338. multiTouchPanning: boolean;
  39339. /**
  39340. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39341. * zoom (pinch) through multitouch.
  39342. */
  39343. multiTouchPanAndZoom: boolean;
  39344. /**
  39345. * Revers pinch action direction.
  39346. */
  39347. pinchInwards: boolean;
  39348. private _isPanClick;
  39349. private _twoFingerActivityCount;
  39350. private _isPinching;
  39351. /**
  39352. * Called on pointer POINTERMOVE event if only a single touch is active.
  39353. */
  39354. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39355. /**
  39356. * Called on pointer POINTERDOUBLETAP event.
  39357. */
  39358. protected onDoubleTap(type: string): void;
  39359. /**
  39360. * Called on pointer POINTERMOVE event if multiple touches are active.
  39361. */
  39362. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39363. /**
  39364. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39365. * press.
  39366. */
  39367. protected onButtonDown(evt: PointerEvent): void;
  39368. /**
  39369. * Called each time a new POINTERUP event occurs. Ie, for each button
  39370. * release.
  39371. */
  39372. protected onButtonUp(evt: PointerEvent): void;
  39373. /**
  39374. * Called when window becomes inactive.
  39375. */
  39376. protected onLostFocus(): void;
  39377. }
  39378. }
  39379. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39380. import { Nullable } from "babylonjs/types";
  39381. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39382. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39383. /**
  39384. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39386. */
  39387. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39388. /**
  39389. * Defines the camera the input is attached to.
  39390. */
  39391. camera: ArcRotateCamera;
  39392. /**
  39393. * Defines the list of key codes associated with the up action (increase alpha)
  39394. */
  39395. keysUp: number[];
  39396. /**
  39397. * Defines the list of key codes associated with the down action (decrease alpha)
  39398. */
  39399. keysDown: number[];
  39400. /**
  39401. * Defines the list of key codes associated with the left action (increase beta)
  39402. */
  39403. keysLeft: number[];
  39404. /**
  39405. * Defines the list of key codes associated with the right action (decrease beta)
  39406. */
  39407. keysRight: number[];
  39408. /**
  39409. * Defines the list of key codes associated with the reset action.
  39410. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39411. */
  39412. keysReset: number[];
  39413. /**
  39414. * Defines the panning sensibility of the inputs.
  39415. * (How fast is the camera paning)
  39416. */
  39417. panningSensibility: number;
  39418. /**
  39419. * Defines the zooming sensibility of the inputs.
  39420. * (How fast is the camera zooming)
  39421. */
  39422. zoomingSensibility: number;
  39423. /**
  39424. * Defines wether maintaining the alt key down switch the movement mode from
  39425. * orientation to zoom.
  39426. */
  39427. useAltToZoom: boolean;
  39428. /**
  39429. * Rotation speed of the camera
  39430. */
  39431. angularSpeed: number;
  39432. private _keys;
  39433. private _ctrlPressed;
  39434. private _altPressed;
  39435. private _onCanvasBlurObserver;
  39436. private _onKeyboardObserver;
  39437. private _engine;
  39438. private _scene;
  39439. /**
  39440. * Attach the input controls to a specific dom element to get the input from.
  39441. * @param element Defines the element the controls should be listened from
  39442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39443. */
  39444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39445. /**
  39446. * Detach the current controls from the specified dom element.
  39447. * @param element Defines the element to stop listening the inputs from
  39448. */
  39449. detachControl(element: Nullable<HTMLElement>): void;
  39450. /**
  39451. * Update the current camera state depending on the inputs that have been used this frame.
  39452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39453. */
  39454. checkInputs(): void;
  39455. /**
  39456. * Gets the class name of the current intput.
  39457. * @returns the class name
  39458. */
  39459. getClassName(): string;
  39460. /**
  39461. * Get the friendly name associated with the input class.
  39462. * @returns the input friendly name
  39463. */
  39464. getSimpleName(): string;
  39465. }
  39466. }
  39467. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39468. import { Nullable } from "babylonjs/types";
  39469. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39470. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39471. /**
  39472. * Manage the mouse wheel inputs to control an arc rotate camera.
  39473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39474. */
  39475. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39476. /**
  39477. * Defines the camera the input is attached to.
  39478. */
  39479. camera: ArcRotateCamera;
  39480. /**
  39481. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39482. */
  39483. wheelPrecision: number;
  39484. /**
  39485. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39486. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39487. */
  39488. wheelDeltaPercentage: number;
  39489. private _wheel;
  39490. private _observer;
  39491. private computeDeltaFromMouseWheelLegacyEvent;
  39492. /**
  39493. * Attach the input controls to a specific dom element to get the input from.
  39494. * @param element Defines the element the controls should be listened from
  39495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39496. */
  39497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39498. /**
  39499. * Detach the current controls from the specified dom element.
  39500. * @param element Defines the element to stop listening the inputs from
  39501. */
  39502. detachControl(element: Nullable<HTMLElement>): void;
  39503. /**
  39504. * Gets the class name of the current intput.
  39505. * @returns the class name
  39506. */
  39507. getClassName(): string;
  39508. /**
  39509. * Get the friendly name associated with the input class.
  39510. * @returns the input friendly name
  39511. */
  39512. getSimpleName(): string;
  39513. }
  39514. }
  39515. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39516. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39517. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39518. /**
  39519. * Default Inputs manager for the ArcRotateCamera.
  39520. * It groups all the default supported inputs for ease of use.
  39521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39522. */
  39523. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39524. /**
  39525. * Instantiates a new ArcRotateCameraInputsManager.
  39526. * @param camera Defines the camera the inputs belong to
  39527. */
  39528. constructor(camera: ArcRotateCamera);
  39529. /**
  39530. * Add mouse wheel input support to the input manager.
  39531. * @returns the current input manager
  39532. */
  39533. addMouseWheel(): ArcRotateCameraInputsManager;
  39534. /**
  39535. * Add pointers input support to the input manager.
  39536. * @returns the current input manager
  39537. */
  39538. addPointers(): ArcRotateCameraInputsManager;
  39539. /**
  39540. * Add keyboard input support to the input manager.
  39541. * @returns the current input manager
  39542. */
  39543. addKeyboard(): ArcRotateCameraInputsManager;
  39544. }
  39545. }
  39546. declare module "babylonjs/Cameras/arcRotateCamera" {
  39547. import { Observable } from "babylonjs/Misc/observable";
  39548. import { Nullable } from "babylonjs/types";
  39549. import { Scene } from "babylonjs/scene";
  39550. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39552. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39553. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39554. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39555. import { Camera } from "babylonjs/Cameras/camera";
  39556. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39557. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39558. import { Collider } from "babylonjs/Collisions/collider";
  39559. /**
  39560. * This represents an orbital type of camera.
  39561. *
  39562. * 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.
  39563. * 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.
  39564. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39565. */
  39566. export class ArcRotateCamera extends TargetCamera {
  39567. /**
  39568. * Defines the rotation angle of the camera along the longitudinal axis.
  39569. */
  39570. alpha: number;
  39571. /**
  39572. * Defines the rotation angle of the camera along the latitudinal axis.
  39573. */
  39574. beta: number;
  39575. /**
  39576. * Defines the radius of the camera from it s target point.
  39577. */
  39578. radius: number;
  39579. protected _target: Vector3;
  39580. protected _targetHost: Nullable<AbstractMesh>;
  39581. /**
  39582. * Defines the target point of the camera.
  39583. * The camera looks towards it form the radius distance.
  39584. */
  39585. get target(): Vector3;
  39586. set target(value: Vector3);
  39587. /**
  39588. * Define the current local position of the camera in the scene
  39589. */
  39590. get position(): Vector3;
  39591. set position(newPosition: Vector3);
  39592. protected _upVector: Vector3;
  39593. protected _upToYMatrix: Matrix;
  39594. protected _YToUpMatrix: Matrix;
  39595. /**
  39596. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39597. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39598. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39599. */
  39600. set upVector(vec: Vector3);
  39601. get upVector(): Vector3;
  39602. /**
  39603. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39604. */
  39605. setMatUp(): void;
  39606. /**
  39607. * Current inertia value on the longitudinal axis.
  39608. * The bigger this number the longer it will take for the camera to stop.
  39609. */
  39610. inertialAlphaOffset: number;
  39611. /**
  39612. * Current inertia value on the latitudinal axis.
  39613. * The bigger this number the longer it will take for the camera to stop.
  39614. */
  39615. inertialBetaOffset: number;
  39616. /**
  39617. * Current inertia value on the radius axis.
  39618. * The bigger this number the longer it will take for the camera to stop.
  39619. */
  39620. inertialRadiusOffset: number;
  39621. /**
  39622. * Minimum allowed angle on the longitudinal axis.
  39623. * This can help limiting how the Camera is able to move in the scene.
  39624. */
  39625. lowerAlphaLimit: Nullable<number>;
  39626. /**
  39627. * Maximum allowed angle on the longitudinal axis.
  39628. * This can help limiting how the Camera is able to move in the scene.
  39629. */
  39630. upperAlphaLimit: Nullable<number>;
  39631. /**
  39632. * Minimum allowed angle on the latitudinal axis.
  39633. * This can help limiting how the Camera is able to move in the scene.
  39634. */
  39635. lowerBetaLimit: number;
  39636. /**
  39637. * Maximum allowed angle on the latitudinal axis.
  39638. * This can help limiting how the Camera is able to move in the scene.
  39639. */
  39640. upperBetaLimit: number;
  39641. /**
  39642. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39643. * This can help limiting how the Camera is able to move in the scene.
  39644. */
  39645. lowerRadiusLimit: Nullable<number>;
  39646. /**
  39647. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39648. * This can help limiting how the Camera is able to move in the scene.
  39649. */
  39650. upperRadiusLimit: Nullable<number>;
  39651. /**
  39652. * Defines the current inertia value used during panning of the camera along the X axis.
  39653. */
  39654. inertialPanningX: number;
  39655. /**
  39656. * Defines the current inertia value used during panning of the camera along the Y axis.
  39657. */
  39658. inertialPanningY: number;
  39659. /**
  39660. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39661. * Basically if your fingers moves away from more than this distance you will be considered
  39662. * in pinch mode.
  39663. */
  39664. pinchToPanMaxDistance: number;
  39665. /**
  39666. * Defines the maximum distance the camera can pan.
  39667. * This could help keeping the cammera always in your scene.
  39668. */
  39669. panningDistanceLimit: Nullable<number>;
  39670. /**
  39671. * Defines the target of the camera before paning.
  39672. */
  39673. panningOriginTarget: Vector3;
  39674. /**
  39675. * Defines the value of the inertia used during panning.
  39676. * 0 would mean stop inertia and one would mean no decelleration at all.
  39677. */
  39678. panningInertia: number;
  39679. /**
  39680. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39681. */
  39682. get angularSensibilityX(): number;
  39683. set angularSensibilityX(value: number);
  39684. /**
  39685. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39686. */
  39687. get angularSensibilityY(): number;
  39688. set angularSensibilityY(value: number);
  39689. /**
  39690. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39691. */
  39692. get pinchPrecision(): number;
  39693. set pinchPrecision(value: number);
  39694. /**
  39695. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39696. * It will be used instead of pinchDeltaPrecision if different from 0.
  39697. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39698. */
  39699. get pinchDeltaPercentage(): number;
  39700. set pinchDeltaPercentage(value: number);
  39701. /**
  39702. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39703. */
  39704. get panningSensibility(): number;
  39705. set panningSensibility(value: number);
  39706. /**
  39707. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39708. */
  39709. get keysUp(): number[];
  39710. set keysUp(value: number[]);
  39711. /**
  39712. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39713. */
  39714. get keysDown(): number[];
  39715. set keysDown(value: number[]);
  39716. /**
  39717. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39718. */
  39719. get keysLeft(): number[];
  39720. set keysLeft(value: number[]);
  39721. /**
  39722. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39723. */
  39724. get keysRight(): number[];
  39725. set keysRight(value: number[]);
  39726. /**
  39727. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39728. */
  39729. get wheelPrecision(): number;
  39730. set wheelPrecision(value: number);
  39731. /**
  39732. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39733. * It will be used instead of pinchDeltaPrecision if different from 0.
  39734. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39735. */
  39736. get wheelDeltaPercentage(): number;
  39737. set wheelDeltaPercentage(value: number);
  39738. /**
  39739. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39740. */
  39741. zoomOnFactor: number;
  39742. /**
  39743. * Defines a screen offset for the camera position.
  39744. */
  39745. targetScreenOffset: Vector2;
  39746. /**
  39747. * Allows the camera to be completely reversed.
  39748. * If false the camera can not arrive upside down.
  39749. */
  39750. allowUpsideDown: boolean;
  39751. /**
  39752. * Define if double tap/click is used to restore the previously saved state of the camera.
  39753. */
  39754. useInputToRestoreState: boolean;
  39755. /** @hidden */
  39756. _viewMatrix: Matrix;
  39757. /** @hidden */
  39758. _useCtrlForPanning: boolean;
  39759. /** @hidden */
  39760. _panningMouseButton: number;
  39761. /**
  39762. * Defines the input associated to the camera.
  39763. */
  39764. inputs: ArcRotateCameraInputsManager;
  39765. /** @hidden */
  39766. _reset: () => void;
  39767. /**
  39768. * Defines the allowed panning axis.
  39769. */
  39770. panningAxis: Vector3;
  39771. protected _localDirection: Vector3;
  39772. protected _transformedDirection: Vector3;
  39773. private _bouncingBehavior;
  39774. /**
  39775. * Gets the bouncing behavior of the camera if it has been enabled.
  39776. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39777. */
  39778. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39779. /**
  39780. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39781. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39782. */
  39783. get useBouncingBehavior(): boolean;
  39784. set useBouncingBehavior(value: boolean);
  39785. private _framingBehavior;
  39786. /**
  39787. * Gets the framing behavior of the camera if it has been enabled.
  39788. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39789. */
  39790. get framingBehavior(): Nullable<FramingBehavior>;
  39791. /**
  39792. * Defines if the framing behavior of the camera is enabled on the camera.
  39793. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39794. */
  39795. get useFramingBehavior(): boolean;
  39796. set useFramingBehavior(value: boolean);
  39797. private _autoRotationBehavior;
  39798. /**
  39799. * Gets the auto rotation behavior of the camera if it has been enabled.
  39800. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39801. */
  39802. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39803. /**
  39804. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39805. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39806. */
  39807. get useAutoRotationBehavior(): boolean;
  39808. set useAutoRotationBehavior(value: boolean);
  39809. /**
  39810. * Observable triggered when the mesh target has been changed on the camera.
  39811. */
  39812. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39813. /**
  39814. * Event raised when the camera is colliding with a mesh.
  39815. */
  39816. onCollide: (collidedMesh: AbstractMesh) => void;
  39817. /**
  39818. * Defines whether the camera should check collision with the objects oh the scene.
  39819. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39820. */
  39821. checkCollisions: boolean;
  39822. /**
  39823. * Defines the collision radius of the camera.
  39824. * This simulates a sphere around the camera.
  39825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39826. */
  39827. collisionRadius: Vector3;
  39828. protected _collider: Collider;
  39829. protected _previousPosition: Vector3;
  39830. protected _collisionVelocity: Vector3;
  39831. protected _newPosition: Vector3;
  39832. protected _previousAlpha: number;
  39833. protected _previousBeta: number;
  39834. protected _previousRadius: number;
  39835. protected _collisionTriggered: boolean;
  39836. protected _targetBoundingCenter: Nullable<Vector3>;
  39837. private _computationVector;
  39838. /**
  39839. * Instantiates a new ArcRotateCamera in a given scene
  39840. * @param name Defines the name of the camera
  39841. * @param alpha Defines the camera rotation along the logitudinal axis
  39842. * @param beta Defines the camera rotation along the latitudinal axis
  39843. * @param radius Defines the camera distance from its target
  39844. * @param target Defines the camera target
  39845. * @param scene Defines the scene the camera belongs to
  39846. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39847. */
  39848. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39849. /** @hidden */
  39850. _initCache(): void;
  39851. /** @hidden */
  39852. _updateCache(ignoreParentClass?: boolean): void;
  39853. protected _getTargetPosition(): Vector3;
  39854. private _storedAlpha;
  39855. private _storedBeta;
  39856. private _storedRadius;
  39857. private _storedTarget;
  39858. private _storedTargetScreenOffset;
  39859. /**
  39860. * Stores the current state of the camera (alpha, beta, radius and target)
  39861. * @returns the camera itself
  39862. */
  39863. storeState(): Camera;
  39864. /**
  39865. * @hidden
  39866. * Restored camera state. You must call storeState() first
  39867. */
  39868. _restoreStateValues(): boolean;
  39869. /** @hidden */
  39870. _isSynchronizedViewMatrix(): boolean;
  39871. /**
  39872. * Attached controls to the current camera.
  39873. * @param element Defines the element the controls should be listened from
  39874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39875. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39876. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39877. */
  39878. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39879. /**
  39880. * Detach the current controls from the camera.
  39881. * The camera will stop reacting to inputs.
  39882. * @param element Defines the element to stop listening the inputs from
  39883. */
  39884. detachControl(element: HTMLElement): void;
  39885. /** @hidden */
  39886. _checkInputs(): void;
  39887. protected _checkLimits(): void;
  39888. /**
  39889. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39890. */
  39891. rebuildAnglesAndRadius(): void;
  39892. /**
  39893. * Use a position to define the current camera related information like alpha, beta and radius
  39894. * @param position Defines the position to set the camera at
  39895. */
  39896. setPosition(position: Vector3): void;
  39897. /**
  39898. * Defines the target the camera should look at.
  39899. * This will automatically adapt alpha beta and radius to fit within the new target.
  39900. * @param target Defines the new target as a Vector or a mesh
  39901. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39902. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39903. */
  39904. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39905. /** @hidden */
  39906. _getViewMatrix(): Matrix;
  39907. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39908. /**
  39909. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39910. * @param meshes Defines the mesh to zoom on
  39911. * @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)
  39912. */
  39913. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39914. /**
  39915. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39916. * The target will be changed but the radius
  39917. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39918. * @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)
  39919. */
  39920. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39921. min: Vector3;
  39922. max: Vector3;
  39923. distance: number;
  39924. }, doNotUpdateMaxZ?: boolean): void;
  39925. /**
  39926. * @override
  39927. * Override Camera.createRigCamera
  39928. */
  39929. createRigCamera(name: string, cameraIndex: number): Camera;
  39930. /**
  39931. * @hidden
  39932. * @override
  39933. * Override Camera._updateRigCameras
  39934. */
  39935. _updateRigCameras(): void;
  39936. /**
  39937. * Destroy the camera and release the current resources hold by it.
  39938. */
  39939. dispose(): void;
  39940. /**
  39941. * Gets the current object class name.
  39942. * @return the class name
  39943. */
  39944. getClassName(): string;
  39945. }
  39946. }
  39947. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39948. import { Behavior } from "babylonjs/Behaviors/behavior";
  39949. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39950. /**
  39951. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39952. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39953. */
  39954. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39955. /**
  39956. * Gets the name of the behavior.
  39957. */
  39958. get name(): string;
  39959. private _zoomStopsAnimation;
  39960. private _idleRotationSpeed;
  39961. private _idleRotationWaitTime;
  39962. private _idleRotationSpinupTime;
  39963. /**
  39964. * Sets the flag that indicates if user zooming should stop animation.
  39965. */
  39966. set zoomStopsAnimation(flag: boolean);
  39967. /**
  39968. * Gets the flag that indicates if user zooming should stop animation.
  39969. */
  39970. get zoomStopsAnimation(): boolean;
  39971. /**
  39972. * Sets the default speed at which the camera rotates around the model.
  39973. */
  39974. set idleRotationSpeed(speed: number);
  39975. /**
  39976. * Gets the default speed at which the camera rotates around the model.
  39977. */
  39978. get idleRotationSpeed(): number;
  39979. /**
  39980. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39981. */
  39982. set idleRotationWaitTime(time: number);
  39983. /**
  39984. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39985. */
  39986. get idleRotationWaitTime(): number;
  39987. /**
  39988. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39989. */
  39990. set idleRotationSpinupTime(time: number);
  39991. /**
  39992. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39993. */
  39994. get idleRotationSpinupTime(): number;
  39995. /**
  39996. * Gets a value indicating if the camera is currently rotating because of this behavior
  39997. */
  39998. get rotationInProgress(): boolean;
  39999. private _onPrePointerObservableObserver;
  40000. private _onAfterCheckInputsObserver;
  40001. private _attachedCamera;
  40002. private _isPointerDown;
  40003. private _lastFrameTime;
  40004. private _lastInteractionTime;
  40005. private _cameraRotationSpeed;
  40006. /**
  40007. * Initializes the behavior.
  40008. */
  40009. init(): void;
  40010. /**
  40011. * Attaches the behavior to its arc rotate camera.
  40012. * @param camera Defines the camera to attach the behavior to
  40013. */
  40014. attach(camera: ArcRotateCamera): void;
  40015. /**
  40016. * Detaches the behavior from its current arc rotate camera.
  40017. */
  40018. detach(): void;
  40019. /**
  40020. * Returns true if user is scrolling.
  40021. * @return true if user is scrolling.
  40022. */
  40023. private _userIsZooming;
  40024. private _lastFrameRadius;
  40025. private _shouldAnimationStopForInteraction;
  40026. /**
  40027. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40028. */
  40029. private _applyUserInteraction;
  40030. private _userIsMoving;
  40031. }
  40032. }
  40033. declare module "babylonjs/Behaviors/Cameras/index" {
  40034. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40035. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40036. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40037. }
  40038. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40039. import { Mesh } from "babylonjs/Meshes/mesh";
  40040. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40041. import { Behavior } from "babylonjs/Behaviors/behavior";
  40042. /**
  40043. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40044. */
  40045. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40046. private ui;
  40047. /**
  40048. * The name of the behavior
  40049. */
  40050. name: string;
  40051. /**
  40052. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40053. */
  40054. distanceAwayFromFace: number;
  40055. /**
  40056. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40057. */
  40058. distanceAwayFromBottomOfFace: number;
  40059. private _faceVectors;
  40060. private _target;
  40061. private _scene;
  40062. private _onRenderObserver;
  40063. private _tmpMatrix;
  40064. private _tmpVector;
  40065. /**
  40066. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40067. * @param ui The transform node that should be attched to the mesh
  40068. */
  40069. constructor(ui: TransformNode);
  40070. /**
  40071. * Initializes the behavior
  40072. */
  40073. init(): void;
  40074. private _closestFace;
  40075. private _zeroVector;
  40076. private _lookAtTmpMatrix;
  40077. private _lookAtToRef;
  40078. /**
  40079. * Attaches the AttachToBoxBehavior to the passed in mesh
  40080. * @param target The mesh that the specified node will be attached to
  40081. */
  40082. attach(target: Mesh): void;
  40083. /**
  40084. * Detaches the behavior from the mesh
  40085. */
  40086. detach(): void;
  40087. }
  40088. }
  40089. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40090. import { Behavior } from "babylonjs/Behaviors/behavior";
  40091. import { Mesh } from "babylonjs/Meshes/mesh";
  40092. /**
  40093. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40094. */
  40095. export class FadeInOutBehavior implements Behavior<Mesh> {
  40096. /**
  40097. * Time in milliseconds to delay before fading in (Default: 0)
  40098. */
  40099. delay: number;
  40100. /**
  40101. * Time in milliseconds for the mesh to fade in (Default: 300)
  40102. */
  40103. fadeInTime: number;
  40104. private _millisecondsPerFrame;
  40105. private _hovered;
  40106. private _hoverValue;
  40107. private _ownerNode;
  40108. /**
  40109. * Instatiates the FadeInOutBehavior
  40110. */
  40111. constructor();
  40112. /**
  40113. * The name of the behavior
  40114. */
  40115. get name(): string;
  40116. /**
  40117. * Initializes the behavior
  40118. */
  40119. init(): void;
  40120. /**
  40121. * Attaches the fade behavior on the passed in mesh
  40122. * @param ownerNode The mesh that will be faded in/out once attached
  40123. */
  40124. attach(ownerNode: Mesh): void;
  40125. /**
  40126. * Detaches the behavior from the mesh
  40127. */
  40128. detach(): void;
  40129. /**
  40130. * Triggers the mesh to begin fading in or out
  40131. * @param value if the object should fade in or out (true to fade in)
  40132. */
  40133. fadeIn(value: boolean): void;
  40134. private _update;
  40135. private _setAllVisibility;
  40136. }
  40137. }
  40138. declare module "babylonjs/Misc/pivotTools" {
  40139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40140. /**
  40141. * Class containing a set of static utilities functions for managing Pivots
  40142. * @hidden
  40143. */
  40144. export class PivotTools {
  40145. private static _PivotCached;
  40146. private static _OldPivotPoint;
  40147. private static _PivotTranslation;
  40148. private static _PivotTmpVector;
  40149. /** @hidden */
  40150. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40151. /** @hidden */
  40152. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40153. }
  40154. }
  40155. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40156. import { Scene } from "babylonjs/scene";
  40157. import { Vector4 } from "babylonjs/Maths/math.vector";
  40158. import { Mesh } from "babylonjs/Meshes/mesh";
  40159. import { Nullable } from "babylonjs/types";
  40160. import { Plane } from "babylonjs/Maths/math.plane";
  40161. /**
  40162. * Class containing static functions to help procedurally build meshes
  40163. */
  40164. export class PlaneBuilder {
  40165. /**
  40166. * Creates a plane mesh
  40167. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40168. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40169. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40173. * @param name defines the name of the mesh
  40174. * @param options defines the options used to create the mesh
  40175. * @param scene defines the hosting scene
  40176. * @returns the plane mesh
  40177. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40178. */
  40179. static CreatePlane(name: string, options: {
  40180. size?: number;
  40181. width?: number;
  40182. height?: number;
  40183. sideOrientation?: number;
  40184. frontUVs?: Vector4;
  40185. backUVs?: Vector4;
  40186. updatable?: boolean;
  40187. sourcePlane?: Plane;
  40188. }, scene?: Nullable<Scene>): Mesh;
  40189. }
  40190. }
  40191. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40192. import { Behavior } from "babylonjs/Behaviors/behavior";
  40193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40194. import { Observable } from "babylonjs/Misc/observable";
  40195. import { Vector3 } from "babylonjs/Maths/math.vector";
  40196. import { Ray } from "babylonjs/Culling/ray";
  40197. import "babylonjs/Meshes/Builders/planeBuilder";
  40198. /**
  40199. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40200. */
  40201. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40202. private static _AnyMouseID;
  40203. /**
  40204. * Abstract mesh the behavior is set on
  40205. */
  40206. attachedNode: AbstractMesh;
  40207. private _dragPlane;
  40208. private _scene;
  40209. private _pointerObserver;
  40210. private _beforeRenderObserver;
  40211. private static _planeScene;
  40212. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40213. /**
  40214. * 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)
  40215. */
  40216. maxDragAngle: number;
  40217. /**
  40218. * @hidden
  40219. */
  40220. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40221. /**
  40222. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40223. */
  40224. currentDraggingPointerID: number;
  40225. /**
  40226. * The last position where the pointer hit the drag plane in world space
  40227. */
  40228. lastDragPosition: Vector3;
  40229. /**
  40230. * If the behavior is currently in a dragging state
  40231. */
  40232. dragging: boolean;
  40233. /**
  40234. * 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)
  40235. */
  40236. dragDeltaRatio: number;
  40237. /**
  40238. * If the drag plane orientation should be updated during the dragging (Default: true)
  40239. */
  40240. updateDragPlane: boolean;
  40241. private _debugMode;
  40242. private _moving;
  40243. /**
  40244. * Fires each time the attached mesh is dragged with the pointer
  40245. * * delta between last drag position and current drag position in world space
  40246. * * dragDistance along the drag axis
  40247. * * dragPlaneNormal normal of the current drag plane used during the drag
  40248. * * dragPlanePoint in world space where the drag intersects the drag plane
  40249. */
  40250. onDragObservable: Observable<{
  40251. delta: Vector3;
  40252. dragPlanePoint: Vector3;
  40253. dragPlaneNormal: Vector3;
  40254. dragDistance: number;
  40255. pointerId: number;
  40256. }>;
  40257. /**
  40258. * Fires each time a drag begins (eg. mouse down on mesh)
  40259. */
  40260. onDragStartObservable: Observable<{
  40261. dragPlanePoint: Vector3;
  40262. pointerId: number;
  40263. }>;
  40264. /**
  40265. * Fires each time a drag ends (eg. mouse release after drag)
  40266. */
  40267. onDragEndObservable: Observable<{
  40268. dragPlanePoint: Vector3;
  40269. pointerId: number;
  40270. }>;
  40271. /**
  40272. * If the attached mesh should be moved when dragged
  40273. */
  40274. moveAttached: boolean;
  40275. /**
  40276. * If the drag behavior will react to drag events (Default: true)
  40277. */
  40278. enabled: boolean;
  40279. /**
  40280. * If pointer events should start and release the drag (Default: true)
  40281. */
  40282. startAndReleaseDragOnPointerEvents: boolean;
  40283. /**
  40284. * If camera controls should be detached during the drag
  40285. */
  40286. detachCameraControls: boolean;
  40287. /**
  40288. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40289. */
  40290. useObjectOrientationForDragging: boolean;
  40291. private _options;
  40292. /**
  40293. * Gets the options used by the behavior
  40294. */
  40295. get options(): {
  40296. dragAxis?: Vector3;
  40297. dragPlaneNormal?: Vector3;
  40298. };
  40299. /**
  40300. * Sets the options used by the behavior
  40301. */
  40302. set options(options: {
  40303. dragAxis?: Vector3;
  40304. dragPlaneNormal?: Vector3;
  40305. });
  40306. /**
  40307. * Creates a pointer drag behavior that can be attached to a mesh
  40308. * @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)
  40309. */
  40310. constructor(options?: {
  40311. dragAxis?: Vector3;
  40312. dragPlaneNormal?: Vector3;
  40313. });
  40314. /**
  40315. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40316. */
  40317. validateDrag: (targetPosition: Vector3) => boolean;
  40318. /**
  40319. * The name of the behavior
  40320. */
  40321. get name(): string;
  40322. /**
  40323. * Initializes the behavior
  40324. */
  40325. init(): void;
  40326. private _tmpVector;
  40327. private _alternatePickedPoint;
  40328. private _worldDragAxis;
  40329. private _targetPosition;
  40330. private _attachedElement;
  40331. /**
  40332. * Attaches the drag behavior the passed in mesh
  40333. * @param ownerNode The mesh that will be dragged around once attached
  40334. * @param predicate Predicate to use for pick filtering
  40335. */
  40336. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40337. /**
  40338. * Force relase the drag action by code.
  40339. */
  40340. releaseDrag(): void;
  40341. private _startDragRay;
  40342. private _lastPointerRay;
  40343. /**
  40344. * Simulates the start of a pointer drag event on the behavior
  40345. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40346. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40347. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40348. */
  40349. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40350. private _startDrag;
  40351. private _dragDelta;
  40352. private _moveDrag;
  40353. private _pickWithRayOnDragPlane;
  40354. private _pointA;
  40355. private _pointB;
  40356. private _pointC;
  40357. private _lineA;
  40358. private _lineB;
  40359. private _localAxis;
  40360. private _lookAt;
  40361. private _updateDragPlanePosition;
  40362. /**
  40363. * Detaches the behavior from the mesh
  40364. */
  40365. detach(): void;
  40366. }
  40367. }
  40368. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40369. import { Mesh } from "babylonjs/Meshes/mesh";
  40370. import { Behavior } from "babylonjs/Behaviors/behavior";
  40371. /**
  40372. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40373. */
  40374. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40375. private _dragBehaviorA;
  40376. private _dragBehaviorB;
  40377. private _startDistance;
  40378. private _initialScale;
  40379. private _targetScale;
  40380. private _ownerNode;
  40381. private _sceneRenderObserver;
  40382. /**
  40383. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40384. */
  40385. constructor();
  40386. /**
  40387. * The name of the behavior
  40388. */
  40389. get name(): string;
  40390. /**
  40391. * Initializes the behavior
  40392. */
  40393. init(): void;
  40394. private _getCurrentDistance;
  40395. /**
  40396. * Attaches the scale behavior the passed in mesh
  40397. * @param ownerNode The mesh that will be scaled around once attached
  40398. */
  40399. attach(ownerNode: Mesh): void;
  40400. /**
  40401. * Detaches the behavior from the mesh
  40402. */
  40403. detach(): void;
  40404. }
  40405. }
  40406. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40407. import { Behavior } from "babylonjs/Behaviors/behavior";
  40408. import { Mesh } from "babylonjs/Meshes/mesh";
  40409. import { Observable } from "babylonjs/Misc/observable";
  40410. /**
  40411. * 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
  40412. */
  40413. export class SixDofDragBehavior implements Behavior<Mesh> {
  40414. private static _virtualScene;
  40415. private _ownerNode;
  40416. private _sceneRenderObserver;
  40417. private _scene;
  40418. private _targetPosition;
  40419. private _virtualOriginMesh;
  40420. private _virtualDragMesh;
  40421. private _pointerObserver;
  40422. private _moving;
  40423. private _startingOrientation;
  40424. /**
  40425. * 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)
  40426. */
  40427. private zDragFactor;
  40428. /**
  40429. * If the object should rotate to face the drag origin
  40430. */
  40431. rotateDraggedObject: boolean;
  40432. /**
  40433. * If the behavior is currently in a dragging state
  40434. */
  40435. dragging: boolean;
  40436. /**
  40437. * 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)
  40438. */
  40439. dragDeltaRatio: number;
  40440. /**
  40441. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40442. */
  40443. currentDraggingPointerID: number;
  40444. /**
  40445. * If camera controls should be detached during the drag
  40446. */
  40447. detachCameraControls: boolean;
  40448. /**
  40449. * Fires each time a drag starts
  40450. */
  40451. onDragStartObservable: Observable<{}>;
  40452. /**
  40453. * Fires each time a drag ends (eg. mouse release after drag)
  40454. */
  40455. onDragEndObservable: Observable<{}>;
  40456. /**
  40457. * 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
  40458. */
  40459. constructor();
  40460. /**
  40461. * The name of the behavior
  40462. */
  40463. get name(): string;
  40464. /**
  40465. * Initializes the behavior
  40466. */
  40467. init(): void;
  40468. /**
  40469. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40470. */
  40471. private get _pointerCamera();
  40472. /**
  40473. * Attaches the scale behavior the passed in mesh
  40474. * @param ownerNode The mesh that will be scaled around once attached
  40475. */
  40476. attach(ownerNode: Mesh): void;
  40477. /**
  40478. * Detaches the behavior from the mesh
  40479. */
  40480. detach(): void;
  40481. }
  40482. }
  40483. declare module "babylonjs/Behaviors/Meshes/index" {
  40484. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40485. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40486. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40487. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40488. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40489. }
  40490. declare module "babylonjs/Behaviors/index" {
  40491. export * from "babylonjs/Behaviors/behavior";
  40492. export * from "babylonjs/Behaviors/Cameras/index";
  40493. export * from "babylonjs/Behaviors/Meshes/index";
  40494. }
  40495. declare module "babylonjs/Bones/boneIKController" {
  40496. import { Bone } from "babylonjs/Bones/bone";
  40497. import { Vector3 } from "babylonjs/Maths/math.vector";
  40498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40499. import { Nullable } from "babylonjs/types";
  40500. /**
  40501. * Class used to apply inverse kinematics to bones
  40502. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40503. */
  40504. export class BoneIKController {
  40505. private static _tmpVecs;
  40506. private static _tmpQuat;
  40507. private static _tmpMats;
  40508. /**
  40509. * Gets or sets the target mesh
  40510. */
  40511. targetMesh: AbstractMesh;
  40512. /** Gets or sets the mesh used as pole */
  40513. poleTargetMesh: AbstractMesh;
  40514. /**
  40515. * Gets or sets the bone used as pole
  40516. */
  40517. poleTargetBone: Nullable<Bone>;
  40518. /**
  40519. * Gets or sets the target position
  40520. */
  40521. targetPosition: Vector3;
  40522. /**
  40523. * Gets or sets the pole target position
  40524. */
  40525. poleTargetPosition: Vector3;
  40526. /**
  40527. * Gets or sets the pole target local offset
  40528. */
  40529. poleTargetLocalOffset: Vector3;
  40530. /**
  40531. * Gets or sets the pole angle
  40532. */
  40533. poleAngle: number;
  40534. /**
  40535. * Gets or sets the mesh associated with the controller
  40536. */
  40537. mesh: AbstractMesh;
  40538. /**
  40539. * 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)
  40540. */
  40541. slerpAmount: number;
  40542. private _bone1Quat;
  40543. private _bone1Mat;
  40544. private _bone2Ang;
  40545. private _bone1;
  40546. private _bone2;
  40547. private _bone1Length;
  40548. private _bone2Length;
  40549. private _maxAngle;
  40550. private _maxReach;
  40551. private _rightHandedSystem;
  40552. private _bendAxis;
  40553. private _slerping;
  40554. private _adjustRoll;
  40555. /**
  40556. * Gets or sets maximum allowed angle
  40557. */
  40558. get maxAngle(): number;
  40559. set maxAngle(value: number);
  40560. /**
  40561. * Creates a new BoneIKController
  40562. * @param mesh defines the mesh to control
  40563. * @param bone defines the bone to control
  40564. * @param options defines options to set up the controller
  40565. */
  40566. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40567. targetMesh?: AbstractMesh;
  40568. poleTargetMesh?: AbstractMesh;
  40569. poleTargetBone?: Bone;
  40570. poleTargetLocalOffset?: Vector3;
  40571. poleAngle?: number;
  40572. bendAxis?: Vector3;
  40573. maxAngle?: number;
  40574. slerpAmount?: number;
  40575. });
  40576. private _setMaxAngle;
  40577. /**
  40578. * Force the controller to update the bones
  40579. */
  40580. update(): void;
  40581. }
  40582. }
  40583. declare module "babylonjs/Bones/boneLookController" {
  40584. import { Vector3 } from "babylonjs/Maths/math.vector";
  40585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40586. import { Bone } from "babylonjs/Bones/bone";
  40587. import { Space } from "babylonjs/Maths/math.axis";
  40588. /**
  40589. * Class used to make a bone look toward a point in space
  40590. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40591. */
  40592. export class BoneLookController {
  40593. private static _tmpVecs;
  40594. private static _tmpQuat;
  40595. private static _tmpMats;
  40596. /**
  40597. * The target Vector3 that the bone will look at
  40598. */
  40599. target: Vector3;
  40600. /**
  40601. * The mesh that the bone is attached to
  40602. */
  40603. mesh: AbstractMesh;
  40604. /**
  40605. * The bone that will be looking to the target
  40606. */
  40607. bone: Bone;
  40608. /**
  40609. * The up axis of the coordinate system that is used when the bone is rotated
  40610. */
  40611. upAxis: Vector3;
  40612. /**
  40613. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40614. */
  40615. upAxisSpace: Space;
  40616. /**
  40617. * Used to make an adjustment to the yaw of the bone
  40618. */
  40619. adjustYaw: number;
  40620. /**
  40621. * Used to make an adjustment to the pitch of the bone
  40622. */
  40623. adjustPitch: number;
  40624. /**
  40625. * Used to make an adjustment to the roll of the bone
  40626. */
  40627. adjustRoll: number;
  40628. /**
  40629. * 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)
  40630. */
  40631. slerpAmount: number;
  40632. private _minYaw;
  40633. private _maxYaw;
  40634. private _minPitch;
  40635. private _maxPitch;
  40636. private _minYawSin;
  40637. private _minYawCos;
  40638. private _maxYawSin;
  40639. private _maxYawCos;
  40640. private _midYawConstraint;
  40641. private _minPitchTan;
  40642. private _maxPitchTan;
  40643. private _boneQuat;
  40644. private _slerping;
  40645. private _transformYawPitch;
  40646. private _transformYawPitchInv;
  40647. private _firstFrameSkipped;
  40648. private _yawRange;
  40649. private _fowardAxis;
  40650. /**
  40651. * Gets or sets the minimum yaw angle that the bone can look to
  40652. */
  40653. get minYaw(): number;
  40654. set minYaw(value: number);
  40655. /**
  40656. * Gets or sets the maximum yaw angle that the bone can look to
  40657. */
  40658. get maxYaw(): number;
  40659. set maxYaw(value: number);
  40660. /**
  40661. * Gets or sets the minimum pitch angle that the bone can look to
  40662. */
  40663. get minPitch(): number;
  40664. set minPitch(value: number);
  40665. /**
  40666. * Gets or sets the maximum pitch angle that the bone can look to
  40667. */
  40668. get maxPitch(): number;
  40669. set maxPitch(value: number);
  40670. /**
  40671. * Create a BoneLookController
  40672. * @param mesh the mesh that the bone belongs to
  40673. * @param bone the bone that will be looking to the target
  40674. * @param target the target Vector3 to look at
  40675. * @param options optional settings:
  40676. * * maxYaw: the maximum angle the bone will yaw to
  40677. * * minYaw: the minimum angle the bone will yaw to
  40678. * * maxPitch: the maximum angle the bone will pitch to
  40679. * * minPitch: the minimum angle the bone will yaw to
  40680. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40681. * * upAxis: the up axis of the coordinate system
  40682. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40683. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40684. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40685. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40686. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40687. * * adjustRoll: used to make an adjustment to the roll of the bone
  40688. **/
  40689. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40690. maxYaw?: number;
  40691. minYaw?: number;
  40692. maxPitch?: number;
  40693. minPitch?: number;
  40694. slerpAmount?: number;
  40695. upAxis?: Vector3;
  40696. upAxisSpace?: Space;
  40697. yawAxis?: Vector3;
  40698. pitchAxis?: Vector3;
  40699. adjustYaw?: number;
  40700. adjustPitch?: number;
  40701. adjustRoll?: number;
  40702. });
  40703. /**
  40704. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40705. */
  40706. update(): void;
  40707. private _getAngleDiff;
  40708. private _getAngleBetween;
  40709. private _isAngleBetween;
  40710. }
  40711. }
  40712. declare module "babylonjs/Bones/index" {
  40713. export * from "babylonjs/Bones/bone";
  40714. export * from "babylonjs/Bones/boneIKController";
  40715. export * from "babylonjs/Bones/boneLookController";
  40716. export * from "babylonjs/Bones/skeleton";
  40717. }
  40718. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40719. import { Nullable } from "babylonjs/types";
  40720. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40721. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40722. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40723. /**
  40724. * Manage the gamepad inputs to control an arc rotate camera.
  40725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40726. */
  40727. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40728. /**
  40729. * Defines the camera the input is attached to.
  40730. */
  40731. camera: ArcRotateCamera;
  40732. /**
  40733. * Defines the gamepad the input is gathering event from.
  40734. */
  40735. gamepad: Nullable<Gamepad>;
  40736. /**
  40737. * Defines the gamepad rotation sensiblity.
  40738. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40739. */
  40740. gamepadRotationSensibility: number;
  40741. /**
  40742. * Defines the gamepad move sensiblity.
  40743. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40744. */
  40745. gamepadMoveSensibility: number;
  40746. private _yAxisScale;
  40747. /**
  40748. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40749. */
  40750. get invertYAxis(): boolean;
  40751. set invertYAxis(value: boolean);
  40752. private _onGamepadConnectedObserver;
  40753. private _onGamepadDisconnectedObserver;
  40754. /**
  40755. * Attach the input controls to a specific dom element to get the input from.
  40756. * @param element Defines the element the controls should be listened from
  40757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40758. */
  40759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40760. /**
  40761. * Detach the current controls from the specified dom element.
  40762. * @param element Defines the element to stop listening the inputs from
  40763. */
  40764. detachControl(element: Nullable<HTMLElement>): void;
  40765. /**
  40766. * Update the current camera state depending on the inputs that have been used this frame.
  40767. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40768. */
  40769. checkInputs(): void;
  40770. /**
  40771. * Gets the class name of the current intput.
  40772. * @returns the class name
  40773. */
  40774. getClassName(): string;
  40775. /**
  40776. * Get the friendly name associated with the input class.
  40777. * @returns the input friendly name
  40778. */
  40779. getSimpleName(): string;
  40780. }
  40781. }
  40782. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40783. import { Nullable } from "babylonjs/types";
  40784. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40785. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40786. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40787. interface ArcRotateCameraInputsManager {
  40788. /**
  40789. * Add orientation input support to the input manager.
  40790. * @returns the current input manager
  40791. */
  40792. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40793. }
  40794. }
  40795. /**
  40796. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40798. */
  40799. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40800. /**
  40801. * Defines the camera the input is attached to.
  40802. */
  40803. camera: ArcRotateCamera;
  40804. /**
  40805. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40806. */
  40807. alphaCorrection: number;
  40808. /**
  40809. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40810. */
  40811. gammaCorrection: number;
  40812. private _alpha;
  40813. private _gamma;
  40814. private _dirty;
  40815. private _deviceOrientationHandler;
  40816. /**
  40817. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40818. */
  40819. constructor();
  40820. /**
  40821. * Attach the input controls to a specific dom element to get the input from.
  40822. * @param element Defines the element the controls should be listened from
  40823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40824. */
  40825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40826. /** @hidden */
  40827. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40828. /**
  40829. * Update the current camera state depending on the inputs that have been used this frame.
  40830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40831. */
  40832. checkInputs(): void;
  40833. /**
  40834. * Detach the current controls from the specified dom element.
  40835. * @param element Defines the element to stop listening the inputs from
  40836. */
  40837. detachControl(element: Nullable<HTMLElement>): void;
  40838. /**
  40839. * Gets the class name of the current intput.
  40840. * @returns the class name
  40841. */
  40842. getClassName(): string;
  40843. /**
  40844. * Get the friendly name associated with the input class.
  40845. * @returns the input friendly name
  40846. */
  40847. getSimpleName(): string;
  40848. }
  40849. }
  40850. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40851. import { Nullable } from "babylonjs/types";
  40852. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40853. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40854. /**
  40855. * Listen to mouse events to control the camera.
  40856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40857. */
  40858. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40859. /**
  40860. * Defines the camera the input is attached to.
  40861. */
  40862. camera: FlyCamera;
  40863. /**
  40864. * Defines if touch is enabled. (Default is true.)
  40865. */
  40866. touchEnabled: boolean;
  40867. /**
  40868. * Defines the buttons associated with the input to handle camera rotation.
  40869. */
  40870. buttons: number[];
  40871. /**
  40872. * Assign buttons for Yaw control.
  40873. */
  40874. buttonsYaw: number[];
  40875. /**
  40876. * Assign buttons for Pitch control.
  40877. */
  40878. buttonsPitch: number[];
  40879. /**
  40880. * Assign buttons for Roll control.
  40881. */
  40882. buttonsRoll: number[];
  40883. /**
  40884. * Detect if any button is being pressed while mouse is moved.
  40885. * -1 = Mouse locked.
  40886. * 0 = Left button.
  40887. * 1 = Middle Button.
  40888. * 2 = Right Button.
  40889. */
  40890. activeButton: number;
  40891. /**
  40892. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40893. * Higher values reduce its sensitivity.
  40894. */
  40895. angularSensibility: number;
  40896. private _mousemoveCallback;
  40897. private _observer;
  40898. private _rollObserver;
  40899. private previousPosition;
  40900. private noPreventDefault;
  40901. private element;
  40902. /**
  40903. * Listen to mouse events to control the camera.
  40904. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40906. */
  40907. constructor(touchEnabled?: boolean);
  40908. /**
  40909. * Attach the mouse control to the HTML DOM element.
  40910. * @param element Defines the element that listens to the input events.
  40911. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40912. */
  40913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40914. /**
  40915. * Detach the current controls from the specified dom element.
  40916. * @param element Defines the element to stop listening the inputs from
  40917. */
  40918. detachControl(element: Nullable<HTMLElement>): void;
  40919. /**
  40920. * Gets the class name of the current input.
  40921. * @returns the class name.
  40922. */
  40923. getClassName(): string;
  40924. /**
  40925. * Get the friendly name associated with the input class.
  40926. * @returns the input's friendly name.
  40927. */
  40928. getSimpleName(): string;
  40929. private _pointerInput;
  40930. private _onMouseMove;
  40931. /**
  40932. * Rotate camera by mouse offset.
  40933. */
  40934. private rotateCamera;
  40935. }
  40936. }
  40937. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40938. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40939. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40940. /**
  40941. * Default Inputs manager for the FlyCamera.
  40942. * It groups all the default supported inputs for ease of use.
  40943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40944. */
  40945. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40946. /**
  40947. * Instantiates a new FlyCameraInputsManager.
  40948. * @param camera Defines the camera the inputs belong to.
  40949. */
  40950. constructor(camera: FlyCamera);
  40951. /**
  40952. * Add keyboard input support to the input manager.
  40953. * @returns the new FlyCameraKeyboardMoveInput().
  40954. */
  40955. addKeyboard(): FlyCameraInputsManager;
  40956. /**
  40957. * Add mouse input support to the input manager.
  40958. * @param touchEnabled Enable touch screen support.
  40959. * @returns the new FlyCameraMouseInput().
  40960. */
  40961. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40962. }
  40963. }
  40964. declare module "babylonjs/Cameras/flyCamera" {
  40965. import { Scene } from "babylonjs/scene";
  40966. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40968. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40969. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40970. /**
  40971. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40972. * such as in a 3D Space Shooter or a Flight Simulator.
  40973. */
  40974. export class FlyCamera extends TargetCamera {
  40975. /**
  40976. * Define the collision ellipsoid of the camera.
  40977. * This is helpful for simulating a camera body, like a player's body.
  40978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40979. */
  40980. ellipsoid: Vector3;
  40981. /**
  40982. * Define an offset for the position of the ellipsoid around the camera.
  40983. * This can be helpful if the camera is attached away from the player's body center,
  40984. * such as at its head.
  40985. */
  40986. ellipsoidOffset: Vector3;
  40987. /**
  40988. * Enable or disable collisions of the camera with the rest of the scene objects.
  40989. */
  40990. checkCollisions: boolean;
  40991. /**
  40992. * Enable or disable gravity on the camera.
  40993. */
  40994. applyGravity: boolean;
  40995. /**
  40996. * Define the current direction the camera is moving to.
  40997. */
  40998. cameraDirection: Vector3;
  40999. /**
  41000. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41001. * This overrides and empties cameraRotation.
  41002. */
  41003. rotationQuaternion: Quaternion;
  41004. /**
  41005. * Track Roll to maintain the wanted Rolling when looking around.
  41006. */
  41007. _trackRoll: number;
  41008. /**
  41009. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41010. */
  41011. rollCorrect: number;
  41012. /**
  41013. * Mimic a banked turn, Rolling the camera when Yawing.
  41014. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41015. */
  41016. bankedTurn: boolean;
  41017. /**
  41018. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41019. */
  41020. bankedTurnLimit: number;
  41021. /**
  41022. * Value of 0 disables the banked Roll.
  41023. * Value of 1 is equal to the Yaw angle in radians.
  41024. */
  41025. bankedTurnMultiplier: number;
  41026. /**
  41027. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41028. */
  41029. inputs: FlyCameraInputsManager;
  41030. /**
  41031. * Gets the input sensibility for mouse input.
  41032. * Higher values reduce sensitivity.
  41033. */
  41034. get angularSensibility(): number;
  41035. /**
  41036. * Sets the input sensibility for a mouse input.
  41037. * Higher values reduce sensitivity.
  41038. */
  41039. set angularSensibility(value: number);
  41040. /**
  41041. * Get the keys for camera movement forward.
  41042. */
  41043. get keysForward(): number[];
  41044. /**
  41045. * Set the keys for camera movement forward.
  41046. */
  41047. set keysForward(value: number[]);
  41048. /**
  41049. * Get the keys for camera movement backward.
  41050. */
  41051. get keysBackward(): number[];
  41052. set keysBackward(value: number[]);
  41053. /**
  41054. * Get the keys for camera movement up.
  41055. */
  41056. get keysUp(): number[];
  41057. /**
  41058. * Set the keys for camera movement up.
  41059. */
  41060. set keysUp(value: number[]);
  41061. /**
  41062. * Get the keys for camera movement down.
  41063. */
  41064. get keysDown(): number[];
  41065. /**
  41066. * Set the keys for camera movement down.
  41067. */
  41068. set keysDown(value: number[]);
  41069. /**
  41070. * Get the keys for camera movement left.
  41071. */
  41072. get keysLeft(): number[];
  41073. /**
  41074. * Set the keys for camera movement left.
  41075. */
  41076. set keysLeft(value: number[]);
  41077. /**
  41078. * Set the keys for camera movement right.
  41079. */
  41080. get keysRight(): number[];
  41081. /**
  41082. * Set the keys for camera movement right.
  41083. */
  41084. set keysRight(value: number[]);
  41085. /**
  41086. * Event raised when the camera collides with a mesh in the scene.
  41087. */
  41088. onCollide: (collidedMesh: AbstractMesh) => void;
  41089. private _collider;
  41090. private _needMoveForGravity;
  41091. private _oldPosition;
  41092. private _diffPosition;
  41093. private _newPosition;
  41094. /** @hidden */
  41095. _localDirection: Vector3;
  41096. /** @hidden */
  41097. _transformedDirection: Vector3;
  41098. /**
  41099. * Instantiates a FlyCamera.
  41100. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41101. * such as in a 3D Space Shooter or a Flight Simulator.
  41102. * @param name Define the name of the camera in the scene.
  41103. * @param position Define the starting position of the camera in the scene.
  41104. * @param scene Define the scene the camera belongs to.
  41105. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41106. */
  41107. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41108. /**
  41109. * Attach a control to the HTML DOM element.
  41110. * @param element Defines the element that listens to the input events.
  41111. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41112. */
  41113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41114. /**
  41115. * Detach a control from the HTML DOM element.
  41116. * The camera will stop reacting to that input.
  41117. * @param element Defines the element that listens to the input events.
  41118. */
  41119. detachControl(element: HTMLElement): void;
  41120. private _collisionMask;
  41121. /**
  41122. * Get the mask that the camera ignores in collision events.
  41123. */
  41124. get collisionMask(): number;
  41125. /**
  41126. * Set the mask that the camera ignores in collision events.
  41127. */
  41128. set collisionMask(mask: number);
  41129. /** @hidden */
  41130. _collideWithWorld(displacement: Vector3): void;
  41131. /** @hidden */
  41132. private _onCollisionPositionChange;
  41133. /** @hidden */
  41134. _checkInputs(): void;
  41135. /** @hidden */
  41136. _decideIfNeedsToMove(): boolean;
  41137. /** @hidden */
  41138. _updatePosition(): void;
  41139. /**
  41140. * Restore the Roll to its target value at the rate specified.
  41141. * @param rate - Higher means slower restoring.
  41142. * @hidden
  41143. */
  41144. restoreRoll(rate: number): void;
  41145. /**
  41146. * Destroy the camera and release the current resources held by it.
  41147. */
  41148. dispose(): void;
  41149. /**
  41150. * Get the current object class name.
  41151. * @returns the class name.
  41152. */
  41153. getClassName(): string;
  41154. }
  41155. }
  41156. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41157. import { Nullable } from "babylonjs/types";
  41158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41159. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41160. /**
  41161. * Listen to keyboard events to control the camera.
  41162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41163. */
  41164. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41165. /**
  41166. * Defines the camera the input is attached to.
  41167. */
  41168. camera: FlyCamera;
  41169. /**
  41170. * The list of keyboard keys used to control the forward move of the camera.
  41171. */
  41172. keysForward: number[];
  41173. /**
  41174. * The list of keyboard keys used to control the backward move of the camera.
  41175. */
  41176. keysBackward: number[];
  41177. /**
  41178. * The list of keyboard keys used to control the forward move of the camera.
  41179. */
  41180. keysUp: number[];
  41181. /**
  41182. * The list of keyboard keys used to control the backward move of the camera.
  41183. */
  41184. keysDown: number[];
  41185. /**
  41186. * The list of keyboard keys used to control the right strafe move of the camera.
  41187. */
  41188. keysRight: number[];
  41189. /**
  41190. * The list of keyboard keys used to control the left strafe move of the camera.
  41191. */
  41192. keysLeft: number[];
  41193. private _keys;
  41194. private _onCanvasBlurObserver;
  41195. private _onKeyboardObserver;
  41196. private _engine;
  41197. private _scene;
  41198. /**
  41199. * Attach the input controls to a specific dom element to get the input from.
  41200. * @param element Defines the element the controls should be listened from
  41201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41202. */
  41203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41204. /**
  41205. * Detach the current controls from the specified dom element.
  41206. * @param element Defines the element to stop listening the inputs from
  41207. */
  41208. detachControl(element: Nullable<HTMLElement>): void;
  41209. /**
  41210. * Gets the class name of the current intput.
  41211. * @returns the class name
  41212. */
  41213. getClassName(): string;
  41214. /** @hidden */
  41215. _onLostFocus(e: FocusEvent): void;
  41216. /**
  41217. * Get the friendly name associated with the input class.
  41218. * @returns the input friendly name
  41219. */
  41220. getSimpleName(): string;
  41221. /**
  41222. * Update the current camera state depending on the inputs that have been used this frame.
  41223. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41224. */
  41225. checkInputs(): void;
  41226. }
  41227. }
  41228. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41229. import { Nullable } from "babylonjs/types";
  41230. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41231. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41232. /**
  41233. * Manage the mouse wheel inputs to control a follow camera.
  41234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41235. */
  41236. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41237. /**
  41238. * Defines the camera the input is attached to.
  41239. */
  41240. camera: FollowCamera;
  41241. /**
  41242. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41243. */
  41244. axisControlRadius: boolean;
  41245. /**
  41246. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41247. */
  41248. axisControlHeight: boolean;
  41249. /**
  41250. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41251. */
  41252. axisControlRotation: boolean;
  41253. /**
  41254. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41255. * relation to mouseWheel events.
  41256. */
  41257. wheelPrecision: number;
  41258. /**
  41259. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41260. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41261. */
  41262. wheelDeltaPercentage: number;
  41263. private _wheel;
  41264. private _observer;
  41265. /**
  41266. * Attach the input controls to a specific dom element to get the input from.
  41267. * @param element Defines the element the controls should be listened from
  41268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41269. */
  41270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41271. /**
  41272. * Detach the current controls from the specified dom element.
  41273. * @param element Defines the element to stop listening the inputs from
  41274. */
  41275. detachControl(element: Nullable<HTMLElement>): void;
  41276. /**
  41277. * Gets the class name of the current intput.
  41278. * @returns the class name
  41279. */
  41280. getClassName(): string;
  41281. /**
  41282. * Get the friendly name associated with the input class.
  41283. * @returns the input friendly name
  41284. */
  41285. getSimpleName(): string;
  41286. }
  41287. }
  41288. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41289. import { Nullable } from "babylonjs/types";
  41290. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41291. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41292. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41293. /**
  41294. * Manage the pointers inputs to control an follow camera.
  41295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41296. */
  41297. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41298. /**
  41299. * Defines the camera the input is attached to.
  41300. */
  41301. camera: FollowCamera;
  41302. /**
  41303. * Gets the class name of the current input.
  41304. * @returns the class name
  41305. */
  41306. getClassName(): string;
  41307. /**
  41308. * Defines the pointer angular sensibility along the X axis or how fast is
  41309. * the camera rotating.
  41310. * A negative number will reverse the axis direction.
  41311. */
  41312. angularSensibilityX: number;
  41313. /**
  41314. * Defines the pointer angular sensibility along the Y axis or how fast is
  41315. * the camera rotating.
  41316. * A negative number will reverse the axis direction.
  41317. */
  41318. angularSensibilityY: number;
  41319. /**
  41320. * Defines the pointer pinch precision or how fast is the camera zooming.
  41321. * A negative number will reverse the axis direction.
  41322. */
  41323. pinchPrecision: number;
  41324. /**
  41325. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41326. * from 0.
  41327. * It defines the percentage of current camera.radius to use as delta when
  41328. * pinch zoom is used.
  41329. */
  41330. pinchDeltaPercentage: number;
  41331. /**
  41332. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41333. */
  41334. axisXControlRadius: boolean;
  41335. /**
  41336. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41337. */
  41338. axisXControlHeight: boolean;
  41339. /**
  41340. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41341. */
  41342. axisXControlRotation: boolean;
  41343. /**
  41344. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41345. */
  41346. axisYControlRadius: boolean;
  41347. /**
  41348. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41349. */
  41350. axisYControlHeight: boolean;
  41351. /**
  41352. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41353. */
  41354. axisYControlRotation: boolean;
  41355. /**
  41356. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41357. */
  41358. axisPinchControlRadius: boolean;
  41359. /**
  41360. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41361. */
  41362. axisPinchControlHeight: boolean;
  41363. /**
  41364. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41365. */
  41366. axisPinchControlRotation: boolean;
  41367. /**
  41368. * Log error messages if basic misconfiguration has occurred.
  41369. */
  41370. warningEnable: boolean;
  41371. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41372. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41373. private _warningCounter;
  41374. private _warning;
  41375. }
  41376. }
  41377. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41378. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41379. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41380. /**
  41381. * Default Inputs manager for the FollowCamera.
  41382. * It groups all the default supported inputs for ease of use.
  41383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41384. */
  41385. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41386. /**
  41387. * Instantiates a new FollowCameraInputsManager.
  41388. * @param camera Defines the camera the inputs belong to
  41389. */
  41390. constructor(camera: FollowCamera);
  41391. /**
  41392. * Add keyboard input support to the input manager.
  41393. * @returns the current input manager
  41394. */
  41395. addKeyboard(): FollowCameraInputsManager;
  41396. /**
  41397. * Add mouse wheel input support to the input manager.
  41398. * @returns the current input manager
  41399. */
  41400. addMouseWheel(): FollowCameraInputsManager;
  41401. /**
  41402. * Add pointers input support to the input manager.
  41403. * @returns the current input manager
  41404. */
  41405. addPointers(): FollowCameraInputsManager;
  41406. /**
  41407. * Add orientation input support to the input manager.
  41408. * @returns the current input manager
  41409. */
  41410. addVRDeviceOrientation(): FollowCameraInputsManager;
  41411. }
  41412. }
  41413. declare module "babylonjs/Cameras/followCamera" {
  41414. import { Nullable } from "babylonjs/types";
  41415. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41416. import { Scene } from "babylonjs/scene";
  41417. import { Vector3 } from "babylonjs/Maths/math.vector";
  41418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41419. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41420. /**
  41421. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41422. * an arc rotate version arcFollowCamera are available.
  41423. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41424. */
  41425. export class FollowCamera extends TargetCamera {
  41426. /**
  41427. * Distance the follow camera should follow an object at
  41428. */
  41429. radius: number;
  41430. /**
  41431. * Minimum allowed distance of the camera to the axis of rotation
  41432. * (The camera can not get closer).
  41433. * This can help limiting how the Camera is able to move in the scene.
  41434. */
  41435. lowerRadiusLimit: Nullable<number>;
  41436. /**
  41437. * Maximum allowed distance of the camera to the axis of rotation
  41438. * (The camera can not get further).
  41439. * This can help limiting how the Camera is able to move in the scene.
  41440. */
  41441. upperRadiusLimit: Nullable<number>;
  41442. /**
  41443. * Define a rotation offset between the camera and the object it follows
  41444. */
  41445. rotationOffset: number;
  41446. /**
  41447. * Minimum allowed angle to camera position relative to target object.
  41448. * This can help limiting how the Camera is able to move in the scene.
  41449. */
  41450. lowerRotationOffsetLimit: Nullable<number>;
  41451. /**
  41452. * Maximum allowed angle to camera position relative to target object.
  41453. * This can help limiting how the Camera is able to move in the scene.
  41454. */
  41455. upperRotationOffsetLimit: Nullable<number>;
  41456. /**
  41457. * Define a height offset between the camera and the object it follows.
  41458. * It can help following an object from the top (like a car chaing a plane)
  41459. */
  41460. heightOffset: number;
  41461. /**
  41462. * Minimum allowed height of camera position relative to target object.
  41463. * This can help limiting how the Camera is able to move in the scene.
  41464. */
  41465. lowerHeightOffsetLimit: Nullable<number>;
  41466. /**
  41467. * Maximum allowed height of camera position relative to target object.
  41468. * This can help limiting how the Camera is able to move in the scene.
  41469. */
  41470. upperHeightOffsetLimit: Nullable<number>;
  41471. /**
  41472. * Define how fast the camera can accelerate to follow it s target.
  41473. */
  41474. cameraAcceleration: number;
  41475. /**
  41476. * Define the speed limit of the camera following an object.
  41477. */
  41478. maxCameraSpeed: number;
  41479. /**
  41480. * Define the target of the camera.
  41481. */
  41482. lockedTarget: Nullable<AbstractMesh>;
  41483. /**
  41484. * Defines the input associated with the camera.
  41485. */
  41486. inputs: FollowCameraInputsManager;
  41487. /**
  41488. * Instantiates the follow camera.
  41489. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41490. * @param name Define the name of the camera in the scene
  41491. * @param position Define the position of the camera
  41492. * @param scene Define the scene the camera belong to
  41493. * @param lockedTarget Define the target of the camera
  41494. */
  41495. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41496. private _follow;
  41497. /**
  41498. * Attached controls to the current camera.
  41499. * @param element Defines the element the controls should be listened from
  41500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41501. */
  41502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41503. /**
  41504. * Detach the current controls from the camera.
  41505. * The camera will stop reacting to inputs.
  41506. * @param element Defines the element to stop listening the inputs from
  41507. */
  41508. detachControl(element: HTMLElement): void;
  41509. /** @hidden */
  41510. _checkInputs(): void;
  41511. private _checkLimits;
  41512. /**
  41513. * Gets the camera class name.
  41514. * @returns the class name
  41515. */
  41516. getClassName(): string;
  41517. }
  41518. /**
  41519. * Arc Rotate version of the follow camera.
  41520. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41521. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41522. */
  41523. export class ArcFollowCamera extends TargetCamera {
  41524. /** The longitudinal angle of the camera */
  41525. alpha: number;
  41526. /** The latitudinal angle of the camera */
  41527. beta: number;
  41528. /** The radius of the camera from its target */
  41529. radius: number;
  41530. /** Define the camera target (the messh it should follow) */
  41531. target: Nullable<AbstractMesh>;
  41532. private _cartesianCoordinates;
  41533. /**
  41534. * Instantiates a new ArcFollowCamera
  41535. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41536. * @param name Define the name of the camera
  41537. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41538. * @param beta Define the rotation angle of the camera around the elevation axis
  41539. * @param radius Define the radius of the camera from its target point
  41540. * @param target Define the target of the camera
  41541. * @param scene Define the scene the camera belongs to
  41542. */
  41543. constructor(name: string,
  41544. /** The longitudinal angle of the camera */
  41545. alpha: number,
  41546. /** The latitudinal angle of the camera */
  41547. beta: number,
  41548. /** The radius of the camera from its target */
  41549. radius: number,
  41550. /** Define the camera target (the messh it should follow) */
  41551. target: Nullable<AbstractMesh>, scene: Scene);
  41552. private _follow;
  41553. /** @hidden */
  41554. _checkInputs(): void;
  41555. /**
  41556. * Returns the class name of the object.
  41557. * It is mostly used internally for serialization purposes.
  41558. */
  41559. getClassName(): string;
  41560. }
  41561. }
  41562. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41563. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41564. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41565. import { Nullable } from "babylonjs/types";
  41566. /**
  41567. * Manage the keyboard inputs to control the movement of a follow camera.
  41568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41569. */
  41570. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41571. /**
  41572. * Defines the camera the input is attached to.
  41573. */
  41574. camera: FollowCamera;
  41575. /**
  41576. * Defines the list of key codes associated with the up action (increase heightOffset)
  41577. */
  41578. keysHeightOffsetIncr: number[];
  41579. /**
  41580. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41581. */
  41582. keysHeightOffsetDecr: number[];
  41583. /**
  41584. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41585. */
  41586. keysHeightOffsetModifierAlt: boolean;
  41587. /**
  41588. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41589. */
  41590. keysHeightOffsetModifierCtrl: boolean;
  41591. /**
  41592. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41593. */
  41594. keysHeightOffsetModifierShift: boolean;
  41595. /**
  41596. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41597. */
  41598. keysRotationOffsetIncr: number[];
  41599. /**
  41600. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41601. */
  41602. keysRotationOffsetDecr: number[];
  41603. /**
  41604. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41605. */
  41606. keysRotationOffsetModifierAlt: boolean;
  41607. /**
  41608. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41609. */
  41610. keysRotationOffsetModifierCtrl: boolean;
  41611. /**
  41612. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41613. */
  41614. keysRotationOffsetModifierShift: boolean;
  41615. /**
  41616. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41617. */
  41618. keysRadiusIncr: number[];
  41619. /**
  41620. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41621. */
  41622. keysRadiusDecr: number[];
  41623. /**
  41624. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41625. */
  41626. keysRadiusModifierAlt: boolean;
  41627. /**
  41628. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41629. */
  41630. keysRadiusModifierCtrl: boolean;
  41631. /**
  41632. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41633. */
  41634. keysRadiusModifierShift: boolean;
  41635. /**
  41636. * Defines the rate of change of heightOffset.
  41637. */
  41638. heightSensibility: number;
  41639. /**
  41640. * Defines the rate of change of rotationOffset.
  41641. */
  41642. rotationSensibility: number;
  41643. /**
  41644. * Defines the rate of change of radius.
  41645. */
  41646. radiusSensibility: number;
  41647. private _keys;
  41648. private _ctrlPressed;
  41649. private _altPressed;
  41650. private _shiftPressed;
  41651. private _onCanvasBlurObserver;
  41652. private _onKeyboardObserver;
  41653. private _engine;
  41654. private _scene;
  41655. /**
  41656. * Attach the input controls to a specific dom element to get the input from.
  41657. * @param element Defines the element the controls should be listened from
  41658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41659. */
  41660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41661. /**
  41662. * Detach the current controls from the specified dom element.
  41663. * @param element Defines the element to stop listening the inputs from
  41664. */
  41665. detachControl(element: Nullable<HTMLElement>): void;
  41666. /**
  41667. * Update the current camera state depending on the inputs that have been used this frame.
  41668. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41669. */
  41670. checkInputs(): void;
  41671. /**
  41672. * Gets the class name of the current input.
  41673. * @returns the class name
  41674. */
  41675. getClassName(): string;
  41676. /**
  41677. * Get the friendly name associated with the input class.
  41678. * @returns the input friendly name
  41679. */
  41680. getSimpleName(): string;
  41681. /**
  41682. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41683. * allow modification of the heightOffset value.
  41684. */
  41685. private _modifierHeightOffset;
  41686. /**
  41687. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41688. * allow modification of the rotationOffset value.
  41689. */
  41690. private _modifierRotationOffset;
  41691. /**
  41692. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41693. * allow modification of the radius value.
  41694. */
  41695. private _modifierRadius;
  41696. }
  41697. }
  41698. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41699. import { Nullable } from "babylonjs/types";
  41700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41701. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41702. import { Observable } from "babylonjs/Misc/observable";
  41703. module "babylonjs/Cameras/freeCameraInputsManager" {
  41704. interface FreeCameraInputsManager {
  41705. /**
  41706. * @hidden
  41707. */
  41708. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41709. /**
  41710. * Add orientation input support to the input manager.
  41711. * @returns the current input manager
  41712. */
  41713. addDeviceOrientation(): FreeCameraInputsManager;
  41714. }
  41715. }
  41716. /**
  41717. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41718. * Screen rotation is taken into account.
  41719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41720. */
  41721. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41722. private _camera;
  41723. private _screenOrientationAngle;
  41724. private _constantTranform;
  41725. private _screenQuaternion;
  41726. private _alpha;
  41727. private _beta;
  41728. private _gamma;
  41729. /**
  41730. * Can be used to detect if a device orientation sensor is available on a device
  41731. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41732. * @returns a promise that will resolve on orientation change
  41733. */
  41734. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41735. /**
  41736. * @hidden
  41737. */
  41738. _onDeviceOrientationChangedObservable: Observable<void>;
  41739. /**
  41740. * Instantiates a new input
  41741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41742. */
  41743. constructor();
  41744. /**
  41745. * Define the camera controlled by the input.
  41746. */
  41747. get camera(): FreeCamera;
  41748. set camera(camera: FreeCamera);
  41749. /**
  41750. * Attach the input controls to a specific dom element to get the input from.
  41751. * @param element Defines the element the controls should be listened from
  41752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41753. */
  41754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41755. private _orientationChanged;
  41756. private _deviceOrientation;
  41757. /**
  41758. * Detach the current controls from the specified dom element.
  41759. * @param element Defines the element to stop listening the inputs from
  41760. */
  41761. detachControl(element: Nullable<HTMLElement>): void;
  41762. /**
  41763. * Update the current camera state depending on the inputs that have been used this frame.
  41764. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41765. */
  41766. checkInputs(): void;
  41767. /**
  41768. * Gets the class name of the current intput.
  41769. * @returns the class name
  41770. */
  41771. getClassName(): string;
  41772. /**
  41773. * Get the friendly name associated with the input class.
  41774. * @returns the input friendly name
  41775. */
  41776. getSimpleName(): string;
  41777. }
  41778. }
  41779. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41780. import { Nullable } from "babylonjs/types";
  41781. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41782. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41783. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41784. /**
  41785. * Manage the gamepad inputs to control a free camera.
  41786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41787. */
  41788. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41789. /**
  41790. * Define the camera the input is attached to.
  41791. */
  41792. camera: FreeCamera;
  41793. /**
  41794. * Define the Gamepad controlling the input
  41795. */
  41796. gamepad: Nullable<Gamepad>;
  41797. /**
  41798. * Defines the gamepad rotation sensiblity.
  41799. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41800. */
  41801. gamepadAngularSensibility: number;
  41802. /**
  41803. * Defines the gamepad move sensiblity.
  41804. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41805. */
  41806. gamepadMoveSensibility: number;
  41807. private _yAxisScale;
  41808. /**
  41809. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41810. */
  41811. get invertYAxis(): boolean;
  41812. set invertYAxis(value: boolean);
  41813. private _onGamepadConnectedObserver;
  41814. private _onGamepadDisconnectedObserver;
  41815. private _cameraTransform;
  41816. private _deltaTransform;
  41817. private _vector3;
  41818. private _vector2;
  41819. /**
  41820. * Attach the input controls to a specific dom element to get the input from.
  41821. * @param element Defines the element the controls should be listened from
  41822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41823. */
  41824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41825. /**
  41826. * Detach the current controls from the specified dom element.
  41827. * @param element Defines the element to stop listening the inputs from
  41828. */
  41829. detachControl(element: Nullable<HTMLElement>): void;
  41830. /**
  41831. * Update the current camera state depending on the inputs that have been used this frame.
  41832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41833. */
  41834. checkInputs(): void;
  41835. /**
  41836. * Gets the class name of the current intput.
  41837. * @returns the class name
  41838. */
  41839. getClassName(): string;
  41840. /**
  41841. * Get the friendly name associated with the input class.
  41842. * @returns the input friendly name
  41843. */
  41844. getSimpleName(): string;
  41845. }
  41846. }
  41847. declare module "babylonjs/Misc/virtualJoystick" {
  41848. import { Nullable } from "babylonjs/types";
  41849. import { Vector3 } from "babylonjs/Maths/math.vector";
  41850. /**
  41851. * Defines the potential axis of a Joystick
  41852. */
  41853. export enum JoystickAxis {
  41854. /** X axis */
  41855. X = 0,
  41856. /** Y axis */
  41857. Y = 1,
  41858. /** Z axis */
  41859. Z = 2
  41860. }
  41861. /**
  41862. * Class used to define virtual joystick (used in touch mode)
  41863. */
  41864. export class VirtualJoystick {
  41865. /**
  41866. * Gets or sets a boolean indicating that left and right values must be inverted
  41867. */
  41868. reverseLeftRight: boolean;
  41869. /**
  41870. * Gets or sets a boolean indicating that up and down values must be inverted
  41871. */
  41872. reverseUpDown: boolean;
  41873. /**
  41874. * Gets the offset value for the position (ie. the change of the position value)
  41875. */
  41876. deltaPosition: Vector3;
  41877. /**
  41878. * Gets a boolean indicating if the virtual joystick was pressed
  41879. */
  41880. pressed: boolean;
  41881. /**
  41882. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41883. */
  41884. static Canvas: Nullable<HTMLCanvasElement>;
  41885. private static _globalJoystickIndex;
  41886. private static vjCanvasContext;
  41887. private static vjCanvasWidth;
  41888. private static vjCanvasHeight;
  41889. private static halfWidth;
  41890. private _action;
  41891. private _axisTargetedByLeftAndRight;
  41892. private _axisTargetedByUpAndDown;
  41893. private _joystickSensibility;
  41894. private _inversedSensibility;
  41895. private _joystickPointerID;
  41896. private _joystickColor;
  41897. private _joystickPointerPos;
  41898. private _joystickPreviousPointerPos;
  41899. private _joystickPointerStartPos;
  41900. private _deltaJoystickVector;
  41901. private _leftJoystick;
  41902. private _touches;
  41903. private _onPointerDownHandlerRef;
  41904. private _onPointerMoveHandlerRef;
  41905. private _onPointerUpHandlerRef;
  41906. private _onResize;
  41907. /**
  41908. * Creates a new virtual joystick
  41909. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41910. */
  41911. constructor(leftJoystick?: boolean);
  41912. /**
  41913. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41914. * @param newJoystickSensibility defines the new sensibility
  41915. */
  41916. setJoystickSensibility(newJoystickSensibility: number): void;
  41917. private _onPointerDown;
  41918. private _onPointerMove;
  41919. private _onPointerUp;
  41920. /**
  41921. * Change the color of the virtual joystick
  41922. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41923. */
  41924. setJoystickColor(newColor: string): void;
  41925. /**
  41926. * Defines a callback to call when the joystick is touched
  41927. * @param action defines the callback
  41928. */
  41929. setActionOnTouch(action: () => any): void;
  41930. /**
  41931. * Defines which axis you'd like to control for left & right
  41932. * @param axis defines the axis to use
  41933. */
  41934. setAxisForLeftRight(axis: JoystickAxis): void;
  41935. /**
  41936. * Defines which axis you'd like to control for up & down
  41937. * @param axis defines the axis to use
  41938. */
  41939. setAxisForUpDown(axis: JoystickAxis): void;
  41940. private _drawVirtualJoystick;
  41941. /**
  41942. * Release internal HTML canvas
  41943. */
  41944. releaseCanvas(): void;
  41945. }
  41946. }
  41947. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41948. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41949. import { Nullable } from "babylonjs/types";
  41950. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41952. module "babylonjs/Cameras/freeCameraInputsManager" {
  41953. interface FreeCameraInputsManager {
  41954. /**
  41955. * Add virtual joystick input support to the input manager.
  41956. * @returns the current input manager
  41957. */
  41958. addVirtualJoystick(): FreeCameraInputsManager;
  41959. }
  41960. }
  41961. /**
  41962. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41964. */
  41965. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41966. /**
  41967. * Defines the camera the input is attached to.
  41968. */
  41969. camera: FreeCamera;
  41970. private _leftjoystick;
  41971. private _rightjoystick;
  41972. /**
  41973. * Gets the left stick of the virtual joystick.
  41974. * @returns The virtual Joystick
  41975. */
  41976. getLeftJoystick(): VirtualJoystick;
  41977. /**
  41978. * Gets the right stick of the virtual joystick.
  41979. * @returns The virtual Joystick
  41980. */
  41981. getRightJoystick(): VirtualJoystick;
  41982. /**
  41983. * Update the current camera state depending on the inputs that have been used this frame.
  41984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41985. */
  41986. checkInputs(): void;
  41987. /**
  41988. * Attach the input controls to a specific dom element to get the input from.
  41989. * @param element Defines the element the controls should be listened from
  41990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41991. */
  41992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41993. /**
  41994. * Detach the current controls from the specified dom element.
  41995. * @param element Defines the element to stop listening the inputs from
  41996. */
  41997. detachControl(element: Nullable<HTMLElement>): void;
  41998. /**
  41999. * Gets the class name of the current intput.
  42000. * @returns the class name
  42001. */
  42002. getClassName(): string;
  42003. /**
  42004. * Get the friendly name associated with the input class.
  42005. * @returns the input friendly name
  42006. */
  42007. getSimpleName(): string;
  42008. }
  42009. }
  42010. declare module "babylonjs/Cameras/Inputs/index" {
  42011. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42012. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42013. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42014. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42015. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42016. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42017. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42018. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42019. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42020. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42021. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42022. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42023. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42024. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42025. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42026. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42027. }
  42028. declare module "babylonjs/Cameras/touchCamera" {
  42029. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42030. import { Scene } from "babylonjs/scene";
  42031. import { Vector3 } from "babylonjs/Maths/math.vector";
  42032. /**
  42033. * This represents a FPS type of camera controlled by touch.
  42034. * This is like a universal camera minus the Gamepad controls.
  42035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42036. */
  42037. export class TouchCamera extends FreeCamera {
  42038. /**
  42039. * Defines the touch sensibility for rotation.
  42040. * The higher the faster.
  42041. */
  42042. get touchAngularSensibility(): number;
  42043. set touchAngularSensibility(value: number);
  42044. /**
  42045. * Defines the touch sensibility for move.
  42046. * The higher the faster.
  42047. */
  42048. get touchMoveSensibility(): number;
  42049. set touchMoveSensibility(value: number);
  42050. /**
  42051. * Instantiates a new touch camera.
  42052. * This represents a FPS type of camera controlled by touch.
  42053. * This is like a universal camera minus the Gamepad controls.
  42054. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42055. * @param name Define the name of the camera in the scene
  42056. * @param position Define the start position of the camera in the scene
  42057. * @param scene Define the scene the camera belongs to
  42058. */
  42059. constructor(name: string, position: Vector3, scene: Scene);
  42060. /**
  42061. * Gets the current object class name.
  42062. * @return the class name
  42063. */
  42064. getClassName(): string;
  42065. /** @hidden */
  42066. _setupInputs(): void;
  42067. }
  42068. }
  42069. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42071. import { Scene } from "babylonjs/scene";
  42072. import { Vector3 } from "babylonjs/Maths/math.vector";
  42073. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42074. import { Axis } from "babylonjs/Maths/math.axis";
  42075. /**
  42076. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42077. * being tilted forward or back and left or right.
  42078. */
  42079. export class DeviceOrientationCamera extends FreeCamera {
  42080. private _initialQuaternion;
  42081. private _quaternionCache;
  42082. private _tmpDragQuaternion;
  42083. private _disablePointerInputWhenUsingDeviceOrientation;
  42084. /**
  42085. * Creates a new device orientation camera
  42086. * @param name The name of the camera
  42087. * @param position The start position camera
  42088. * @param scene The scene the camera belongs to
  42089. */
  42090. constructor(name: string, position: Vector3, scene: Scene);
  42091. /**
  42092. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42093. */
  42094. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42095. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42096. private _dragFactor;
  42097. /**
  42098. * Enabled turning on the y axis when the orientation sensor is active
  42099. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42100. */
  42101. enableHorizontalDragging(dragFactor?: number): void;
  42102. /**
  42103. * Gets the current instance class name ("DeviceOrientationCamera").
  42104. * This helps avoiding instanceof at run time.
  42105. * @returns the class name
  42106. */
  42107. getClassName(): string;
  42108. /**
  42109. * @hidden
  42110. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42111. */
  42112. _checkInputs(): void;
  42113. /**
  42114. * Reset the camera to its default orientation on the specified axis only.
  42115. * @param axis The axis to reset
  42116. */
  42117. resetToCurrentRotation(axis?: Axis): void;
  42118. }
  42119. }
  42120. declare module "babylonjs/Gamepads/xboxGamepad" {
  42121. import { Observable } from "babylonjs/Misc/observable";
  42122. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42123. /**
  42124. * Defines supported buttons for XBox360 compatible gamepads
  42125. */
  42126. export enum Xbox360Button {
  42127. /** A */
  42128. A = 0,
  42129. /** B */
  42130. B = 1,
  42131. /** X */
  42132. X = 2,
  42133. /** Y */
  42134. Y = 3,
  42135. /** Start */
  42136. Start = 4,
  42137. /** Back */
  42138. Back = 5,
  42139. /** Left button */
  42140. LB = 6,
  42141. /** Right button */
  42142. RB = 7,
  42143. /** Left stick */
  42144. LeftStick = 8,
  42145. /** Right stick */
  42146. RightStick = 9
  42147. }
  42148. /** Defines values for XBox360 DPad */
  42149. export enum Xbox360Dpad {
  42150. /** Up */
  42151. Up = 0,
  42152. /** Down */
  42153. Down = 1,
  42154. /** Left */
  42155. Left = 2,
  42156. /** Right */
  42157. Right = 3
  42158. }
  42159. /**
  42160. * Defines a XBox360 gamepad
  42161. */
  42162. export class Xbox360Pad extends Gamepad {
  42163. private _leftTrigger;
  42164. private _rightTrigger;
  42165. private _onlefttriggerchanged;
  42166. private _onrighttriggerchanged;
  42167. private _onbuttondown;
  42168. private _onbuttonup;
  42169. private _ondpaddown;
  42170. private _ondpadup;
  42171. /** Observable raised when a button is pressed */
  42172. onButtonDownObservable: Observable<Xbox360Button>;
  42173. /** Observable raised when a button is released */
  42174. onButtonUpObservable: Observable<Xbox360Button>;
  42175. /** Observable raised when a pad is pressed */
  42176. onPadDownObservable: Observable<Xbox360Dpad>;
  42177. /** Observable raised when a pad is released */
  42178. onPadUpObservable: Observable<Xbox360Dpad>;
  42179. private _buttonA;
  42180. private _buttonB;
  42181. private _buttonX;
  42182. private _buttonY;
  42183. private _buttonBack;
  42184. private _buttonStart;
  42185. private _buttonLB;
  42186. private _buttonRB;
  42187. private _buttonLeftStick;
  42188. private _buttonRightStick;
  42189. private _dPadUp;
  42190. private _dPadDown;
  42191. private _dPadLeft;
  42192. private _dPadRight;
  42193. private _isXboxOnePad;
  42194. /**
  42195. * Creates a new XBox360 gamepad object
  42196. * @param id defines the id of this gamepad
  42197. * @param index defines its index
  42198. * @param gamepad defines the internal HTML gamepad object
  42199. * @param xboxOne defines if it is a XBox One gamepad
  42200. */
  42201. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42202. /**
  42203. * Defines the callback to call when left trigger is pressed
  42204. * @param callback defines the callback to use
  42205. */
  42206. onlefttriggerchanged(callback: (value: number) => void): void;
  42207. /**
  42208. * Defines the callback to call when right trigger is pressed
  42209. * @param callback defines the callback to use
  42210. */
  42211. onrighttriggerchanged(callback: (value: number) => void): void;
  42212. /**
  42213. * Gets the left trigger value
  42214. */
  42215. get leftTrigger(): number;
  42216. /**
  42217. * Sets the left trigger value
  42218. */
  42219. set leftTrigger(newValue: number);
  42220. /**
  42221. * Gets the right trigger value
  42222. */
  42223. get rightTrigger(): number;
  42224. /**
  42225. * Sets the right trigger value
  42226. */
  42227. set rightTrigger(newValue: number);
  42228. /**
  42229. * Defines the callback to call when a button is pressed
  42230. * @param callback defines the callback to use
  42231. */
  42232. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42233. /**
  42234. * Defines the callback to call when a button is released
  42235. * @param callback defines the callback to use
  42236. */
  42237. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42238. /**
  42239. * Defines the callback to call when a pad is pressed
  42240. * @param callback defines the callback to use
  42241. */
  42242. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42243. /**
  42244. * Defines the callback to call when a pad is released
  42245. * @param callback defines the callback to use
  42246. */
  42247. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42248. private _setButtonValue;
  42249. private _setDPadValue;
  42250. /**
  42251. * Gets the value of the `A` button
  42252. */
  42253. get buttonA(): number;
  42254. /**
  42255. * Sets the value of the `A` button
  42256. */
  42257. set buttonA(value: number);
  42258. /**
  42259. * Gets the value of the `B` button
  42260. */
  42261. get buttonB(): number;
  42262. /**
  42263. * Sets the value of the `B` button
  42264. */
  42265. set buttonB(value: number);
  42266. /**
  42267. * Gets the value of the `X` button
  42268. */
  42269. get buttonX(): number;
  42270. /**
  42271. * Sets the value of the `X` button
  42272. */
  42273. set buttonX(value: number);
  42274. /**
  42275. * Gets the value of the `Y` button
  42276. */
  42277. get buttonY(): number;
  42278. /**
  42279. * Sets the value of the `Y` button
  42280. */
  42281. set buttonY(value: number);
  42282. /**
  42283. * Gets the value of the `Start` button
  42284. */
  42285. get buttonStart(): number;
  42286. /**
  42287. * Sets the value of the `Start` button
  42288. */
  42289. set buttonStart(value: number);
  42290. /**
  42291. * Gets the value of the `Back` button
  42292. */
  42293. get buttonBack(): number;
  42294. /**
  42295. * Sets the value of the `Back` button
  42296. */
  42297. set buttonBack(value: number);
  42298. /**
  42299. * Gets the value of the `Left` button
  42300. */
  42301. get buttonLB(): number;
  42302. /**
  42303. * Sets the value of the `Left` button
  42304. */
  42305. set buttonLB(value: number);
  42306. /**
  42307. * Gets the value of the `Right` button
  42308. */
  42309. get buttonRB(): number;
  42310. /**
  42311. * Sets the value of the `Right` button
  42312. */
  42313. set buttonRB(value: number);
  42314. /**
  42315. * Gets the value of the Left joystick
  42316. */
  42317. get buttonLeftStick(): number;
  42318. /**
  42319. * Sets the value of the Left joystick
  42320. */
  42321. set buttonLeftStick(value: number);
  42322. /**
  42323. * Gets the value of the Right joystick
  42324. */
  42325. get buttonRightStick(): number;
  42326. /**
  42327. * Sets the value of the Right joystick
  42328. */
  42329. set buttonRightStick(value: number);
  42330. /**
  42331. * Gets the value of D-pad up
  42332. */
  42333. get dPadUp(): number;
  42334. /**
  42335. * Sets the value of D-pad up
  42336. */
  42337. set dPadUp(value: number);
  42338. /**
  42339. * Gets the value of D-pad down
  42340. */
  42341. get dPadDown(): number;
  42342. /**
  42343. * Sets the value of D-pad down
  42344. */
  42345. set dPadDown(value: number);
  42346. /**
  42347. * Gets the value of D-pad left
  42348. */
  42349. get dPadLeft(): number;
  42350. /**
  42351. * Sets the value of D-pad left
  42352. */
  42353. set dPadLeft(value: number);
  42354. /**
  42355. * Gets the value of D-pad right
  42356. */
  42357. get dPadRight(): number;
  42358. /**
  42359. * Sets the value of D-pad right
  42360. */
  42361. set dPadRight(value: number);
  42362. /**
  42363. * Force the gamepad to synchronize with device values
  42364. */
  42365. update(): void;
  42366. /**
  42367. * Disposes the gamepad
  42368. */
  42369. dispose(): void;
  42370. }
  42371. }
  42372. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42373. import { Observable } from "babylonjs/Misc/observable";
  42374. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42375. /**
  42376. * Defines supported buttons for DualShock compatible gamepads
  42377. */
  42378. export enum DualShockButton {
  42379. /** Cross */
  42380. Cross = 0,
  42381. /** Circle */
  42382. Circle = 1,
  42383. /** Square */
  42384. Square = 2,
  42385. /** Triangle */
  42386. Triangle = 3,
  42387. /** Options */
  42388. Options = 4,
  42389. /** Share */
  42390. Share = 5,
  42391. /** L1 */
  42392. L1 = 6,
  42393. /** R1 */
  42394. R1 = 7,
  42395. /** Left stick */
  42396. LeftStick = 8,
  42397. /** Right stick */
  42398. RightStick = 9
  42399. }
  42400. /** Defines values for DualShock DPad */
  42401. export enum DualShockDpad {
  42402. /** Up */
  42403. Up = 0,
  42404. /** Down */
  42405. Down = 1,
  42406. /** Left */
  42407. Left = 2,
  42408. /** Right */
  42409. Right = 3
  42410. }
  42411. /**
  42412. * Defines a DualShock gamepad
  42413. */
  42414. export class DualShockPad extends Gamepad {
  42415. private _leftTrigger;
  42416. private _rightTrigger;
  42417. private _onlefttriggerchanged;
  42418. private _onrighttriggerchanged;
  42419. private _onbuttondown;
  42420. private _onbuttonup;
  42421. private _ondpaddown;
  42422. private _ondpadup;
  42423. /** Observable raised when a button is pressed */
  42424. onButtonDownObservable: Observable<DualShockButton>;
  42425. /** Observable raised when a button is released */
  42426. onButtonUpObservable: Observable<DualShockButton>;
  42427. /** Observable raised when a pad is pressed */
  42428. onPadDownObservable: Observable<DualShockDpad>;
  42429. /** Observable raised when a pad is released */
  42430. onPadUpObservable: Observable<DualShockDpad>;
  42431. private _buttonCross;
  42432. private _buttonCircle;
  42433. private _buttonSquare;
  42434. private _buttonTriangle;
  42435. private _buttonShare;
  42436. private _buttonOptions;
  42437. private _buttonL1;
  42438. private _buttonR1;
  42439. private _buttonLeftStick;
  42440. private _buttonRightStick;
  42441. private _dPadUp;
  42442. private _dPadDown;
  42443. private _dPadLeft;
  42444. private _dPadRight;
  42445. /**
  42446. * Creates a new DualShock gamepad object
  42447. * @param id defines the id of this gamepad
  42448. * @param index defines its index
  42449. * @param gamepad defines the internal HTML gamepad object
  42450. */
  42451. constructor(id: string, index: number, gamepad: any);
  42452. /**
  42453. * Defines the callback to call when left trigger is pressed
  42454. * @param callback defines the callback to use
  42455. */
  42456. onlefttriggerchanged(callback: (value: number) => void): void;
  42457. /**
  42458. * Defines the callback to call when right trigger is pressed
  42459. * @param callback defines the callback to use
  42460. */
  42461. onrighttriggerchanged(callback: (value: number) => void): void;
  42462. /**
  42463. * Gets the left trigger value
  42464. */
  42465. get leftTrigger(): number;
  42466. /**
  42467. * Sets the left trigger value
  42468. */
  42469. set leftTrigger(newValue: number);
  42470. /**
  42471. * Gets the right trigger value
  42472. */
  42473. get rightTrigger(): number;
  42474. /**
  42475. * Sets the right trigger value
  42476. */
  42477. set rightTrigger(newValue: number);
  42478. /**
  42479. * Defines the callback to call when a button is pressed
  42480. * @param callback defines the callback to use
  42481. */
  42482. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42483. /**
  42484. * Defines the callback to call when a button is released
  42485. * @param callback defines the callback to use
  42486. */
  42487. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42488. /**
  42489. * Defines the callback to call when a pad is pressed
  42490. * @param callback defines the callback to use
  42491. */
  42492. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42493. /**
  42494. * Defines the callback to call when a pad is released
  42495. * @param callback defines the callback to use
  42496. */
  42497. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42498. private _setButtonValue;
  42499. private _setDPadValue;
  42500. /**
  42501. * Gets the value of the `Cross` button
  42502. */
  42503. get buttonCross(): number;
  42504. /**
  42505. * Sets the value of the `Cross` button
  42506. */
  42507. set buttonCross(value: number);
  42508. /**
  42509. * Gets the value of the `Circle` button
  42510. */
  42511. get buttonCircle(): number;
  42512. /**
  42513. * Sets the value of the `Circle` button
  42514. */
  42515. set buttonCircle(value: number);
  42516. /**
  42517. * Gets the value of the `Square` button
  42518. */
  42519. get buttonSquare(): number;
  42520. /**
  42521. * Sets the value of the `Square` button
  42522. */
  42523. set buttonSquare(value: number);
  42524. /**
  42525. * Gets the value of the `Triangle` button
  42526. */
  42527. get buttonTriangle(): number;
  42528. /**
  42529. * Sets the value of the `Triangle` button
  42530. */
  42531. set buttonTriangle(value: number);
  42532. /**
  42533. * Gets the value of the `Options` button
  42534. */
  42535. get buttonOptions(): number;
  42536. /**
  42537. * Sets the value of the `Options` button
  42538. */
  42539. set buttonOptions(value: number);
  42540. /**
  42541. * Gets the value of the `Share` button
  42542. */
  42543. get buttonShare(): number;
  42544. /**
  42545. * Sets the value of the `Share` button
  42546. */
  42547. set buttonShare(value: number);
  42548. /**
  42549. * Gets the value of the `L1` button
  42550. */
  42551. get buttonL1(): number;
  42552. /**
  42553. * Sets the value of the `L1` button
  42554. */
  42555. set buttonL1(value: number);
  42556. /**
  42557. * Gets the value of the `R1` button
  42558. */
  42559. get buttonR1(): number;
  42560. /**
  42561. * Sets the value of the `R1` button
  42562. */
  42563. set buttonR1(value: number);
  42564. /**
  42565. * Gets the value of the Left joystick
  42566. */
  42567. get buttonLeftStick(): number;
  42568. /**
  42569. * Sets the value of the Left joystick
  42570. */
  42571. set buttonLeftStick(value: number);
  42572. /**
  42573. * Gets the value of the Right joystick
  42574. */
  42575. get buttonRightStick(): number;
  42576. /**
  42577. * Sets the value of the Right joystick
  42578. */
  42579. set buttonRightStick(value: number);
  42580. /**
  42581. * Gets the value of D-pad up
  42582. */
  42583. get dPadUp(): number;
  42584. /**
  42585. * Sets the value of D-pad up
  42586. */
  42587. set dPadUp(value: number);
  42588. /**
  42589. * Gets the value of D-pad down
  42590. */
  42591. get dPadDown(): number;
  42592. /**
  42593. * Sets the value of D-pad down
  42594. */
  42595. set dPadDown(value: number);
  42596. /**
  42597. * Gets the value of D-pad left
  42598. */
  42599. get dPadLeft(): number;
  42600. /**
  42601. * Sets the value of D-pad left
  42602. */
  42603. set dPadLeft(value: number);
  42604. /**
  42605. * Gets the value of D-pad right
  42606. */
  42607. get dPadRight(): number;
  42608. /**
  42609. * Sets the value of D-pad right
  42610. */
  42611. set dPadRight(value: number);
  42612. /**
  42613. * Force the gamepad to synchronize with device values
  42614. */
  42615. update(): void;
  42616. /**
  42617. * Disposes the gamepad
  42618. */
  42619. dispose(): void;
  42620. }
  42621. }
  42622. declare module "babylonjs/Gamepads/gamepadManager" {
  42623. import { Observable } from "babylonjs/Misc/observable";
  42624. import { Nullable } from "babylonjs/types";
  42625. import { Scene } from "babylonjs/scene";
  42626. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42627. /**
  42628. * Manager for handling gamepads
  42629. */
  42630. export class GamepadManager {
  42631. private _scene?;
  42632. private _babylonGamepads;
  42633. private _oneGamepadConnected;
  42634. /** @hidden */
  42635. _isMonitoring: boolean;
  42636. private _gamepadEventSupported;
  42637. private _gamepadSupport?;
  42638. /**
  42639. * observable to be triggered when the gamepad controller has been connected
  42640. */
  42641. onGamepadConnectedObservable: Observable<Gamepad>;
  42642. /**
  42643. * observable to be triggered when the gamepad controller has been disconnected
  42644. */
  42645. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42646. private _onGamepadConnectedEvent;
  42647. private _onGamepadDisconnectedEvent;
  42648. /**
  42649. * Initializes the gamepad manager
  42650. * @param _scene BabylonJS scene
  42651. */
  42652. constructor(_scene?: Scene | undefined);
  42653. /**
  42654. * The gamepads in the game pad manager
  42655. */
  42656. get gamepads(): Gamepad[];
  42657. /**
  42658. * Get the gamepad controllers based on type
  42659. * @param type The type of gamepad controller
  42660. * @returns Nullable gamepad
  42661. */
  42662. getGamepadByType(type?: number): Nullable<Gamepad>;
  42663. /**
  42664. * Disposes the gamepad manager
  42665. */
  42666. dispose(): void;
  42667. private _addNewGamepad;
  42668. private _startMonitoringGamepads;
  42669. private _stopMonitoringGamepads;
  42670. /** @hidden */
  42671. _checkGamepadsStatus(): void;
  42672. private _updateGamepadObjects;
  42673. }
  42674. }
  42675. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42676. import { Nullable } from "babylonjs/types";
  42677. import { Scene } from "babylonjs/scene";
  42678. import { ISceneComponent } from "babylonjs/sceneComponent";
  42679. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42680. module "babylonjs/scene" {
  42681. interface Scene {
  42682. /** @hidden */
  42683. _gamepadManager: Nullable<GamepadManager>;
  42684. /**
  42685. * Gets the gamepad manager associated with the scene
  42686. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42687. */
  42688. gamepadManager: GamepadManager;
  42689. }
  42690. }
  42691. module "babylonjs/Cameras/freeCameraInputsManager" {
  42692. /**
  42693. * Interface representing a free camera inputs manager
  42694. */
  42695. interface FreeCameraInputsManager {
  42696. /**
  42697. * Adds gamepad input support to the FreeCameraInputsManager.
  42698. * @returns the FreeCameraInputsManager
  42699. */
  42700. addGamepad(): FreeCameraInputsManager;
  42701. }
  42702. }
  42703. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42704. /**
  42705. * Interface representing an arc rotate camera inputs manager
  42706. */
  42707. interface ArcRotateCameraInputsManager {
  42708. /**
  42709. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42710. * @returns the camera inputs manager
  42711. */
  42712. addGamepad(): ArcRotateCameraInputsManager;
  42713. }
  42714. }
  42715. /**
  42716. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42717. */
  42718. export class GamepadSystemSceneComponent implements ISceneComponent {
  42719. /**
  42720. * The component name helpfull to identify the component in the list of scene components.
  42721. */
  42722. readonly name: string;
  42723. /**
  42724. * The scene the component belongs to.
  42725. */
  42726. scene: Scene;
  42727. /**
  42728. * Creates a new instance of the component for the given scene
  42729. * @param scene Defines the scene to register the component in
  42730. */
  42731. constructor(scene: Scene);
  42732. /**
  42733. * Registers the component in a given scene
  42734. */
  42735. register(): void;
  42736. /**
  42737. * Rebuilds the elements related to this component in case of
  42738. * context lost for instance.
  42739. */
  42740. rebuild(): void;
  42741. /**
  42742. * Disposes the component and the associated ressources
  42743. */
  42744. dispose(): void;
  42745. private _beforeCameraUpdate;
  42746. }
  42747. }
  42748. declare module "babylonjs/Cameras/universalCamera" {
  42749. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42750. import { Scene } from "babylonjs/scene";
  42751. import { Vector3 } from "babylonjs/Maths/math.vector";
  42752. import "babylonjs/Gamepads/gamepadSceneComponent";
  42753. /**
  42754. * 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,
  42755. * which still works and will still be found in many Playgrounds.
  42756. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42757. */
  42758. export class UniversalCamera extends TouchCamera {
  42759. /**
  42760. * Defines the gamepad rotation sensiblity.
  42761. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42762. */
  42763. get gamepadAngularSensibility(): number;
  42764. set gamepadAngularSensibility(value: number);
  42765. /**
  42766. * Defines the gamepad move sensiblity.
  42767. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42768. */
  42769. get gamepadMoveSensibility(): number;
  42770. set gamepadMoveSensibility(value: number);
  42771. /**
  42772. * 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,
  42773. * which still works and will still be found in many Playgrounds.
  42774. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42775. * @param name Define the name of the camera in the scene
  42776. * @param position Define the start position of the camera in the scene
  42777. * @param scene Define the scene the camera belongs to
  42778. */
  42779. constructor(name: string, position: Vector3, scene: Scene);
  42780. /**
  42781. * Gets the current object class name.
  42782. * @return the class name
  42783. */
  42784. getClassName(): string;
  42785. }
  42786. }
  42787. declare module "babylonjs/Cameras/gamepadCamera" {
  42788. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42789. import { Scene } from "babylonjs/scene";
  42790. import { Vector3 } from "babylonjs/Maths/math.vector";
  42791. /**
  42792. * This represents a FPS type of camera. This is only here for back compat purpose.
  42793. * Please use the UniversalCamera instead as both are identical.
  42794. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42795. */
  42796. export class GamepadCamera extends UniversalCamera {
  42797. /**
  42798. * Instantiates a new Gamepad Camera
  42799. * This represents a FPS type of camera. This is only here for back compat purpose.
  42800. * Please use the UniversalCamera instead as both are identical.
  42801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42802. * @param name Define the name of the camera in the scene
  42803. * @param position Define the start position of the camera in the scene
  42804. * @param scene Define the scene the camera belongs to
  42805. */
  42806. constructor(name: string, position: Vector3, scene: Scene);
  42807. /**
  42808. * Gets the current object class name.
  42809. * @return the class name
  42810. */
  42811. getClassName(): string;
  42812. }
  42813. }
  42814. declare module "babylonjs/Shaders/pass.fragment" {
  42815. /** @hidden */
  42816. export var passPixelShader: {
  42817. name: string;
  42818. shader: string;
  42819. };
  42820. }
  42821. declare module "babylonjs/Shaders/passCube.fragment" {
  42822. /** @hidden */
  42823. export var passCubePixelShader: {
  42824. name: string;
  42825. shader: string;
  42826. };
  42827. }
  42828. declare module "babylonjs/PostProcesses/passPostProcess" {
  42829. import { Nullable } from "babylonjs/types";
  42830. import { Camera } from "babylonjs/Cameras/camera";
  42831. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42832. import { Engine } from "babylonjs/Engines/engine";
  42833. import "babylonjs/Shaders/pass.fragment";
  42834. import "babylonjs/Shaders/passCube.fragment";
  42835. /**
  42836. * PassPostProcess which produces an output the same as it's input
  42837. */
  42838. export class PassPostProcess extends PostProcess {
  42839. /**
  42840. * Creates the PassPostProcess
  42841. * @param name The name of the effect.
  42842. * @param options The required width/height ratio to downsize to before computing the render pass.
  42843. * @param camera The camera to apply the render pass to.
  42844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42845. * @param engine The engine which the post process will be applied. (default: current engine)
  42846. * @param reusable If the post process can be reused on the same frame. (default: false)
  42847. * @param textureType The type of texture to be used when performing the post processing.
  42848. * @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)
  42849. */
  42850. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42851. }
  42852. /**
  42853. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42854. */
  42855. export class PassCubePostProcess extends PostProcess {
  42856. private _face;
  42857. /**
  42858. * Gets or sets the cube face to display.
  42859. * * 0 is +X
  42860. * * 1 is -X
  42861. * * 2 is +Y
  42862. * * 3 is -Y
  42863. * * 4 is +Z
  42864. * * 5 is -Z
  42865. */
  42866. get face(): number;
  42867. set face(value: number);
  42868. /**
  42869. * Creates the PassCubePostProcess
  42870. * @param name The name of the effect.
  42871. * @param options The required width/height ratio to downsize to before computing the render pass.
  42872. * @param camera The camera to apply the render pass to.
  42873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42874. * @param engine The engine which the post process will be applied. (default: current engine)
  42875. * @param reusable If the post process can be reused on the same frame. (default: false)
  42876. * @param textureType The type of texture to be used when performing the post processing.
  42877. * @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)
  42878. */
  42879. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42880. }
  42881. }
  42882. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42883. /** @hidden */
  42884. export var anaglyphPixelShader: {
  42885. name: string;
  42886. shader: string;
  42887. };
  42888. }
  42889. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42890. import { Engine } from "babylonjs/Engines/engine";
  42891. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42892. import { Camera } from "babylonjs/Cameras/camera";
  42893. import "babylonjs/Shaders/anaglyph.fragment";
  42894. /**
  42895. * Postprocess used to generate anaglyphic rendering
  42896. */
  42897. export class AnaglyphPostProcess extends PostProcess {
  42898. private _passedProcess;
  42899. /**
  42900. * Creates a new AnaglyphPostProcess
  42901. * @param name defines postprocess name
  42902. * @param options defines creation options or target ratio scale
  42903. * @param rigCameras defines cameras using this postprocess
  42904. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42905. * @param engine defines hosting engine
  42906. * @param reusable defines if the postprocess will be reused multiple times per frame
  42907. */
  42908. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42909. }
  42910. }
  42911. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42912. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42913. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42914. import { Scene } from "babylonjs/scene";
  42915. import { Vector3 } from "babylonjs/Maths/math.vector";
  42916. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42917. /**
  42918. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42919. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42920. */
  42921. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42922. /**
  42923. * Creates a new AnaglyphArcRotateCamera
  42924. * @param name defines camera name
  42925. * @param alpha defines alpha angle (in radians)
  42926. * @param beta defines beta angle (in radians)
  42927. * @param radius defines radius
  42928. * @param target defines camera target
  42929. * @param interaxialDistance defines distance between each color axis
  42930. * @param scene defines the hosting scene
  42931. */
  42932. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42933. /**
  42934. * Gets camera class name
  42935. * @returns AnaglyphArcRotateCamera
  42936. */
  42937. getClassName(): string;
  42938. }
  42939. }
  42940. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42941. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42942. import { Scene } from "babylonjs/scene";
  42943. import { Vector3 } from "babylonjs/Maths/math.vector";
  42944. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42945. /**
  42946. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42947. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42948. */
  42949. export class AnaglyphFreeCamera extends FreeCamera {
  42950. /**
  42951. * Creates a new AnaglyphFreeCamera
  42952. * @param name defines camera name
  42953. * @param position defines initial position
  42954. * @param interaxialDistance defines distance between each color axis
  42955. * @param scene defines the hosting scene
  42956. */
  42957. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42958. /**
  42959. * Gets camera class name
  42960. * @returns AnaglyphFreeCamera
  42961. */
  42962. getClassName(): string;
  42963. }
  42964. }
  42965. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42966. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42967. import { Scene } from "babylonjs/scene";
  42968. import { Vector3 } from "babylonjs/Maths/math.vector";
  42969. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42970. /**
  42971. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42972. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42973. */
  42974. export class AnaglyphGamepadCamera extends GamepadCamera {
  42975. /**
  42976. * Creates a new AnaglyphGamepadCamera
  42977. * @param name defines camera name
  42978. * @param position defines initial position
  42979. * @param interaxialDistance defines distance between each color axis
  42980. * @param scene defines the hosting scene
  42981. */
  42982. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42983. /**
  42984. * Gets camera class name
  42985. * @returns AnaglyphGamepadCamera
  42986. */
  42987. getClassName(): string;
  42988. }
  42989. }
  42990. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42991. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42992. import { Scene } from "babylonjs/scene";
  42993. import { Vector3 } from "babylonjs/Maths/math.vector";
  42994. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42995. /**
  42996. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42997. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42998. */
  42999. export class AnaglyphUniversalCamera extends UniversalCamera {
  43000. /**
  43001. * Creates a new AnaglyphUniversalCamera
  43002. * @param name defines camera name
  43003. * @param position defines initial position
  43004. * @param interaxialDistance defines distance between each color axis
  43005. * @param scene defines the hosting scene
  43006. */
  43007. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43008. /**
  43009. * Gets camera class name
  43010. * @returns AnaglyphUniversalCamera
  43011. */
  43012. getClassName(): string;
  43013. }
  43014. }
  43015. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43016. /** @hidden */
  43017. export var stereoscopicInterlacePixelShader: {
  43018. name: string;
  43019. shader: string;
  43020. };
  43021. }
  43022. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43023. import { Camera } from "babylonjs/Cameras/camera";
  43024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43025. import { Engine } from "babylonjs/Engines/engine";
  43026. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43027. /**
  43028. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43029. */
  43030. export class StereoscopicInterlacePostProcess extends PostProcess {
  43031. private _stepSize;
  43032. private _passedProcess;
  43033. /**
  43034. * Initializes a StereoscopicInterlacePostProcess
  43035. * @param name The name of the effect.
  43036. * @param rigCameras The rig cameras to be appled to the post process
  43037. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43039. * @param engine The engine which the post process will be applied. (default: current engine)
  43040. * @param reusable If the post process can be reused on the same frame. (default: false)
  43041. */
  43042. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43043. }
  43044. }
  43045. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43046. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43047. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43048. import { Scene } from "babylonjs/scene";
  43049. import { Vector3 } from "babylonjs/Maths/math.vector";
  43050. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43051. /**
  43052. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43053. * @see http://doc.babylonjs.com/features/cameras
  43054. */
  43055. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43056. /**
  43057. * Creates a new StereoscopicArcRotateCamera
  43058. * @param name defines camera name
  43059. * @param alpha defines alpha angle (in radians)
  43060. * @param beta defines beta angle (in radians)
  43061. * @param radius defines radius
  43062. * @param target defines camera target
  43063. * @param interaxialDistance defines distance between each color axis
  43064. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43065. * @param scene defines the hosting scene
  43066. */
  43067. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43068. /**
  43069. * Gets camera class name
  43070. * @returns StereoscopicArcRotateCamera
  43071. */
  43072. getClassName(): string;
  43073. }
  43074. }
  43075. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43076. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43077. import { Scene } from "babylonjs/scene";
  43078. import { Vector3 } from "babylonjs/Maths/math.vector";
  43079. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43080. /**
  43081. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43082. * @see http://doc.babylonjs.com/features/cameras
  43083. */
  43084. export class StereoscopicFreeCamera extends FreeCamera {
  43085. /**
  43086. * Creates a new StereoscopicFreeCamera
  43087. * @param name defines camera name
  43088. * @param position defines initial position
  43089. * @param interaxialDistance defines distance between each color axis
  43090. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43091. * @param scene defines the hosting scene
  43092. */
  43093. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43094. /**
  43095. * Gets camera class name
  43096. * @returns StereoscopicFreeCamera
  43097. */
  43098. getClassName(): string;
  43099. }
  43100. }
  43101. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43102. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43103. import { Scene } from "babylonjs/scene";
  43104. import { Vector3 } from "babylonjs/Maths/math.vector";
  43105. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43106. /**
  43107. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43108. * @see http://doc.babylonjs.com/features/cameras
  43109. */
  43110. export class StereoscopicGamepadCamera extends GamepadCamera {
  43111. /**
  43112. * Creates a new StereoscopicGamepadCamera
  43113. * @param name defines camera name
  43114. * @param position defines initial position
  43115. * @param interaxialDistance defines distance between each color axis
  43116. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43117. * @param scene defines the hosting scene
  43118. */
  43119. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43120. /**
  43121. * Gets camera class name
  43122. * @returns StereoscopicGamepadCamera
  43123. */
  43124. getClassName(): string;
  43125. }
  43126. }
  43127. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43128. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43129. import { Scene } from "babylonjs/scene";
  43130. import { Vector3 } from "babylonjs/Maths/math.vector";
  43131. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43132. /**
  43133. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43134. * @see http://doc.babylonjs.com/features/cameras
  43135. */
  43136. export class StereoscopicUniversalCamera extends UniversalCamera {
  43137. /**
  43138. * Creates a new StereoscopicUniversalCamera
  43139. * @param name defines camera name
  43140. * @param position defines initial position
  43141. * @param interaxialDistance defines distance between each color axis
  43142. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43143. * @param scene defines the hosting scene
  43144. */
  43145. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43146. /**
  43147. * Gets camera class name
  43148. * @returns StereoscopicUniversalCamera
  43149. */
  43150. getClassName(): string;
  43151. }
  43152. }
  43153. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43154. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43155. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43156. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43157. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43158. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43159. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43160. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43161. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43162. }
  43163. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43165. import { Scene } from "babylonjs/scene";
  43166. import { Vector3 } from "babylonjs/Maths/math.vector";
  43167. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43168. /**
  43169. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43170. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43171. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43172. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43173. */
  43174. export class VirtualJoysticksCamera extends FreeCamera {
  43175. /**
  43176. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43177. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43178. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43179. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43180. * @param name Define the name of the camera in the scene
  43181. * @param position Define the start position of the camera in the scene
  43182. * @param scene Define the scene the camera belongs to
  43183. */
  43184. constructor(name: string, position: Vector3, scene: Scene);
  43185. /**
  43186. * Gets the current object class name.
  43187. * @return the class name
  43188. */
  43189. getClassName(): string;
  43190. }
  43191. }
  43192. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43193. import { Matrix } from "babylonjs/Maths/math.vector";
  43194. /**
  43195. * This represents all the required metrics to create a VR camera.
  43196. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43197. */
  43198. export class VRCameraMetrics {
  43199. /**
  43200. * Define the horizontal resolution off the screen.
  43201. */
  43202. hResolution: number;
  43203. /**
  43204. * Define the vertical resolution off the screen.
  43205. */
  43206. vResolution: number;
  43207. /**
  43208. * Define the horizontal screen size.
  43209. */
  43210. hScreenSize: number;
  43211. /**
  43212. * Define the vertical screen size.
  43213. */
  43214. vScreenSize: number;
  43215. /**
  43216. * Define the vertical screen center position.
  43217. */
  43218. vScreenCenter: number;
  43219. /**
  43220. * Define the distance of the eyes to the screen.
  43221. */
  43222. eyeToScreenDistance: number;
  43223. /**
  43224. * Define the distance between both lenses
  43225. */
  43226. lensSeparationDistance: number;
  43227. /**
  43228. * Define the distance between both viewer's eyes.
  43229. */
  43230. interpupillaryDistance: number;
  43231. /**
  43232. * Define the distortion factor of the VR postprocess.
  43233. * Please, touch with care.
  43234. */
  43235. distortionK: number[];
  43236. /**
  43237. * Define the chromatic aberration correction factors for the VR post process.
  43238. */
  43239. chromaAbCorrection: number[];
  43240. /**
  43241. * Define the scale factor of the post process.
  43242. * The smaller the better but the slower.
  43243. */
  43244. postProcessScaleFactor: number;
  43245. /**
  43246. * Define an offset for the lens center.
  43247. */
  43248. lensCenterOffset: number;
  43249. /**
  43250. * Define if the current vr camera should compensate the distortion of the lense or not.
  43251. */
  43252. compensateDistortion: boolean;
  43253. /**
  43254. * Defines if multiview should be enabled when rendering (Default: false)
  43255. */
  43256. multiviewEnabled: boolean;
  43257. /**
  43258. * Gets the rendering aspect ratio based on the provided resolutions.
  43259. */
  43260. get aspectRatio(): number;
  43261. /**
  43262. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43263. */
  43264. get aspectRatioFov(): number;
  43265. /**
  43266. * @hidden
  43267. */
  43268. get leftHMatrix(): Matrix;
  43269. /**
  43270. * @hidden
  43271. */
  43272. get rightHMatrix(): Matrix;
  43273. /**
  43274. * @hidden
  43275. */
  43276. get leftPreViewMatrix(): Matrix;
  43277. /**
  43278. * @hidden
  43279. */
  43280. get rightPreViewMatrix(): Matrix;
  43281. /**
  43282. * Get the default VRMetrics based on the most generic setup.
  43283. * @returns the default vr metrics
  43284. */
  43285. static GetDefault(): VRCameraMetrics;
  43286. }
  43287. }
  43288. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43289. /** @hidden */
  43290. export var vrDistortionCorrectionPixelShader: {
  43291. name: string;
  43292. shader: string;
  43293. };
  43294. }
  43295. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43296. import { Camera } from "babylonjs/Cameras/camera";
  43297. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43298. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43299. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43300. /**
  43301. * VRDistortionCorrectionPostProcess used for mobile VR
  43302. */
  43303. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43304. private _isRightEye;
  43305. private _distortionFactors;
  43306. private _postProcessScaleFactor;
  43307. private _lensCenterOffset;
  43308. private _scaleIn;
  43309. private _scaleFactor;
  43310. private _lensCenter;
  43311. /**
  43312. * Initializes the VRDistortionCorrectionPostProcess
  43313. * @param name The name of the effect.
  43314. * @param camera The camera to apply the render pass to.
  43315. * @param isRightEye If this is for the right eye distortion
  43316. * @param vrMetrics All the required metrics for the VR camera
  43317. */
  43318. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43319. }
  43320. }
  43321. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43322. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43323. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43324. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43325. import { Scene } from "babylonjs/scene";
  43326. import { Vector3 } from "babylonjs/Maths/math.vector";
  43327. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43328. import "babylonjs/Cameras/RigModes/vrRigMode";
  43329. /**
  43330. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43331. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43332. */
  43333. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43334. /**
  43335. * Creates a new VRDeviceOrientationArcRotateCamera
  43336. * @param name defines camera name
  43337. * @param alpha defines the camera rotation along the logitudinal axis
  43338. * @param beta defines the camera rotation along the latitudinal axis
  43339. * @param radius defines the camera distance from its target
  43340. * @param target defines the camera target
  43341. * @param scene defines the scene the camera belongs to
  43342. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43343. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43344. */
  43345. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43346. /**
  43347. * Gets camera class name
  43348. * @returns VRDeviceOrientationArcRotateCamera
  43349. */
  43350. getClassName(): string;
  43351. }
  43352. }
  43353. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43354. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43355. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { Vector3 } from "babylonjs/Maths/math.vector";
  43358. import "babylonjs/Cameras/RigModes/vrRigMode";
  43359. /**
  43360. * Camera used to simulate VR rendering (based on FreeCamera)
  43361. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43362. */
  43363. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43364. /**
  43365. * Creates a new VRDeviceOrientationFreeCamera
  43366. * @param name defines camera name
  43367. * @param position defines the start position of the camera
  43368. * @param scene defines the scene the camera belongs to
  43369. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43370. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43371. */
  43372. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43373. /**
  43374. * Gets camera class name
  43375. * @returns VRDeviceOrientationFreeCamera
  43376. */
  43377. getClassName(): string;
  43378. }
  43379. }
  43380. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43381. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43382. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43383. import { Scene } from "babylonjs/scene";
  43384. import { Vector3 } from "babylonjs/Maths/math.vector";
  43385. import "babylonjs/Gamepads/gamepadSceneComponent";
  43386. /**
  43387. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43388. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43389. */
  43390. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43391. /**
  43392. * Creates a new VRDeviceOrientationGamepadCamera
  43393. * @param name defines camera name
  43394. * @param position defines the start position of the camera
  43395. * @param scene defines the scene the camera belongs to
  43396. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43397. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43398. */
  43399. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43400. /**
  43401. * Gets camera class name
  43402. * @returns VRDeviceOrientationGamepadCamera
  43403. */
  43404. getClassName(): string;
  43405. }
  43406. }
  43407. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43408. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43409. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43410. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43411. /** @hidden */
  43412. export var imageProcessingPixelShader: {
  43413. name: string;
  43414. shader: string;
  43415. };
  43416. }
  43417. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43418. import { Nullable } from "babylonjs/types";
  43419. import { Color4 } from "babylonjs/Maths/math.color";
  43420. import { Camera } from "babylonjs/Cameras/camera";
  43421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43422. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43423. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43424. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43425. import { Engine } from "babylonjs/Engines/engine";
  43426. import "babylonjs/Shaders/imageProcessing.fragment";
  43427. import "babylonjs/Shaders/postprocess.vertex";
  43428. /**
  43429. * ImageProcessingPostProcess
  43430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43431. */
  43432. export class ImageProcessingPostProcess extends PostProcess {
  43433. /**
  43434. * Default configuration related to image processing available in the PBR Material.
  43435. */
  43436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43437. /**
  43438. * Gets the image processing configuration used either in this material.
  43439. */
  43440. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43441. /**
  43442. * Sets the Default image processing configuration used either in the this material.
  43443. *
  43444. * If sets to null, the scene one is in use.
  43445. */
  43446. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43447. /**
  43448. * Keep track of the image processing observer to allow dispose and replace.
  43449. */
  43450. private _imageProcessingObserver;
  43451. /**
  43452. * Attaches a new image processing configuration to the PBR Material.
  43453. * @param configuration
  43454. */
  43455. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43456. /**
  43457. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43458. */
  43459. get colorCurves(): Nullable<ColorCurves>;
  43460. /**
  43461. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43462. */
  43463. set colorCurves(value: Nullable<ColorCurves>);
  43464. /**
  43465. * Gets wether the color curves effect is enabled.
  43466. */
  43467. get colorCurvesEnabled(): boolean;
  43468. /**
  43469. * Sets wether the color curves effect is enabled.
  43470. */
  43471. set colorCurvesEnabled(value: boolean);
  43472. /**
  43473. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43474. */
  43475. get colorGradingTexture(): Nullable<BaseTexture>;
  43476. /**
  43477. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43478. */
  43479. set colorGradingTexture(value: Nullable<BaseTexture>);
  43480. /**
  43481. * Gets wether the color grading effect is enabled.
  43482. */
  43483. get colorGradingEnabled(): boolean;
  43484. /**
  43485. * Gets wether the color grading effect is enabled.
  43486. */
  43487. set colorGradingEnabled(value: boolean);
  43488. /**
  43489. * Gets exposure used in the effect.
  43490. */
  43491. get exposure(): number;
  43492. /**
  43493. * Sets exposure used in the effect.
  43494. */
  43495. set exposure(value: number);
  43496. /**
  43497. * Gets wether tonemapping is enabled or not.
  43498. */
  43499. get toneMappingEnabled(): boolean;
  43500. /**
  43501. * Sets wether tonemapping is enabled or not
  43502. */
  43503. set toneMappingEnabled(value: boolean);
  43504. /**
  43505. * Gets the type of tone mapping effect.
  43506. */
  43507. get toneMappingType(): number;
  43508. /**
  43509. * Sets the type of tone mapping effect.
  43510. */
  43511. set toneMappingType(value: number);
  43512. /**
  43513. * Gets contrast used in the effect.
  43514. */
  43515. get contrast(): number;
  43516. /**
  43517. * Sets contrast used in the effect.
  43518. */
  43519. set contrast(value: number);
  43520. /**
  43521. * Gets Vignette stretch size.
  43522. */
  43523. get vignetteStretch(): number;
  43524. /**
  43525. * Sets Vignette stretch size.
  43526. */
  43527. set vignetteStretch(value: number);
  43528. /**
  43529. * Gets Vignette centre X Offset.
  43530. */
  43531. get vignetteCentreX(): number;
  43532. /**
  43533. * Sets Vignette centre X Offset.
  43534. */
  43535. set vignetteCentreX(value: number);
  43536. /**
  43537. * Gets Vignette centre Y Offset.
  43538. */
  43539. get vignetteCentreY(): number;
  43540. /**
  43541. * Sets Vignette centre Y Offset.
  43542. */
  43543. set vignetteCentreY(value: number);
  43544. /**
  43545. * Gets Vignette weight or intensity of the vignette effect.
  43546. */
  43547. get vignetteWeight(): number;
  43548. /**
  43549. * Sets Vignette weight or intensity of the vignette effect.
  43550. */
  43551. set vignetteWeight(value: number);
  43552. /**
  43553. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43554. * if vignetteEnabled is set to true.
  43555. */
  43556. get vignetteColor(): Color4;
  43557. /**
  43558. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43559. * if vignetteEnabled is set to true.
  43560. */
  43561. set vignetteColor(value: Color4);
  43562. /**
  43563. * Gets Camera field of view used by the Vignette effect.
  43564. */
  43565. get vignetteCameraFov(): number;
  43566. /**
  43567. * Sets Camera field of view used by the Vignette effect.
  43568. */
  43569. set vignetteCameraFov(value: number);
  43570. /**
  43571. * Gets the vignette blend mode allowing different kind of effect.
  43572. */
  43573. get vignetteBlendMode(): number;
  43574. /**
  43575. * Sets the vignette blend mode allowing different kind of effect.
  43576. */
  43577. set vignetteBlendMode(value: number);
  43578. /**
  43579. * Gets wether the vignette effect is enabled.
  43580. */
  43581. get vignetteEnabled(): boolean;
  43582. /**
  43583. * Sets wether the vignette effect is enabled.
  43584. */
  43585. set vignetteEnabled(value: boolean);
  43586. private _fromLinearSpace;
  43587. /**
  43588. * Gets wether the input of the processing is in Gamma or Linear Space.
  43589. */
  43590. get fromLinearSpace(): boolean;
  43591. /**
  43592. * Sets wether the input of the processing is in Gamma or Linear Space.
  43593. */
  43594. set fromLinearSpace(value: boolean);
  43595. /**
  43596. * Defines cache preventing GC.
  43597. */
  43598. private _defines;
  43599. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43600. /**
  43601. * "ImageProcessingPostProcess"
  43602. * @returns "ImageProcessingPostProcess"
  43603. */
  43604. getClassName(): string;
  43605. protected _updateParameters(): void;
  43606. dispose(camera?: Camera): void;
  43607. }
  43608. }
  43609. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43610. import { Scene } from "babylonjs/scene";
  43611. import { Color3 } from "babylonjs/Maths/math.color";
  43612. import { Mesh } from "babylonjs/Meshes/mesh";
  43613. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43614. import { Nullable } from "babylonjs/types";
  43615. /**
  43616. * Class containing static functions to help procedurally build meshes
  43617. */
  43618. export class GroundBuilder {
  43619. /**
  43620. * Creates a ground mesh
  43621. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43622. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43624. * @param name defines the name of the mesh
  43625. * @param options defines the options used to create the mesh
  43626. * @param scene defines the hosting scene
  43627. * @returns the ground mesh
  43628. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43629. */
  43630. static CreateGround(name: string, options: {
  43631. width?: number;
  43632. height?: number;
  43633. subdivisions?: number;
  43634. subdivisionsX?: number;
  43635. subdivisionsY?: number;
  43636. updatable?: boolean;
  43637. }, scene: any): Mesh;
  43638. /**
  43639. * Creates a tiled ground mesh
  43640. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43641. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43642. * * 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
  43643. * * 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
  43644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43645. * @param name defines the name of the mesh
  43646. * @param options defines the options used to create the mesh
  43647. * @param scene defines the hosting scene
  43648. * @returns the tiled ground mesh
  43649. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43650. */
  43651. static CreateTiledGround(name: string, options: {
  43652. xmin: number;
  43653. zmin: number;
  43654. xmax: number;
  43655. zmax: number;
  43656. subdivisions?: {
  43657. w: number;
  43658. h: number;
  43659. };
  43660. precision?: {
  43661. w: number;
  43662. h: number;
  43663. };
  43664. updatable?: boolean;
  43665. }, scene?: Nullable<Scene>): Mesh;
  43666. /**
  43667. * Creates a ground mesh from a height map
  43668. * * The parameter `url` sets the URL of the height map image resource.
  43669. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43670. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43671. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43672. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43673. * * 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.
  43674. * * 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).
  43675. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43677. * @param name defines the name of the mesh
  43678. * @param url defines the url to the height map
  43679. * @param options defines the options used to create the mesh
  43680. * @param scene defines the hosting scene
  43681. * @returns the ground mesh
  43682. * @see https://doc.babylonjs.com/babylon101/height_map
  43683. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43684. */
  43685. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43686. width?: number;
  43687. height?: number;
  43688. subdivisions?: number;
  43689. minHeight?: number;
  43690. maxHeight?: number;
  43691. colorFilter?: Color3;
  43692. alphaFilter?: number;
  43693. updatable?: boolean;
  43694. onReady?: (mesh: GroundMesh) => void;
  43695. }, scene?: Nullable<Scene>): GroundMesh;
  43696. }
  43697. }
  43698. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43699. import { Vector4 } from "babylonjs/Maths/math.vector";
  43700. import { Mesh } from "babylonjs/Meshes/mesh";
  43701. /**
  43702. * Class containing static functions to help procedurally build meshes
  43703. */
  43704. export class TorusBuilder {
  43705. /**
  43706. * Creates a torus mesh
  43707. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43708. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43709. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43713. * @param name defines the name of the mesh
  43714. * @param options defines the options used to create the mesh
  43715. * @param scene defines the hosting scene
  43716. * @returns the torus mesh
  43717. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43718. */
  43719. static CreateTorus(name: string, options: {
  43720. diameter?: number;
  43721. thickness?: number;
  43722. tessellation?: number;
  43723. updatable?: boolean;
  43724. sideOrientation?: number;
  43725. frontUVs?: Vector4;
  43726. backUVs?: Vector4;
  43727. }, scene: any): Mesh;
  43728. }
  43729. }
  43730. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43731. import { Vector4 } from "babylonjs/Maths/math.vector";
  43732. import { Color4 } from "babylonjs/Maths/math.color";
  43733. import { Mesh } from "babylonjs/Meshes/mesh";
  43734. /**
  43735. * Class containing static functions to help procedurally build meshes
  43736. */
  43737. export class CylinderBuilder {
  43738. /**
  43739. * Creates a cylinder or a cone mesh
  43740. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43741. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43742. * * 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.
  43743. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43744. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43745. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43746. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43747. * * 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).
  43748. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43749. * * 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).
  43750. * * 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
  43751. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43752. * * 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
  43753. * * 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.
  43754. * * If `enclose` is false, a ring surface is one element.
  43755. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43756. * * 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
  43757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43760. * @param name defines the name of the mesh
  43761. * @param options defines the options used to create the mesh
  43762. * @param scene defines the hosting scene
  43763. * @returns the cylinder mesh
  43764. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43765. */
  43766. static CreateCylinder(name: string, options: {
  43767. height?: number;
  43768. diameterTop?: number;
  43769. diameterBottom?: number;
  43770. diameter?: number;
  43771. tessellation?: number;
  43772. subdivisions?: number;
  43773. arc?: number;
  43774. faceColors?: Color4[];
  43775. faceUV?: Vector4[];
  43776. updatable?: boolean;
  43777. hasRings?: boolean;
  43778. enclose?: boolean;
  43779. cap?: number;
  43780. sideOrientation?: number;
  43781. frontUVs?: Vector4;
  43782. backUVs?: Vector4;
  43783. }, scene: any): Mesh;
  43784. }
  43785. }
  43786. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43787. import { Nullable } from "babylonjs/types";
  43788. import { IDisposable } from "babylonjs/scene";
  43789. /**
  43790. * States of the webXR experience
  43791. */
  43792. export enum WebXRState {
  43793. /**
  43794. * Transitioning to being in XR mode
  43795. */
  43796. ENTERING_XR = 0,
  43797. /**
  43798. * Transitioning to non XR mode
  43799. */
  43800. EXITING_XR = 1,
  43801. /**
  43802. * In XR mode and presenting
  43803. */
  43804. IN_XR = 2,
  43805. /**
  43806. * Not entered XR mode
  43807. */
  43808. NOT_IN_XR = 3
  43809. }
  43810. /**
  43811. * Abstraction of the XR render target
  43812. */
  43813. export interface WebXRRenderTarget extends IDisposable {
  43814. /**
  43815. * xrpresent context of the canvas which can be used to display/mirror xr content
  43816. */
  43817. canvasContext: WebGLRenderingContext;
  43818. /**
  43819. * xr layer for the canvas
  43820. */
  43821. xrLayer: Nullable<XRWebGLLayer>;
  43822. /**
  43823. * Initializes the xr layer for the session
  43824. * @param xrSession xr session
  43825. * @returns a promise that will resolve once the XR Layer has been created
  43826. */
  43827. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43828. }
  43829. }
  43830. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43831. import { Nullable } from "babylonjs/types";
  43832. import { Observable } from "babylonjs/Misc/observable";
  43833. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43834. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43835. /**
  43836. * COnfiguration object for WebXR output canvas
  43837. */
  43838. export class WebXRManagedOutputCanvasOptions {
  43839. /**
  43840. * Options for this XR Layer output
  43841. */
  43842. canvasOptions: XRWebGLLayerOptions;
  43843. /**
  43844. * CSS styling for a newly created canvas (if not provided)
  43845. */
  43846. newCanvasCssStyle?: string;
  43847. /**
  43848. * Get the default values of the configuration object
  43849. * @returns default values of this configuration object
  43850. */
  43851. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43852. }
  43853. /**
  43854. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43855. */
  43856. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43857. private configuration;
  43858. private _engine;
  43859. private _canvas;
  43860. /**
  43861. * xrpresent context of the canvas which can be used to display/mirror xr content
  43862. */
  43863. canvasContext: WebGLRenderingContext;
  43864. /**
  43865. * xr layer for the canvas
  43866. */
  43867. xrLayer: Nullable<XRWebGLLayer>;
  43868. /**
  43869. * Initializes the xr layer for the session
  43870. * @param xrSession xr session
  43871. * @returns a promise that will resolve once the XR Layer has been created
  43872. */
  43873. initializeXRLayerAsync(xrSession: any): any;
  43874. /**
  43875. * Initializes the canvas to be added/removed upon entering/exiting xr
  43876. * @param engine the Babylon engine
  43877. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43878. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43879. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43880. */
  43881. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43882. /**
  43883. * Disposes of the object
  43884. */
  43885. dispose(): void;
  43886. private _setManagedOutputCanvas;
  43887. private _addCanvas;
  43888. private _removeCanvas;
  43889. }
  43890. }
  43891. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43892. import { Observable } from "babylonjs/Misc/observable";
  43893. import { Nullable } from "babylonjs/types";
  43894. import { IDisposable, Scene } from "babylonjs/scene";
  43895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43896. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43897. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43898. /**
  43899. * Manages an XRSession to work with Babylon's engine
  43900. * @see https://doc.babylonjs.com/how_to/webxr
  43901. */
  43902. export class WebXRSessionManager implements IDisposable {
  43903. /** The scene which the session should be created for */
  43904. scene: Scene;
  43905. /**
  43906. * Fires every time a new xrFrame arrives which can be used to update the camera
  43907. */
  43908. onXRFrameObservable: Observable<XRFrame>;
  43909. /**
  43910. * Fires when the xr session is ended either by the device or manually done
  43911. */
  43912. onXRSessionEnded: Observable<any>;
  43913. /**
  43914. * Fires when the xr session is ended either by the device or manually done
  43915. */
  43916. onXRSessionInit: Observable<XRSession>;
  43917. /**
  43918. * Fires when the reference space changed
  43919. */
  43920. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43921. /**
  43922. * Underlying xr session
  43923. */
  43924. session: XRSession;
  43925. /**
  43926. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43927. * or get the offset the player is currently at.
  43928. */
  43929. viewerReferenceSpace: XRReferenceSpace;
  43930. private _referenceSpace;
  43931. /**
  43932. * The current reference space used in this session. This reference space can constantly change!
  43933. * It is mainly used to offset the camera's position.
  43934. */
  43935. get referenceSpace(): XRReferenceSpace;
  43936. /**
  43937. * Set a new reference space and triggers the observable
  43938. */
  43939. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43940. /**
  43941. * The base reference space from which the session started. good if you want to reset your
  43942. * reference space
  43943. */
  43944. baseReferenceSpace: XRReferenceSpace;
  43945. /**
  43946. * Used just in case of a failure to initialize an immersive session.
  43947. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43948. */
  43949. defaultHeightCompensation: number;
  43950. /**
  43951. * Current XR frame
  43952. */
  43953. currentFrame: Nullable<XRFrame>;
  43954. /** WebXR timestamp updated every frame */
  43955. currentTimestamp: number;
  43956. private _xrNavigator;
  43957. private baseLayer;
  43958. private _rttProvider;
  43959. private _sessionEnded;
  43960. /**
  43961. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43962. * @param scene The scene which the session should be created for
  43963. */
  43964. constructor(
  43965. /** The scene which the session should be created for */
  43966. scene: Scene);
  43967. /**
  43968. * Initializes the manager
  43969. * After initialization enterXR can be called to start an XR session
  43970. * @returns Promise which resolves after it is initialized
  43971. */
  43972. initializeAsync(): Promise<void>;
  43973. /**
  43974. * Initializes an xr session
  43975. * @param xrSessionMode mode to initialize
  43976. * @param optionalFeatures defines optional values to pass to the session builder
  43977. * @returns a promise which will resolve once the session has been initialized
  43978. */
  43979. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43980. /**
  43981. * Sets the reference space on the xr session
  43982. * @param referenceSpace space to set
  43983. * @returns a promise that will resolve once the reference space has been set
  43984. */
  43985. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43986. /**
  43987. * Updates the render state of the session
  43988. * @param state state to set
  43989. * @returns a promise that resolves once the render state has been updated
  43990. */
  43991. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43992. /**
  43993. * Starts rendering to the xr layer
  43994. * @returns a promise that will resolve once rendering has started
  43995. */
  43996. startRenderingToXRAsync(): Promise<void>;
  43997. /**
  43998. * Gets the correct render target texture to be rendered this frame for this eye
  43999. * @param eye the eye for which to get the render target
  44000. * @returns the render target for the specified eye
  44001. */
  44002. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44003. /**
  44004. * Stops the xrSession and restores the renderloop
  44005. * @returns Promise which resolves after it exits XR
  44006. */
  44007. exitXRAsync(): Promise<void>;
  44008. /**
  44009. * Checks if a session would be supported for the creation options specified
  44010. * @param sessionMode session mode to check if supported eg. immersive-vr
  44011. * @returns true if supported
  44012. */
  44013. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44014. /**
  44015. * Creates a WebXRRenderTarget object for the XR session
  44016. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44017. * @param options optional options to provide when creating a new render target
  44018. * @returns a WebXR render target to which the session can render
  44019. */
  44020. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44021. /**
  44022. * @hidden
  44023. * Converts the render layer of xrSession to a render target
  44024. * @param session session to create render target for
  44025. * @param scene scene the new render target should be created for
  44026. * @param baseLayer the webgl layer to create the render target for
  44027. */
  44028. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44029. /**
  44030. * Disposes of the session manager
  44031. */
  44032. dispose(): void;
  44033. /**
  44034. * Gets a promise returning true when fullfiled if the given session mode is supported
  44035. * @param sessionMode defines the session to test
  44036. * @returns a promise
  44037. */
  44038. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44039. }
  44040. }
  44041. declare module "babylonjs/Cameras/XR/webXRCamera" {
  44042. import { Scene } from "babylonjs/scene";
  44043. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44044. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44045. /**
  44046. * WebXR Camera which holds the views for the xrSession
  44047. * @see https://doc.babylonjs.com/how_to/webxr
  44048. */
  44049. export class WebXRCamera extends FreeCamera {
  44050. private _xrSessionManager;
  44051. /**
  44052. * Is the camera in debug mode. Used when using an emulator
  44053. */
  44054. debugMode: boolean;
  44055. private _firstFrame;
  44056. private _referencedPosition;
  44057. private _referenceQuaternion;
  44058. private _xrInvPositionCache;
  44059. private _xrInvQuaternionCache;
  44060. /**
  44061. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44062. * @param name the name of the camera
  44063. * @param scene the scene to add the camera to
  44064. */
  44065. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44066. private _updateNumberOfRigCameras;
  44067. /** @hidden */
  44068. _updateForDualEyeDebugging(): void;
  44069. private _updateReferenceSpace;
  44070. private _updateReferenceSpaceOffset;
  44071. private _updateFromXRSession;
  44072. }
  44073. }
  44074. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  44075. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44076. import { IDisposable } from "babylonjs/scene";
  44077. /**
  44078. * Defining the interface required for a (webxr) feature
  44079. */
  44080. export interface IWebXRFeature extends IDisposable {
  44081. /**
  44082. * Is this feature attached
  44083. */
  44084. attached: boolean;
  44085. /**
  44086. * Attach the feature to the session
  44087. * Will usually be called by the features manager
  44088. *
  44089. * @returns true if successful.
  44090. */
  44091. attach(): boolean;
  44092. /**
  44093. * Detach the feature from the session
  44094. * Will usually be called by the features manager
  44095. *
  44096. * @returns true if successful.
  44097. */
  44098. detach(): boolean;
  44099. }
  44100. /**
  44101. * Defining the constructor of a feature. Used to register the modules.
  44102. */
  44103. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44104. /**
  44105. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44106. * It is mainly used in AR sessions.
  44107. *
  44108. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44109. */
  44110. export class WebXRFeaturesManager implements IDisposable {
  44111. private _xrSessionManager;
  44112. private static readonly _AvailableFeatures;
  44113. /**
  44114. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44115. * Mainly used internally.
  44116. *
  44117. * @param featureName the name of the feature to register
  44118. * @param constructorFunction the function used to construct the module
  44119. * @param version the (babylon) version of the module
  44120. * @param stable is that a stable version of this module
  44121. */
  44122. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44123. /**
  44124. * Returns a constructor of a specific feature.
  44125. *
  44126. * @param featureName the name of the feature to construct
  44127. * @param version the version of the feature to load
  44128. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44129. * @param options optional options provided to the module.
  44130. * @returns a function that, when called, will return a new instance of this feature
  44131. */
  44132. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44133. /**
  44134. * Return the latest unstable version of this feature
  44135. * @param featureName the name of the feature to search
  44136. * @returns the version number. if not found will return -1
  44137. */
  44138. static GetLatestVersionOfFeature(featureName: string): number;
  44139. /**
  44140. * Return the latest stable version of this feature
  44141. * @param featureName the name of the feature to search
  44142. * @returns the version number. if not found will return -1
  44143. */
  44144. static GetStableVersionOfFeature(featureName: string): number;
  44145. /**
  44146. * Can be used to return the list of features currently registered
  44147. *
  44148. * @returns an Array of available features
  44149. */
  44150. static GetAvailableFeatures(): string[];
  44151. /**
  44152. * Gets the versions available for a specific feature
  44153. * @param featureName the name of the feature
  44154. * @returns an array with the available versions
  44155. */
  44156. static GetAvailableVersions(featureName: string): string[];
  44157. private _features;
  44158. /**
  44159. * constructs a new features manages.
  44160. *
  44161. * @param _xrSessionManager an instance of WebXRSessionManager
  44162. */
  44163. constructor(_xrSessionManager: WebXRSessionManager);
  44164. /**
  44165. * 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.
  44166. *
  44167. * @param featureName the name of the feature to load or the class of the feature
  44168. * @param version optional version to load. if not provided the latest version will be enabled
  44169. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44170. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44171. * @returns a new constructed feature or throws an error if feature not found.
  44172. */
  44173. enableFeature(featureName: string | {
  44174. Name: string;
  44175. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44176. /**
  44177. * Used to disable an already-enabled feature
  44178. * @param featureName the feature to disable
  44179. * @returns true if disable was successful
  44180. */
  44181. disableFeature(featureName: string | {
  44182. Name: string;
  44183. }): boolean;
  44184. /**
  44185. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44186. * Can be used during a session to start a feature
  44187. * @param featureName the name of feature to attach
  44188. */
  44189. attachFeature(featureName: string): void;
  44190. /**
  44191. * Can be used inside a session or when the session ends to detach a specific feature
  44192. * @param featureName the name of the feature to detach
  44193. */
  44194. detachFeature(featureName: string): void;
  44195. /**
  44196. * Get the list of enabled features
  44197. * @returns an array of enabled features
  44198. */
  44199. getEnabledFeatures(): string[];
  44200. /**
  44201. * get the implementation of an enabled feature.
  44202. * @param featureName the name of the feature to load
  44203. * @returns the feature class, if found
  44204. */
  44205. getEnabledFeature(featureName: string): IWebXRFeature;
  44206. /**
  44207. * dispose this features manager
  44208. */
  44209. dispose(): void;
  44210. }
  44211. }
  44212. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44213. import { Observable } from "babylonjs/Misc/observable";
  44214. import { IDisposable, Scene } from "babylonjs/scene";
  44215. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44216. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44217. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44218. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44219. /**
  44220. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44221. * @see https://doc.babylonjs.com/how_to/webxr
  44222. */
  44223. export class WebXRExperienceHelper implements IDisposable {
  44224. private scene;
  44225. /**
  44226. * Camera used to render xr content
  44227. */
  44228. camera: WebXRCamera;
  44229. /**
  44230. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44231. */
  44232. state: WebXRState;
  44233. private _setState;
  44234. /**
  44235. * Fires when the state of the experience helper has changed
  44236. */
  44237. onStateChangedObservable: Observable<WebXRState>;
  44238. /**
  44239. * Observers registered here will be triggered after the camera's initial transformation is set
  44240. * This can be used to set a different ground level or an extra rotation.
  44241. *
  44242. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44243. * to the position set after this observable is done executing.
  44244. */
  44245. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44246. /** Session manager used to keep track of xr session */
  44247. sessionManager: WebXRSessionManager;
  44248. /** A features manager for this xr session */
  44249. featuresManager: WebXRFeaturesManager;
  44250. private _nonVRCamera;
  44251. private _originalSceneAutoClear;
  44252. private _supported;
  44253. /**
  44254. * Creates the experience helper
  44255. * @param scene the scene to attach the experience helper to
  44256. * @returns a promise for the experience helper
  44257. */
  44258. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44259. /**
  44260. * Creates a WebXRExperienceHelper
  44261. * @param scene The scene the helper should be created in
  44262. */
  44263. private constructor();
  44264. /**
  44265. * Exits XR mode and returns the scene to its original state
  44266. * @returns promise that resolves after xr mode has exited
  44267. */
  44268. exitXRAsync(): Promise<void>;
  44269. /**
  44270. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44271. * @param sessionMode options for the XR session
  44272. * @param referenceSpaceType frame of reference of the XR session
  44273. * @param renderTarget the output canvas that will be used to enter XR mode
  44274. * @returns promise that resolves after xr mode has entered
  44275. */
  44276. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44277. /**
  44278. * Disposes of the experience helper
  44279. */
  44280. dispose(): void;
  44281. private _nonXRToXRCamera;
  44282. }
  44283. }
  44284. declare module "babylonjs/Cameras/XR/motionController/webXRControllerComponent" {
  44285. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  44286. import { Observable } from "babylonjs/Misc/observable";
  44287. import { IDisposable } from "babylonjs/scene";
  44288. /**
  44289. * X-Y values for axes in WebXR
  44290. */
  44291. export interface IWebXRMotionControllerAxesValue {
  44292. /**
  44293. * The value of the x axis
  44294. */
  44295. x: number;
  44296. /**
  44297. * The value of the y-axis
  44298. */
  44299. y: number;
  44300. }
  44301. /**
  44302. * changed / previous values for the values of this component
  44303. */
  44304. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44305. /**
  44306. * current (this frame) value
  44307. */
  44308. current: T;
  44309. /**
  44310. * previous (last change) value
  44311. */
  44312. previous: T;
  44313. }
  44314. /**
  44315. * Represents changes in the component between current frame and last values recorded
  44316. */
  44317. export interface IWebXRMotionControllerComponentChanges {
  44318. /**
  44319. * will be populated with previous and current values if touched changed
  44320. */
  44321. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44322. /**
  44323. * will be populated with previous and current values if pressed changed
  44324. */
  44325. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44326. /**
  44327. * will be populated with previous and current values if value changed
  44328. */
  44329. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44330. /**
  44331. * will be populated with previous and current values if axes changed
  44332. */
  44333. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44334. }
  44335. /**
  44336. * This class represents a single component (for example button or thumbstick) of a motion controller
  44337. */
  44338. export class WebXRControllerComponent implements IDisposable {
  44339. /**
  44340. * the id of this component
  44341. */
  44342. id: string;
  44343. /**
  44344. * the type of the component
  44345. */
  44346. type: MotionControllerComponentType;
  44347. private _buttonIndex;
  44348. private _axesIndices;
  44349. /**
  44350. * Thumbstick component type
  44351. */
  44352. static THUMBSTICK: string;
  44353. /**
  44354. * Touchpad component type
  44355. */
  44356. static TOUCHPAD: string;
  44357. /**
  44358. * trigger component type
  44359. */
  44360. static TRIGGER: string;
  44361. /**
  44362. * squeeze component type
  44363. */
  44364. static SQUEEZE: string;
  44365. /**
  44366. * Observers registered here will be triggered when the state of a button changes
  44367. * State change is either pressed / touched / value
  44368. */
  44369. onButtonStateChanged: Observable<WebXRControllerComponent>;
  44370. /**
  44371. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44372. * the axes data changes
  44373. */
  44374. onAxisValueChanged: Observable<{
  44375. x: number;
  44376. y: number;
  44377. }>;
  44378. private _currentValue;
  44379. private _touched;
  44380. private _pressed;
  44381. private _axes;
  44382. private _changes;
  44383. /**
  44384. * Creates a new component for a motion controller.
  44385. * It is created by the motion controller itself
  44386. *
  44387. * @param id the id of this component
  44388. * @param type the type of the component
  44389. * @param _buttonIndex index in the buttons array of the gamepad
  44390. * @param _axesIndices indices of the values in the axes array of the gamepad
  44391. */
  44392. constructor(
  44393. /**
  44394. * the id of this component
  44395. */
  44396. id: string,
  44397. /**
  44398. * the type of the component
  44399. */
  44400. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44401. /**
  44402. * Get the current value of this component
  44403. */
  44404. get value(): number;
  44405. /**
  44406. * is the button currently pressed
  44407. */
  44408. get pressed(): boolean;
  44409. /**
  44410. * is the button currently touched
  44411. */
  44412. get touched(): boolean;
  44413. /**
  44414. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44415. */
  44416. get axes(): IWebXRMotionControllerAxesValue;
  44417. /**
  44418. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44419. */
  44420. get changes(): IWebXRMotionControllerComponentChanges;
  44421. /**
  44422. * Is this component a button (hence - pressable)
  44423. * @returns true if can be pressed
  44424. */
  44425. isButton(): boolean;
  44426. /**
  44427. * Are there axes correlating to this component
  44428. * @return true is axes data is available
  44429. */
  44430. isAxes(): boolean;
  44431. /**
  44432. * update this component using the gamepad object it is in. Called on every frame
  44433. * @param nativeController the native gamepad controller object
  44434. */
  44435. update(nativeController: IMinimalMotionControllerObject): void;
  44436. /**
  44437. * Dispose this component
  44438. */
  44439. dispose(): void;
  44440. }
  44441. }
  44442. declare module "babylonjs/Loading/sceneLoader" {
  44443. import { Observable } from "babylonjs/Misc/observable";
  44444. import { Nullable } from "babylonjs/types";
  44445. import { Scene } from "babylonjs/scene";
  44446. import { Engine } from "babylonjs/Engines/engine";
  44447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44448. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44449. import { AssetContainer } from "babylonjs/assetContainer";
  44450. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44451. import { Skeleton } from "babylonjs/Bones/skeleton";
  44452. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44453. import { WebRequest } from "babylonjs/Misc/webRequest";
  44454. /**
  44455. * Class used to represent data loading progression
  44456. */
  44457. export class SceneLoaderProgressEvent {
  44458. /** defines if data length to load can be evaluated */
  44459. readonly lengthComputable: boolean;
  44460. /** defines the loaded data length */
  44461. readonly loaded: number;
  44462. /** defines the data length to load */
  44463. readonly total: number;
  44464. /**
  44465. * Create a new progress event
  44466. * @param lengthComputable defines if data length to load can be evaluated
  44467. * @param loaded defines the loaded data length
  44468. * @param total defines the data length to load
  44469. */
  44470. constructor(
  44471. /** defines if data length to load can be evaluated */
  44472. lengthComputable: boolean,
  44473. /** defines the loaded data length */
  44474. loaded: number,
  44475. /** defines the data length to load */
  44476. total: number);
  44477. /**
  44478. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44479. * @param event defines the source event
  44480. * @returns a new SceneLoaderProgressEvent
  44481. */
  44482. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44483. }
  44484. /**
  44485. * Interface used by SceneLoader plugins to define supported file extensions
  44486. */
  44487. export interface ISceneLoaderPluginExtensions {
  44488. /**
  44489. * Defines the list of supported extensions
  44490. */
  44491. [extension: string]: {
  44492. isBinary: boolean;
  44493. };
  44494. }
  44495. /**
  44496. * Interface used by SceneLoader plugin factory
  44497. */
  44498. export interface ISceneLoaderPluginFactory {
  44499. /**
  44500. * Defines the name of the factory
  44501. */
  44502. name: string;
  44503. /**
  44504. * Function called to create a new plugin
  44505. * @return the new plugin
  44506. */
  44507. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44508. /**
  44509. * The callback that returns true if the data can be directly loaded.
  44510. * @param data string containing the file data
  44511. * @returns if the data can be loaded directly
  44512. */
  44513. canDirectLoad?(data: string): boolean;
  44514. }
  44515. /**
  44516. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44517. */
  44518. export interface ISceneLoaderPluginBase {
  44519. /**
  44520. * The friendly name of this plugin.
  44521. */
  44522. name: string;
  44523. /**
  44524. * The file extensions supported by this plugin.
  44525. */
  44526. extensions: string | ISceneLoaderPluginExtensions;
  44527. /**
  44528. * The callback called when loading from a url.
  44529. * @param scene scene loading this url
  44530. * @param url url to load
  44531. * @param onSuccess callback called when the file successfully loads
  44532. * @param onProgress callback called while file is loading (if the server supports this mode)
  44533. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44534. * @param onError callback called when the file fails to load
  44535. * @returns a file request object
  44536. */
  44537. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44538. /**
  44539. * The callback called when loading from a file object.
  44540. * @param scene scene loading this file
  44541. * @param file defines the file to load
  44542. * @param onSuccess defines the callback to call when data is loaded
  44543. * @param onProgress defines the callback to call during loading process
  44544. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44545. * @param onError defines the callback to call when an error occurs
  44546. * @returns a file request object
  44547. */
  44548. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44549. /**
  44550. * The callback that returns true if the data can be directly loaded.
  44551. * @param data string containing the file data
  44552. * @returns if the data can be loaded directly
  44553. */
  44554. canDirectLoad?(data: string): boolean;
  44555. /**
  44556. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44557. * @param scene scene loading this data
  44558. * @param data string containing the data
  44559. * @returns data to pass to the plugin
  44560. */
  44561. directLoad?(scene: Scene, data: string): any;
  44562. /**
  44563. * The callback that allows custom handling of the root url based on the response url.
  44564. * @param rootUrl the original root url
  44565. * @param responseURL the response url if available
  44566. * @returns the new root url
  44567. */
  44568. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44569. }
  44570. /**
  44571. * Interface used to define a SceneLoader plugin
  44572. */
  44573. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44574. /**
  44575. * Import meshes into a scene.
  44576. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44577. * @param scene The scene to import into
  44578. * @param data The data to import
  44579. * @param rootUrl The root url for scene and resources
  44580. * @param meshes The meshes array to import into
  44581. * @param particleSystems The particle systems array to import into
  44582. * @param skeletons The skeletons array to import into
  44583. * @param onError The callback when import fails
  44584. * @returns True if successful or false otherwise
  44585. */
  44586. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44587. /**
  44588. * Load into a scene.
  44589. * @param scene The scene to load into
  44590. * @param data The data to import
  44591. * @param rootUrl The root url for scene and resources
  44592. * @param onError The callback when import fails
  44593. * @returns True if successful or false otherwise
  44594. */
  44595. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44596. /**
  44597. * Load into an asset container.
  44598. * @param scene The scene to load into
  44599. * @param data The data to import
  44600. * @param rootUrl The root url for scene and resources
  44601. * @param onError The callback when import fails
  44602. * @returns The loaded asset container
  44603. */
  44604. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44605. }
  44606. /**
  44607. * Interface used to define an async SceneLoader plugin
  44608. */
  44609. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44610. /**
  44611. * Import meshes into a scene.
  44612. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44613. * @param scene The scene to import into
  44614. * @param data The data to import
  44615. * @param rootUrl The root url for scene and resources
  44616. * @param onProgress The callback when the load progresses
  44617. * @param fileName Defines the name of the file to load
  44618. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44619. */
  44620. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44621. meshes: AbstractMesh[];
  44622. particleSystems: IParticleSystem[];
  44623. skeletons: Skeleton[];
  44624. animationGroups: AnimationGroup[];
  44625. }>;
  44626. /**
  44627. * Load into a scene.
  44628. * @param scene The scene to load into
  44629. * @param data The data to import
  44630. * @param rootUrl The root url for scene and resources
  44631. * @param onProgress The callback when the load progresses
  44632. * @param fileName Defines the name of the file to load
  44633. * @returns Nothing
  44634. */
  44635. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44636. /**
  44637. * Load into an asset container.
  44638. * @param scene The scene to load into
  44639. * @param data The data to import
  44640. * @param rootUrl The root url for scene and resources
  44641. * @param onProgress The callback when the load progresses
  44642. * @param fileName Defines the name of the file to load
  44643. * @returns The loaded asset container
  44644. */
  44645. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44646. }
  44647. /**
  44648. * Mode that determines how to handle old animation groups before loading new ones.
  44649. */
  44650. export enum SceneLoaderAnimationGroupLoadingMode {
  44651. /**
  44652. * Reset all old animations to initial state then dispose them.
  44653. */
  44654. Clean = 0,
  44655. /**
  44656. * Stop all old animations.
  44657. */
  44658. Stop = 1,
  44659. /**
  44660. * Restart old animations from first frame.
  44661. */
  44662. Sync = 2,
  44663. /**
  44664. * Old animations remains untouched.
  44665. */
  44666. NoSync = 3
  44667. }
  44668. /**
  44669. * Class used to load scene from various file formats using registered plugins
  44670. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44671. */
  44672. export class SceneLoader {
  44673. /**
  44674. * No logging while loading
  44675. */
  44676. static readonly NO_LOGGING: number;
  44677. /**
  44678. * Minimal logging while loading
  44679. */
  44680. static readonly MINIMAL_LOGGING: number;
  44681. /**
  44682. * Summary logging while loading
  44683. */
  44684. static readonly SUMMARY_LOGGING: number;
  44685. /**
  44686. * Detailled logging while loading
  44687. */
  44688. static readonly DETAILED_LOGGING: number;
  44689. /**
  44690. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44691. */
  44692. static get ForceFullSceneLoadingForIncremental(): boolean;
  44693. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44694. /**
  44695. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44696. */
  44697. static get ShowLoadingScreen(): boolean;
  44698. static set ShowLoadingScreen(value: boolean);
  44699. /**
  44700. * Defines the current logging level (while loading the scene)
  44701. * @ignorenaming
  44702. */
  44703. static get loggingLevel(): number;
  44704. static set loggingLevel(value: number);
  44705. /**
  44706. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44707. */
  44708. static get CleanBoneMatrixWeights(): boolean;
  44709. static set CleanBoneMatrixWeights(value: boolean);
  44710. /**
  44711. * Event raised when a plugin is used to load a scene
  44712. */
  44713. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44714. private static _registeredPlugins;
  44715. private static _getDefaultPlugin;
  44716. private static _getPluginForExtension;
  44717. private static _getPluginForDirectLoad;
  44718. private static _getPluginForFilename;
  44719. private static _getDirectLoad;
  44720. private static _loadData;
  44721. private static _getFileInfo;
  44722. /**
  44723. * Gets a plugin that can load the given extension
  44724. * @param extension defines the extension to load
  44725. * @returns a plugin or null if none works
  44726. */
  44727. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44728. /**
  44729. * Gets a boolean indicating that the given extension can be loaded
  44730. * @param extension defines the extension to load
  44731. * @returns true if the extension is supported
  44732. */
  44733. static IsPluginForExtensionAvailable(extension: string): boolean;
  44734. /**
  44735. * Adds a new plugin to the list of registered plugins
  44736. * @param plugin defines the plugin to add
  44737. */
  44738. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44739. /**
  44740. * Import meshes into a scene
  44741. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44742. * @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)
  44743. * @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)
  44744. * @param scene the instance of BABYLON.Scene to append to
  44745. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44746. * @param onProgress a callback with a progress event for each file being loaded
  44747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44748. * @param pluginExtension the extension used to determine the plugin
  44749. * @returns The loaded plugin
  44750. */
  44751. 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>;
  44752. /**
  44753. * Import meshes into a scene
  44754. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44755. * @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)
  44756. * @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)
  44757. * @param scene the instance of BABYLON.Scene to append to
  44758. * @param onProgress a callback with a progress event for each file being loaded
  44759. * @param pluginExtension the extension used to determine the plugin
  44760. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44761. */
  44762. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44763. meshes: AbstractMesh[];
  44764. particleSystems: IParticleSystem[];
  44765. skeletons: Skeleton[];
  44766. animationGroups: AnimationGroup[];
  44767. }>;
  44768. /**
  44769. * Load a scene
  44770. * @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)
  44771. * @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)
  44772. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44773. * @param onSuccess a callback with the scene when import succeeds
  44774. * @param onProgress a callback with a progress event for each file being loaded
  44775. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44776. * @param pluginExtension the extension used to determine the plugin
  44777. * @returns The loaded plugin
  44778. */
  44779. 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>;
  44780. /**
  44781. * Load a scene
  44782. * @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)
  44783. * @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)
  44784. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44785. * @param onProgress a callback with a progress event for each file being loaded
  44786. * @param pluginExtension the extension used to determine the plugin
  44787. * @returns The loaded scene
  44788. */
  44789. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44790. /**
  44791. * Append a scene
  44792. * @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)
  44793. * @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)
  44794. * @param scene is the instance of BABYLON.Scene to append to
  44795. * @param onSuccess a callback with the scene when import succeeds
  44796. * @param onProgress a callback with a progress event for each file being loaded
  44797. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44798. * @param pluginExtension the extension used to determine the plugin
  44799. * @returns The loaded plugin
  44800. */
  44801. 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>;
  44802. /**
  44803. * Append a scene
  44804. * @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)
  44805. * @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)
  44806. * @param scene is the instance of BABYLON.Scene to append to
  44807. * @param onProgress a callback with a progress event for each file being loaded
  44808. * @param pluginExtension the extension used to determine the plugin
  44809. * @returns The given scene
  44810. */
  44811. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44812. /**
  44813. * Load a scene into an asset container
  44814. * @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)
  44815. * @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)
  44816. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44817. * @param onSuccess a callback with the scene when import succeeds
  44818. * @param onProgress a callback with a progress event for each file being loaded
  44819. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44820. * @param pluginExtension the extension used to determine the plugin
  44821. * @returns The loaded plugin
  44822. */
  44823. 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>;
  44824. /**
  44825. * Load a scene into an asset container
  44826. * @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)
  44827. * @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)
  44828. * @param scene is the instance of Scene to append to
  44829. * @param onProgress a callback with a progress event for each file being loaded
  44830. * @param pluginExtension the extension used to determine the plugin
  44831. * @returns The loaded asset container
  44832. */
  44833. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44834. /**
  44835. * Import animations from a file into a scene
  44836. * @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)
  44837. * @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)
  44838. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44839. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44840. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44841. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44842. * @param onSuccess a callback with the scene when import succeeds
  44843. * @param onProgress a callback with a progress event for each file being loaded
  44844. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44845. */
  44846. 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;
  44847. /**
  44848. * Import animations from a file into a scene
  44849. * @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)
  44850. * @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)
  44851. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44852. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44853. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44854. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44855. * @param onSuccess a callback with the scene when import succeeds
  44856. * @param onProgress a callback with a progress event for each file being loaded
  44857. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44858. * @returns the updated scene with imported animations
  44859. */
  44860. 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>;
  44861. }
  44862. }
  44863. declare module "babylonjs/Cameras/XR/motionController/webXRAbstractController" {
  44864. import { IDisposable, Scene } from "babylonjs/scene";
  44865. import { WebXRControllerComponent } from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  44866. import { Observable } from "babylonjs/Misc/observable";
  44867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44868. import { Nullable } from "babylonjs/types";
  44869. /**
  44870. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44871. */
  44872. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  44873. /**
  44874. * The type of components available in motion controllers.
  44875. * This is not the name of the component.
  44876. */
  44877. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44878. /**
  44879. * The schema of motion controller layout.
  44880. * No object will be initialized using this interface
  44881. * This is used just to define the profile.
  44882. */
  44883. export interface IMotionControllerLayout {
  44884. /**
  44885. * Defines the main button component id
  44886. */
  44887. selectComponentId: string;
  44888. /**
  44889. * Available components (unsorted)
  44890. */
  44891. components: {
  44892. /**
  44893. * A map of component Ids
  44894. */
  44895. [componentId: string]: {
  44896. /**
  44897. * The type of input the component outputs
  44898. */
  44899. type: MotionControllerComponentType;
  44900. };
  44901. };
  44902. /**
  44903. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  44904. */
  44905. gamepad?: {
  44906. /**
  44907. * Is the mapping based on the xr-standard defined here:
  44908. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  44909. */
  44910. mapping: "" | "xr-standard";
  44911. /**
  44912. * The buttons available in this input in the right order
  44913. * index of this button will be the index in the gamepadObject.buttons array
  44914. * correlates to the componentId in components
  44915. */
  44916. buttons: Array<string | null>;
  44917. /**
  44918. * Definition of the axes of the gamepad input, sorted
  44919. * Correlates to componentIds in the components map
  44920. */
  44921. axes: Array<{
  44922. /**
  44923. * The component id that the axis correlates to
  44924. */
  44925. componentId: string;
  44926. /**
  44927. * X or Y Axis
  44928. */
  44929. axis: "x-axis" | "y-axis";
  44930. } | null>;
  44931. };
  44932. }
  44933. /**
  44934. * A definition for the layout map in the input profile
  44935. */
  44936. export interface IMotionControllerLayoutMap {
  44937. /**
  44938. * Layouts with handness type as a key
  44939. */
  44940. [handness: string]: IMotionControllerLayout;
  44941. }
  44942. /**
  44943. * The XR Input profile schema
  44944. * Profiles can be found here:
  44945. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44946. */
  44947. export interface IMotionControllerProfile {
  44948. /**
  44949. * The id of this profile
  44950. * correlates to the profile(s) in the xrInput.profiles array
  44951. */
  44952. profileId: string;
  44953. /**
  44954. * fallback profiles for this profileId
  44955. */
  44956. fallbackProfileIds: string[];
  44957. /**
  44958. * The layout map, with handness as key
  44959. */
  44960. layouts: IMotionControllerLayoutMap;
  44961. }
  44962. /**
  44963. * A helper-interface for the 3 meshes needed for controller button animation
  44964. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44965. */
  44966. export interface IMotionControllerButtonMeshMap {
  44967. /**
  44968. * The mesh that will be changed when value changes
  44969. */
  44970. valueMesh: AbstractMesh;
  44971. /**
  44972. * the mesh that defines the pressed value mesh position.
  44973. * This is used to find the max-position of this button
  44974. */
  44975. pressedMesh: AbstractMesh;
  44976. /**
  44977. * the mesh that defines the unpressed value mesh position.
  44978. * This is used to find the min (or initial) position of this button
  44979. */
  44980. unpressedMesh: AbstractMesh;
  44981. }
  44982. /**
  44983. * A helper-interface for the 3 meshes needed for controller axis animation.
  44984. * This will be expanded when touchpad animations are fully supported
  44985. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44986. */
  44987. export interface IMotionControllerAxisMeshMap {
  44988. /**
  44989. * The mesh that will be changed when axis value changes
  44990. */
  44991. valueMesh: AbstractMesh;
  44992. /**
  44993. * the mesh that defines the minimum value mesh position.
  44994. */
  44995. minMesh: AbstractMesh;
  44996. /**
  44997. * the mesh that defines the maximum value mesh position.
  44998. */
  44999. maxMesh: AbstractMesh;
  45000. }
  45001. /**
  45002. * The elements needed for change-detection of the gamepad objects in motion controllers
  45003. */
  45004. export interface IMinimalMotionControllerObject {
  45005. /**
  45006. * An array of available buttons
  45007. */
  45008. buttons: Array<{
  45009. /**
  45010. * Value of the button/trigger
  45011. */
  45012. value: number;
  45013. /**
  45014. * If the button/trigger is currently touched
  45015. */
  45016. touched: boolean;
  45017. /**
  45018. * If the button/trigger is currently pressed
  45019. */
  45020. pressed: boolean;
  45021. }>;
  45022. /**
  45023. * Available axes of this controller
  45024. */
  45025. axes: number[];
  45026. }
  45027. /**
  45028. * An Abstract Motion controller
  45029. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45030. * Each component has an observable to check for changes in value and state
  45031. */
  45032. export abstract class WebXRAbstractMotionController implements IDisposable {
  45033. protected scene: Scene;
  45034. protected layout: IMotionControllerLayout;
  45035. /**
  45036. * The gamepad object correlating to this controller
  45037. */
  45038. gamepadObject: IMinimalMotionControllerObject;
  45039. /**
  45040. * handness (left/right/none) of this controller
  45041. */
  45042. handness: MotionControllerHandness;
  45043. /**
  45044. * Component type map
  45045. */
  45046. static ComponentType: {
  45047. TRIGGER: string;
  45048. SQUEEZE: string;
  45049. TOUCHPAD: string;
  45050. THUMBSTICK: string;
  45051. BUTTON: string;
  45052. };
  45053. /**
  45054. * The profile id of this motion controller
  45055. */
  45056. abstract profileId: string;
  45057. /**
  45058. * A map of components (WebXRControllerComponent) in this motion controller
  45059. * Components have a ComponentType and can also have both button and axis definitions
  45060. */
  45061. readonly components: {
  45062. [id: string]: WebXRControllerComponent;
  45063. };
  45064. /**
  45065. * Observers registered here will be triggered when the model of this controller is done loading
  45066. */
  45067. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45068. /**
  45069. * The root mesh of the model. It is null if the model was not yet initialized
  45070. */
  45071. rootMesh: Nullable<AbstractMesh>;
  45072. private _modelReady;
  45073. /**
  45074. * constructs a new abstract motion controller
  45075. * @param scene the scene to which the model of the controller will be added
  45076. * @param layout The profile layout to load
  45077. * @param gamepadObject The gamepad object correlating to this controller
  45078. * @param handness handness (left/right/none) of this controller
  45079. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45080. */
  45081. constructor(scene: Scene, layout: IMotionControllerLayout,
  45082. /**
  45083. * The gamepad object correlating to this controller
  45084. */
  45085. gamepadObject: IMinimalMotionControllerObject,
  45086. /**
  45087. * handness (left/right/none) of this controller
  45088. */
  45089. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45090. private _initComponent;
  45091. /**
  45092. * Update this model using the current XRFrame
  45093. * @param xrFrame the current xr frame to use and update the model
  45094. */
  45095. updateFromXRFrame(xrFrame: XRFrame): void;
  45096. /**
  45097. * Get the list of components available in this motion controller
  45098. * @returns an array of strings correlating to available components
  45099. */
  45100. getComponentTypes(): string[];
  45101. /**
  45102. * Get the main (Select) component of this controller as defined in the layout
  45103. * @returns the main component of this controller
  45104. */
  45105. getMainComponent(): WebXRControllerComponent;
  45106. /**
  45107. * get a component based an its component id as defined in layout.components
  45108. * @param id the id of the component
  45109. * @returns the component correlates to the id or undefined if not found
  45110. */
  45111. getComponent(id: string): WebXRControllerComponent;
  45112. /**
  45113. * Loads the model correlating to this controller
  45114. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45115. * @returns A promise fulfilled with the result of the model loading
  45116. */
  45117. loadModel(): Promise<boolean>;
  45118. /**
  45119. * Update the model itself with the current frame data
  45120. * @param xrFrame the frame to use for updating the model mesh
  45121. */
  45122. protected updateModel(xrFrame: XRFrame): void;
  45123. /**
  45124. * Moves the axis on the controller mesh based on its current state
  45125. * @param axis the index of the axis
  45126. * @param axisValue the value of the axis which determines the meshes new position
  45127. * @hidden
  45128. */
  45129. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  45130. /**
  45131. * Moves the buttons on the controller mesh based on their current state
  45132. * @param buttonName the name of the button to move
  45133. * @param buttonValue the value of the button which determines the buttons new position
  45134. */
  45135. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  45136. private _getGenericFilenameAndPath;
  45137. private _getGenericParentMesh;
  45138. /**
  45139. * Get the filename and path for this controller's model
  45140. * @returns a map of filename and path
  45141. */
  45142. protected abstract _getFilenameAndPath(): {
  45143. filename: string;
  45144. path: string;
  45145. };
  45146. /**
  45147. * This function will be called after the model was successfully loaded and can be used
  45148. * for mesh transformations before it is available for the user
  45149. * @param meshes the loaded meshes
  45150. */
  45151. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45152. /**
  45153. * Set the root mesh for this controller. Important for the WebXR controller class
  45154. * @param meshes the loaded meshes
  45155. */
  45156. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45157. /**
  45158. * A function executed each frame that updates the mesh (if needed)
  45159. * @param xrFrame the current xrFrame
  45160. */
  45161. protected abstract _updateModel(xrFrame: XRFrame): void;
  45162. /**
  45163. * This function is called before the mesh is loaded. It checks for loading constraints.
  45164. * For example, this function can check if the GLB loader is available
  45165. * If this function returns false, the generic controller will be loaded instead
  45166. * @returns Is the client ready to load the mesh
  45167. */
  45168. protected abstract _getModelLoadingConstraints(): boolean;
  45169. /**
  45170. * Dispose this controller, the model mesh and all its components
  45171. */
  45172. dispose(): void;
  45173. }
  45174. }
  45175. declare module "babylonjs/Cameras/XR/motionController/webXRGenericMotionController" {
  45176. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45178. import { Scene } from "babylonjs/scene";
  45179. /**
  45180. * A generic trigger-only motion controller for WebXR
  45181. */
  45182. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45183. /**
  45184. * Static version of the profile id of this controller
  45185. */
  45186. static ProfileId: string;
  45187. profileId: string;
  45188. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45189. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45190. protected _updateModel(): void;
  45191. protected _getFilenameAndPath(): {
  45192. filename: string;
  45193. path: string;
  45194. };
  45195. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45196. protected _getModelLoadingConstraints(): boolean;
  45197. }
  45198. }
  45199. declare module "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager" {
  45200. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45201. import { Scene } from "babylonjs/scene";
  45202. /**
  45203. * A construction function type to create a new controller based on an xrInput object
  45204. */
  45205. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45206. /**
  45207. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45208. *
  45209. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45210. * it should be replaced with auto-loaded controllers.
  45211. *
  45212. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45213. */
  45214. export class WebXRMotionControllerManager {
  45215. private static _AvailableControllers;
  45216. private static _Fallbacks;
  45217. /**
  45218. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45219. *
  45220. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45221. *
  45222. * @param type the profile type to register
  45223. * @param constructFunction the function to be called when loading this profile
  45224. */
  45225. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45226. /**
  45227. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45228. * The order of search:
  45229. *
  45230. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45231. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45232. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45233. * 4) return the generic trigger controller if none were found
  45234. *
  45235. * @param xrInput the xrInput to which a new controller is initialized
  45236. * @param scene the scene to which the model will be added
  45237. * @param forceProfile force a certain profile for this controller
  45238. * @return the motion controller class for this profile id or the generic standard class if none was found
  45239. */
  45240. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  45241. /**
  45242. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45243. * @param profileId the profile to which a fallback needs to be found
  45244. * @return an array with corresponding fallback profiles
  45245. */
  45246. static FindFallbackWithProfileId(profileId: string): string[];
  45247. /**
  45248. * Register a fallback to a specific profile.
  45249. * @param profileId the profileId that will receive the fallbacks
  45250. * @param fallbacks A list of fallback profiles
  45251. */
  45252. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45253. /**
  45254. * Register the default fallbacks.
  45255. * This function is called automatically when this file is imported.
  45256. */
  45257. static DefaultFallbacks(): void;
  45258. }
  45259. }
  45260. declare module "babylonjs/Cameras/XR/webXRController" {
  45261. import { Observable } from "babylonjs/Misc/observable";
  45262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45263. import { Ray } from "babylonjs/Culling/ray";
  45264. import { Scene } from "babylonjs/scene";
  45265. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45266. /**
  45267. * Represents an XR controller
  45268. */
  45269. export class WebXRController {
  45270. private scene;
  45271. /** The underlying input source for the controller */
  45272. inputSource: XRInputSource;
  45273. /**
  45274. * 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
  45275. */
  45276. grip?: AbstractMesh;
  45277. /**
  45278. * Pointer which can be used to select objects or attach a visible laser to
  45279. */
  45280. pointer: AbstractMesh;
  45281. /**
  45282. * If available, this is the gamepad object related to this controller.
  45283. * Using this object it is possible to get click events and trackpad changes of the
  45284. * webxr controller that is currently being used.
  45285. */
  45286. gamepadController?: WebXRAbstractMotionController;
  45287. /**
  45288. * Event that fires when the controller is removed/disposed
  45289. */
  45290. onDisposeObservable: Observable<{}>;
  45291. private _tmpQuaternion;
  45292. private _tmpVector;
  45293. private _uniqueId;
  45294. /**
  45295. * Creates the controller
  45296. * @see https://doc.babylonjs.com/how_to/webxr
  45297. * @param scene the scene which the controller should be associated to
  45298. * @param inputSource the underlying input source for the controller
  45299. * @param controllerProfile An optional controller profile for this input. This will override the xrInput profile.
  45300. */
  45301. constructor(scene: Scene,
  45302. /** The underlying input source for the controller */
  45303. inputSource: XRInputSource, controllerProfile?: string);
  45304. /**
  45305. * Get this controllers unique id
  45306. */
  45307. get uniqueId(): string;
  45308. /**
  45309. * Updates the controller pose based on the given XRFrame
  45310. * @param xrFrame xr frame to update the pose with
  45311. * @param referenceSpace reference space to use
  45312. */
  45313. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45314. /**
  45315. * Gets a world space ray coming from the controller
  45316. * @param result the resulting ray
  45317. */
  45318. getWorldPointerRayToRef(result: Ray): void;
  45319. /**
  45320. * Get the scene associated with this controller
  45321. * @returns the scene object
  45322. */
  45323. getScene(): Scene;
  45324. /**
  45325. * Disposes of the object
  45326. */
  45327. dispose(): void;
  45328. }
  45329. }
  45330. declare module "babylonjs/Cameras/XR/webXRInput" {
  45331. import { Observable } from "babylonjs/Misc/observable";
  45332. import { IDisposable } from "babylonjs/scene";
  45333. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45334. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45335. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  45336. /**
  45337. * The schema for initialization options of the XR Input class
  45338. */
  45339. export interface IWebXRInputOptions {
  45340. /**
  45341. * If set to true no model will be automatically loaded
  45342. */
  45343. doNotLoadControllerMeshes?: boolean;
  45344. /**
  45345. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45346. * If not found, the xr input profile data will be used.
  45347. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45348. */
  45349. forceInputProfile?: string;
  45350. }
  45351. /**
  45352. * XR input used to track XR inputs such as controllers/rays
  45353. */
  45354. export class WebXRInput implements IDisposable {
  45355. /**
  45356. * the xr session manager for this session
  45357. */
  45358. xrSessionManager: WebXRSessionManager;
  45359. /**
  45360. * the WebXR camera for this session. Mainly used for teleportation
  45361. */
  45362. xrCamera: WebXRCamera;
  45363. private readonly options;
  45364. /**
  45365. * XR controllers being tracked
  45366. */
  45367. controllers: Array<WebXRController>;
  45368. private _frameObserver;
  45369. private _sessionEndedObserver;
  45370. private _sessionInitObserver;
  45371. /**
  45372. * Event when a controller has been connected/added
  45373. */
  45374. onControllerAddedObservable: Observable<WebXRController>;
  45375. /**
  45376. * Event when a controller has been removed/disconnected
  45377. */
  45378. onControllerRemovedObservable: Observable<WebXRController>;
  45379. /**
  45380. * Initializes the WebXRInput
  45381. * @param xrSessionManager the xr session manager for this session
  45382. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45383. * @param options = initialization options for this xr input
  45384. */
  45385. constructor(
  45386. /**
  45387. * the xr session manager for this session
  45388. */
  45389. xrSessionManager: WebXRSessionManager,
  45390. /**
  45391. * the WebXR camera for this session. Mainly used for teleportation
  45392. */
  45393. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45394. private _onInputSourcesChange;
  45395. private _addAndRemoveControllers;
  45396. /**
  45397. * Disposes of the object
  45398. */
  45399. dispose(): void;
  45400. }
  45401. }
  45402. declare module "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection" {
  45403. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45404. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45405. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45406. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45407. import { Nullable } from "babylonjs/types";
  45408. import { Color3 } from "babylonjs/Maths/math.color";
  45409. /**
  45410. * Options interface for the pointer selection module
  45411. */
  45412. export interface IWebXRControllerPointerSelectionOptions {
  45413. /**
  45414. * the xr input to use with this pointer selection
  45415. */
  45416. xrInput: WebXRInput;
  45417. /**
  45418. * Different button type to use instead of the main component
  45419. */
  45420. overrideButtonId?: string;
  45421. /**
  45422. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  45423. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45424. * 3000 means 3 seconds between pointing at something and selecting it
  45425. */
  45426. timeToSelect?: number;
  45427. /**
  45428. * 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)
  45429. * If not disabled, the last picked point will be used to execute a pointer up event
  45430. * If disabled, pointer up event will be triggered right after the pointer down event.
  45431. * Used in screen and gaze target ray mode only
  45432. */
  45433. disablePointerUpOnTouchOut: boolean;
  45434. /**
  45435. * For gaze mode (time to select instead of press)
  45436. */
  45437. forceGazeMode: boolean;
  45438. /**
  45439. * 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
  45440. * to start a new countdown to the pointer down event.
  45441. * Defaults to 1.
  45442. */
  45443. gazeModePointerMovedFactor?: number;
  45444. }
  45445. /**
  45446. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45447. */
  45448. export class WebXRControllerPointerSelection implements IWebXRFeature {
  45449. private _xrSessionManager;
  45450. private readonly _options;
  45451. /**
  45452. * The module's name
  45453. */
  45454. static readonly Name: string;
  45455. /**
  45456. * The (Babylon) version of this module.
  45457. * This is an integer representing the implementation version.
  45458. * This number does not correspond to the webxr specs version
  45459. */
  45460. static readonly Version: number;
  45461. /**
  45462. * This color will be set to the laser pointer when selection is triggered
  45463. */
  45464. laserPointerPickedColor: Color3;
  45465. /**
  45466. * This color will be applied to the selection ring when selection is triggered
  45467. */
  45468. selectionMeshPickedColor: Color3;
  45469. /**
  45470. * default color of the selection ring
  45471. */
  45472. selectionMeshDefaultColor: Color3;
  45473. /**
  45474. * Default color of the laser pointer
  45475. */
  45476. lasterPointerDefaultColor: Color3;
  45477. private static _idCounter;
  45478. private _observerTracked;
  45479. private _attached;
  45480. private _tmpRay;
  45481. private _controllers;
  45482. /**
  45483. * Is this feature attached
  45484. */
  45485. get attached(): boolean;
  45486. private _scene;
  45487. /**
  45488. * constructs a new background remover module
  45489. * @param _xrSessionManager the session manager for this module
  45490. * @param _options read-only options to be used in this module
  45491. */
  45492. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45493. /**
  45494. * attach this feature
  45495. * Will usually be called by the features manager
  45496. *
  45497. * @returns true if successful.
  45498. */
  45499. attach(): boolean;
  45500. /**
  45501. * detach this feature.
  45502. * Will usually be called by the features manager
  45503. *
  45504. * @returns true if successful.
  45505. */
  45506. detach(): boolean;
  45507. /**
  45508. * Get the xr controller that correlates to the pointer id in the pointer event
  45509. *
  45510. * @param id the pointer id to search for
  45511. * @returns the controller that correlates to this id or null if not found
  45512. */
  45513. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  45514. private _attachController;
  45515. private _attachScreenRayMode;
  45516. private _attachGazeMode;
  45517. private _tmpVectorForPickCompare;
  45518. private _pickingMoved;
  45519. private _attachTrackedPointerRayMode;
  45520. private _detachController;
  45521. private _generateNewMeshPair;
  45522. private _convertNormalToDirectionOfRay;
  45523. private _updatePointerDistance;
  45524. /**
  45525. * Dispose this feature and all of the resources attached
  45526. */
  45527. dispose(): void;
  45528. }
  45529. }
  45530. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45531. import { Nullable } from "babylonjs/types";
  45532. import { Observable } from "babylonjs/Misc/observable";
  45533. import { IDisposable, Scene } from "babylonjs/scene";
  45534. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45535. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45536. /**
  45537. * Button which can be used to enter a different mode of XR
  45538. */
  45539. export class WebXREnterExitUIButton {
  45540. /** button element */
  45541. element: HTMLElement;
  45542. /** XR initialization options for the button */
  45543. sessionMode: XRSessionMode;
  45544. /** Reference space type */
  45545. referenceSpaceType: XRReferenceSpaceType;
  45546. /**
  45547. * Creates a WebXREnterExitUIButton
  45548. * @param element button element
  45549. * @param sessionMode XR initialization session mode
  45550. * @param referenceSpaceType the type of reference space to be used
  45551. */
  45552. constructor(
  45553. /** button element */
  45554. element: HTMLElement,
  45555. /** XR initialization options for the button */
  45556. sessionMode: XRSessionMode,
  45557. /** Reference space type */
  45558. referenceSpaceType: XRReferenceSpaceType);
  45559. /**
  45560. * Overwritable function which can be used to update the button's visuals when the state changes
  45561. * @param activeButton the current active button in the UI
  45562. */
  45563. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45564. }
  45565. /**
  45566. * Options to create the webXR UI
  45567. */
  45568. export class WebXREnterExitUIOptions {
  45569. /**
  45570. * Context to enter xr with
  45571. */
  45572. renderTarget?: Nullable<WebXRRenderTarget>;
  45573. /**
  45574. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45575. */
  45576. customButtons?: Array<WebXREnterExitUIButton>;
  45577. /**
  45578. * A session mode to use when creating the default button.
  45579. * Default is immersive-vr
  45580. */
  45581. sessionMode?: XRSessionMode;
  45582. /**
  45583. * A reference space type to use when creating the default button.
  45584. * Default is local-floor
  45585. */
  45586. referenceSpaceType?: XRReferenceSpaceType;
  45587. }
  45588. /**
  45589. * UI to allow the user to enter/exit XR mode
  45590. */
  45591. export class WebXREnterExitUI implements IDisposable {
  45592. private scene;
  45593. /** version of the options passed to this UI */
  45594. options: WebXREnterExitUIOptions;
  45595. private _overlay;
  45596. private _buttons;
  45597. private _activeButton;
  45598. /**
  45599. * Fired every time the active button is changed.
  45600. *
  45601. * When xr is entered via a button that launches xr that button will be the callback parameter
  45602. *
  45603. * When exiting xr the callback parameter will be null)
  45604. */
  45605. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45606. /**
  45607. * Creates UI to allow the user to enter/exit XR mode
  45608. * @param scene the scene to add the ui to
  45609. * @param helper the xr experience helper to enter/exit xr with
  45610. * @param options options to configure the UI
  45611. * @returns the created ui
  45612. */
  45613. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45614. /**
  45615. *
  45616. * @param scene babylon scene object to use
  45617. * @param options (read-only) version of the options passed to this UI
  45618. */
  45619. private constructor();
  45620. private _updateButtons;
  45621. /**
  45622. * Disposes of the object
  45623. */
  45624. dispose(): void;
  45625. }
  45626. }
  45627. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45628. import { Vector3 } from "babylonjs/Maths/math.vector";
  45629. import { Color4 } from "babylonjs/Maths/math.color";
  45630. import { Nullable } from "babylonjs/types";
  45631. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45632. import { Scene } from "babylonjs/scene";
  45633. /**
  45634. * Class containing static functions to help procedurally build meshes
  45635. */
  45636. export class LinesBuilder {
  45637. /**
  45638. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45639. * * 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
  45640. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45641. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45642. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45643. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45644. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45645. * * 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
  45646. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45649. * @param name defines the name of the new line system
  45650. * @param options defines the options used to create the line system
  45651. * @param scene defines the hosting scene
  45652. * @returns a new line system mesh
  45653. */
  45654. static CreateLineSystem(name: string, options: {
  45655. lines: Vector3[][];
  45656. updatable?: boolean;
  45657. instance?: Nullable<LinesMesh>;
  45658. colors?: Nullable<Color4[][]>;
  45659. useVertexAlpha?: boolean;
  45660. }, scene: Nullable<Scene>): LinesMesh;
  45661. /**
  45662. * Creates a line mesh
  45663. * 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
  45664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45665. * * The parameter `points` is an array successive Vector3
  45666. * * 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
  45667. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45668. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45669. * * When updating an instance, remember that only point positions can change, not the number of points
  45670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45672. * @param name defines the name of the new line system
  45673. * @param options defines the options used to create the line system
  45674. * @param scene defines the hosting scene
  45675. * @returns a new line mesh
  45676. */
  45677. static CreateLines(name: string, options: {
  45678. points: Vector3[];
  45679. updatable?: boolean;
  45680. instance?: Nullable<LinesMesh>;
  45681. colors?: Color4[];
  45682. useVertexAlpha?: boolean;
  45683. }, scene?: Nullable<Scene>): LinesMesh;
  45684. /**
  45685. * Creates a dashed line mesh
  45686. * * 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
  45687. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45688. * * The parameter `points` is an array successive Vector3
  45689. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45690. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45691. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45692. * * 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
  45693. * * When updating an instance, remember that only point positions can change, not the number of points
  45694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45695. * @param name defines the name of the mesh
  45696. * @param options defines the options used to create the mesh
  45697. * @param scene defines the hosting scene
  45698. * @returns the dashed line mesh
  45699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45700. */
  45701. static CreateDashedLines(name: string, options: {
  45702. points: Vector3[];
  45703. dashSize?: number;
  45704. gapSize?: number;
  45705. dashNb?: number;
  45706. updatable?: boolean;
  45707. instance?: LinesMesh;
  45708. }, scene?: Nullable<Scene>): LinesMesh;
  45709. }
  45710. }
  45711. declare module "babylonjs/Cameras/XR/features/WebXRControllerTeleportation" {
  45712. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45713. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45714. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45716. import { Material } from "babylonjs/Materials/material";
  45717. /**
  45718. * The options container for the teleportation module
  45719. */
  45720. export interface IWebXRTeleportationOptions {
  45721. /**
  45722. * Babylon XR Input class for controller
  45723. */
  45724. xrInput: WebXRInput;
  45725. /**
  45726. * A list of meshes to use as floor meshes.
  45727. * Meshes can be added and removed after initializing the feature using the
  45728. * addFloorMesh and removeFloorMesh functions
  45729. */
  45730. floorMeshes: AbstractMesh[];
  45731. /**
  45732. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45733. * If you want to support rotation, make sure your mesh has a direction indicator.
  45734. *
  45735. * When left untouched, the default mesh will be initialized.
  45736. */
  45737. teleportationTargetMesh?: AbstractMesh;
  45738. /**
  45739. * Values to configure the default target mesh
  45740. */
  45741. defaultTargetMeshOptions?: {
  45742. /**
  45743. * Fill color of the teleportation area
  45744. */
  45745. teleportationFillColor?: string;
  45746. /**
  45747. * Border color for the teleportation area
  45748. */
  45749. teleportationBorderColor?: string;
  45750. /**
  45751. * Override the default material of the torus and arrow
  45752. */
  45753. torusArrowMaterial?: Material;
  45754. /**
  45755. * Disable the mesh's animation sequence
  45756. */
  45757. disableAnimation?: boolean;
  45758. };
  45759. /**
  45760. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  45761. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  45762. */
  45763. useMainComponentOnly?: boolean;
  45764. /**
  45765. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  45766. */
  45767. timeToTeleport?: number;
  45768. }
  45769. /**
  45770. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  45771. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  45772. * the input of the attached controllers.
  45773. */
  45774. export class WebXRMotionControllerTeleportation implements IWebXRFeature {
  45775. private _xrSessionManager;
  45776. private _options;
  45777. /**
  45778. * The module's name
  45779. */
  45780. static readonly Name: string;
  45781. /**
  45782. * The (Babylon) version of this module.
  45783. * This is an integer representing the implementation version.
  45784. * This number does not correspond to the webxr specs version
  45785. */
  45786. static readonly Version: number;
  45787. /**
  45788. * Is rotation enabled when moving forward?
  45789. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45790. */
  45791. rotationEnabled: boolean;
  45792. /**
  45793. * Should the module support parabolic ray on top of direct ray
  45794. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45795. * Very helpful when moving between floors / different heights
  45796. */
  45797. parabolicRayEnabled: boolean;
  45798. /**
  45799. * The distance from the user to the inspection point in the direction of the controller
  45800. * A higher number will allow the user to move further
  45801. * defaults to 5 (meters, in xr units)
  45802. */
  45803. parabolicCheckRadius: number;
  45804. /**
  45805. * How much rotation should be applied when rotating right and left
  45806. */
  45807. rotationAngle: number;
  45808. /**
  45809. * Distance to travel when moving backwards
  45810. */
  45811. backwardsTeleportationDistance: number;
  45812. private _observerTracked;
  45813. private _attached;
  45814. /**
  45815. * Is this feature attached
  45816. */
  45817. get attached(): boolean;
  45818. /**
  45819. * Add a new mesh to the floor meshes array
  45820. * @param mesh the mesh to use as floor mesh
  45821. */
  45822. addFloorMesh(mesh: AbstractMesh): void;
  45823. /**
  45824. * Remove a mesh from the floor meshes array
  45825. * @param mesh the mesh to remove
  45826. */
  45827. removeFloorMesh(mesh: AbstractMesh): void;
  45828. /**
  45829. * Remove a mesh from the floor meshes array using its name
  45830. * @param name the mesh name to remove
  45831. */
  45832. removeFloorMeshByName(name: string): void;
  45833. private _tmpRay;
  45834. private _tmpVector;
  45835. private _controllers;
  45836. /**
  45837. * constructs a new anchor system
  45838. * @param _xrSessionManager an instance of WebXRSessionManager
  45839. * @param _options configuration object for this feature
  45840. */
  45841. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45842. private _selectionFeature;
  45843. /**
  45844. * This function sets a selection feature that will be disabled when
  45845. * the forward ray is shown and will be reattached when hidden.
  45846. * This is used to remove the selection rays when moving.
  45847. * @param selectionFeature the feature to disable when forward movement is enabled
  45848. */
  45849. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45850. /**
  45851. * attach this feature
  45852. * Will usually be called by the features manager
  45853. *
  45854. * @returns true if successful.
  45855. */
  45856. attach(): boolean;
  45857. /**
  45858. * detach this feature.
  45859. * Will usually be called by the features manager
  45860. *
  45861. * @returns true if successful.
  45862. */
  45863. detach(): boolean;
  45864. /**
  45865. * Dispose this feature and all of the resources attached
  45866. */
  45867. dispose(): void;
  45868. private _currentTeleportationControllerId;
  45869. private _attachController;
  45870. private _teleportForward;
  45871. private _detachController;
  45872. private createDefaultTargetMesh;
  45873. private setTargetMeshVisibility;
  45874. private setTargetMeshPosition;
  45875. private _quadraticBezierCurve;
  45876. private showParabolicPath;
  45877. }
  45878. }
  45879. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45880. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45881. import { Scene } from "babylonjs/scene";
  45882. import { WebXRInput, IWebXRInputOptions } from "babylonjs/Cameras/XR/webXRInput";
  45883. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection";
  45884. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45885. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45887. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45888. import { WebXRMotionControllerTeleportation } from "babylonjs/Cameras/XR/features/WebXRControllerTeleportation";
  45889. /**
  45890. * Options for the default xr helper
  45891. */
  45892. export class WebXRDefaultExperienceOptions {
  45893. /**
  45894. * Floor meshes that should be used for teleporting
  45895. */
  45896. floorMeshes?: Array<AbstractMesh>;
  45897. /**
  45898. * Enable or disable default UI to enter XR
  45899. */
  45900. disableDefaultUI?: boolean;
  45901. /**
  45902. * optional configuration for the output canvas
  45903. */
  45904. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45905. /**
  45906. * optional UI options. This can be used among other to change session mode and reference space type
  45907. */
  45908. uiOptions?: WebXREnterExitUIOptions;
  45909. /**
  45910. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45911. */
  45912. inputOptions?: IWebXRInputOptions;
  45913. }
  45914. /**
  45915. * Default experience which provides a similar setup to the previous webVRExperience
  45916. */
  45917. export class WebXRDefaultExperience {
  45918. /**
  45919. * Base experience
  45920. */
  45921. baseExperience: WebXRExperienceHelper;
  45922. /**
  45923. * Input experience extension
  45924. */
  45925. input: WebXRInput;
  45926. /**
  45927. * Enables laser pointer and selection
  45928. */
  45929. pointerSelection: WebXRControllerPointerSelection;
  45930. /**
  45931. * Enables teleportation
  45932. */
  45933. teleportation: WebXRMotionControllerTeleportation;
  45934. /**
  45935. * Enables ui for entering/exiting xr
  45936. */
  45937. enterExitUI: WebXREnterExitUI;
  45938. /**
  45939. * Default target xr should render to
  45940. */
  45941. renderTarget: WebXRRenderTarget;
  45942. /**
  45943. * Creates the default xr experience
  45944. * @param scene scene
  45945. * @param options options for basic configuration
  45946. * @returns resulting WebXRDefaultExperience
  45947. */
  45948. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45949. private constructor();
  45950. /**
  45951. * DIsposes of the experience helper
  45952. */
  45953. dispose(): void;
  45954. }
  45955. }
  45956. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45957. import { Observable } from "babylonjs/Misc/observable";
  45958. import { Nullable } from "babylonjs/types";
  45959. import { Camera } from "babylonjs/Cameras/camera";
  45960. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45961. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45962. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45963. import { Scene } from "babylonjs/scene";
  45964. import { Vector3 } from "babylonjs/Maths/math.vector";
  45965. import { Color3 } from "babylonjs/Maths/math.color";
  45966. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45968. import { Mesh } from "babylonjs/Meshes/mesh";
  45969. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45970. import { EasingFunction } from "babylonjs/Animations/easing";
  45971. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45972. import "babylonjs/Meshes/Builders/groundBuilder";
  45973. import "babylonjs/Meshes/Builders/torusBuilder";
  45974. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45975. import "babylonjs/Gamepads/gamepadSceneComponent";
  45976. import "babylonjs/Animations/animatable";
  45977. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45978. /**
  45979. * Options to modify the vr teleportation behavior.
  45980. */
  45981. export interface VRTeleportationOptions {
  45982. /**
  45983. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45984. */
  45985. floorMeshName?: string;
  45986. /**
  45987. * A list of meshes to be used as the teleportation floor. (default: empty)
  45988. */
  45989. floorMeshes?: Mesh[];
  45990. /**
  45991. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45992. */
  45993. teleportationMode?: number;
  45994. /**
  45995. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45996. */
  45997. teleportationTime?: number;
  45998. /**
  45999. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46000. */
  46001. teleportationSpeed?: number;
  46002. /**
  46003. * The easing function used in the animation or null for Linear. (default CircleEase)
  46004. */
  46005. easingFunction?: EasingFunction;
  46006. }
  46007. /**
  46008. * Options to modify the vr experience helper's behavior.
  46009. */
  46010. export interface VRExperienceHelperOptions extends WebVROptions {
  46011. /**
  46012. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46013. */
  46014. createDeviceOrientationCamera?: boolean;
  46015. /**
  46016. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46017. */
  46018. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46019. /**
  46020. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46021. */
  46022. laserToggle?: boolean;
  46023. /**
  46024. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46025. */
  46026. floorMeshes?: Mesh[];
  46027. /**
  46028. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46029. */
  46030. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46031. /**
  46032. * Defines if WebXR should be used instead of WebVR (if available)
  46033. */
  46034. useXR?: boolean;
  46035. }
  46036. /**
  46037. * Event containing information after VR has been entered
  46038. */
  46039. export class OnAfterEnteringVRObservableEvent {
  46040. /**
  46041. * If entering vr was successful
  46042. */
  46043. success: boolean;
  46044. }
  46045. /**
  46046. * Helps to quickly add VR support to an existing scene.
  46047. * See http://doc.babylonjs.com/how_to/webvr_helper
  46048. */
  46049. export class VRExperienceHelper {
  46050. /** Options to modify the vr experience helper's behavior. */
  46051. webVROptions: VRExperienceHelperOptions;
  46052. private _scene;
  46053. private _position;
  46054. private _btnVR;
  46055. private _btnVRDisplayed;
  46056. private _webVRsupported;
  46057. private _webVRready;
  46058. private _webVRrequesting;
  46059. private _webVRpresenting;
  46060. private _hasEnteredVR;
  46061. private _fullscreenVRpresenting;
  46062. private _inputElement;
  46063. private _webVRCamera;
  46064. private _vrDeviceOrientationCamera;
  46065. private _deviceOrientationCamera;
  46066. private _existingCamera;
  46067. private _onKeyDown;
  46068. private _onVrDisplayPresentChange;
  46069. private _onVRDisplayChanged;
  46070. private _onVRRequestPresentStart;
  46071. private _onVRRequestPresentComplete;
  46072. /**
  46073. * 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)
  46074. */
  46075. enableGazeEvenWhenNoPointerLock: boolean;
  46076. /**
  46077. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46078. */
  46079. exitVROnDoubleTap: boolean;
  46080. /**
  46081. * Observable raised right before entering VR.
  46082. */
  46083. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46084. /**
  46085. * Observable raised when entering VR has completed.
  46086. */
  46087. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46088. /**
  46089. * Observable raised when exiting VR.
  46090. */
  46091. onExitingVRObservable: Observable<VRExperienceHelper>;
  46092. /**
  46093. * Observable raised when controller mesh is loaded.
  46094. */
  46095. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46096. /** Return this.onEnteringVRObservable
  46097. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46098. */
  46099. get onEnteringVR(): Observable<VRExperienceHelper>;
  46100. /** Return this.onExitingVRObservable
  46101. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46102. */
  46103. get onExitingVR(): Observable<VRExperienceHelper>;
  46104. /** Return this.onControllerMeshLoadedObservable
  46105. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46106. */
  46107. get onControllerMeshLoaded(): Observable<WebVRController>;
  46108. private _rayLength;
  46109. private _useCustomVRButton;
  46110. private _teleportationRequested;
  46111. private _teleportActive;
  46112. private _floorMeshName;
  46113. private _floorMeshesCollection;
  46114. private _teleportationMode;
  46115. private _teleportationTime;
  46116. private _teleportationSpeed;
  46117. private _teleportationEasing;
  46118. private _rotationAllowed;
  46119. private _teleportBackwardsVector;
  46120. private _teleportationTarget;
  46121. private _isDefaultTeleportationTarget;
  46122. private _postProcessMove;
  46123. private _teleportationFillColor;
  46124. private _teleportationBorderColor;
  46125. private _rotationAngle;
  46126. private _haloCenter;
  46127. private _cameraGazer;
  46128. private _padSensibilityUp;
  46129. private _padSensibilityDown;
  46130. private _leftController;
  46131. private _rightController;
  46132. private _gazeColor;
  46133. private _laserColor;
  46134. private _pickedLaserColor;
  46135. private _pickedGazeColor;
  46136. /**
  46137. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46138. */
  46139. onNewMeshSelected: Observable<AbstractMesh>;
  46140. /**
  46141. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46142. * This observable will provide the mesh and the controller used to select the mesh
  46143. */
  46144. onMeshSelectedWithController: Observable<{
  46145. mesh: AbstractMesh;
  46146. controller: WebVRController;
  46147. }>;
  46148. /**
  46149. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46150. */
  46151. onNewMeshPicked: Observable<PickingInfo>;
  46152. private _circleEase;
  46153. /**
  46154. * Observable raised before camera teleportation
  46155. */
  46156. onBeforeCameraTeleport: Observable<Vector3>;
  46157. /**
  46158. * Observable raised after camera teleportation
  46159. */
  46160. onAfterCameraTeleport: Observable<Vector3>;
  46161. /**
  46162. * Observable raised when current selected mesh gets unselected
  46163. */
  46164. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46165. private _raySelectionPredicate;
  46166. /**
  46167. * To be optionaly changed by user to define custom ray selection
  46168. */
  46169. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46170. /**
  46171. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46172. */
  46173. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46174. /**
  46175. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46176. */
  46177. teleportationEnabled: boolean;
  46178. private _defaultHeight;
  46179. private _teleportationInitialized;
  46180. private _interactionsEnabled;
  46181. private _interactionsRequested;
  46182. private _displayGaze;
  46183. private _displayLaserPointer;
  46184. /**
  46185. * The mesh used to display where the user is going to teleport.
  46186. */
  46187. get teleportationTarget(): Mesh;
  46188. /**
  46189. * Sets the mesh to be used to display where the user is going to teleport.
  46190. */
  46191. set teleportationTarget(value: Mesh);
  46192. /**
  46193. * 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
  46194. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46195. * See http://doc.babylonjs.com/resources/baking_transformations
  46196. */
  46197. get gazeTrackerMesh(): Mesh;
  46198. set gazeTrackerMesh(value: Mesh);
  46199. /**
  46200. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46201. */
  46202. updateGazeTrackerScale: boolean;
  46203. /**
  46204. * If the gaze trackers color should be updated when selecting meshes
  46205. */
  46206. updateGazeTrackerColor: boolean;
  46207. /**
  46208. * If the controller laser color should be updated when selecting meshes
  46209. */
  46210. updateControllerLaserColor: boolean;
  46211. /**
  46212. * The gaze tracking mesh corresponding to the left controller
  46213. */
  46214. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46215. /**
  46216. * The gaze tracking mesh corresponding to the right controller
  46217. */
  46218. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46219. /**
  46220. * If the ray of the gaze should be displayed.
  46221. */
  46222. get displayGaze(): boolean;
  46223. /**
  46224. * Sets if the ray of the gaze should be displayed.
  46225. */
  46226. set displayGaze(value: boolean);
  46227. /**
  46228. * If the ray of the LaserPointer should be displayed.
  46229. */
  46230. get displayLaserPointer(): boolean;
  46231. /**
  46232. * Sets if the ray of the LaserPointer should be displayed.
  46233. */
  46234. set displayLaserPointer(value: boolean);
  46235. /**
  46236. * The deviceOrientationCamera used as the camera when not in VR.
  46237. */
  46238. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46239. /**
  46240. * Based on the current WebVR support, returns the current VR camera used.
  46241. */
  46242. get currentVRCamera(): Nullable<Camera>;
  46243. /**
  46244. * The webVRCamera which is used when in VR.
  46245. */
  46246. get webVRCamera(): WebVRFreeCamera;
  46247. /**
  46248. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46249. */
  46250. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46251. /**
  46252. * The html button that is used to trigger entering into VR.
  46253. */
  46254. get vrButton(): Nullable<HTMLButtonElement>;
  46255. private get _teleportationRequestInitiated();
  46256. /**
  46257. * Defines wether or not Pointer lock should be requested when switching to
  46258. * full screen.
  46259. */
  46260. requestPointerLockOnFullScreen: boolean;
  46261. /**
  46262. * If asking to force XR, this will be populated with the default xr experience
  46263. */
  46264. xr: WebXRDefaultExperience;
  46265. /**
  46266. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46267. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46268. */
  46269. xrTestDone: boolean;
  46270. /**
  46271. * Instantiates a VRExperienceHelper.
  46272. * Helps to quickly add VR support to an existing scene.
  46273. * @param scene The scene the VRExperienceHelper belongs to.
  46274. * @param webVROptions Options to modify the vr experience helper's behavior.
  46275. */
  46276. constructor(scene: Scene,
  46277. /** Options to modify the vr experience helper's behavior. */
  46278. webVROptions?: VRExperienceHelperOptions);
  46279. private completeVRInit;
  46280. private _onDefaultMeshLoaded;
  46281. private _onResize;
  46282. private _onFullscreenChange;
  46283. /**
  46284. * Gets a value indicating if we are currently in VR mode.
  46285. */
  46286. get isInVRMode(): boolean;
  46287. private onVrDisplayPresentChange;
  46288. private onVRDisplayChanged;
  46289. private moveButtonToBottomRight;
  46290. private displayVRButton;
  46291. private updateButtonVisibility;
  46292. private _cachedAngularSensibility;
  46293. /**
  46294. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46295. * Otherwise, will use the fullscreen API.
  46296. */
  46297. enterVR(): void;
  46298. /**
  46299. * Attempt to exit VR, or fullscreen.
  46300. */
  46301. exitVR(): void;
  46302. /**
  46303. * The position of the vr experience helper.
  46304. */
  46305. get position(): Vector3;
  46306. /**
  46307. * Sets the position of the vr experience helper.
  46308. */
  46309. set position(value: Vector3);
  46310. /**
  46311. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46312. */
  46313. enableInteractions(): void;
  46314. private get _noControllerIsActive();
  46315. private beforeRender;
  46316. private _isTeleportationFloor;
  46317. /**
  46318. * Adds a floor mesh to be used for teleportation.
  46319. * @param floorMesh the mesh to be used for teleportation.
  46320. */
  46321. addFloorMesh(floorMesh: Mesh): void;
  46322. /**
  46323. * Removes a floor mesh from being used for teleportation.
  46324. * @param floorMesh the mesh to be removed.
  46325. */
  46326. removeFloorMesh(floorMesh: Mesh): void;
  46327. /**
  46328. * Enables interactions and teleportation using the VR controllers and gaze.
  46329. * @param vrTeleportationOptions options to modify teleportation behavior.
  46330. */
  46331. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46332. private _onNewGamepadConnected;
  46333. private _tryEnableInteractionOnController;
  46334. private _onNewGamepadDisconnected;
  46335. private _enableInteractionOnController;
  46336. private _checkTeleportWithRay;
  46337. private _checkRotate;
  46338. private _checkTeleportBackwards;
  46339. private _enableTeleportationOnController;
  46340. private _createTeleportationCircles;
  46341. private _displayTeleportationTarget;
  46342. private _hideTeleportationTarget;
  46343. private _rotateCamera;
  46344. private _moveTeleportationSelectorTo;
  46345. private _workingVector;
  46346. private _workingQuaternion;
  46347. private _workingMatrix;
  46348. /**
  46349. * Time Constant Teleportation Mode
  46350. */
  46351. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46352. /**
  46353. * Speed Constant Teleportation Mode
  46354. */
  46355. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46356. /**
  46357. * Teleports the users feet to the desired location
  46358. * @param location The location where the user's feet should be placed
  46359. */
  46360. teleportCamera(location: Vector3): void;
  46361. private _convertNormalToDirectionOfRay;
  46362. private _castRayAndSelectObject;
  46363. private _notifySelectedMeshUnselected;
  46364. /**
  46365. * Permanently set new colors for the laser pointer
  46366. * @param color the new laser color
  46367. * @param pickedColor the new laser color when picked mesh detected
  46368. */
  46369. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46370. /**
  46371. * Permanently set new colors for the gaze pointer
  46372. * @param color the new gaze color
  46373. * @param pickedColor the new gaze color when picked mesh detected
  46374. */
  46375. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46376. /**
  46377. * Sets the color of the laser ray from the vr controllers.
  46378. * @param color new color for the ray.
  46379. */
  46380. changeLaserColor(color: Color3): void;
  46381. /**
  46382. * Sets the color of the ray from the vr headsets gaze.
  46383. * @param color new color for the ray.
  46384. */
  46385. changeGazeColor(color: Color3): void;
  46386. /**
  46387. * Exits VR and disposes of the vr experience helper
  46388. */
  46389. dispose(): void;
  46390. /**
  46391. * Gets the name of the VRExperienceHelper class
  46392. * @returns "VRExperienceHelper"
  46393. */
  46394. getClassName(): string;
  46395. }
  46396. }
  46397. declare module "babylonjs/Cameras/VR/index" {
  46398. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  46399. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  46400. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46401. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  46402. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  46403. export * from "babylonjs/Cameras/VR/webVRCamera";
  46404. }
  46405. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  46406. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46407. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46408. import { Observable } from "babylonjs/Misc/observable";
  46409. import { Matrix } from "babylonjs/Maths/math.vector";
  46410. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46411. /**
  46412. * Options used for hit testing
  46413. */
  46414. export interface IWebXRHitTestOptions {
  46415. /**
  46416. * Only test when user interacted with the scene. Default - hit test every frame
  46417. */
  46418. testOnPointerDownOnly?: boolean;
  46419. /**
  46420. * The node to use to transform the local results to world coordinates
  46421. */
  46422. worldParentNode?: TransformNode;
  46423. }
  46424. /**
  46425. * Interface defining the babylon result of raycasting/hit-test
  46426. */
  46427. export interface IWebXRHitResult {
  46428. /**
  46429. * The native hit test result
  46430. */
  46431. xrHitResult: XRHitResult;
  46432. /**
  46433. * Transformation matrix that can be applied to a node that will put it in the hit point location
  46434. */
  46435. transformationMatrix: Matrix;
  46436. }
  46437. /**
  46438. * The currently-working hit-test module.
  46439. * Hit test (or raycasting) is used to interact with the real world.
  46440. * For further information read here - https://github.com/immersive-web/hit-test
  46441. */
  46442. export class WebXRHitTestLegacy implements IWebXRFeature {
  46443. private _xrSessionManager;
  46444. /**
  46445. * options to use when constructing this feature
  46446. */
  46447. readonly options: IWebXRHitTestOptions;
  46448. /**
  46449. * The module's name
  46450. */
  46451. static readonly Name: string;
  46452. /**
  46453. * The (Babylon) version of this module.
  46454. * This is an integer representing the implementation version.
  46455. * This number does not correspond to the webxr specs version
  46456. */
  46457. static readonly Version: number;
  46458. private _attached;
  46459. /**
  46460. * Is this feature attached
  46461. */
  46462. get attached(): boolean;
  46463. /**
  46464. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  46465. * @param event the (select) event to use to select with
  46466. * @param referenceSpace the reference space to use for this hit test
  46467. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46468. */
  46469. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  46470. /**
  46471. * execute a hit test with an XR Ray
  46472. *
  46473. * @param xrSession a native xrSession that will execute this hit test
  46474. * @param xrRay the ray (position and direction) to use for raycasting
  46475. * @param referenceSpace native XR reference space to use for the hit-test
  46476. * @param filter filter function that will filter the results
  46477. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46478. */
  46479. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  46480. /**
  46481. * Triggered when new babylon (transformed) hit test results are available
  46482. */
  46483. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  46484. private _onSelectEnabled;
  46485. private _xrFrameObserver;
  46486. /**
  46487. * Creates a new instance of the (legacy version) hit test feature
  46488. * @param _xrSessionManager an instance of WebXRSessionManager
  46489. * @param options options to use when constructing this feature
  46490. */
  46491. constructor(_xrSessionManager: WebXRSessionManager,
  46492. /**
  46493. * options to use when constructing this feature
  46494. */
  46495. options?: IWebXRHitTestOptions);
  46496. /**
  46497. * Populated with the last native XR Hit Results
  46498. */
  46499. lastNativeXRHitResults: XRHitResult[];
  46500. /**
  46501. * attach this feature
  46502. * Will usually be called by the features manager
  46503. *
  46504. * @returns true if successful.
  46505. */
  46506. attach(): boolean;
  46507. /**
  46508. * detach this feature.
  46509. * Will usually be called by the features manager
  46510. *
  46511. * @returns true if successful.
  46512. */
  46513. detach(): boolean;
  46514. private _onHitTestResults;
  46515. private _onSelect;
  46516. /**
  46517. * Dispose this feature and all of the resources attached
  46518. */
  46519. dispose(): void;
  46520. }
  46521. }
  46522. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  46523. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46524. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46525. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46526. import { Observable } from "babylonjs/Misc/observable";
  46527. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  46528. /**
  46529. * Options used in the plane detector module
  46530. */
  46531. export interface IWebXRPlaneDetectorOptions {
  46532. /**
  46533. * The node to use to transform the local results to world coordinates
  46534. */
  46535. worldParentNode?: TransformNode;
  46536. }
  46537. /**
  46538. * A babylon interface for a webxr plane.
  46539. * A Plane is actually a polygon, built from N points in space
  46540. */
  46541. export interface IWebXRPlane {
  46542. /**
  46543. * a babylon-assigned ID for this polygon
  46544. */
  46545. id: number;
  46546. /**
  46547. * the native xr-plane object
  46548. */
  46549. xrPlane: XRPlane;
  46550. /**
  46551. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  46552. */
  46553. polygonDefinition: Array<Vector3>;
  46554. /**
  46555. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  46556. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  46557. */
  46558. transformationMatrix: Matrix;
  46559. }
  46560. /**
  46561. * The plane detector is used to detect planes in the real world when in AR
  46562. * For more information see https://github.com/immersive-web/real-world-geometry/
  46563. */
  46564. export class WebXRPlaneDetector implements IWebXRFeature {
  46565. private _xrSessionManager;
  46566. private _options;
  46567. /**
  46568. * The module's name
  46569. */
  46570. static readonly Name: string;
  46571. /**
  46572. * The (Babylon) version of this module.
  46573. * This is an integer representing the implementation version.
  46574. * This number does not correspond to the webxr specs version
  46575. */
  46576. static readonly Version: number;
  46577. /**
  46578. * Observers registered here will be executed when a new plane was added to the session
  46579. */
  46580. onPlaneAddedObservable: Observable<IWebXRPlane>;
  46581. /**
  46582. * Observers registered here will be executed when a plane is no longer detected in the session
  46583. */
  46584. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  46585. /**
  46586. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  46587. * This can execute N times every frame
  46588. */
  46589. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  46590. private _attached;
  46591. /**
  46592. * Is this feature attached
  46593. */
  46594. get attached(): boolean;
  46595. private _enabled;
  46596. private _detectedPlanes;
  46597. private _lastFrameDetected;
  46598. private _observerTracked;
  46599. /**
  46600. * construct a new Plane Detector
  46601. * @param _xrSessionManager an instance of xr Session manager
  46602. * @param _options configuration to use when constructing this feature
  46603. */
  46604. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  46605. /**
  46606. * attach this feature
  46607. * Will usually be called by the features manager
  46608. *
  46609. * @returns true if successful.
  46610. */
  46611. attach(): boolean;
  46612. /**
  46613. * detach this feature.
  46614. * Will usually be called by the features manager
  46615. *
  46616. * @returns true if successful.
  46617. */
  46618. detach(): boolean;
  46619. /**
  46620. * Dispose this feature and all of the resources attached
  46621. */
  46622. dispose(): void;
  46623. private _updatePlaneWithXRPlane;
  46624. /**
  46625. * avoiding using Array.find for global support.
  46626. * @param xrPlane the plane to find in the array
  46627. */
  46628. private findIndexInPlaneArray;
  46629. }
  46630. }
  46631. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46632. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46633. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46634. import { Observable } from "babylonjs/Misc/observable";
  46635. import { Matrix } from "babylonjs/Maths/math.vector";
  46636. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46637. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46638. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46639. /**
  46640. * Configuration options of the anchor system
  46641. */
  46642. export interface IWebXRAnchorSystemOptions {
  46643. /**
  46644. * a node that will be used to convert local to world coordinates
  46645. */
  46646. worldParentNode?: TransformNode;
  46647. /**
  46648. * should the anchor system use plane detection.
  46649. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46650. */
  46651. usePlaneDetection?: boolean;
  46652. /**
  46653. * Should a new anchor be added every time a select event is triggered
  46654. */
  46655. addAnchorOnSelect?: boolean;
  46656. }
  46657. /**
  46658. * A babylon container for an XR Anchor
  46659. */
  46660. export interface IWebXRAnchor {
  46661. /**
  46662. * A babylon-assigned ID for this anchor
  46663. */
  46664. id: number;
  46665. /**
  46666. * The native anchor object
  46667. */
  46668. xrAnchor: XRAnchor;
  46669. /**
  46670. * Transformation matrix to apply to an object attached to this anchor
  46671. */
  46672. transformationMatrix: Matrix;
  46673. }
  46674. /**
  46675. * An implementation of the anchor system of WebXR.
  46676. * Note that the current documented implementation is not available in any browser. Future implementations
  46677. * will use the frame to create an anchor and not the session or a detected plane
  46678. * For further information see https://github.com/immersive-web/anchors/
  46679. */
  46680. export class WebXRAnchorSystem implements IWebXRFeature {
  46681. private _xrSessionManager;
  46682. private _options;
  46683. /**
  46684. * The module's name
  46685. */
  46686. static readonly Name: string;
  46687. /**
  46688. * The (Babylon) version of this module.
  46689. * This is an integer representing the implementation version.
  46690. * This number does not correspond to the webxr specs version
  46691. */
  46692. static readonly Version: number;
  46693. /**
  46694. * Observers registered here will be executed when a new anchor was added to the session
  46695. */
  46696. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46697. /**
  46698. * Observers registered here will be executed when an existing anchor updates
  46699. * This can execute N times every frame
  46700. */
  46701. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46702. /**
  46703. * Observers registered here will be executed when an anchor was removed from the session
  46704. */
  46705. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46706. private _attached;
  46707. /**
  46708. * Is this feature attached
  46709. */
  46710. get attached(): boolean;
  46711. private _planeDetector;
  46712. private _hitTestModule;
  46713. private _enabled;
  46714. private _trackedAnchors;
  46715. private _lastFrameDetected;
  46716. private _observerTracked;
  46717. /**
  46718. * constructs a new anchor system
  46719. * @param _xrSessionManager an instance of WebXRSessionManager
  46720. * @param _options configuration object for this feature
  46721. */
  46722. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46723. /**
  46724. * set the plane detector to use in order to create anchors from frames
  46725. * @param planeDetector the plane-detector module to use
  46726. * @param enable enable plane-anchors. default is true
  46727. */
  46728. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46729. /**
  46730. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46731. * @param hitTestModule the hit-test module to use.
  46732. */
  46733. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46734. /**
  46735. * attach this feature
  46736. * Will usually be called by the features manager
  46737. *
  46738. * @returns true if successful.
  46739. */
  46740. attach(): boolean;
  46741. /**
  46742. * detach this feature.
  46743. * Will usually be called by the features manager
  46744. *
  46745. * @returns true if successful.
  46746. */
  46747. detach(): boolean;
  46748. /**
  46749. * Dispose this feature and all of the resources attached
  46750. */
  46751. dispose(): void;
  46752. private _onSelect;
  46753. /**
  46754. * Add anchor at a specific XR point.
  46755. *
  46756. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46757. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46758. * @returns a promise the fulfills when the anchor was created
  46759. */
  46760. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46761. private _updateAnchorWithXRFrame;
  46762. /**
  46763. * avoiding using Array.find for global support.
  46764. * @param xrAnchor the plane to find in the array
  46765. */
  46766. private _findIndexInAnchorArray;
  46767. }
  46768. }
  46769. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46770. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46771. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46773. import { Observable } from "babylonjs/Misc/observable";
  46774. /**
  46775. * Options interface for the background remover plugin
  46776. */
  46777. export interface IWebXRBackgroundRemoverOptions {
  46778. /**
  46779. * don't disable the environment helper
  46780. */
  46781. ignoreEnvironmentHelper?: boolean;
  46782. /**
  46783. * flags to configure the removal of the environment helper.
  46784. * If not set, the entire background will be removed. If set, flags should be set as well.
  46785. */
  46786. environmentHelperRemovalFlags?: {
  46787. /**
  46788. * Should the skybox be removed (default false)
  46789. */
  46790. skyBox?: boolean;
  46791. /**
  46792. * Should the ground be removed (default false)
  46793. */
  46794. ground?: boolean;
  46795. };
  46796. /**
  46797. * Further background meshes to disable when entering AR
  46798. */
  46799. backgroundMeshes?: AbstractMesh[];
  46800. }
  46801. /**
  46802. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46803. */
  46804. export class WebXRBackgroundRemover implements IWebXRFeature {
  46805. private _xrSessionManager;
  46806. /**
  46807. * read-only options to be used in this module
  46808. */
  46809. readonly options: IWebXRBackgroundRemoverOptions;
  46810. /**
  46811. * The module's name
  46812. */
  46813. static readonly Name: string;
  46814. /**
  46815. * The (Babylon) version of this module.
  46816. * This is an integer representing the implementation version.
  46817. * This number does not correspond to the webxr specs version
  46818. */
  46819. static readonly Version: number;
  46820. /**
  46821. * registered observers will be triggered when the background state changes
  46822. */
  46823. onBackgroundStateChangedObservable: Observable<boolean>;
  46824. private _attached;
  46825. /**
  46826. * Is this feature attached
  46827. */
  46828. get attached(): boolean;
  46829. /**
  46830. * constructs a new background remover module
  46831. * @param _xrSessionManager the session manager for this module
  46832. * @param options read-only options to be used in this module
  46833. */
  46834. constructor(_xrSessionManager: WebXRSessionManager,
  46835. /**
  46836. * read-only options to be used in this module
  46837. */
  46838. options?: IWebXRBackgroundRemoverOptions);
  46839. /**
  46840. * attach this feature
  46841. * Will usually be called by the features manager
  46842. *
  46843. * @returns true if successful.
  46844. */
  46845. attach(): boolean;
  46846. /**
  46847. * detach this feature.
  46848. * Will usually be called by the features manager
  46849. *
  46850. * @returns true if successful.
  46851. */
  46852. detach(): boolean;
  46853. private _setBackgroundState;
  46854. /**
  46855. * Dispose this feature and all of the resources attached
  46856. */
  46857. dispose(): void;
  46858. }
  46859. }
  46860. declare module "babylonjs/Cameras/XR/features/index" {
  46861. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46862. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46863. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46864. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46865. export * from "babylonjs/Cameras/XR/features/WebXRControllerTeleportation";
  46866. export * from "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection";
  46867. }
  46868. declare module "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController" {
  46869. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46871. import { Scene } from "babylonjs/scene";
  46872. /**
  46873. * The motion controller class for all microsoft mixed reality controllers
  46874. */
  46875. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  46876. /**
  46877. * The base url used to load the left and right controller models
  46878. */
  46879. static MODEL_BASE_URL: string;
  46880. /**
  46881. * The name of the left controller model file
  46882. */
  46883. static MODEL_LEFT_FILENAME: string;
  46884. /**
  46885. * The name of the right controller model file
  46886. */
  46887. static MODEL_RIGHT_FILENAME: string;
  46888. profileId: string;
  46889. protected readonly _mapping: {
  46890. defaultButton: {
  46891. "valueNodeName": string;
  46892. "unpressedNodeName": string;
  46893. "pressedNodeName": string;
  46894. };
  46895. defaultAxis: {
  46896. "valueNodeName": string;
  46897. "minNodeName": string;
  46898. "maxNodeName": string;
  46899. };
  46900. buttons: {
  46901. "xr-standard-trigger": {
  46902. "rootNodeName": string;
  46903. "componentProperty": string;
  46904. "states": string[];
  46905. };
  46906. "xr-standard-squeeze": {
  46907. "rootNodeName": string;
  46908. "componentProperty": string;
  46909. "states": string[];
  46910. };
  46911. "xr-standard-touchpad": {
  46912. "rootNodeName": string;
  46913. "labelAnchorNodeName": string;
  46914. "touchPointNodeName": string;
  46915. };
  46916. "xr-standard-thumbstick": {
  46917. "rootNodeName": string;
  46918. "componentProperty": string;
  46919. "states": string[];
  46920. };
  46921. };
  46922. axes: {
  46923. "xr-standard-touchpad": {
  46924. "x-axis": {
  46925. "rootNodeName": string;
  46926. };
  46927. "y-axis": {
  46928. "rootNodeName": string;
  46929. };
  46930. };
  46931. "xr-standard-thumbstick": {
  46932. "x-axis": {
  46933. "rootNodeName": string;
  46934. };
  46935. "y-axis": {
  46936. "rootNodeName": string;
  46937. };
  46938. };
  46939. };
  46940. };
  46941. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  46942. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46943. private _getChildByName;
  46944. private _getImmediateChildByName;
  46945. protected _getFilenameAndPath(): {
  46946. filename: string;
  46947. path: string;
  46948. };
  46949. protected _updateModel(): void;
  46950. protected _getModelLoadingConstraints(): boolean;
  46951. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46952. }
  46953. }
  46954. declare module "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController" {
  46955. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46957. import { Scene } from "babylonjs/scene";
  46958. /**
  46959. * The motion controller class for oculus touch (quest, rift).
  46960. * This class supports legacy mapping as well the standard xr mapping
  46961. */
  46962. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  46963. private _forceLegacyControllers;
  46964. /**
  46965. * The base url used to load the left and right controller models
  46966. */
  46967. static MODEL_BASE_URL: string;
  46968. /**
  46969. * The name of the left controller model file
  46970. */
  46971. static MODEL_LEFT_FILENAME: string;
  46972. /**
  46973. * The name of the right controller model file
  46974. */
  46975. static MODEL_RIGHT_FILENAME: string;
  46976. /**
  46977. * Base Url for the Quest controller model.
  46978. */
  46979. static QUEST_MODEL_BASE_URL: string;
  46980. profileId: string;
  46981. private _modelRootNode;
  46982. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  46983. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46984. protected _getFilenameAndPath(): {
  46985. filename: string;
  46986. path: string;
  46987. };
  46988. /**
  46989. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  46990. * between the touch and touch 2.
  46991. */
  46992. private _isQuest;
  46993. protected _updateModel(): void;
  46994. protected _getModelLoadingConstraints(): boolean;
  46995. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46996. }
  46997. }
  46998. declare module "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController" {
  46999. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47000. import { Scene } from "babylonjs/scene";
  47001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47002. /**
  47003. * The motion controller class for the standard HTC-Vive controllers
  47004. */
  47005. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  47006. /**
  47007. * The base url used to load the left and right controller models
  47008. */
  47009. static MODEL_BASE_URL: string;
  47010. /**
  47011. * File name for the controller model.
  47012. */
  47013. static MODEL_FILENAME: string;
  47014. profileId: string;
  47015. private _modelRootNode;
  47016. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  47017. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47018. protected _getFilenameAndPath(): {
  47019. filename: string;
  47020. path: string;
  47021. };
  47022. protected _updateModel(): void;
  47023. protected _getModelLoadingConstraints(): boolean;
  47024. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47025. }
  47026. }
  47027. declare module "babylonjs/Cameras/XR/motionController/index" {
  47028. export * from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47029. export * from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  47030. export * from "babylonjs/Cameras/XR/motionController/webXRGenericMotionController";
  47031. export * from "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController";
  47032. export * from "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager";
  47033. export * from "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController";
  47034. export * from "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController";
  47035. }
  47036. declare module "babylonjs/Cameras/XR/index" {
  47037. export * from "babylonjs/Cameras/XR/webXRCamera";
  47038. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  47039. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47040. export * from "babylonjs/Cameras/XR/webXRInput";
  47041. export * from "babylonjs/Cameras/XR/webXRController";
  47042. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  47043. export * from "babylonjs/Cameras/XR/webXRTypes";
  47044. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  47045. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  47046. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  47047. export * from "babylonjs/Cameras/XR/features/index";
  47048. export * from "babylonjs/Cameras/XR/motionController/index";
  47049. }
  47050. declare module "babylonjs/Cameras/RigModes/index" {
  47051. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47052. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47053. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47054. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47055. }
  47056. declare module "babylonjs/Cameras/index" {
  47057. export * from "babylonjs/Cameras/Inputs/index";
  47058. export * from "babylonjs/Cameras/cameraInputsManager";
  47059. export * from "babylonjs/Cameras/camera";
  47060. export * from "babylonjs/Cameras/targetCamera";
  47061. export * from "babylonjs/Cameras/freeCamera";
  47062. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47063. export * from "babylonjs/Cameras/touchCamera";
  47064. export * from "babylonjs/Cameras/arcRotateCamera";
  47065. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47066. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47067. export * from "babylonjs/Cameras/flyCamera";
  47068. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47069. export * from "babylonjs/Cameras/followCamera";
  47070. export * from "babylonjs/Cameras/followCameraInputsManager";
  47071. export * from "babylonjs/Cameras/gamepadCamera";
  47072. export * from "babylonjs/Cameras/Stereoscopic/index";
  47073. export * from "babylonjs/Cameras/universalCamera";
  47074. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47075. export * from "babylonjs/Cameras/VR/index";
  47076. export * from "babylonjs/Cameras/XR/index";
  47077. export * from "babylonjs/Cameras/RigModes/index";
  47078. }
  47079. declare module "babylonjs/Collisions/index" {
  47080. export * from "babylonjs/Collisions/collider";
  47081. export * from "babylonjs/Collisions/collisionCoordinator";
  47082. export * from "babylonjs/Collisions/pickingInfo";
  47083. export * from "babylonjs/Collisions/intersectionInfo";
  47084. export * from "babylonjs/Collisions/meshCollisionData";
  47085. }
  47086. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47087. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47088. import { Vector3 } from "babylonjs/Maths/math.vector";
  47089. import { Ray } from "babylonjs/Culling/ray";
  47090. import { Plane } from "babylonjs/Maths/math.plane";
  47091. /**
  47092. * Contains an array of blocks representing the octree
  47093. */
  47094. export interface IOctreeContainer<T> {
  47095. /**
  47096. * Blocks within the octree
  47097. */
  47098. blocks: Array<OctreeBlock<T>>;
  47099. }
  47100. /**
  47101. * Class used to store a cell in an octree
  47102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47103. */
  47104. export class OctreeBlock<T> {
  47105. /**
  47106. * Gets the content of the current block
  47107. */
  47108. entries: T[];
  47109. /**
  47110. * Gets the list of block children
  47111. */
  47112. blocks: Array<OctreeBlock<T>>;
  47113. private _depth;
  47114. private _maxDepth;
  47115. private _capacity;
  47116. private _minPoint;
  47117. private _maxPoint;
  47118. private _boundingVectors;
  47119. private _creationFunc;
  47120. /**
  47121. * Creates a new block
  47122. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47123. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47124. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47125. * @param depth defines the current depth of this block in the octree
  47126. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47127. * @param creationFunc defines a callback to call when an element is added to the block
  47128. */
  47129. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47130. /**
  47131. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47132. */
  47133. get capacity(): number;
  47134. /**
  47135. * Gets the minimum vector (in world space) of the block's bounding box
  47136. */
  47137. get minPoint(): Vector3;
  47138. /**
  47139. * Gets the maximum vector (in world space) of the block's bounding box
  47140. */
  47141. get maxPoint(): Vector3;
  47142. /**
  47143. * Add a new element to this block
  47144. * @param entry defines the element to add
  47145. */
  47146. addEntry(entry: T): void;
  47147. /**
  47148. * Remove an element from this block
  47149. * @param entry defines the element to remove
  47150. */
  47151. removeEntry(entry: T): void;
  47152. /**
  47153. * Add an array of elements to this block
  47154. * @param entries defines the array of elements to add
  47155. */
  47156. addEntries(entries: T[]): void;
  47157. /**
  47158. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47159. * @param frustumPlanes defines the frustum planes to test
  47160. * @param selection defines the array to store current content if selection is positive
  47161. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47162. */
  47163. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47164. /**
  47165. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47166. * @param sphereCenter defines the bounding sphere center
  47167. * @param sphereRadius defines the bounding sphere radius
  47168. * @param selection defines the array to store current content if selection is positive
  47169. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47170. */
  47171. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47172. /**
  47173. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47174. * @param ray defines the ray to test with
  47175. * @param selection defines the array to store current content if selection is positive
  47176. */
  47177. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47178. /**
  47179. * Subdivide the content into child blocks (this block will then be empty)
  47180. */
  47181. createInnerBlocks(): void;
  47182. /**
  47183. * @hidden
  47184. */
  47185. 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;
  47186. }
  47187. }
  47188. declare module "babylonjs/Culling/Octrees/octree" {
  47189. import { SmartArray } from "babylonjs/Misc/smartArray";
  47190. import { Vector3 } from "babylonjs/Maths/math.vector";
  47191. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47193. import { Ray } from "babylonjs/Culling/ray";
  47194. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47195. import { Plane } from "babylonjs/Maths/math.plane";
  47196. /**
  47197. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47198. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47199. */
  47200. export class Octree<T> {
  47201. /** 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.) */
  47202. maxDepth: number;
  47203. /**
  47204. * Blocks within the octree containing objects
  47205. */
  47206. blocks: Array<OctreeBlock<T>>;
  47207. /**
  47208. * Content stored in the octree
  47209. */
  47210. dynamicContent: T[];
  47211. private _maxBlockCapacity;
  47212. private _selectionContent;
  47213. private _creationFunc;
  47214. /**
  47215. * Creates a octree
  47216. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47217. * @param creationFunc function to be used to instatiate the octree
  47218. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47219. * @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.)
  47220. */
  47221. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47222. /** 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.) */
  47223. maxDepth?: number);
  47224. /**
  47225. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47226. * @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);
  47227. * @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);
  47228. * @param entries meshes to be added to the octree blocks
  47229. */
  47230. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47231. /**
  47232. * Adds a mesh to the octree
  47233. * @param entry Mesh to add to the octree
  47234. */
  47235. addMesh(entry: T): void;
  47236. /**
  47237. * Remove an element from the octree
  47238. * @param entry defines the element to remove
  47239. */
  47240. removeMesh(entry: T): void;
  47241. /**
  47242. * Selects an array of meshes within the frustum
  47243. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47244. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47245. * @returns array of meshes within the frustum
  47246. */
  47247. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47248. /**
  47249. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47250. * @param sphereCenter defines the bounding sphere center
  47251. * @param sphereRadius defines the bounding sphere radius
  47252. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47253. * @returns an array of objects that intersect the sphere
  47254. */
  47255. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47256. /**
  47257. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47258. * @param ray defines the ray to test with
  47259. * @returns array of intersected objects
  47260. */
  47261. intersectsRay(ray: Ray): SmartArray<T>;
  47262. /**
  47263. * Adds a mesh into the octree block if it intersects the block
  47264. */
  47265. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47266. /**
  47267. * Adds a submesh into the octree block if it intersects the block
  47268. */
  47269. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47270. }
  47271. }
  47272. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47273. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47274. import { Scene } from "babylonjs/scene";
  47275. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47277. import { Ray } from "babylonjs/Culling/ray";
  47278. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47279. import { Collider } from "babylonjs/Collisions/collider";
  47280. module "babylonjs/scene" {
  47281. interface Scene {
  47282. /**
  47283. * @hidden
  47284. * Backing Filed
  47285. */
  47286. _selectionOctree: Octree<AbstractMesh>;
  47287. /**
  47288. * Gets the octree used to boost mesh selection (picking)
  47289. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47290. */
  47291. selectionOctree: Octree<AbstractMesh>;
  47292. /**
  47293. * Creates or updates the octree used to boost selection (picking)
  47294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47295. * @param maxCapacity defines the maximum capacity per leaf
  47296. * @param maxDepth defines the maximum depth of the octree
  47297. * @returns an octree of AbstractMesh
  47298. */
  47299. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47300. }
  47301. }
  47302. module "babylonjs/Meshes/abstractMesh" {
  47303. interface AbstractMesh {
  47304. /**
  47305. * @hidden
  47306. * Backing Field
  47307. */
  47308. _submeshesOctree: Octree<SubMesh>;
  47309. /**
  47310. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47311. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47312. * @param maxCapacity defines the maximum size of each block (64 by default)
  47313. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47314. * @returns the new octree
  47315. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47316. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47317. */
  47318. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47319. }
  47320. }
  47321. /**
  47322. * Defines the octree scene component responsible to manage any octrees
  47323. * in a given scene.
  47324. */
  47325. export class OctreeSceneComponent {
  47326. /**
  47327. * The component name help to identify the component in the list of scene components.
  47328. */
  47329. readonly name: string;
  47330. /**
  47331. * The scene the component belongs to.
  47332. */
  47333. scene: Scene;
  47334. /**
  47335. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47336. */
  47337. readonly checksIsEnabled: boolean;
  47338. /**
  47339. * Creates a new instance of the component for the given scene
  47340. * @param scene Defines the scene to register the component in
  47341. */
  47342. constructor(scene: Scene);
  47343. /**
  47344. * Registers the component in a given scene
  47345. */
  47346. register(): void;
  47347. /**
  47348. * Return the list of active meshes
  47349. * @returns the list of active meshes
  47350. */
  47351. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47352. /**
  47353. * Return the list of active sub meshes
  47354. * @param mesh The mesh to get the candidates sub meshes from
  47355. * @returns the list of active sub meshes
  47356. */
  47357. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47358. private _tempRay;
  47359. /**
  47360. * Return the list of sub meshes intersecting with a given local ray
  47361. * @param mesh defines the mesh to find the submesh for
  47362. * @param localRay defines the ray in local space
  47363. * @returns the list of intersecting sub meshes
  47364. */
  47365. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47366. /**
  47367. * Return the list of sub meshes colliding with a collider
  47368. * @param mesh defines the mesh to find the submesh for
  47369. * @param collider defines the collider to evaluate the collision against
  47370. * @returns the list of colliding sub meshes
  47371. */
  47372. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47373. /**
  47374. * Rebuilds the elements related to this component in case of
  47375. * context lost for instance.
  47376. */
  47377. rebuild(): void;
  47378. /**
  47379. * Disposes the component and the associated ressources.
  47380. */
  47381. dispose(): void;
  47382. }
  47383. }
  47384. declare module "babylonjs/Culling/Octrees/index" {
  47385. export * from "babylonjs/Culling/Octrees/octree";
  47386. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47387. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47388. }
  47389. declare module "babylonjs/Culling/index" {
  47390. export * from "babylonjs/Culling/boundingBox";
  47391. export * from "babylonjs/Culling/boundingInfo";
  47392. export * from "babylonjs/Culling/boundingSphere";
  47393. export * from "babylonjs/Culling/Octrees/index";
  47394. export * from "babylonjs/Culling/ray";
  47395. }
  47396. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  47397. import { IDisposable, Scene } from "babylonjs/scene";
  47398. import { Nullable } from "babylonjs/types";
  47399. import { Observable } from "babylonjs/Misc/observable";
  47400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47401. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  47402. import { Camera } from "babylonjs/Cameras/camera";
  47403. /**
  47404. * Renders a layer on top of an existing scene
  47405. */
  47406. export class UtilityLayerRenderer implements IDisposable {
  47407. /** the original scene that will be rendered on top of */
  47408. originalScene: Scene;
  47409. private _pointerCaptures;
  47410. private _lastPointerEvents;
  47411. private static _DefaultUtilityLayer;
  47412. private static _DefaultKeepDepthUtilityLayer;
  47413. private _sharedGizmoLight;
  47414. private _renderCamera;
  47415. /**
  47416. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47417. * @returns the camera that is used when rendering the utility layer
  47418. */
  47419. getRenderCamera(): Nullable<Camera>;
  47420. /**
  47421. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47422. * @param cam the camera that should be used when rendering the utility layer
  47423. */
  47424. setRenderCamera(cam: Nullable<Camera>): void;
  47425. /**
  47426. * @hidden
  47427. * Light which used by gizmos to get light shading
  47428. */
  47429. _getSharedGizmoLight(): HemisphericLight;
  47430. /**
  47431. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47432. */
  47433. pickUtilitySceneFirst: boolean;
  47434. /**
  47435. * 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)
  47436. */
  47437. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47438. /**
  47439. * 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)
  47440. */
  47441. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47442. /**
  47443. * The scene that is rendered on top of the original scene
  47444. */
  47445. utilityLayerScene: Scene;
  47446. /**
  47447. * If the utility layer should automatically be rendered on top of existing scene
  47448. */
  47449. shouldRender: boolean;
  47450. /**
  47451. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47452. */
  47453. onlyCheckPointerDownEvents: boolean;
  47454. /**
  47455. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47456. */
  47457. processAllEvents: boolean;
  47458. /**
  47459. * Observable raised when the pointer move from the utility layer scene to the main scene
  47460. */
  47461. onPointerOutObservable: Observable<number>;
  47462. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47463. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47464. private _afterRenderObserver;
  47465. private _sceneDisposeObserver;
  47466. private _originalPointerObserver;
  47467. /**
  47468. * Instantiates a UtilityLayerRenderer
  47469. * @param originalScene the original scene that will be rendered on top of
  47470. * @param handleEvents boolean indicating if the utility layer should handle events
  47471. */
  47472. constructor(
  47473. /** the original scene that will be rendered on top of */
  47474. originalScene: Scene, handleEvents?: boolean);
  47475. private _notifyObservers;
  47476. /**
  47477. * Renders the utility layers scene on top of the original scene
  47478. */
  47479. render(): void;
  47480. /**
  47481. * Disposes of the renderer
  47482. */
  47483. dispose(): void;
  47484. private _updateCamera;
  47485. }
  47486. }
  47487. declare module "babylonjs/Gizmos/gizmo" {
  47488. import { Nullable } from "babylonjs/types";
  47489. import { IDisposable } from "babylonjs/scene";
  47490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47491. import { Mesh } from "babylonjs/Meshes/mesh";
  47492. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47493. /**
  47494. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47495. */
  47496. export class Gizmo implements IDisposable {
  47497. /** The utility layer the gizmo will be added to */
  47498. gizmoLayer: UtilityLayerRenderer;
  47499. /**
  47500. * The root mesh of the gizmo
  47501. */
  47502. _rootMesh: Mesh;
  47503. private _attachedMesh;
  47504. /**
  47505. * Ratio for the scale of the gizmo (Default: 1)
  47506. */
  47507. scaleRatio: number;
  47508. /**
  47509. * If a custom mesh has been set (Default: false)
  47510. */
  47511. protected _customMeshSet: boolean;
  47512. /**
  47513. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47514. * * When set, interactions will be enabled
  47515. */
  47516. get attachedMesh(): Nullable<AbstractMesh>;
  47517. set attachedMesh(value: Nullable<AbstractMesh>);
  47518. /**
  47519. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47520. * @param mesh The mesh to replace the default mesh of the gizmo
  47521. */
  47522. setCustomMesh(mesh: Mesh): void;
  47523. /**
  47524. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47525. */
  47526. updateGizmoRotationToMatchAttachedMesh: boolean;
  47527. /**
  47528. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47529. */
  47530. updateGizmoPositionToMatchAttachedMesh: boolean;
  47531. /**
  47532. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47533. */
  47534. updateScale: boolean;
  47535. protected _interactionsEnabled: boolean;
  47536. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47537. private _beforeRenderObserver;
  47538. private _tempVector;
  47539. /**
  47540. * Creates a gizmo
  47541. * @param gizmoLayer The utility layer the gizmo will be added to
  47542. */
  47543. constructor(
  47544. /** The utility layer the gizmo will be added to */
  47545. gizmoLayer?: UtilityLayerRenderer);
  47546. /**
  47547. * Updates the gizmo to match the attached mesh's position/rotation
  47548. */
  47549. protected _update(): void;
  47550. /**
  47551. * Disposes of the gizmo
  47552. */
  47553. dispose(): void;
  47554. }
  47555. }
  47556. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47557. import { Observable } from "babylonjs/Misc/observable";
  47558. import { Nullable } from "babylonjs/types";
  47559. import { Vector3 } from "babylonjs/Maths/math.vector";
  47560. import { Color3 } from "babylonjs/Maths/math.color";
  47561. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47563. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47564. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47565. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47566. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47567. import { Scene } from "babylonjs/scene";
  47568. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47569. /**
  47570. * Single plane drag gizmo
  47571. */
  47572. export class PlaneDragGizmo extends Gizmo {
  47573. /**
  47574. * Drag behavior responsible for the gizmos dragging interactions
  47575. */
  47576. dragBehavior: PointerDragBehavior;
  47577. private _pointerObserver;
  47578. /**
  47579. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47580. */
  47581. snapDistance: number;
  47582. /**
  47583. * Event that fires each time the gizmo snaps to a new location.
  47584. * * snapDistance is the the change in distance
  47585. */
  47586. onSnapObservable: Observable<{
  47587. snapDistance: number;
  47588. }>;
  47589. private _plane;
  47590. private _coloredMaterial;
  47591. private _hoverMaterial;
  47592. private _isEnabled;
  47593. private _parent;
  47594. /** @hidden */
  47595. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47596. /** @hidden */
  47597. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47598. /**
  47599. * Creates a PlaneDragGizmo
  47600. * @param gizmoLayer The utility layer the gizmo will be added to
  47601. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47602. * @param color The color of the gizmo
  47603. */
  47604. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47605. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47606. /**
  47607. * If the gizmo is enabled
  47608. */
  47609. set isEnabled(value: boolean);
  47610. get isEnabled(): boolean;
  47611. /**
  47612. * Disposes of the gizmo
  47613. */
  47614. dispose(): void;
  47615. }
  47616. }
  47617. declare module "babylonjs/Gizmos/positionGizmo" {
  47618. import { Observable } from "babylonjs/Misc/observable";
  47619. import { Nullable } from "babylonjs/types";
  47620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47621. import { Mesh } from "babylonjs/Meshes/mesh";
  47622. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47623. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47624. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47625. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47626. /**
  47627. * Gizmo that enables dragging a mesh along 3 axis
  47628. */
  47629. export class PositionGizmo extends Gizmo {
  47630. /**
  47631. * Internal gizmo used for interactions on the x axis
  47632. */
  47633. xGizmo: AxisDragGizmo;
  47634. /**
  47635. * Internal gizmo used for interactions on the y axis
  47636. */
  47637. yGizmo: AxisDragGizmo;
  47638. /**
  47639. * Internal gizmo used for interactions on the z axis
  47640. */
  47641. zGizmo: AxisDragGizmo;
  47642. /**
  47643. * Internal gizmo used for interactions on the yz plane
  47644. */
  47645. xPlaneGizmo: PlaneDragGizmo;
  47646. /**
  47647. * Internal gizmo used for interactions on the xz plane
  47648. */
  47649. yPlaneGizmo: PlaneDragGizmo;
  47650. /**
  47651. * Internal gizmo used for interactions on the xy plane
  47652. */
  47653. zPlaneGizmo: PlaneDragGizmo;
  47654. /**
  47655. * private variables
  47656. */
  47657. private _meshAttached;
  47658. private _updateGizmoRotationToMatchAttachedMesh;
  47659. private _snapDistance;
  47660. private _scaleRatio;
  47661. /** Fires an event when any of it's sub gizmos are dragged */
  47662. onDragStartObservable: Observable<unknown>;
  47663. /** Fires an event when any of it's sub gizmos are released from dragging */
  47664. onDragEndObservable: Observable<unknown>;
  47665. /**
  47666. * If set to true, planar drag is enabled
  47667. */
  47668. private _planarGizmoEnabled;
  47669. get attachedMesh(): Nullable<AbstractMesh>;
  47670. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47671. /**
  47672. * Creates a PositionGizmo
  47673. * @param gizmoLayer The utility layer the gizmo will be added to
  47674. */
  47675. constructor(gizmoLayer?: UtilityLayerRenderer);
  47676. /**
  47677. * If the planar drag gizmo is enabled
  47678. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47679. */
  47680. set planarGizmoEnabled(value: boolean);
  47681. get planarGizmoEnabled(): boolean;
  47682. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47683. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47684. /**
  47685. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47686. */
  47687. set snapDistance(value: number);
  47688. get snapDistance(): number;
  47689. /**
  47690. * Ratio for the scale of the gizmo (Default: 1)
  47691. */
  47692. set scaleRatio(value: number);
  47693. get scaleRatio(): number;
  47694. /**
  47695. * Disposes of the gizmo
  47696. */
  47697. dispose(): void;
  47698. /**
  47699. * CustomMeshes are not supported by this gizmo
  47700. * @param mesh The mesh to replace the default mesh of the gizmo
  47701. */
  47702. setCustomMesh(mesh: Mesh): void;
  47703. }
  47704. }
  47705. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47706. import { Observable } from "babylonjs/Misc/observable";
  47707. import { Nullable } from "babylonjs/types";
  47708. import { Vector3 } from "babylonjs/Maths/math.vector";
  47709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47711. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47712. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47713. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47714. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47715. import { Scene } from "babylonjs/scene";
  47716. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47717. import { Color3 } from "babylonjs/Maths/math.color";
  47718. /**
  47719. * Single axis drag gizmo
  47720. */
  47721. export class AxisDragGizmo extends Gizmo {
  47722. /**
  47723. * Drag behavior responsible for the gizmos dragging interactions
  47724. */
  47725. dragBehavior: PointerDragBehavior;
  47726. private _pointerObserver;
  47727. /**
  47728. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47729. */
  47730. snapDistance: number;
  47731. /**
  47732. * Event that fires each time the gizmo snaps to a new location.
  47733. * * snapDistance is the the change in distance
  47734. */
  47735. onSnapObservable: Observable<{
  47736. snapDistance: number;
  47737. }>;
  47738. private _isEnabled;
  47739. private _parent;
  47740. private _arrow;
  47741. private _coloredMaterial;
  47742. private _hoverMaterial;
  47743. /** @hidden */
  47744. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47745. /** @hidden */
  47746. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47747. /**
  47748. * Creates an AxisDragGizmo
  47749. * @param gizmoLayer The utility layer the gizmo will be added to
  47750. * @param dragAxis The axis which the gizmo will be able to drag on
  47751. * @param color The color of the gizmo
  47752. */
  47753. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47754. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47755. /**
  47756. * If the gizmo is enabled
  47757. */
  47758. set isEnabled(value: boolean);
  47759. get isEnabled(): boolean;
  47760. /**
  47761. * Disposes of the gizmo
  47762. */
  47763. dispose(): void;
  47764. }
  47765. }
  47766. declare module "babylonjs/Debug/axesViewer" {
  47767. import { Vector3 } from "babylonjs/Maths/math.vector";
  47768. import { Nullable } from "babylonjs/types";
  47769. import { Scene } from "babylonjs/scene";
  47770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47771. /**
  47772. * The Axes viewer will show 3 axes in a specific point in space
  47773. */
  47774. export class AxesViewer {
  47775. private _xAxis;
  47776. private _yAxis;
  47777. private _zAxis;
  47778. private _scaleLinesFactor;
  47779. private _instanced;
  47780. /**
  47781. * Gets the hosting scene
  47782. */
  47783. scene: Scene;
  47784. /**
  47785. * Gets or sets a number used to scale line length
  47786. */
  47787. scaleLines: number;
  47788. /** Gets the node hierarchy used to render x-axis */
  47789. get xAxis(): TransformNode;
  47790. /** Gets the node hierarchy used to render y-axis */
  47791. get yAxis(): TransformNode;
  47792. /** Gets the node hierarchy used to render z-axis */
  47793. get zAxis(): TransformNode;
  47794. /**
  47795. * Creates a new AxesViewer
  47796. * @param scene defines the hosting scene
  47797. * @param scaleLines defines a number used to scale line length (1 by default)
  47798. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47799. * @param xAxis defines the node hierarchy used to render the x-axis
  47800. * @param yAxis defines the node hierarchy used to render the y-axis
  47801. * @param zAxis defines the node hierarchy used to render the z-axis
  47802. */
  47803. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47804. /**
  47805. * Force the viewer to update
  47806. * @param position defines the position of the viewer
  47807. * @param xaxis defines the x axis of the viewer
  47808. * @param yaxis defines the y axis of the viewer
  47809. * @param zaxis defines the z axis of the viewer
  47810. */
  47811. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47812. /**
  47813. * Creates an instance of this axes viewer.
  47814. * @returns a new axes viewer with instanced meshes
  47815. */
  47816. createInstance(): AxesViewer;
  47817. /** Releases resources */
  47818. dispose(): void;
  47819. private static _SetRenderingGroupId;
  47820. }
  47821. }
  47822. declare module "babylonjs/Debug/boneAxesViewer" {
  47823. import { Nullable } from "babylonjs/types";
  47824. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47825. import { Vector3 } from "babylonjs/Maths/math.vector";
  47826. import { Mesh } from "babylonjs/Meshes/mesh";
  47827. import { Bone } from "babylonjs/Bones/bone";
  47828. import { Scene } from "babylonjs/scene";
  47829. /**
  47830. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47831. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47832. */
  47833. export class BoneAxesViewer extends AxesViewer {
  47834. /**
  47835. * Gets or sets the target mesh where to display the axes viewer
  47836. */
  47837. mesh: Nullable<Mesh>;
  47838. /**
  47839. * Gets or sets the target bone where to display the axes viewer
  47840. */
  47841. bone: Nullable<Bone>;
  47842. /** Gets current position */
  47843. pos: Vector3;
  47844. /** Gets direction of X axis */
  47845. xaxis: Vector3;
  47846. /** Gets direction of Y axis */
  47847. yaxis: Vector3;
  47848. /** Gets direction of Z axis */
  47849. zaxis: Vector3;
  47850. /**
  47851. * Creates a new BoneAxesViewer
  47852. * @param scene defines the hosting scene
  47853. * @param bone defines the target bone
  47854. * @param mesh defines the target mesh
  47855. * @param scaleLines defines a scaling factor for line length (1 by default)
  47856. */
  47857. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47858. /**
  47859. * Force the viewer to update
  47860. */
  47861. update(): void;
  47862. /** Releases resources */
  47863. dispose(): void;
  47864. }
  47865. }
  47866. declare module "babylonjs/Debug/debugLayer" {
  47867. import { Scene } from "babylonjs/scene";
  47868. /**
  47869. * Interface used to define scene explorer extensibility option
  47870. */
  47871. export interface IExplorerExtensibilityOption {
  47872. /**
  47873. * Define the option label
  47874. */
  47875. label: string;
  47876. /**
  47877. * Defines the action to execute on click
  47878. */
  47879. action: (entity: any) => void;
  47880. }
  47881. /**
  47882. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47883. */
  47884. export interface IExplorerExtensibilityGroup {
  47885. /**
  47886. * Defines a predicate to test if a given type mut be extended
  47887. */
  47888. predicate: (entity: any) => boolean;
  47889. /**
  47890. * Gets the list of options added to a type
  47891. */
  47892. entries: IExplorerExtensibilityOption[];
  47893. }
  47894. /**
  47895. * Interface used to define the options to use to create the Inspector
  47896. */
  47897. export interface IInspectorOptions {
  47898. /**
  47899. * Display in overlay mode (default: false)
  47900. */
  47901. overlay?: boolean;
  47902. /**
  47903. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47904. */
  47905. globalRoot?: HTMLElement;
  47906. /**
  47907. * Display the Scene explorer
  47908. */
  47909. showExplorer?: boolean;
  47910. /**
  47911. * Display the property inspector
  47912. */
  47913. showInspector?: boolean;
  47914. /**
  47915. * Display in embed mode (both panes on the right)
  47916. */
  47917. embedMode?: boolean;
  47918. /**
  47919. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47920. */
  47921. handleResize?: boolean;
  47922. /**
  47923. * Allow the panes to popup (default: true)
  47924. */
  47925. enablePopup?: boolean;
  47926. /**
  47927. * Allow the panes to be closed by users (default: true)
  47928. */
  47929. enableClose?: boolean;
  47930. /**
  47931. * Optional list of extensibility entries
  47932. */
  47933. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47934. /**
  47935. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47936. */
  47937. inspectorURL?: string;
  47938. /**
  47939. * Optional initial tab (default to DebugLayerTab.Properties)
  47940. */
  47941. initialTab?: DebugLayerTab;
  47942. }
  47943. module "babylonjs/scene" {
  47944. interface Scene {
  47945. /**
  47946. * @hidden
  47947. * Backing field
  47948. */
  47949. _debugLayer: DebugLayer;
  47950. /**
  47951. * Gets the debug layer (aka Inspector) associated with the scene
  47952. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47953. */
  47954. debugLayer: DebugLayer;
  47955. }
  47956. }
  47957. /**
  47958. * Enum of inspector action tab
  47959. */
  47960. export enum DebugLayerTab {
  47961. /**
  47962. * Properties tag (default)
  47963. */
  47964. Properties = 0,
  47965. /**
  47966. * Debug tab
  47967. */
  47968. Debug = 1,
  47969. /**
  47970. * Statistics tab
  47971. */
  47972. Statistics = 2,
  47973. /**
  47974. * Tools tab
  47975. */
  47976. Tools = 3,
  47977. /**
  47978. * Settings tab
  47979. */
  47980. Settings = 4
  47981. }
  47982. /**
  47983. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47984. * what is happening in your scene
  47985. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47986. */
  47987. export class DebugLayer {
  47988. /**
  47989. * Define the url to get the inspector script from.
  47990. * By default it uses the babylonjs CDN.
  47991. * @ignoreNaming
  47992. */
  47993. static InspectorURL: string;
  47994. private _scene;
  47995. private BJSINSPECTOR;
  47996. private _onPropertyChangedObservable?;
  47997. /**
  47998. * Observable triggered when a property is changed through the inspector.
  47999. */
  48000. get onPropertyChangedObservable(): any;
  48001. /**
  48002. * Instantiates a new debug layer.
  48003. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48004. * what is happening in your scene
  48005. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48006. * @param scene Defines the scene to inspect
  48007. */
  48008. constructor(scene: Scene);
  48009. /** Creates the inspector window. */
  48010. private _createInspector;
  48011. /**
  48012. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48013. * @param entity defines the entity to select
  48014. * @param lineContainerTitle defines the specific block to highlight
  48015. */
  48016. select(entity: any, lineContainerTitle?: string): void;
  48017. /** Get the inspector from bundle or global */
  48018. private _getGlobalInspector;
  48019. /**
  48020. * Get if the inspector is visible or not.
  48021. * @returns true if visible otherwise, false
  48022. */
  48023. isVisible(): boolean;
  48024. /**
  48025. * Hide the inspector and close its window.
  48026. */
  48027. hide(): void;
  48028. /**
  48029. * Launch the debugLayer.
  48030. * @param config Define the configuration of the inspector
  48031. * @return a promise fulfilled when the debug layer is visible
  48032. */
  48033. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48034. }
  48035. }
  48036. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48037. import { Nullable } from "babylonjs/types";
  48038. import { Scene } from "babylonjs/scene";
  48039. import { Vector4 } from "babylonjs/Maths/math.vector";
  48040. import { Color4 } from "babylonjs/Maths/math.color";
  48041. import { Mesh } from "babylonjs/Meshes/mesh";
  48042. /**
  48043. * Class containing static functions to help procedurally build meshes
  48044. */
  48045. export class BoxBuilder {
  48046. /**
  48047. * Creates a box mesh
  48048. * * The parameter `size` sets the size (float) of each box side (default 1)
  48049. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48050. * * 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)
  48051. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48055. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48056. * @param name defines the name of the mesh
  48057. * @param options defines the options used to create the mesh
  48058. * @param scene defines the hosting scene
  48059. * @returns the box mesh
  48060. */
  48061. static CreateBox(name: string, options: {
  48062. size?: number;
  48063. width?: number;
  48064. height?: number;
  48065. depth?: number;
  48066. faceUV?: Vector4[];
  48067. faceColors?: Color4[];
  48068. sideOrientation?: number;
  48069. frontUVs?: Vector4;
  48070. backUVs?: Vector4;
  48071. wrap?: boolean;
  48072. topBaseAt?: number;
  48073. bottomBaseAt?: number;
  48074. updatable?: boolean;
  48075. }, scene?: Nullable<Scene>): Mesh;
  48076. }
  48077. }
  48078. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48079. import { Vector4 } from "babylonjs/Maths/math.vector";
  48080. import { Mesh } from "babylonjs/Meshes/mesh";
  48081. import { Scene } from "babylonjs/scene";
  48082. import { Nullable } from "babylonjs/types";
  48083. /**
  48084. * Class containing static functions to help procedurally build meshes
  48085. */
  48086. export class SphereBuilder {
  48087. /**
  48088. * Creates a sphere mesh
  48089. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48090. * * 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`)
  48091. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48092. * * 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
  48093. * * 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)
  48094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48097. * @param name defines the name of the mesh
  48098. * @param options defines the options used to create the mesh
  48099. * @param scene defines the hosting scene
  48100. * @returns the sphere mesh
  48101. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48102. */
  48103. static CreateSphere(name: string, options: {
  48104. segments?: number;
  48105. diameter?: number;
  48106. diameterX?: number;
  48107. diameterY?: number;
  48108. diameterZ?: number;
  48109. arc?: number;
  48110. slice?: number;
  48111. sideOrientation?: number;
  48112. frontUVs?: Vector4;
  48113. backUVs?: Vector4;
  48114. updatable?: boolean;
  48115. }, scene?: Nullable<Scene>): Mesh;
  48116. }
  48117. }
  48118. declare module "babylonjs/Debug/physicsViewer" {
  48119. import { Nullable } from "babylonjs/types";
  48120. import { Scene } from "babylonjs/scene";
  48121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48122. import { Mesh } from "babylonjs/Meshes/mesh";
  48123. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48124. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48125. /**
  48126. * Used to show the physics impostor around the specific mesh
  48127. */
  48128. export class PhysicsViewer {
  48129. /** @hidden */
  48130. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48131. /** @hidden */
  48132. protected _meshes: Array<Nullable<AbstractMesh>>;
  48133. /** @hidden */
  48134. protected _scene: Nullable<Scene>;
  48135. /** @hidden */
  48136. protected _numMeshes: number;
  48137. /** @hidden */
  48138. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48139. private _renderFunction;
  48140. private _utilityLayer;
  48141. private _debugBoxMesh;
  48142. private _debugSphereMesh;
  48143. private _debugCylinderMesh;
  48144. private _debugMaterial;
  48145. private _debugMeshMeshes;
  48146. /**
  48147. * Creates a new PhysicsViewer
  48148. * @param scene defines the hosting scene
  48149. */
  48150. constructor(scene: Scene);
  48151. /** @hidden */
  48152. protected _updateDebugMeshes(): void;
  48153. /**
  48154. * Renders a specified physic impostor
  48155. * @param impostor defines the impostor to render
  48156. * @param targetMesh defines the mesh represented by the impostor
  48157. * @returns the new debug mesh used to render the impostor
  48158. */
  48159. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48160. /**
  48161. * Hides a specified physic impostor
  48162. * @param impostor defines the impostor to hide
  48163. */
  48164. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48165. private _getDebugMaterial;
  48166. private _getDebugBoxMesh;
  48167. private _getDebugSphereMesh;
  48168. private _getDebugCylinderMesh;
  48169. private _getDebugMeshMesh;
  48170. private _getDebugMesh;
  48171. /** Releases all resources */
  48172. dispose(): void;
  48173. }
  48174. }
  48175. declare module "babylonjs/Debug/rayHelper" {
  48176. import { Nullable } from "babylonjs/types";
  48177. import { Ray } from "babylonjs/Culling/ray";
  48178. import { Vector3 } from "babylonjs/Maths/math.vector";
  48179. import { Color3 } from "babylonjs/Maths/math.color";
  48180. import { Scene } from "babylonjs/scene";
  48181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48182. import "babylonjs/Meshes/Builders/linesBuilder";
  48183. /**
  48184. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48185. * in order to better appreciate the issue one might have.
  48186. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48187. */
  48188. export class RayHelper {
  48189. /**
  48190. * Defines the ray we are currently tryin to visualize.
  48191. */
  48192. ray: Nullable<Ray>;
  48193. private _renderPoints;
  48194. private _renderLine;
  48195. private _renderFunction;
  48196. private _scene;
  48197. private _updateToMeshFunction;
  48198. private _attachedToMesh;
  48199. private _meshSpaceDirection;
  48200. private _meshSpaceOrigin;
  48201. /**
  48202. * Helper function to create a colored helper in a scene in one line.
  48203. * @param ray Defines the ray we are currently tryin to visualize
  48204. * @param scene Defines the scene the ray is used in
  48205. * @param color Defines the color we want to see the ray in
  48206. * @returns The newly created ray helper.
  48207. */
  48208. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48209. /**
  48210. * Instantiate a new ray helper.
  48211. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48212. * in order to better appreciate the issue one might have.
  48213. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48214. * @param ray Defines the ray we are currently tryin to visualize
  48215. */
  48216. constructor(ray: Ray);
  48217. /**
  48218. * Shows the ray we are willing to debug.
  48219. * @param scene Defines the scene the ray needs to be rendered in
  48220. * @param color Defines the color the ray needs to be rendered in
  48221. */
  48222. show(scene: Scene, color?: Color3): void;
  48223. /**
  48224. * Hides the ray we are debugging.
  48225. */
  48226. hide(): void;
  48227. private _render;
  48228. /**
  48229. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48230. * @param mesh Defines the mesh we want the helper attached to
  48231. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48232. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48233. * @param length Defines the length of the ray
  48234. */
  48235. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48236. /**
  48237. * Detach the ray helper from the mesh it has previously been attached to.
  48238. */
  48239. detachFromMesh(): void;
  48240. private _updateToMesh;
  48241. /**
  48242. * Dispose the helper and release its associated resources.
  48243. */
  48244. dispose(): void;
  48245. }
  48246. }
  48247. declare module "babylonjs/Debug/skeletonViewer" {
  48248. import { Color3 } from "babylonjs/Maths/math.color";
  48249. import { Scene } from "babylonjs/scene";
  48250. import { Nullable } from "babylonjs/types";
  48251. import { Skeleton } from "babylonjs/Bones/skeleton";
  48252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48253. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48254. /**
  48255. * Class used to render a debug view of a given skeleton
  48256. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48257. */
  48258. export class SkeletonViewer {
  48259. /** defines the skeleton to render */
  48260. skeleton: Skeleton;
  48261. /** defines the mesh attached to the skeleton */
  48262. mesh: AbstractMesh;
  48263. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48264. autoUpdateBonesMatrices: boolean;
  48265. /** defines the rendering group id to use with the viewer */
  48266. renderingGroupId: number;
  48267. /** Gets or sets the color used to render the skeleton */
  48268. color: Color3;
  48269. private _scene;
  48270. private _debugLines;
  48271. private _debugMesh;
  48272. private _isEnabled;
  48273. private _renderFunction;
  48274. private _utilityLayer;
  48275. /**
  48276. * Returns the mesh used to render the bones
  48277. */
  48278. get debugMesh(): Nullable<LinesMesh>;
  48279. /**
  48280. * Creates a new SkeletonViewer
  48281. * @param skeleton defines the skeleton to render
  48282. * @param mesh defines the mesh attached to the skeleton
  48283. * @param scene defines the hosting scene
  48284. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48285. * @param renderingGroupId defines the rendering group id to use with the viewer
  48286. */
  48287. constructor(
  48288. /** defines the skeleton to render */
  48289. skeleton: Skeleton,
  48290. /** defines the mesh attached to the skeleton */
  48291. mesh: AbstractMesh, scene: Scene,
  48292. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48293. autoUpdateBonesMatrices?: boolean,
  48294. /** defines the rendering group id to use with the viewer */
  48295. renderingGroupId?: number);
  48296. /** Gets or sets a boolean indicating if the viewer is enabled */
  48297. set isEnabled(value: boolean);
  48298. get isEnabled(): boolean;
  48299. private _getBonePosition;
  48300. private _getLinesForBonesWithLength;
  48301. private _getLinesForBonesNoLength;
  48302. /** Update the viewer to sync with current skeleton state */
  48303. update(): void;
  48304. /** Release associated resources */
  48305. dispose(): void;
  48306. }
  48307. }
  48308. declare module "babylonjs/Debug/index" {
  48309. export * from "babylonjs/Debug/axesViewer";
  48310. export * from "babylonjs/Debug/boneAxesViewer";
  48311. export * from "babylonjs/Debug/debugLayer";
  48312. export * from "babylonjs/Debug/physicsViewer";
  48313. export * from "babylonjs/Debug/rayHelper";
  48314. export * from "babylonjs/Debug/skeletonViewer";
  48315. }
  48316. declare module "babylonjs/Engines/nullEngine" {
  48317. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48318. import { Scene } from "babylonjs/scene";
  48319. import { Engine } from "babylonjs/Engines/engine";
  48320. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48321. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48322. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48323. import { Effect } from "babylonjs/Materials/effect";
  48324. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48325. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48326. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48327. /**
  48328. * Options to create the null engine
  48329. */
  48330. export class NullEngineOptions {
  48331. /**
  48332. * Render width (Default: 512)
  48333. */
  48334. renderWidth: number;
  48335. /**
  48336. * Render height (Default: 256)
  48337. */
  48338. renderHeight: number;
  48339. /**
  48340. * Texture size (Default: 512)
  48341. */
  48342. textureSize: number;
  48343. /**
  48344. * If delta time between frames should be constant
  48345. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48346. */
  48347. deterministicLockstep: boolean;
  48348. /**
  48349. * Maximum about of steps between frames (Default: 4)
  48350. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48351. */
  48352. lockstepMaxSteps: number;
  48353. }
  48354. /**
  48355. * The null engine class provides support for headless version of babylon.js.
  48356. * This can be used in server side scenario or for testing purposes
  48357. */
  48358. export class NullEngine extends Engine {
  48359. private _options;
  48360. /**
  48361. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48362. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48363. * @returns true if engine is in deterministic lock step mode
  48364. */
  48365. isDeterministicLockStep(): boolean;
  48366. /**
  48367. * Gets the max steps when engine is running in deterministic lock step
  48368. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48369. * @returns the max steps
  48370. */
  48371. getLockstepMaxSteps(): number;
  48372. /**
  48373. * Gets the current hardware scaling level.
  48374. * By default the hardware scaling level is computed from the window device ratio.
  48375. * 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.
  48376. * @returns a number indicating the current hardware scaling level
  48377. */
  48378. getHardwareScalingLevel(): number;
  48379. constructor(options?: NullEngineOptions);
  48380. /**
  48381. * Creates a vertex buffer
  48382. * @param vertices the data for the vertex buffer
  48383. * @returns the new WebGL static buffer
  48384. */
  48385. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48386. /**
  48387. * Creates a new index buffer
  48388. * @param indices defines the content of the index buffer
  48389. * @param updatable defines if the index buffer must be updatable
  48390. * @returns a new webGL buffer
  48391. */
  48392. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48393. /**
  48394. * Clear the current render buffer or the current render target (if any is set up)
  48395. * @param color defines the color to use
  48396. * @param backBuffer defines if the back buffer must be cleared
  48397. * @param depth defines if the depth buffer must be cleared
  48398. * @param stencil defines if the stencil buffer must be cleared
  48399. */
  48400. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48401. /**
  48402. * Gets the current render width
  48403. * @param useScreen defines if screen size must be used (or the current render target if any)
  48404. * @returns a number defining the current render width
  48405. */
  48406. getRenderWidth(useScreen?: boolean): number;
  48407. /**
  48408. * Gets the current render height
  48409. * @param useScreen defines if screen size must be used (or the current render target if any)
  48410. * @returns a number defining the current render height
  48411. */
  48412. getRenderHeight(useScreen?: boolean): number;
  48413. /**
  48414. * Set the WebGL's viewport
  48415. * @param viewport defines the viewport element to be used
  48416. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48417. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48418. */
  48419. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48420. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48421. /**
  48422. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48423. * @param pipelineContext defines the pipeline context to use
  48424. * @param uniformsNames defines the list of uniform names
  48425. * @returns an array of webGL uniform locations
  48426. */
  48427. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48428. /**
  48429. * Gets the lsit of active attributes for a given webGL program
  48430. * @param pipelineContext defines the pipeline context to use
  48431. * @param attributesNames defines the list of attribute names to get
  48432. * @returns an array of indices indicating the offset of each attribute
  48433. */
  48434. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48435. /**
  48436. * Binds an effect to the webGL context
  48437. * @param effect defines the effect to bind
  48438. */
  48439. bindSamplers(effect: Effect): void;
  48440. /**
  48441. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48442. * @param effect defines the effect to activate
  48443. */
  48444. enableEffect(effect: Effect): void;
  48445. /**
  48446. * Set various states to the webGL context
  48447. * @param culling defines backface culling state
  48448. * @param zOffset defines the value to apply to zOffset (0 by default)
  48449. * @param force defines if states must be applied even if cache is up to date
  48450. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48451. */
  48452. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48453. /**
  48454. * Set the value of an uniform to an array of int32
  48455. * @param uniform defines the webGL uniform location where to store the value
  48456. * @param array defines the array of int32 to store
  48457. */
  48458. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48459. /**
  48460. * Set the value of an uniform to an array of int32 (stored as vec2)
  48461. * @param uniform defines the webGL uniform location where to store the value
  48462. * @param array defines the array of int32 to store
  48463. */
  48464. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48465. /**
  48466. * Set the value of an uniform to an array of int32 (stored as vec3)
  48467. * @param uniform defines the webGL uniform location where to store the value
  48468. * @param array defines the array of int32 to store
  48469. */
  48470. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48471. /**
  48472. * Set the value of an uniform to an array of int32 (stored as vec4)
  48473. * @param uniform defines the webGL uniform location where to store the value
  48474. * @param array defines the array of int32 to store
  48475. */
  48476. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48477. /**
  48478. * Set the value of an uniform to an array of float32
  48479. * @param uniform defines the webGL uniform location where to store the value
  48480. * @param array defines the array of float32 to store
  48481. */
  48482. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48483. /**
  48484. * Set the value of an uniform to an array of float32 (stored as vec2)
  48485. * @param uniform defines the webGL uniform location where to store the value
  48486. * @param array defines the array of float32 to store
  48487. */
  48488. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48489. /**
  48490. * Set the value of an uniform to an array of float32 (stored as vec3)
  48491. * @param uniform defines the webGL uniform location where to store the value
  48492. * @param array defines the array of float32 to store
  48493. */
  48494. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48495. /**
  48496. * Set the value of an uniform to an array of float32 (stored as vec4)
  48497. * @param uniform defines the webGL uniform location where to store the value
  48498. * @param array defines the array of float32 to store
  48499. */
  48500. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48501. /**
  48502. * Set the value of an uniform to an array of number
  48503. * @param uniform defines the webGL uniform location where to store the value
  48504. * @param array defines the array of number to store
  48505. */
  48506. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48507. /**
  48508. * Set the value of an uniform to an array of number (stored as vec2)
  48509. * @param uniform defines the webGL uniform location where to store the value
  48510. * @param array defines the array of number to store
  48511. */
  48512. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48513. /**
  48514. * Set the value of an uniform to an array of number (stored as vec3)
  48515. * @param uniform defines the webGL uniform location where to store the value
  48516. * @param array defines the array of number to store
  48517. */
  48518. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48519. /**
  48520. * Set the value of an uniform to an array of number (stored as vec4)
  48521. * @param uniform defines the webGL uniform location where to store the value
  48522. * @param array defines the array of number to store
  48523. */
  48524. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48525. /**
  48526. * Set the value of an uniform to an array of float32 (stored as matrices)
  48527. * @param uniform defines the webGL uniform location where to store the value
  48528. * @param matrices defines the array of float32 to store
  48529. */
  48530. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48531. /**
  48532. * Set the value of an uniform to a matrix (3x3)
  48533. * @param uniform defines the webGL uniform location where to store the value
  48534. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48535. */
  48536. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48537. /**
  48538. * Set the value of an uniform to a matrix (2x2)
  48539. * @param uniform defines the webGL uniform location where to store the value
  48540. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48541. */
  48542. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48543. /**
  48544. * Set the value of an uniform to a number (float)
  48545. * @param uniform defines the webGL uniform location where to store the value
  48546. * @param value defines the float number to store
  48547. */
  48548. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48549. /**
  48550. * Set the value of an uniform to a vec2
  48551. * @param uniform defines the webGL uniform location where to store the value
  48552. * @param x defines the 1st component of the value
  48553. * @param y defines the 2nd component of the value
  48554. */
  48555. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48556. /**
  48557. * Set the value of an uniform to a vec3
  48558. * @param uniform defines the webGL uniform location where to store the value
  48559. * @param x defines the 1st component of the value
  48560. * @param y defines the 2nd component of the value
  48561. * @param z defines the 3rd component of the value
  48562. */
  48563. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48564. /**
  48565. * Set the value of an uniform to a boolean
  48566. * @param uniform defines the webGL uniform location where to store the value
  48567. * @param bool defines the boolean to store
  48568. */
  48569. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48570. /**
  48571. * Set the value of an uniform to a vec4
  48572. * @param uniform defines the webGL uniform location where to store the value
  48573. * @param x defines the 1st component of the value
  48574. * @param y defines the 2nd component of the value
  48575. * @param z defines the 3rd component of the value
  48576. * @param w defines the 4th component of the value
  48577. */
  48578. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48579. /**
  48580. * Sets the current alpha mode
  48581. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48582. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48583. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48584. */
  48585. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48586. /**
  48587. * Bind webGl buffers directly to the webGL context
  48588. * @param vertexBuffers defines the vertex buffer to bind
  48589. * @param indexBuffer defines the index buffer to bind
  48590. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48591. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48592. * @param effect defines the effect associated with the vertex buffer
  48593. */
  48594. bindBuffers(vertexBuffers: {
  48595. [key: string]: VertexBuffer;
  48596. }, indexBuffer: DataBuffer, effect: Effect): void;
  48597. /**
  48598. * Force the entire cache to be cleared
  48599. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48600. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48601. */
  48602. wipeCaches(bruteForce?: boolean): void;
  48603. /**
  48604. * Send a draw order
  48605. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48606. * @param indexStart defines the starting index
  48607. * @param indexCount defines the number of index to draw
  48608. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48609. */
  48610. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48611. /**
  48612. * Draw a list of indexed primitives
  48613. * @param fillMode defines the primitive to use
  48614. * @param indexStart defines the starting index
  48615. * @param indexCount defines the number of index to draw
  48616. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48617. */
  48618. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48619. /**
  48620. * Draw a list of unindexed primitives
  48621. * @param fillMode defines the primitive to use
  48622. * @param verticesStart defines the index of first vertex to draw
  48623. * @param verticesCount defines the count of vertices to draw
  48624. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48625. */
  48626. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48627. /** @hidden */
  48628. _createTexture(): WebGLTexture;
  48629. /** @hidden */
  48630. _releaseTexture(texture: InternalTexture): void;
  48631. /**
  48632. * Usually called from Texture.ts.
  48633. * Passed information to create a WebGLTexture
  48634. * @param urlArg defines a value which contains one of the following:
  48635. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48636. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48637. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48638. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48639. * @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)
  48640. * @param scene needed for loading to the correct scene
  48641. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48642. * @param onLoad optional callback to be called upon successful completion
  48643. * @param onError optional callback to be called upon failure
  48644. * @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
  48645. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48646. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48647. * @param forcedExtension defines the extension to use to pick the right loader
  48648. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48649. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48650. */
  48651. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  48652. /**
  48653. * Creates a new render target texture
  48654. * @param size defines the size of the texture
  48655. * @param options defines the options used to create the texture
  48656. * @returns a new render target texture stored in an InternalTexture
  48657. */
  48658. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48659. /**
  48660. * Update the sampling mode of a given texture
  48661. * @param samplingMode defines the required sampling mode
  48662. * @param texture defines the texture to update
  48663. */
  48664. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48665. /**
  48666. * Binds the frame buffer to the specified texture.
  48667. * @param texture The texture to render to or null for the default canvas
  48668. * @param faceIndex The face of the texture to render to in case of cube texture
  48669. * @param requiredWidth The width of the target to render to
  48670. * @param requiredHeight The height of the target to render to
  48671. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48672. * @param lodLevel defines le lod level to bind to the frame buffer
  48673. */
  48674. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48675. /**
  48676. * Unbind the current render target texture from the webGL context
  48677. * @param texture defines the render target texture to unbind
  48678. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48679. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48680. */
  48681. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48682. /**
  48683. * Creates a dynamic vertex buffer
  48684. * @param vertices the data for the dynamic vertex buffer
  48685. * @returns the new WebGL dynamic buffer
  48686. */
  48687. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48688. /**
  48689. * Update the content of a dynamic texture
  48690. * @param texture defines the texture to update
  48691. * @param canvas defines the canvas containing the source
  48692. * @param invertY defines if data must be stored with Y axis inverted
  48693. * @param premulAlpha defines if alpha is stored as premultiplied
  48694. * @param format defines the format of the data
  48695. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48696. */
  48697. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48698. /**
  48699. * Gets a boolean indicating if all created effects are ready
  48700. * @returns true if all effects are ready
  48701. */
  48702. areAllEffectsReady(): boolean;
  48703. /**
  48704. * @hidden
  48705. * Get the current error code of the webGL context
  48706. * @returns the error code
  48707. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48708. */
  48709. getError(): number;
  48710. /** @hidden */
  48711. _getUnpackAlignement(): number;
  48712. /** @hidden */
  48713. _unpackFlipY(value: boolean): void;
  48714. /**
  48715. * Update a dynamic index buffer
  48716. * @param indexBuffer defines the target index buffer
  48717. * @param indices defines the data to update
  48718. * @param offset defines the offset in the target index buffer where update should start
  48719. */
  48720. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48721. /**
  48722. * Updates a dynamic vertex buffer.
  48723. * @param vertexBuffer the vertex buffer to update
  48724. * @param vertices the data used to update the vertex buffer
  48725. * @param byteOffset the byte offset of the data (optional)
  48726. * @param byteLength the byte length of the data (optional)
  48727. */
  48728. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48729. /** @hidden */
  48730. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48731. /** @hidden */
  48732. _bindTexture(channel: number, texture: InternalTexture): void;
  48733. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48734. /**
  48735. * 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
  48736. */
  48737. releaseEffects(): void;
  48738. displayLoadingUI(): void;
  48739. hideLoadingUI(): void;
  48740. /** @hidden */
  48741. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48742. /** @hidden */
  48743. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48744. /** @hidden */
  48745. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48746. /** @hidden */
  48747. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48748. }
  48749. }
  48750. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48751. import { Nullable, int } from "babylonjs/types";
  48752. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48753. /** @hidden */
  48754. export class _OcclusionDataStorage {
  48755. /** @hidden */
  48756. occlusionInternalRetryCounter: number;
  48757. /** @hidden */
  48758. isOcclusionQueryInProgress: boolean;
  48759. /** @hidden */
  48760. isOccluded: boolean;
  48761. /** @hidden */
  48762. occlusionRetryCount: number;
  48763. /** @hidden */
  48764. occlusionType: number;
  48765. /** @hidden */
  48766. occlusionQueryAlgorithmType: number;
  48767. }
  48768. module "babylonjs/Engines/engine" {
  48769. interface Engine {
  48770. /**
  48771. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48772. * @return the new query
  48773. */
  48774. createQuery(): WebGLQuery;
  48775. /**
  48776. * Delete and release a webGL query
  48777. * @param query defines the query to delete
  48778. * @return the current engine
  48779. */
  48780. deleteQuery(query: WebGLQuery): Engine;
  48781. /**
  48782. * Check if a given query has resolved and got its value
  48783. * @param query defines the query to check
  48784. * @returns true if the query got its value
  48785. */
  48786. isQueryResultAvailable(query: WebGLQuery): boolean;
  48787. /**
  48788. * Gets the value of a given query
  48789. * @param query defines the query to check
  48790. * @returns the value of the query
  48791. */
  48792. getQueryResult(query: WebGLQuery): number;
  48793. /**
  48794. * Initiates an occlusion query
  48795. * @param algorithmType defines the algorithm to use
  48796. * @param query defines the query to use
  48797. * @returns the current engine
  48798. * @see http://doc.babylonjs.com/features/occlusionquery
  48799. */
  48800. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48801. /**
  48802. * Ends an occlusion query
  48803. * @see http://doc.babylonjs.com/features/occlusionquery
  48804. * @param algorithmType defines the algorithm to use
  48805. * @returns the current engine
  48806. */
  48807. endOcclusionQuery(algorithmType: number): Engine;
  48808. /**
  48809. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48810. * Please note that only one query can be issued at a time
  48811. * @returns a time token used to track the time span
  48812. */
  48813. startTimeQuery(): Nullable<_TimeToken>;
  48814. /**
  48815. * Ends a time query
  48816. * @param token defines the token used to measure the time span
  48817. * @returns the time spent (in ns)
  48818. */
  48819. endTimeQuery(token: _TimeToken): int;
  48820. /** @hidden */
  48821. _currentNonTimestampToken: Nullable<_TimeToken>;
  48822. /** @hidden */
  48823. _createTimeQuery(): WebGLQuery;
  48824. /** @hidden */
  48825. _deleteTimeQuery(query: WebGLQuery): void;
  48826. /** @hidden */
  48827. _getGlAlgorithmType(algorithmType: number): number;
  48828. /** @hidden */
  48829. _getTimeQueryResult(query: WebGLQuery): any;
  48830. /** @hidden */
  48831. _getTimeQueryAvailability(query: WebGLQuery): any;
  48832. }
  48833. }
  48834. module "babylonjs/Meshes/abstractMesh" {
  48835. interface AbstractMesh {
  48836. /**
  48837. * Backing filed
  48838. * @hidden
  48839. */
  48840. __occlusionDataStorage: _OcclusionDataStorage;
  48841. /**
  48842. * Access property
  48843. * @hidden
  48844. */
  48845. _occlusionDataStorage: _OcclusionDataStorage;
  48846. /**
  48847. * 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.
  48848. * The default value is -1 which means don't break the query and wait till the result
  48849. * @see http://doc.babylonjs.com/features/occlusionquery
  48850. */
  48851. occlusionRetryCount: number;
  48852. /**
  48853. * 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:
  48854. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48855. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48856. * * 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.
  48857. * @see http://doc.babylonjs.com/features/occlusionquery
  48858. */
  48859. occlusionType: number;
  48860. /**
  48861. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48862. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48863. * * 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.
  48864. * @see http://doc.babylonjs.com/features/occlusionquery
  48865. */
  48866. occlusionQueryAlgorithmType: number;
  48867. /**
  48868. * 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
  48869. * @see http://doc.babylonjs.com/features/occlusionquery
  48870. */
  48871. isOccluded: boolean;
  48872. /**
  48873. * Flag to check the progress status of the query
  48874. * @see http://doc.babylonjs.com/features/occlusionquery
  48875. */
  48876. isOcclusionQueryInProgress: boolean;
  48877. }
  48878. }
  48879. }
  48880. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48881. import { Nullable } from "babylonjs/types";
  48882. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48883. /** @hidden */
  48884. export var _forceTransformFeedbackToBundle: boolean;
  48885. module "babylonjs/Engines/engine" {
  48886. interface Engine {
  48887. /**
  48888. * Creates a webGL transform feedback object
  48889. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48890. * @returns the webGL transform feedback object
  48891. */
  48892. createTransformFeedback(): WebGLTransformFeedback;
  48893. /**
  48894. * Delete a webGL transform feedback object
  48895. * @param value defines the webGL transform feedback object to delete
  48896. */
  48897. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48898. /**
  48899. * Bind a webGL transform feedback object to the webgl context
  48900. * @param value defines the webGL transform feedback object to bind
  48901. */
  48902. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48903. /**
  48904. * Begins a transform feedback operation
  48905. * @param usePoints defines if points or triangles must be used
  48906. */
  48907. beginTransformFeedback(usePoints: boolean): void;
  48908. /**
  48909. * Ends a transform feedback operation
  48910. */
  48911. endTransformFeedback(): void;
  48912. /**
  48913. * Specify the varyings to use with transform feedback
  48914. * @param program defines the associated webGL program
  48915. * @param value defines the list of strings representing the varying names
  48916. */
  48917. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48918. /**
  48919. * Bind a webGL buffer for a transform feedback operation
  48920. * @param value defines the webGL buffer to bind
  48921. */
  48922. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48923. }
  48924. }
  48925. }
  48926. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48927. import { Scene } from "babylonjs/scene";
  48928. import { Engine } from "babylonjs/Engines/engine";
  48929. import { Texture } from "babylonjs/Materials/Textures/texture";
  48930. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48931. import "babylonjs/Engines/Extensions/engine.multiRender";
  48932. /**
  48933. * Creation options of the multi render target texture.
  48934. */
  48935. export interface IMultiRenderTargetOptions {
  48936. /**
  48937. * Define if the texture needs to create mip maps after render.
  48938. */
  48939. generateMipMaps?: boolean;
  48940. /**
  48941. * Define the types of all the draw buffers we want to create
  48942. */
  48943. types?: number[];
  48944. /**
  48945. * Define the sampling modes of all the draw buffers we want to create
  48946. */
  48947. samplingModes?: number[];
  48948. /**
  48949. * Define if a depth buffer is required
  48950. */
  48951. generateDepthBuffer?: boolean;
  48952. /**
  48953. * Define if a stencil buffer is required
  48954. */
  48955. generateStencilBuffer?: boolean;
  48956. /**
  48957. * Define if a depth texture is required instead of a depth buffer
  48958. */
  48959. generateDepthTexture?: boolean;
  48960. /**
  48961. * Define the number of desired draw buffers
  48962. */
  48963. textureCount?: number;
  48964. /**
  48965. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48966. */
  48967. doNotChangeAspectRatio?: boolean;
  48968. /**
  48969. * Define the default type of the buffers we are creating
  48970. */
  48971. defaultType?: number;
  48972. }
  48973. /**
  48974. * A multi render target, like a render target provides the ability to render to a texture.
  48975. * Unlike the render target, it can render to several draw buffers in one draw.
  48976. * This is specially interesting in deferred rendering or for any effects requiring more than
  48977. * just one color from a single pass.
  48978. */
  48979. export class MultiRenderTarget extends RenderTargetTexture {
  48980. private _internalTextures;
  48981. private _textures;
  48982. private _multiRenderTargetOptions;
  48983. /**
  48984. * Get if draw buffers are currently supported by the used hardware and browser.
  48985. */
  48986. get isSupported(): boolean;
  48987. /**
  48988. * Get the list of textures generated by the multi render target.
  48989. */
  48990. get textures(): Texture[];
  48991. /**
  48992. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48993. */
  48994. get depthTexture(): Texture;
  48995. /**
  48996. * Set the wrapping mode on U of all the textures we are rendering to.
  48997. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48998. */
  48999. set wrapU(wrap: number);
  49000. /**
  49001. * Set the wrapping mode on V of all the textures we are rendering to.
  49002. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49003. */
  49004. set wrapV(wrap: number);
  49005. /**
  49006. * Instantiate a new multi render target texture.
  49007. * A multi render target, like a render target provides the ability to render to a texture.
  49008. * Unlike the render target, it can render to several draw buffers in one draw.
  49009. * This is specially interesting in deferred rendering or for any effects requiring more than
  49010. * just one color from a single pass.
  49011. * @param name Define the name of the texture
  49012. * @param size Define the size of the buffers to render to
  49013. * @param count Define the number of target we are rendering into
  49014. * @param scene Define the scene the texture belongs to
  49015. * @param options Define the options used to create the multi render target
  49016. */
  49017. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49018. /** @hidden */
  49019. _rebuild(): void;
  49020. private _createInternalTextures;
  49021. private _createTextures;
  49022. /**
  49023. * Define the number of samples used if MSAA is enabled.
  49024. */
  49025. get samples(): number;
  49026. set samples(value: number);
  49027. /**
  49028. * Resize all the textures in the multi render target.
  49029. * Be carrefull as it will recreate all the data in the new texture.
  49030. * @param size Define the new size
  49031. */
  49032. resize(size: any): void;
  49033. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49034. /**
  49035. * Dispose the render targets and their associated resources
  49036. */
  49037. dispose(): void;
  49038. /**
  49039. * Release all the underlying texture used as draw buffers.
  49040. */
  49041. releaseInternalTextures(): void;
  49042. }
  49043. }
  49044. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49046. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49047. import { Nullable } from "babylonjs/types";
  49048. module "babylonjs/Engines/thinEngine" {
  49049. interface ThinEngine {
  49050. /**
  49051. * Unbind a list of render target textures from the webGL context
  49052. * This is used only when drawBuffer extension or webGL2 are active
  49053. * @param textures defines the render target textures to unbind
  49054. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49055. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49056. */
  49057. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49058. /**
  49059. * Create a multi render target texture
  49060. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49061. * @param size defines the size of the texture
  49062. * @param options defines the creation options
  49063. * @returns the cube texture as an InternalTexture
  49064. */
  49065. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49066. /**
  49067. * Update the sample count for a given multiple render target texture
  49068. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49069. * @param textures defines the textures to update
  49070. * @param samples defines the sample count to set
  49071. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49072. */
  49073. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49074. }
  49075. }
  49076. }
  49077. declare module "babylonjs/Engines/Extensions/engine.views" {
  49078. import { Camera } from "babylonjs/Cameras/camera";
  49079. import { Nullable } from "babylonjs/types";
  49080. /**
  49081. * Class used to define an additional view for the engine
  49082. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49083. */
  49084. export class EngineView {
  49085. /** Defines the canvas where to render the view */
  49086. target: HTMLCanvasElement;
  49087. /** Defines an optional camera used to render the view (will use active camera else) */
  49088. camera?: Camera;
  49089. }
  49090. module "babylonjs/Engines/engine" {
  49091. interface Engine {
  49092. /**
  49093. * Gets or sets the HTML element to use for attaching events
  49094. */
  49095. inputElement: Nullable<HTMLElement>;
  49096. /**
  49097. * Gets the current engine view
  49098. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49099. */
  49100. activeView: Nullable<EngineView>;
  49101. /** Gets or sets the list of views */
  49102. views: EngineView[];
  49103. /**
  49104. * Register a new child canvas
  49105. * @param canvas defines the canvas to register
  49106. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49107. * @returns the associated view
  49108. */
  49109. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49110. /**
  49111. * Remove a registered child canvas
  49112. * @param canvas defines the canvas to remove
  49113. * @returns the current engine
  49114. */
  49115. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49116. }
  49117. }
  49118. }
  49119. declare module "babylonjs/Engines/Extensions/index" {
  49120. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49121. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49122. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49123. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49124. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49125. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49126. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49127. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49128. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49129. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49130. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49131. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49132. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49133. export * from "babylonjs/Engines/Extensions/engine.views";
  49134. }
  49135. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49136. import { Nullable } from "babylonjs/types";
  49137. /**
  49138. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49139. */
  49140. export interface CubeMapInfo {
  49141. /**
  49142. * The pixel array for the front face.
  49143. * This is stored in format, left to right, up to down format.
  49144. */
  49145. front: Nullable<ArrayBufferView>;
  49146. /**
  49147. * The pixel array for the back face.
  49148. * This is stored in format, left to right, up to down format.
  49149. */
  49150. back: Nullable<ArrayBufferView>;
  49151. /**
  49152. * The pixel array for the left face.
  49153. * This is stored in format, left to right, up to down format.
  49154. */
  49155. left: Nullable<ArrayBufferView>;
  49156. /**
  49157. * The pixel array for the right face.
  49158. * This is stored in format, left to right, up to down format.
  49159. */
  49160. right: Nullable<ArrayBufferView>;
  49161. /**
  49162. * The pixel array for the up face.
  49163. * This is stored in format, left to right, up to down format.
  49164. */
  49165. up: Nullable<ArrayBufferView>;
  49166. /**
  49167. * The pixel array for the down face.
  49168. * This is stored in format, left to right, up to down format.
  49169. */
  49170. down: Nullable<ArrayBufferView>;
  49171. /**
  49172. * The size of the cubemap stored.
  49173. *
  49174. * Each faces will be size * size pixels.
  49175. */
  49176. size: number;
  49177. /**
  49178. * The format of the texture.
  49179. *
  49180. * RGBA, RGB.
  49181. */
  49182. format: number;
  49183. /**
  49184. * The type of the texture data.
  49185. *
  49186. * UNSIGNED_INT, FLOAT.
  49187. */
  49188. type: number;
  49189. /**
  49190. * Specifies whether the texture is in gamma space.
  49191. */
  49192. gammaSpace: boolean;
  49193. }
  49194. /**
  49195. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49196. */
  49197. export class PanoramaToCubeMapTools {
  49198. private static FACE_FRONT;
  49199. private static FACE_BACK;
  49200. private static FACE_RIGHT;
  49201. private static FACE_LEFT;
  49202. private static FACE_DOWN;
  49203. private static FACE_UP;
  49204. /**
  49205. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49206. *
  49207. * @param float32Array The source data.
  49208. * @param inputWidth The width of the input panorama.
  49209. * @param inputHeight The height of the input panorama.
  49210. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49211. * @return The cubemap data
  49212. */
  49213. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49214. private static CreateCubemapTexture;
  49215. private static CalcProjectionSpherical;
  49216. }
  49217. }
  49218. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49219. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49221. import { Nullable } from "babylonjs/types";
  49222. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49223. /**
  49224. * Helper class dealing with the extraction of spherical polynomial dataArray
  49225. * from a cube map.
  49226. */
  49227. export class CubeMapToSphericalPolynomialTools {
  49228. private static FileFaces;
  49229. /**
  49230. * Converts a texture to the according Spherical Polynomial data.
  49231. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49232. *
  49233. * @param texture The texture to extract the information from.
  49234. * @return The Spherical Polynomial data.
  49235. */
  49236. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49237. /**
  49238. * Converts a cubemap to the according Spherical Polynomial data.
  49239. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49240. *
  49241. * @param cubeInfo The Cube map to extract the information from.
  49242. * @return The Spherical Polynomial data.
  49243. */
  49244. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49245. }
  49246. }
  49247. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49248. import { Nullable } from "babylonjs/types";
  49249. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49250. module "babylonjs/Materials/Textures/baseTexture" {
  49251. interface BaseTexture {
  49252. /**
  49253. * Get the polynomial representation of the texture data.
  49254. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49255. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49256. */
  49257. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49258. }
  49259. }
  49260. }
  49261. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49262. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49263. /** @hidden */
  49264. export var rgbdEncodePixelShader: {
  49265. name: string;
  49266. shader: string;
  49267. };
  49268. }
  49269. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49270. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49271. /** @hidden */
  49272. export var rgbdDecodePixelShader: {
  49273. name: string;
  49274. shader: string;
  49275. };
  49276. }
  49277. declare module "babylonjs/Misc/environmentTextureTools" {
  49278. import { Nullable } from "babylonjs/types";
  49279. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49280. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49281. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49282. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49283. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49284. import "babylonjs/Shaders/rgbdEncode.fragment";
  49285. import "babylonjs/Shaders/rgbdDecode.fragment";
  49286. /**
  49287. * Raw texture data and descriptor sufficient for WebGL texture upload
  49288. */
  49289. export interface EnvironmentTextureInfo {
  49290. /**
  49291. * Version of the environment map
  49292. */
  49293. version: number;
  49294. /**
  49295. * Width of image
  49296. */
  49297. width: number;
  49298. /**
  49299. * Irradiance information stored in the file.
  49300. */
  49301. irradiance: any;
  49302. /**
  49303. * Specular information stored in the file.
  49304. */
  49305. specular: any;
  49306. }
  49307. /**
  49308. * Defines One Image in the file. It requires only the position in the file
  49309. * as well as the length.
  49310. */
  49311. interface BufferImageData {
  49312. /**
  49313. * Length of the image data.
  49314. */
  49315. length: number;
  49316. /**
  49317. * Position of the data from the null terminator delimiting the end of the JSON.
  49318. */
  49319. position: number;
  49320. }
  49321. /**
  49322. * Defines the specular data enclosed in the file.
  49323. * This corresponds to the version 1 of the data.
  49324. */
  49325. export interface EnvironmentTextureSpecularInfoV1 {
  49326. /**
  49327. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49328. */
  49329. specularDataPosition?: number;
  49330. /**
  49331. * This contains all the images data needed to reconstruct the cubemap.
  49332. */
  49333. mipmaps: Array<BufferImageData>;
  49334. /**
  49335. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49336. */
  49337. lodGenerationScale: number;
  49338. }
  49339. /**
  49340. * Sets of helpers addressing the serialization and deserialization of environment texture
  49341. * stored in a BabylonJS env file.
  49342. * Those files are usually stored as .env files.
  49343. */
  49344. export class EnvironmentTextureTools {
  49345. /**
  49346. * Magic number identifying the env file.
  49347. */
  49348. private static _MagicBytes;
  49349. /**
  49350. * Gets the environment info from an env file.
  49351. * @param data The array buffer containing the .env bytes.
  49352. * @returns the environment file info (the json header) if successfully parsed.
  49353. */
  49354. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49355. /**
  49356. * Creates an environment texture from a loaded cube texture.
  49357. * @param texture defines the cube texture to convert in env file
  49358. * @return a promise containing the environment data if succesfull.
  49359. */
  49360. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49361. /**
  49362. * Creates a JSON representation of the spherical data.
  49363. * @param texture defines the texture containing the polynomials
  49364. * @return the JSON representation of the spherical info
  49365. */
  49366. private static _CreateEnvTextureIrradiance;
  49367. /**
  49368. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49369. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  49370. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49371. * @return the views described by info providing access to the underlying buffer
  49372. */
  49373. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49374. /**
  49375. * Uploads the texture info contained in the env file to the GPU.
  49376. * @param texture defines the internal texture to upload to
  49377. * @param arrayBuffer defines the buffer cotaining the data to load
  49378. * @param info defines the texture info retrieved through the GetEnvInfo method
  49379. * @returns a promise
  49380. */
  49381. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49382. private static _OnImageReadyAsync;
  49383. /**
  49384. * Uploads the levels of image data to the GPU.
  49385. * @param texture defines the internal texture to upload to
  49386. * @param imageData defines the array buffer views of image data [mipmap][face]
  49387. * @returns a promise
  49388. */
  49389. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49390. /**
  49391. * Uploads spherical polynomials information to the texture.
  49392. * @param texture defines the texture we are trying to upload the information to
  49393. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49394. */
  49395. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49396. /** @hidden */
  49397. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49398. }
  49399. }
  49400. declare module "babylonjs/Maths/math.vertexFormat" {
  49401. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49402. /**
  49403. * Contains position and normal vectors for a vertex
  49404. */
  49405. export class PositionNormalVertex {
  49406. /** the position of the vertex (defaut: 0,0,0) */
  49407. position: Vector3;
  49408. /** the normal of the vertex (defaut: 0,1,0) */
  49409. normal: Vector3;
  49410. /**
  49411. * Creates a PositionNormalVertex
  49412. * @param position the position of the vertex (defaut: 0,0,0)
  49413. * @param normal the normal of the vertex (defaut: 0,1,0)
  49414. */
  49415. constructor(
  49416. /** the position of the vertex (defaut: 0,0,0) */
  49417. position?: Vector3,
  49418. /** the normal of the vertex (defaut: 0,1,0) */
  49419. normal?: Vector3);
  49420. /**
  49421. * Clones the PositionNormalVertex
  49422. * @returns the cloned PositionNormalVertex
  49423. */
  49424. clone(): PositionNormalVertex;
  49425. }
  49426. /**
  49427. * Contains position, normal and uv vectors for a vertex
  49428. */
  49429. export class PositionNormalTextureVertex {
  49430. /** the position of the vertex (defaut: 0,0,0) */
  49431. position: Vector3;
  49432. /** the normal of the vertex (defaut: 0,1,0) */
  49433. normal: Vector3;
  49434. /** the uv of the vertex (default: 0,0) */
  49435. uv: Vector2;
  49436. /**
  49437. * Creates a PositionNormalTextureVertex
  49438. * @param position the position of the vertex (defaut: 0,0,0)
  49439. * @param normal the normal of the vertex (defaut: 0,1,0)
  49440. * @param uv the uv of the vertex (default: 0,0)
  49441. */
  49442. constructor(
  49443. /** the position of the vertex (defaut: 0,0,0) */
  49444. position?: Vector3,
  49445. /** the normal of the vertex (defaut: 0,1,0) */
  49446. normal?: Vector3,
  49447. /** the uv of the vertex (default: 0,0) */
  49448. uv?: Vector2);
  49449. /**
  49450. * Clones the PositionNormalTextureVertex
  49451. * @returns the cloned PositionNormalTextureVertex
  49452. */
  49453. clone(): PositionNormalTextureVertex;
  49454. }
  49455. }
  49456. declare module "babylonjs/Maths/math" {
  49457. export * from "babylonjs/Maths/math.axis";
  49458. export * from "babylonjs/Maths/math.color";
  49459. export * from "babylonjs/Maths/math.constants";
  49460. export * from "babylonjs/Maths/math.frustum";
  49461. export * from "babylonjs/Maths/math.path";
  49462. export * from "babylonjs/Maths/math.plane";
  49463. export * from "babylonjs/Maths/math.size";
  49464. export * from "babylonjs/Maths/math.vector";
  49465. export * from "babylonjs/Maths/math.vertexFormat";
  49466. export * from "babylonjs/Maths/math.viewport";
  49467. }
  49468. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49469. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49470. /** @hidden */
  49471. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49472. private _genericAttributeLocation;
  49473. private _varyingLocationCount;
  49474. private _varyingLocationMap;
  49475. private _replacements;
  49476. private _textureCount;
  49477. private _uniforms;
  49478. lineProcessor(line: string): string;
  49479. attributeProcessor(attribute: string): string;
  49480. varyingProcessor(varying: string, isFragment: boolean): string;
  49481. uniformProcessor(uniform: string): string;
  49482. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49483. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49484. }
  49485. }
  49486. declare module "babylonjs/Engines/nativeEngine" {
  49487. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49488. import { Engine } from "babylonjs/Engines/engine";
  49489. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49490. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49492. import { Effect } from "babylonjs/Materials/effect";
  49493. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49494. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49495. import { IColor4Like } from "babylonjs/Maths/math.like";
  49496. import { Scene } from "babylonjs/scene";
  49497. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49498. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49499. /**
  49500. * Container for accessors for natively-stored mesh data buffers.
  49501. */
  49502. class NativeDataBuffer extends DataBuffer {
  49503. /**
  49504. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49505. */
  49506. nativeIndexBuffer?: any;
  49507. /**
  49508. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49509. */
  49510. nativeVertexBuffer?: any;
  49511. }
  49512. /** @hidden */
  49513. class NativeTexture extends InternalTexture {
  49514. getInternalTexture(): InternalTexture;
  49515. getViewCount(): number;
  49516. }
  49517. /** @hidden */
  49518. export class NativeEngine extends Engine {
  49519. private readonly _native;
  49520. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49521. private readonly INVALID_HANDLE;
  49522. getHardwareScalingLevel(): number;
  49523. constructor();
  49524. /**
  49525. * Can be used to override the current requestAnimationFrame requester.
  49526. * @hidden
  49527. */
  49528. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49529. /**
  49530. * Override default engine behavior.
  49531. * @param color
  49532. * @param backBuffer
  49533. * @param depth
  49534. * @param stencil
  49535. */
  49536. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49537. /**
  49538. * Gets host document
  49539. * @returns the host document object
  49540. */
  49541. getHostDocument(): Nullable<Document>;
  49542. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49543. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49544. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49545. recordVertexArrayObject(vertexBuffers: {
  49546. [key: string]: VertexBuffer;
  49547. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49548. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49549. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49550. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49551. /**
  49552. * Draw a list of indexed primitives
  49553. * @param fillMode defines the primitive to use
  49554. * @param indexStart defines the starting index
  49555. * @param indexCount defines the number of index to draw
  49556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49557. */
  49558. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49559. /**
  49560. * Draw a list of unindexed primitives
  49561. * @param fillMode defines the primitive to use
  49562. * @param verticesStart defines the index of first vertex to draw
  49563. * @param verticesCount defines the count of vertices to draw
  49564. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49565. */
  49566. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49567. createPipelineContext(): IPipelineContext;
  49568. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49569. /** @hidden */
  49570. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49571. /** @hidden */
  49572. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49573. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49574. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49575. protected _setProgram(program: WebGLProgram): void;
  49576. _releaseEffect(effect: Effect): void;
  49577. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49578. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49579. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49580. bindSamplers(effect: Effect): void;
  49581. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49582. getRenderWidth(useScreen?: boolean): number;
  49583. getRenderHeight(useScreen?: boolean): number;
  49584. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49585. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49586. /**
  49587. * Set the z offset to apply to current rendering
  49588. * @param value defines the offset to apply
  49589. */
  49590. setZOffset(value: number): void;
  49591. /**
  49592. * Gets the current value of the zOffset
  49593. * @returns the current zOffset state
  49594. */
  49595. getZOffset(): number;
  49596. /**
  49597. * Enable or disable depth buffering
  49598. * @param enable defines the state to set
  49599. */
  49600. setDepthBuffer(enable: boolean): void;
  49601. /**
  49602. * Gets a boolean indicating if depth writing is enabled
  49603. * @returns the current depth writing state
  49604. */
  49605. getDepthWrite(): boolean;
  49606. /**
  49607. * Enable or disable depth writing
  49608. * @param enable defines the state to set
  49609. */
  49610. setDepthWrite(enable: boolean): void;
  49611. /**
  49612. * Enable or disable color writing
  49613. * @param enable defines the state to set
  49614. */
  49615. setColorWrite(enable: boolean): void;
  49616. /**
  49617. * Gets a boolean indicating if color writing is enabled
  49618. * @returns the current color writing state
  49619. */
  49620. getColorWrite(): boolean;
  49621. /**
  49622. * Sets alpha constants used by some alpha blending modes
  49623. * @param r defines the red component
  49624. * @param g defines the green component
  49625. * @param b defines the blue component
  49626. * @param a defines the alpha component
  49627. */
  49628. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49629. /**
  49630. * Sets the current alpha mode
  49631. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49632. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49633. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49634. */
  49635. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49636. /**
  49637. * Gets the current alpha mode
  49638. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49639. * @returns the current alpha mode
  49640. */
  49641. getAlphaMode(): number;
  49642. setInt(uniform: WebGLUniformLocation, int: number): void;
  49643. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49644. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49645. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49646. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49647. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49648. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49649. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49650. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49651. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49652. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49653. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49654. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49655. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49656. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49657. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49658. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49659. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49660. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49661. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49662. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49663. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49664. wipeCaches(bruteForce?: boolean): void;
  49665. _createTexture(): WebGLTexture;
  49666. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49667. /**
  49668. * Usually called from BABYLON.Texture.ts.
  49669. * Passed information to create a WebGLTexture
  49670. * @param urlArg defines a value which contains one of the following:
  49671. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49672. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49673. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49674. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49675. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49676. * @param scene needed for loading to the correct scene
  49677. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49678. * @param onLoad optional callback to be called upon successful completion
  49679. * @param onError optional callback to be called upon failure
  49680. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49681. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49682. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49683. * @param forcedExtension defines the extension to use to pick the right loader
  49684. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49685. */
  49686. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  49687. /**
  49688. * Creates a cube texture
  49689. * @param rootUrl defines the url where the files to load is located
  49690. * @param scene defines the current scene
  49691. * @param files defines the list of files to load (1 per face)
  49692. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49693. * @param onLoad defines an optional callback raised when the texture is loaded
  49694. * @param onError defines an optional callback raised if there is an issue to load the texture
  49695. * @param format defines the format of the data
  49696. * @param forcedExtension defines the extension to use to pick the right loader
  49697. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49698. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49699. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49700. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49701. * @returns the cube texture as an InternalTexture
  49702. */
  49703. 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;
  49704. private _getSamplingFilter;
  49705. private static _GetNativeTextureFormat;
  49706. createRenderTargetTexture(size: number | {
  49707. width: number;
  49708. height: number;
  49709. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49710. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49711. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49712. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49713. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49714. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49715. /**
  49716. * Updates a dynamic vertex buffer.
  49717. * @param vertexBuffer the vertex buffer to update
  49718. * @param data the data used to update the vertex buffer
  49719. * @param byteOffset the byte offset of the data (optional)
  49720. * @param byteLength the byte length of the data (optional)
  49721. */
  49722. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49723. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49724. private _updateAnisotropicLevel;
  49725. private _getAddressMode;
  49726. /** @hidden */
  49727. _bindTexture(channel: number, texture: InternalTexture): void;
  49728. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49729. releaseEffects(): void;
  49730. /** @hidden */
  49731. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49732. /** @hidden */
  49733. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49734. /** @hidden */
  49735. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49736. /** @hidden */
  49737. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49738. }
  49739. }
  49740. declare module "babylonjs/Engines/index" {
  49741. export * from "babylonjs/Engines/constants";
  49742. export * from "babylonjs/Engines/engineCapabilities";
  49743. export * from "babylonjs/Engines/instancingAttributeInfo";
  49744. export * from "babylonjs/Engines/thinEngine";
  49745. export * from "babylonjs/Engines/engine";
  49746. export * from "babylonjs/Engines/engineStore";
  49747. export * from "babylonjs/Engines/nullEngine";
  49748. export * from "babylonjs/Engines/Extensions/index";
  49749. export * from "babylonjs/Engines/IPipelineContext";
  49750. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49751. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49752. export * from "babylonjs/Engines/nativeEngine";
  49753. }
  49754. declare module "babylonjs/Events/clipboardEvents" {
  49755. /**
  49756. * Gather the list of clipboard event types as constants.
  49757. */
  49758. export class ClipboardEventTypes {
  49759. /**
  49760. * The clipboard event is fired when a copy command is active (pressed).
  49761. */
  49762. static readonly COPY: number;
  49763. /**
  49764. * The clipboard event is fired when a cut command is active (pressed).
  49765. */
  49766. static readonly CUT: number;
  49767. /**
  49768. * The clipboard event is fired when a paste command is active (pressed).
  49769. */
  49770. static readonly PASTE: number;
  49771. }
  49772. /**
  49773. * This class is used to store clipboard related info for the onClipboardObservable event.
  49774. */
  49775. export class ClipboardInfo {
  49776. /**
  49777. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49778. */
  49779. type: number;
  49780. /**
  49781. * Defines the related dom event
  49782. */
  49783. event: ClipboardEvent;
  49784. /**
  49785. *Creates an instance of ClipboardInfo.
  49786. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49787. * @param event Defines the related dom event
  49788. */
  49789. constructor(
  49790. /**
  49791. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49792. */
  49793. type: number,
  49794. /**
  49795. * Defines the related dom event
  49796. */
  49797. event: ClipboardEvent);
  49798. /**
  49799. * Get the clipboard event's type from the keycode.
  49800. * @param keyCode Defines the keyCode for the current keyboard event.
  49801. * @return {number}
  49802. */
  49803. static GetTypeFromCharacter(keyCode: number): number;
  49804. }
  49805. }
  49806. declare module "babylonjs/Events/index" {
  49807. export * from "babylonjs/Events/keyboardEvents";
  49808. export * from "babylonjs/Events/pointerEvents";
  49809. export * from "babylonjs/Events/clipboardEvents";
  49810. }
  49811. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49812. import { Scene } from "babylonjs/scene";
  49813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49814. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49815. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49816. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49817. /**
  49818. * Google Daydream controller
  49819. */
  49820. export class DaydreamController extends WebVRController {
  49821. /**
  49822. * Base Url for the controller model.
  49823. */
  49824. static MODEL_BASE_URL: string;
  49825. /**
  49826. * File name for the controller model.
  49827. */
  49828. static MODEL_FILENAME: string;
  49829. /**
  49830. * Gamepad Id prefix used to identify Daydream Controller.
  49831. */
  49832. static readonly GAMEPAD_ID_PREFIX: string;
  49833. /**
  49834. * Creates a new DaydreamController from a gamepad
  49835. * @param vrGamepad the gamepad that the controller should be created from
  49836. */
  49837. constructor(vrGamepad: any);
  49838. /**
  49839. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49840. * @param scene scene in which to add meshes
  49841. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49842. */
  49843. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49844. /**
  49845. * Called once for each button that changed state since the last frame
  49846. * @param buttonIdx Which button index changed
  49847. * @param state New state of the button
  49848. * @param changes Which properties on the state changed since last frame
  49849. */
  49850. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49851. }
  49852. }
  49853. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49854. import { Scene } from "babylonjs/scene";
  49855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49856. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49857. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49858. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49859. /**
  49860. * Gear VR Controller
  49861. */
  49862. export class GearVRController extends WebVRController {
  49863. /**
  49864. * Base Url for the controller model.
  49865. */
  49866. static MODEL_BASE_URL: string;
  49867. /**
  49868. * File name for the controller model.
  49869. */
  49870. static MODEL_FILENAME: string;
  49871. /**
  49872. * Gamepad Id prefix used to identify this controller.
  49873. */
  49874. static readonly GAMEPAD_ID_PREFIX: string;
  49875. private readonly _buttonIndexToObservableNameMap;
  49876. /**
  49877. * Creates a new GearVRController from a gamepad
  49878. * @param vrGamepad the gamepad that the controller should be created from
  49879. */
  49880. constructor(vrGamepad: any);
  49881. /**
  49882. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49883. * @param scene scene in which to add meshes
  49884. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49885. */
  49886. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49887. /**
  49888. * Called once for each button that changed state since the last frame
  49889. * @param buttonIdx Which button index changed
  49890. * @param state New state of the button
  49891. * @param changes Which properties on the state changed since last frame
  49892. */
  49893. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49894. }
  49895. }
  49896. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49897. import { Scene } from "babylonjs/scene";
  49898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49899. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49900. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49901. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49902. /**
  49903. * Generic Controller
  49904. */
  49905. export class GenericController extends WebVRController {
  49906. /**
  49907. * Base Url for the controller model.
  49908. */
  49909. static readonly MODEL_BASE_URL: string;
  49910. /**
  49911. * File name for the controller model.
  49912. */
  49913. static readonly MODEL_FILENAME: string;
  49914. /**
  49915. * Creates a new GenericController from a gamepad
  49916. * @param vrGamepad the gamepad that the controller should be created from
  49917. */
  49918. constructor(vrGamepad: any);
  49919. /**
  49920. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49921. * @param scene scene in which to add meshes
  49922. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49923. */
  49924. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49925. /**
  49926. * Called once for each button that changed state since the last frame
  49927. * @param buttonIdx Which button index changed
  49928. * @param state New state of the button
  49929. * @param changes Which properties on the state changed since last frame
  49930. */
  49931. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49932. }
  49933. }
  49934. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49935. import { Observable } from "babylonjs/Misc/observable";
  49936. import { Scene } from "babylonjs/scene";
  49937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49938. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49939. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49940. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49941. /**
  49942. * Oculus Touch Controller
  49943. */
  49944. export class OculusTouchController extends WebVRController {
  49945. /**
  49946. * Base Url for the controller model.
  49947. */
  49948. static MODEL_BASE_URL: string;
  49949. /**
  49950. * File name for the left controller model.
  49951. */
  49952. static MODEL_LEFT_FILENAME: string;
  49953. /**
  49954. * File name for the right controller model.
  49955. */
  49956. static MODEL_RIGHT_FILENAME: string;
  49957. /**
  49958. * Base Url for the Quest controller model.
  49959. */
  49960. static QUEST_MODEL_BASE_URL: string;
  49961. /**
  49962. * @hidden
  49963. * If the controllers are running on a device that needs the updated Quest controller models
  49964. */
  49965. static _IsQuest: boolean;
  49966. /**
  49967. * Fired when the secondary trigger on this controller is modified
  49968. */
  49969. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49970. /**
  49971. * Fired when the thumb rest on this controller is modified
  49972. */
  49973. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49974. /**
  49975. * Creates a new OculusTouchController from a gamepad
  49976. * @param vrGamepad the gamepad that the controller should be created from
  49977. */
  49978. constructor(vrGamepad: any);
  49979. /**
  49980. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49981. * @param scene scene in which to add meshes
  49982. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49983. */
  49984. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49985. /**
  49986. * Fired when the A button on this controller is modified
  49987. */
  49988. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49989. /**
  49990. * Fired when the B button on this controller is modified
  49991. */
  49992. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49993. /**
  49994. * Fired when the X button on this controller is modified
  49995. */
  49996. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49997. /**
  49998. * Fired when the Y button on this controller is modified
  49999. */
  50000. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50001. /**
  50002. * Called once for each button that changed state since the last frame
  50003. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50004. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50005. * 2) secondary trigger (same)
  50006. * 3) A (right) X (left), touch, pressed = value
  50007. * 4) B / Y
  50008. * 5) thumb rest
  50009. * @param buttonIdx Which button index changed
  50010. * @param state New state of the button
  50011. * @param changes Which properties on the state changed since last frame
  50012. */
  50013. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50014. }
  50015. }
  50016. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50017. import { Scene } from "babylonjs/scene";
  50018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50019. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50020. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50021. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50022. import { Observable } from "babylonjs/Misc/observable";
  50023. /**
  50024. * Vive Controller
  50025. */
  50026. export class ViveController extends WebVRController {
  50027. /**
  50028. * Base Url for the controller model.
  50029. */
  50030. static MODEL_BASE_URL: string;
  50031. /**
  50032. * File name for the controller model.
  50033. */
  50034. static MODEL_FILENAME: string;
  50035. /**
  50036. * Creates a new ViveController from a gamepad
  50037. * @param vrGamepad the gamepad that the controller should be created from
  50038. */
  50039. constructor(vrGamepad: any);
  50040. /**
  50041. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50042. * @param scene scene in which to add meshes
  50043. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50044. */
  50045. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50046. /**
  50047. * Fired when the left button on this controller is modified
  50048. */
  50049. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50050. /**
  50051. * Fired when the right button on this controller is modified
  50052. */
  50053. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50054. /**
  50055. * Fired when the menu button on this controller is modified
  50056. */
  50057. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50058. /**
  50059. * Called once for each button that changed state since the last frame
  50060. * Vive mapping:
  50061. * 0: touchpad
  50062. * 1: trigger
  50063. * 2: left AND right buttons
  50064. * 3: menu button
  50065. * @param buttonIdx Which button index changed
  50066. * @param state New state of the button
  50067. * @param changes Which properties on the state changed since last frame
  50068. */
  50069. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50070. }
  50071. }
  50072. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50073. import { Observable } from "babylonjs/Misc/observable";
  50074. import { Scene } from "babylonjs/scene";
  50075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50076. import { Ray } from "babylonjs/Culling/ray";
  50077. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50078. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50079. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50080. /**
  50081. * Defines the WindowsMotionController object that the state of the windows motion controller
  50082. */
  50083. export class WindowsMotionController extends WebVRController {
  50084. /**
  50085. * The base url used to load the left and right controller models
  50086. */
  50087. static MODEL_BASE_URL: string;
  50088. /**
  50089. * The name of the left controller model file
  50090. */
  50091. static MODEL_LEFT_FILENAME: string;
  50092. /**
  50093. * The name of the right controller model file
  50094. */
  50095. static MODEL_RIGHT_FILENAME: string;
  50096. /**
  50097. * The controller name prefix for this controller type
  50098. */
  50099. static readonly GAMEPAD_ID_PREFIX: string;
  50100. /**
  50101. * The controller id pattern for this controller type
  50102. */
  50103. private static readonly GAMEPAD_ID_PATTERN;
  50104. private _loadedMeshInfo;
  50105. protected readonly _mapping: {
  50106. buttons: string[];
  50107. buttonMeshNames: {
  50108. 'trigger': string;
  50109. 'menu': string;
  50110. 'grip': string;
  50111. 'thumbstick': string;
  50112. 'trackpad': string;
  50113. };
  50114. buttonObservableNames: {
  50115. 'trigger': string;
  50116. 'menu': string;
  50117. 'grip': string;
  50118. 'thumbstick': string;
  50119. 'trackpad': string;
  50120. };
  50121. axisMeshNames: string[];
  50122. pointingPoseMeshName: string;
  50123. };
  50124. /**
  50125. * Fired when the trackpad on this controller is clicked
  50126. */
  50127. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50128. /**
  50129. * Fired when the trackpad on this controller is modified
  50130. */
  50131. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50132. /**
  50133. * The current x and y values of this controller's trackpad
  50134. */
  50135. trackpad: StickValues;
  50136. /**
  50137. * Creates a new WindowsMotionController from a gamepad
  50138. * @param vrGamepad the gamepad that the controller should be created from
  50139. */
  50140. constructor(vrGamepad: any);
  50141. /**
  50142. * Fired when the trigger on this controller is modified
  50143. */
  50144. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50145. /**
  50146. * Fired when the menu button on this controller is modified
  50147. */
  50148. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50149. /**
  50150. * Fired when the grip button on this controller is modified
  50151. */
  50152. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50153. /**
  50154. * Fired when the thumbstick button on this controller is modified
  50155. */
  50156. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50157. /**
  50158. * Fired when the touchpad button on this controller is modified
  50159. */
  50160. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50161. /**
  50162. * Fired when the touchpad values on this controller are modified
  50163. */
  50164. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50165. protected _updateTrackpad(): void;
  50166. /**
  50167. * Called once per frame by the engine.
  50168. */
  50169. update(): void;
  50170. /**
  50171. * Called once for each button that changed state since the last frame
  50172. * @param buttonIdx Which button index changed
  50173. * @param state New state of the button
  50174. * @param changes Which properties on the state changed since last frame
  50175. */
  50176. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50177. /**
  50178. * Moves the buttons on the controller mesh based on their current state
  50179. * @param buttonName the name of the button to move
  50180. * @param buttonValue the value of the button which determines the buttons new position
  50181. */
  50182. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50183. /**
  50184. * Moves the axis on the controller mesh based on its current state
  50185. * @param axis the index of the axis
  50186. * @param axisValue the value of the axis which determines the meshes new position
  50187. * @hidden
  50188. */
  50189. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50190. /**
  50191. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50192. * @param scene scene in which to add meshes
  50193. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50194. */
  50195. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50196. /**
  50197. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50198. * can be transformed by button presses and axes values, based on this._mapping.
  50199. *
  50200. * @param scene scene in which the meshes exist
  50201. * @param meshes list of meshes that make up the controller model to process
  50202. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50203. */
  50204. private processModel;
  50205. private createMeshInfo;
  50206. /**
  50207. * Gets the ray of the controller in the direction the controller is pointing
  50208. * @param length the length the resulting ray should be
  50209. * @returns a ray in the direction the controller is pointing
  50210. */
  50211. getForwardRay(length?: number): Ray;
  50212. /**
  50213. * Disposes of the controller
  50214. */
  50215. dispose(): void;
  50216. }
  50217. /**
  50218. * This class represents a new windows motion controller in XR.
  50219. */
  50220. export class XRWindowsMotionController extends WindowsMotionController {
  50221. /**
  50222. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50223. */
  50224. protected readonly _mapping: {
  50225. buttons: string[];
  50226. buttonMeshNames: {
  50227. 'trigger': string;
  50228. 'menu': string;
  50229. 'grip': string;
  50230. 'thumbstick': string;
  50231. 'trackpad': string;
  50232. };
  50233. buttonObservableNames: {
  50234. 'trigger': string;
  50235. 'menu': string;
  50236. 'grip': string;
  50237. 'thumbstick': string;
  50238. 'trackpad': string;
  50239. };
  50240. axisMeshNames: string[];
  50241. pointingPoseMeshName: string;
  50242. };
  50243. /**
  50244. * Construct a new XR-Based windows motion controller
  50245. *
  50246. * @param gamepadInfo the gamepad object from the browser
  50247. */
  50248. constructor(gamepadInfo: any);
  50249. /**
  50250. * holds the thumbstick values (X,Y)
  50251. */
  50252. thumbstickValues: StickValues;
  50253. /**
  50254. * Fired when the thumbstick on this controller is clicked
  50255. */
  50256. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50257. /**
  50258. * Fired when the thumbstick on this controller is modified
  50259. */
  50260. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50261. /**
  50262. * Fired when the touchpad button on this controller is modified
  50263. */
  50264. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50265. /**
  50266. * Fired when the touchpad values on this controller are modified
  50267. */
  50268. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50269. /**
  50270. * Fired when the thumbstick button on this controller is modified
  50271. * here to prevent breaking changes
  50272. */
  50273. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50274. /**
  50275. * updating the thumbstick(!) and not the trackpad.
  50276. * This is named this way due to the difference between WebVR and XR and to avoid
  50277. * changing the parent class.
  50278. */
  50279. protected _updateTrackpad(): void;
  50280. /**
  50281. * Disposes the class with joy
  50282. */
  50283. dispose(): void;
  50284. }
  50285. }
  50286. declare module "babylonjs/Gamepads/Controllers/index" {
  50287. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50288. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50289. export * from "babylonjs/Gamepads/Controllers/genericController";
  50290. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50291. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50292. export * from "babylonjs/Gamepads/Controllers/viveController";
  50293. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50294. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50295. }
  50296. declare module "babylonjs/Gamepads/index" {
  50297. export * from "babylonjs/Gamepads/Controllers/index";
  50298. export * from "babylonjs/Gamepads/gamepad";
  50299. export * from "babylonjs/Gamepads/gamepadManager";
  50300. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50301. export * from "babylonjs/Gamepads/xboxGamepad";
  50302. export * from "babylonjs/Gamepads/dualShockGamepad";
  50303. }
  50304. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50305. import { Scene } from "babylonjs/scene";
  50306. import { Vector4 } from "babylonjs/Maths/math.vector";
  50307. import { Color4 } from "babylonjs/Maths/math.color";
  50308. import { Mesh } from "babylonjs/Meshes/mesh";
  50309. import { Nullable } from "babylonjs/types";
  50310. /**
  50311. * Class containing static functions to help procedurally build meshes
  50312. */
  50313. export class PolyhedronBuilder {
  50314. /**
  50315. * Creates a polyhedron mesh
  50316. * * 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
  50317. * * The parameter `size` (positive float, default 1) sets the polygon size
  50318. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50319. * * 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`
  50320. * * 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
  50321. * * 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)`)
  50322. * * 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
  50323. * * 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
  50324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50327. * @param name defines the name of the mesh
  50328. * @param options defines the options used to create the mesh
  50329. * @param scene defines the hosting scene
  50330. * @returns the polyhedron mesh
  50331. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50332. */
  50333. static CreatePolyhedron(name: string, options: {
  50334. type?: number;
  50335. size?: number;
  50336. sizeX?: number;
  50337. sizeY?: number;
  50338. sizeZ?: number;
  50339. custom?: any;
  50340. faceUV?: Vector4[];
  50341. faceColors?: Color4[];
  50342. flat?: boolean;
  50343. updatable?: boolean;
  50344. sideOrientation?: number;
  50345. frontUVs?: Vector4;
  50346. backUVs?: Vector4;
  50347. }, scene?: Nullable<Scene>): Mesh;
  50348. }
  50349. }
  50350. declare module "babylonjs/Gizmos/scaleGizmo" {
  50351. import { Observable } from "babylonjs/Misc/observable";
  50352. import { Nullable } from "babylonjs/types";
  50353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50354. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50355. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50356. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50357. /**
  50358. * Gizmo that enables scaling a mesh along 3 axis
  50359. */
  50360. export class ScaleGizmo extends Gizmo {
  50361. /**
  50362. * Internal gizmo used for interactions on the x axis
  50363. */
  50364. xGizmo: AxisScaleGizmo;
  50365. /**
  50366. * Internal gizmo used for interactions on the y axis
  50367. */
  50368. yGizmo: AxisScaleGizmo;
  50369. /**
  50370. * Internal gizmo used for interactions on the z axis
  50371. */
  50372. zGizmo: AxisScaleGizmo;
  50373. /**
  50374. * Internal gizmo used to scale all axis equally
  50375. */
  50376. uniformScaleGizmo: AxisScaleGizmo;
  50377. private _meshAttached;
  50378. private _updateGizmoRotationToMatchAttachedMesh;
  50379. private _snapDistance;
  50380. private _scaleRatio;
  50381. private _uniformScalingMesh;
  50382. private _octahedron;
  50383. private _sensitivity;
  50384. /** Fires an event when any of it's sub gizmos are dragged */
  50385. onDragStartObservable: Observable<unknown>;
  50386. /** Fires an event when any of it's sub gizmos are released from dragging */
  50387. onDragEndObservable: Observable<unknown>;
  50388. get attachedMesh(): Nullable<AbstractMesh>;
  50389. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50390. /**
  50391. * Creates a ScaleGizmo
  50392. * @param gizmoLayer The utility layer the gizmo will be added to
  50393. */
  50394. constructor(gizmoLayer?: UtilityLayerRenderer);
  50395. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50396. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50397. /**
  50398. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50399. */
  50400. set snapDistance(value: number);
  50401. get snapDistance(): number;
  50402. /**
  50403. * Ratio for the scale of the gizmo (Default: 1)
  50404. */
  50405. set scaleRatio(value: number);
  50406. get scaleRatio(): number;
  50407. /**
  50408. * Sensitivity factor for dragging (Default: 1)
  50409. */
  50410. set sensitivity(value: number);
  50411. get sensitivity(): number;
  50412. /**
  50413. * Disposes of the gizmo
  50414. */
  50415. dispose(): void;
  50416. }
  50417. }
  50418. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50419. import { Observable } from "babylonjs/Misc/observable";
  50420. import { Nullable } from "babylonjs/types";
  50421. import { Vector3 } from "babylonjs/Maths/math.vector";
  50422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50423. import { Mesh } from "babylonjs/Meshes/mesh";
  50424. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50425. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50426. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50427. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50428. import { Color3 } from "babylonjs/Maths/math.color";
  50429. /**
  50430. * Single axis scale gizmo
  50431. */
  50432. export class AxisScaleGizmo extends Gizmo {
  50433. /**
  50434. * Drag behavior responsible for the gizmos dragging interactions
  50435. */
  50436. dragBehavior: PointerDragBehavior;
  50437. private _pointerObserver;
  50438. /**
  50439. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50440. */
  50441. snapDistance: number;
  50442. /**
  50443. * Event that fires each time the gizmo snaps to a new location.
  50444. * * snapDistance is the the change in distance
  50445. */
  50446. onSnapObservable: Observable<{
  50447. snapDistance: number;
  50448. }>;
  50449. /**
  50450. * If the scaling operation should be done on all axis (default: false)
  50451. */
  50452. uniformScaling: boolean;
  50453. /**
  50454. * Custom sensitivity value for the drag strength
  50455. */
  50456. sensitivity: number;
  50457. private _isEnabled;
  50458. private _parent;
  50459. private _arrow;
  50460. private _coloredMaterial;
  50461. private _hoverMaterial;
  50462. /**
  50463. * Creates an AxisScaleGizmo
  50464. * @param gizmoLayer The utility layer the gizmo will be added to
  50465. * @param dragAxis The axis which the gizmo will be able to scale on
  50466. * @param color The color of the gizmo
  50467. */
  50468. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50469. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50470. /**
  50471. * If the gizmo is enabled
  50472. */
  50473. set isEnabled(value: boolean);
  50474. get isEnabled(): boolean;
  50475. /**
  50476. * Disposes of the gizmo
  50477. */
  50478. dispose(): void;
  50479. /**
  50480. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50481. * @param mesh The mesh to replace the default mesh of the gizmo
  50482. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50483. */
  50484. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50485. }
  50486. }
  50487. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50488. import { Observable } from "babylonjs/Misc/observable";
  50489. import { Nullable } from "babylonjs/types";
  50490. import { Vector3 } from "babylonjs/Maths/math.vector";
  50491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50492. import { Mesh } from "babylonjs/Meshes/mesh";
  50493. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50494. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50495. import { Color3 } from "babylonjs/Maths/math.color";
  50496. import "babylonjs/Meshes/Builders/boxBuilder";
  50497. /**
  50498. * Bounding box gizmo
  50499. */
  50500. export class BoundingBoxGizmo extends Gizmo {
  50501. private _lineBoundingBox;
  50502. private _rotateSpheresParent;
  50503. private _scaleBoxesParent;
  50504. private _boundingDimensions;
  50505. private _renderObserver;
  50506. private _pointerObserver;
  50507. private _scaleDragSpeed;
  50508. private _tmpQuaternion;
  50509. private _tmpVector;
  50510. private _tmpRotationMatrix;
  50511. /**
  50512. * 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)
  50513. */
  50514. ignoreChildren: boolean;
  50515. /**
  50516. * 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)
  50517. */
  50518. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50519. /**
  50520. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50521. */
  50522. rotationSphereSize: number;
  50523. /**
  50524. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50525. */
  50526. scaleBoxSize: number;
  50527. /**
  50528. * 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)
  50529. */
  50530. fixedDragMeshScreenSize: boolean;
  50531. /**
  50532. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50533. */
  50534. fixedDragMeshScreenSizeDistanceFactor: number;
  50535. /**
  50536. * Fired when a rotation sphere or scale box is dragged
  50537. */
  50538. onDragStartObservable: Observable<{}>;
  50539. /**
  50540. * Fired when a scale box is dragged
  50541. */
  50542. onScaleBoxDragObservable: Observable<{}>;
  50543. /**
  50544. * Fired when a scale box drag is ended
  50545. */
  50546. onScaleBoxDragEndObservable: Observable<{}>;
  50547. /**
  50548. * Fired when a rotation sphere is dragged
  50549. */
  50550. onRotationSphereDragObservable: Observable<{}>;
  50551. /**
  50552. * Fired when a rotation sphere drag is ended
  50553. */
  50554. onRotationSphereDragEndObservable: Observable<{}>;
  50555. /**
  50556. * 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)
  50557. */
  50558. scalePivot: Nullable<Vector3>;
  50559. /**
  50560. * Mesh used as a pivot to rotate the attached mesh
  50561. */
  50562. private _anchorMesh;
  50563. private _existingMeshScale;
  50564. private _dragMesh;
  50565. private pointerDragBehavior;
  50566. private coloredMaterial;
  50567. private hoverColoredMaterial;
  50568. /**
  50569. * Sets the color of the bounding box gizmo
  50570. * @param color the color to set
  50571. */
  50572. setColor(color: Color3): void;
  50573. /**
  50574. * Creates an BoundingBoxGizmo
  50575. * @param gizmoLayer The utility layer the gizmo will be added to
  50576. * @param color The color of the gizmo
  50577. */
  50578. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50579. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50580. private _selectNode;
  50581. /**
  50582. * Updates the bounding box information for the Gizmo
  50583. */
  50584. updateBoundingBox(): void;
  50585. private _updateRotationSpheres;
  50586. private _updateScaleBoxes;
  50587. /**
  50588. * Enables rotation on the specified axis and disables rotation on the others
  50589. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50590. */
  50591. setEnabledRotationAxis(axis: string): void;
  50592. /**
  50593. * Enables/disables scaling
  50594. * @param enable if scaling should be enabled
  50595. */
  50596. setEnabledScaling(enable: boolean): void;
  50597. private _updateDummy;
  50598. /**
  50599. * Enables a pointer drag behavior on the bounding box of the gizmo
  50600. */
  50601. enableDragBehavior(): void;
  50602. /**
  50603. * Disposes of the gizmo
  50604. */
  50605. dispose(): void;
  50606. /**
  50607. * 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)
  50608. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50609. * @returns the bounding box mesh with the passed in mesh as a child
  50610. */
  50611. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50612. /**
  50613. * CustomMeshes are not supported by this gizmo
  50614. * @param mesh The mesh to replace the default mesh of the gizmo
  50615. */
  50616. setCustomMesh(mesh: Mesh): void;
  50617. }
  50618. }
  50619. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50620. import { Observable } from "babylonjs/Misc/observable";
  50621. import { Nullable } from "babylonjs/types";
  50622. import { Vector3 } from "babylonjs/Maths/math.vector";
  50623. import { Color3 } from "babylonjs/Maths/math.color";
  50624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50625. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50626. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50627. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50628. import "babylonjs/Meshes/Builders/linesBuilder";
  50629. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50630. /**
  50631. * Single plane rotation gizmo
  50632. */
  50633. export class PlaneRotationGizmo extends Gizmo {
  50634. /**
  50635. * Drag behavior responsible for the gizmos dragging interactions
  50636. */
  50637. dragBehavior: PointerDragBehavior;
  50638. private _pointerObserver;
  50639. /**
  50640. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50641. */
  50642. snapDistance: number;
  50643. /**
  50644. * Event that fires each time the gizmo snaps to a new location.
  50645. * * snapDistance is the the change in distance
  50646. */
  50647. onSnapObservable: Observable<{
  50648. snapDistance: number;
  50649. }>;
  50650. private _isEnabled;
  50651. private _parent;
  50652. /**
  50653. * Creates a PlaneRotationGizmo
  50654. * @param gizmoLayer The utility layer the gizmo will be added to
  50655. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50656. * @param color The color of the gizmo
  50657. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50658. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50659. */
  50660. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50661. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50662. /**
  50663. * If the gizmo is enabled
  50664. */
  50665. set isEnabled(value: boolean);
  50666. get isEnabled(): boolean;
  50667. /**
  50668. * Disposes of the gizmo
  50669. */
  50670. dispose(): void;
  50671. }
  50672. }
  50673. declare module "babylonjs/Gizmos/rotationGizmo" {
  50674. import { Observable } from "babylonjs/Misc/observable";
  50675. import { Nullable } from "babylonjs/types";
  50676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50677. import { Mesh } from "babylonjs/Meshes/mesh";
  50678. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50679. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50680. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50681. /**
  50682. * Gizmo that enables rotating a mesh along 3 axis
  50683. */
  50684. export class RotationGizmo extends Gizmo {
  50685. /**
  50686. * Internal gizmo used for interactions on the x axis
  50687. */
  50688. xGizmo: PlaneRotationGizmo;
  50689. /**
  50690. * Internal gizmo used for interactions on the y axis
  50691. */
  50692. yGizmo: PlaneRotationGizmo;
  50693. /**
  50694. * Internal gizmo used for interactions on the z axis
  50695. */
  50696. zGizmo: PlaneRotationGizmo;
  50697. /** Fires an event when any of it's sub gizmos are dragged */
  50698. onDragStartObservable: Observable<unknown>;
  50699. /** Fires an event when any of it's sub gizmos are released from dragging */
  50700. onDragEndObservable: Observable<unknown>;
  50701. private _meshAttached;
  50702. get attachedMesh(): Nullable<AbstractMesh>;
  50703. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50704. /**
  50705. * Creates a RotationGizmo
  50706. * @param gizmoLayer The utility layer the gizmo will be added to
  50707. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50708. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50709. */
  50710. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50711. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50712. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50713. /**
  50714. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50715. */
  50716. set snapDistance(value: number);
  50717. get snapDistance(): number;
  50718. /**
  50719. * Ratio for the scale of the gizmo (Default: 1)
  50720. */
  50721. set scaleRatio(value: number);
  50722. get scaleRatio(): number;
  50723. /**
  50724. * Disposes of the gizmo
  50725. */
  50726. dispose(): void;
  50727. /**
  50728. * CustomMeshes are not supported by this gizmo
  50729. * @param mesh The mesh to replace the default mesh of the gizmo
  50730. */
  50731. setCustomMesh(mesh: Mesh): void;
  50732. }
  50733. }
  50734. declare module "babylonjs/Gizmos/gizmoManager" {
  50735. import { Observable } from "babylonjs/Misc/observable";
  50736. import { Nullable } from "babylonjs/types";
  50737. import { Scene, IDisposable } from "babylonjs/scene";
  50738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50739. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50740. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50741. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50742. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50743. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50744. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50745. /**
  50746. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50747. */
  50748. export class GizmoManager implements IDisposable {
  50749. private scene;
  50750. /**
  50751. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50752. */
  50753. gizmos: {
  50754. positionGizmo: Nullable<PositionGizmo>;
  50755. rotationGizmo: Nullable<RotationGizmo>;
  50756. scaleGizmo: Nullable<ScaleGizmo>;
  50757. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50758. };
  50759. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50760. clearGizmoOnEmptyPointerEvent: boolean;
  50761. /** Fires an event when the manager is attached to a mesh */
  50762. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50763. private _gizmosEnabled;
  50764. private _pointerObserver;
  50765. private _attachedMesh;
  50766. private _boundingBoxColor;
  50767. private _defaultUtilityLayer;
  50768. private _defaultKeepDepthUtilityLayer;
  50769. /**
  50770. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50771. */
  50772. boundingBoxDragBehavior: SixDofDragBehavior;
  50773. /**
  50774. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50775. */
  50776. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50777. /**
  50778. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50779. */
  50780. usePointerToAttachGizmos: boolean;
  50781. /**
  50782. * Utility layer that the bounding box gizmo belongs to
  50783. */
  50784. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50785. /**
  50786. * Utility layer that all gizmos besides bounding box belong to
  50787. */
  50788. get utilityLayer(): UtilityLayerRenderer;
  50789. /**
  50790. * Instatiates a gizmo manager
  50791. * @param scene the scene to overlay the gizmos on top of
  50792. */
  50793. constructor(scene: Scene);
  50794. /**
  50795. * Attaches a set of gizmos to the specified mesh
  50796. * @param mesh The mesh the gizmo's should be attached to
  50797. */
  50798. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50799. /**
  50800. * If the position gizmo is enabled
  50801. */
  50802. set positionGizmoEnabled(value: boolean);
  50803. get positionGizmoEnabled(): boolean;
  50804. /**
  50805. * If the rotation gizmo is enabled
  50806. */
  50807. set rotationGizmoEnabled(value: boolean);
  50808. get rotationGizmoEnabled(): boolean;
  50809. /**
  50810. * If the scale gizmo is enabled
  50811. */
  50812. set scaleGizmoEnabled(value: boolean);
  50813. get scaleGizmoEnabled(): boolean;
  50814. /**
  50815. * If the boundingBox gizmo is enabled
  50816. */
  50817. set boundingBoxGizmoEnabled(value: boolean);
  50818. get boundingBoxGizmoEnabled(): boolean;
  50819. /**
  50820. * Disposes of the gizmo manager
  50821. */
  50822. dispose(): void;
  50823. }
  50824. }
  50825. declare module "babylonjs/Lights/directionalLight" {
  50826. import { Camera } from "babylonjs/Cameras/camera";
  50827. import { Scene } from "babylonjs/scene";
  50828. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50830. import { Light } from "babylonjs/Lights/light";
  50831. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50832. import { Effect } from "babylonjs/Materials/effect";
  50833. /**
  50834. * A directional light is defined by a direction (what a surprise!).
  50835. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50836. * 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.
  50837. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50838. */
  50839. export class DirectionalLight extends ShadowLight {
  50840. private _shadowFrustumSize;
  50841. /**
  50842. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50843. */
  50844. get shadowFrustumSize(): number;
  50845. /**
  50846. * Specifies a fix frustum size for the shadow generation.
  50847. */
  50848. set shadowFrustumSize(value: number);
  50849. private _shadowOrthoScale;
  50850. /**
  50851. * Gets the shadow projection scale against the optimal computed one.
  50852. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50853. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50854. */
  50855. get shadowOrthoScale(): number;
  50856. /**
  50857. * Sets the shadow projection scale against the optimal computed one.
  50858. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50859. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50860. */
  50861. set shadowOrthoScale(value: number);
  50862. /**
  50863. * Automatically compute the projection matrix to best fit (including all the casters)
  50864. * on each frame.
  50865. */
  50866. autoUpdateExtends: boolean;
  50867. /**
  50868. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50869. * on each frame. autoUpdateExtends must be set to true for this to work
  50870. */
  50871. autoCalcShadowZBounds: boolean;
  50872. private _orthoLeft;
  50873. private _orthoRight;
  50874. private _orthoTop;
  50875. private _orthoBottom;
  50876. /**
  50877. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50878. * The directional light is emitted from everywhere in the given direction.
  50879. * It can cast shadows.
  50880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50881. * @param name The friendly name of the light
  50882. * @param direction The direction of the light
  50883. * @param scene The scene the light belongs to
  50884. */
  50885. constructor(name: string, direction: Vector3, scene: Scene);
  50886. /**
  50887. * Returns the string "DirectionalLight".
  50888. * @return The class name
  50889. */
  50890. getClassName(): string;
  50891. /**
  50892. * Returns the integer 1.
  50893. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50894. */
  50895. getTypeID(): number;
  50896. /**
  50897. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50898. * Returns the DirectionalLight Shadow projection matrix.
  50899. */
  50900. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50901. /**
  50902. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50903. * Returns the DirectionalLight Shadow projection matrix.
  50904. */
  50905. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50906. /**
  50907. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50908. * Returns the DirectionalLight Shadow projection matrix.
  50909. */
  50910. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50911. protected _buildUniformLayout(): void;
  50912. /**
  50913. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50914. * @param effect The effect to update
  50915. * @param lightIndex The index of the light in the effect to update
  50916. * @returns The directional light
  50917. */
  50918. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50919. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50920. /**
  50921. * Gets the minZ used for shadow according to both the scene and the light.
  50922. *
  50923. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50924. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50925. * @param activeCamera The camera we are returning the min for
  50926. * @returns the depth min z
  50927. */
  50928. getDepthMinZ(activeCamera: Camera): number;
  50929. /**
  50930. * Gets the maxZ used for shadow according to both the scene and the light.
  50931. *
  50932. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50933. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50934. * @param activeCamera The camera we are returning the max for
  50935. * @returns the depth max z
  50936. */
  50937. getDepthMaxZ(activeCamera: Camera): number;
  50938. /**
  50939. * Prepares the list of defines specific to the light type.
  50940. * @param defines the list of defines
  50941. * @param lightIndex defines the index of the light for the effect
  50942. */
  50943. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50944. }
  50945. }
  50946. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50947. import { Mesh } from "babylonjs/Meshes/mesh";
  50948. /**
  50949. * Class containing static functions to help procedurally build meshes
  50950. */
  50951. export class HemisphereBuilder {
  50952. /**
  50953. * Creates a hemisphere mesh
  50954. * @param name defines the name of the mesh
  50955. * @param options defines the options used to create the mesh
  50956. * @param scene defines the hosting scene
  50957. * @returns the hemisphere mesh
  50958. */
  50959. static CreateHemisphere(name: string, options: {
  50960. segments?: number;
  50961. diameter?: number;
  50962. sideOrientation?: number;
  50963. }, scene: any): Mesh;
  50964. }
  50965. }
  50966. declare module "babylonjs/Lights/spotLight" {
  50967. import { Nullable } from "babylonjs/types";
  50968. import { Scene } from "babylonjs/scene";
  50969. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50971. import { Effect } from "babylonjs/Materials/effect";
  50972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50973. import { Light } from "babylonjs/Lights/light";
  50974. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50975. /**
  50976. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50977. * These values define a cone of light starting from the position, emitting toward the direction.
  50978. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50979. * and the exponent defines the speed of the decay of the light with distance (reach).
  50980. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50981. */
  50982. export class SpotLight extends ShadowLight {
  50983. private _angle;
  50984. private _innerAngle;
  50985. private _cosHalfAngle;
  50986. private _lightAngleScale;
  50987. private _lightAngleOffset;
  50988. /**
  50989. * Gets the cone angle of the spot light in Radians.
  50990. */
  50991. get angle(): number;
  50992. /**
  50993. * Sets the cone angle of the spot light in Radians.
  50994. */
  50995. set angle(value: number);
  50996. /**
  50997. * Only used in gltf falloff mode, this defines the angle where
  50998. * the directional falloff will start before cutting at angle which could be seen
  50999. * as outer angle.
  51000. */
  51001. get innerAngle(): number;
  51002. /**
  51003. * Only used in gltf falloff mode, this defines the angle where
  51004. * the directional falloff will start before cutting at angle which could be seen
  51005. * as outer angle.
  51006. */
  51007. set innerAngle(value: number);
  51008. private _shadowAngleScale;
  51009. /**
  51010. * Allows scaling the angle of the light for shadow generation only.
  51011. */
  51012. get shadowAngleScale(): number;
  51013. /**
  51014. * Allows scaling the angle of the light for shadow generation only.
  51015. */
  51016. set shadowAngleScale(value: number);
  51017. /**
  51018. * The light decay speed with the distance from the emission spot.
  51019. */
  51020. exponent: number;
  51021. private _projectionTextureMatrix;
  51022. /**
  51023. * Allows reading the projecton texture
  51024. */
  51025. get projectionTextureMatrix(): Matrix;
  51026. protected _projectionTextureLightNear: number;
  51027. /**
  51028. * Gets the near clip of the Spotlight for texture projection.
  51029. */
  51030. get projectionTextureLightNear(): number;
  51031. /**
  51032. * Sets the near clip of the Spotlight for texture projection.
  51033. */
  51034. set projectionTextureLightNear(value: number);
  51035. protected _projectionTextureLightFar: number;
  51036. /**
  51037. * Gets the far clip of the Spotlight for texture projection.
  51038. */
  51039. get projectionTextureLightFar(): number;
  51040. /**
  51041. * Sets the far clip of the Spotlight for texture projection.
  51042. */
  51043. set projectionTextureLightFar(value: number);
  51044. protected _projectionTextureUpDirection: Vector3;
  51045. /**
  51046. * Gets the Up vector of the Spotlight for texture projection.
  51047. */
  51048. get projectionTextureUpDirection(): Vector3;
  51049. /**
  51050. * Sets the Up vector of the Spotlight for texture projection.
  51051. */
  51052. set projectionTextureUpDirection(value: Vector3);
  51053. private _projectionTexture;
  51054. /**
  51055. * Gets the projection texture of the light.
  51056. */
  51057. get projectionTexture(): Nullable<BaseTexture>;
  51058. /**
  51059. * Sets the projection texture of the light.
  51060. */
  51061. set projectionTexture(value: Nullable<BaseTexture>);
  51062. private _projectionTextureViewLightDirty;
  51063. private _projectionTextureProjectionLightDirty;
  51064. private _projectionTextureDirty;
  51065. private _projectionTextureViewTargetVector;
  51066. private _projectionTextureViewLightMatrix;
  51067. private _projectionTextureProjectionLightMatrix;
  51068. private _projectionTextureScalingMatrix;
  51069. /**
  51070. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51071. * It can cast shadows.
  51072. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51073. * @param name The light friendly name
  51074. * @param position The position of the spot light in the scene
  51075. * @param direction The direction of the light in the scene
  51076. * @param angle The cone angle of the light in Radians
  51077. * @param exponent The light decay speed with the distance from the emission spot
  51078. * @param scene The scene the lights belongs to
  51079. */
  51080. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51081. /**
  51082. * Returns the string "SpotLight".
  51083. * @returns the class name
  51084. */
  51085. getClassName(): string;
  51086. /**
  51087. * Returns the integer 2.
  51088. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51089. */
  51090. getTypeID(): number;
  51091. /**
  51092. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51093. */
  51094. protected _setDirection(value: Vector3): void;
  51095. /**
  51096. * Overrides the position setter to recompute the projection texture view light Matrix.
  51097. */
  51098. protected _setPosition(value: Vector3): void;
  51099. /**
  51100. * 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.
  51101. * Returns the SpotLight.
  51102. */
  51103. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51104. protected _computeProjectionTextureViewLightMatrix(): void;
  51105. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51106. /**
  51107. * Main function for light texture projection matrix computing.
  51108. */
  51109. protected _computeProjectionTextureMatrix(): void;
  51110. protected _buildUniformLayout(): void;
  51111. private _computeAngleValues;
  51112. /**
  51113. * Sets the passed Effect "effect" with the Light textures.
  51114. * @param effect The effect to update
  51115. * @param lightIndex The index of the light in the effect to update
  51116. * @returns The light
  51117. */
  51118. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51119. /**
  51120. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51121. * @param effect The effect to update
  51122. * @param lightIndex The index of the light in the effect to update
  51123. * @returns The spot light
  51124. */
  51125. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51126. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51127. /**
  51128. * Disposes the light and the associated resources.
  51129. */
  51130. dispose(): void;
  51131. /**
  51132. * Prepares the list of defines specific to the light type.
  51133. * @param defines the list of defines
  51134. * @param lightIndex defines the index of the light for the effect
  51135. */
  51136. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51137. }
  51138. }
  51139. declare module "babylonjs/Gizmos/lightGizmo" {
  51140. import { Nullable } from "babylonjs/types";
  51141. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51142. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51143. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51144. import { Light } from "babylonjs/Lights/light";
  51145. /**
  51146. * Gizmo that enables viewing a light
  51147. */
  51148. export class LightGizmo extends Gizmo {
  51149. private _lightMesh;
  51150. private _material;
  51151. private _cachedPosition;
  51152. private _cachedForward;
  51153. private _attachedMeshParent;
  51154. /**
  51155. * Creates a LightGizmo
  51156. * @param gizmoLayer The utility layer the gizmo will be added to
  51157. */
  51158. constructor(gizmoLayer?: UtilityLayerRenderer);
  51159. private _light;
  51160. /**
  51161. * The light that the gizmo is attached to
  51162. */
  51163. set light(light: Nullable<Light>);
  51164. get light(): Nullable<Light>;
  51165. /**
  51166. * Gets the material used to render the light gizmo
  51167. */
  51168. get material(): StandardMaterial;
  51169. /**
  51170. * @hidden
  51171. * Updates the gizmo to match the attached mesh's position/rotation
  51172. */
  51173. protected _update(): void;
  51174. private static _Scale;
  51175. /**
  51176. * Creates the lines for a light mesh
  51177. */
  51178. private static _CreateLightLines;
  51179. /**
  51180. * Disposes of the light gizmo
  51181. */
  51182. dispose(): void;
  51183. private static _CreateHemisphericLightMesh;
  51184. private static _CreatePointLightMesh;
  51185. private static _CreateSpotLightMesh;
  51186. private static _CreateDirectionalLightMesh;
  51187. }
  51188. }
  51189. declare module "babylonjs/Gizmos/index" {
  51190. export * from "babylonjs/Gizmos/axisDragGizmo";
  51191. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51192. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51193. export * from "babylonjs/Gizmos/gizmo";
  51194. export * from "babylonjs/Gizmos/gizmoManager";
  51195. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51196. export * from "babylonjs/Gizmos/positionGizmo";
  51197. export * from "babylonjs/Gizmos/rotationGizmo";
  51198. export * from "babylonjs/Gizmos/scaleGizmo";
  51199. export * from "babylonjs/Gizmos/lightGizmo";
  51200. export * from "babylonjs/Gizmos/planeDragGizmo";
  51201. }
  51202. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51203. /** @hidden */
  51204. export var backgroundFragmentDeclaration: {
  51205. name: string;
  51206. shader: string;
  51207. };
  51208. }
  51209. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51210. /** @hidden */
  51211. export var backgroundUboDeclaration: {
  51212. name: string;
  51213. shader: string;
  51214. };
  51215. }
  51216. declare module "babylonjs/Shaders/background.fragment" {
  51217. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51218. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51219. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51220. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51221. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51222. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51223. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51224. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51225. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51226. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51227. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51228. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51229. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51230. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51231. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51232. /** @hidden */
  51233. export var backgroundPixelShader: {
  51234. name: string;
  51235. shader: string;
  51236. };
  51237. }
  51238. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51239. /** @hidden */
  51240. export var backgroundVertexDeclaration: {
  51241. name: string;
  51242. shader: string;
  51243. };
  51244. }
  51245. declare module "babylonjs/Shaders/background.vertex" {
  51246. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51247. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51248. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51249. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51250. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51251. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51252. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51253. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51254. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51255. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51256. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51257. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51258. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51259. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51260. /** @hidden */
  51261. export var backgroundVertexShader: {
  51262. name: string;
  51263. shader: string;
  51264. };
  51265. }
  51266. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51267. import { Nullable, int, float } from "babylonjs/types";
  51268. import { Scene } from "babylonjs/scene";
  51269. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51272. import { Mesh } from "babylonjs/Meshes/mesh";
  51273. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51274. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51275. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51277. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51278. import { Color3 } from "babylonjs/Maths/math.color";
  51279. import "babylonjs/Shaders/background.fragment";
  51280. import "babylonjs/Shaders/background.vertex";
  51281. /**
  51282. * Background material used to create an efficient environement around your scene.
  51283. */
  51284. export class BackgroundMaterial extends PushMaterial {
  51285. /**
  51286. * Standard reflectance value at parallel view angle.
  51287. */
  51288. static StandardReflectance0: number;
  51289. /**
  51290. * Standard reflectance value at grazing angle.
  51291. */
  51292. static StandardReflectance90: number;
  51293. protected _primaryColor: Color3;
  51294. /**
  51295. * Key light Color (multiply against the environement texture)
  51296. */
  51297. primaryColor: Color3;
  51298. protected __perceptualColor: Nullable<Color3>;
  51299. /**
  51300. * Experimental Internal Use Only.
  51301. *
  51302. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51303. * This acts as a helper to set the primary color to a more "human friendly" value.
  51304. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51305. * output color as close as possible from the chosen value.
  51306. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51307. * part of lighting setup.)
  51308. */
  51309. get _perceptualColor(): Nullable<Color3>;
  51310. set _perceptualColor(value: Nullable<Color3>);
  51311. protected _primaryColorShadowLevel: float;
  51312. /**
  51313. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51314. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51315. */
  51316. get primaryColorShadowLevel(): float;
  51317. set primaryColorShadowLevel(value: float);
  51318. protected _primaryColorHighlightLevel: float;
  51319. /**
  51320. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51321. * The primary color is used at the level chosen to define what the white area would look.
  51322. */
  51323. get primaryColorHighlightLevel(): float;
  51324. set primaryColorHighlightLevel(value: float);
  51325. protected _reflectionTexture: Nullable<BaseTexture>;
  51326. /**
  51327. * Reflection Texture used in the material.
  51328. * Should be author in a specific way for the best result (refer to the documentation).
  51329. */
  51330. reflectionTexture: Nullable<BaseTexture>;
  51331. protected _reflectionBlur: float;
  51332. /**
  51333. * Reflection Texture level of blur.
  51334. *
  51335. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51336. * texture twice.
  51337. */
  51338. reflectionBlur: float;
  51339. protected _diffuseTexture: Nullable<BaseTexture>;
  51340. /**
  51341. * Diffuse Texture used in the material.
  51342. * Should be author in a specific way for the best result (refer to the documentation).
  51343. */
  51344. diffuseTexture: Nullable<BaseTexture>;
  51345. protected _shadowLights: Nullable<IShadowLight[]>;
  51346. /**
  51347. * Specify the list of lights casting shadow on the material.
  51348. * All scene shadow lights will be included if null.
  51349. */
  51350. shadowLights: Nullable<IShadowLight[]>;
  51351. protected _shadowLevel: float;
  51352. /**
  51353. * Helps adjusting the shadow to a softer level if required.
  51354. * 0 means black shadows and 1 means no shadows.
  51355. */
  51356. shadowLevel: float;
  51357. protected _sceneCenter: Vector3;
  51358. /**
  51359. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51360. * It is usually zero but might be interesting to modify according to your setup.
  51361. */
  51362. sceneCenter: Vector3;
  51363. protected _opacityFresnel: boolean;
  51364. /**
  51365. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51366. * This helps ensuring a nice transition when the camera goes under the ground.
  51367. */
  51368. opacityFresnel: boolean;
  51369. protected _reflectionFresnel: boolean;
  51370. /**
  51371. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51372. * This helps adding a mirror texture on the ground.
  51373. */
  51374. reflectionFresnel: boolean;
  51375. protected _reflectionFalloffDistance: number;
  51376. /**
  51377. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51378. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51379. */
  51380. reflectionFalloffDistance: number;
  51381. protected _reflectionAmount: number;
  51382. /**
  51383. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51384. */
  51385. reflectionAmount: number;
  51386. protected _reflectionReflectance0: number;
  51387. /**
  51388. * This specifies the weight of the reflection at grazing angle.
  51389. */
  51390. reflectionReflectance0: number;
  51391. protected _reflectionReflectance90: number;
  51392. /**
  51393. * This specifies the weight of the reflection at a perpendicular point of view.
  51394. */
  51395. reflectionReflectance90: number;
  51396. /**
  51397. * Sets the reflection reflectance fresnel values according to the default standard
  51398. * empirically know to work well :-)
  51399. */
  51400. set reflectionStandardFresnelWeight(value: number);
  51401. protected _useRGBColor: boolean;
  51402. /**
  51403. * Helps to directly use the maps channels instead of their level.
  51404. */
  51405. useRGBColor: boolean;
  51406. protected _enableNoise: boolean;
  51407. /**
  51408. * This helps reducing the banding effect that could occur on the background.
  51409. */
  51410. enableNoise: boolean;
  51411. /**
  51412. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51413. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51414. * Recommended to be keep at 1.0 except for special cases.
  51415. */
  51416. get fovMultiplier(): number;
  51417. set fovMultiplier(value: number);
  51418. private _fovMultiplier;
  51419. /**
  51420. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51421. */
  51422. useEquirectangularFOV: boolean;
  51423. private _maxSimultaneousLights;
  51424. /**
  51425. * Number of Simultaneous lights allowed on the material.
  51426. */
  51427. maxSimultaneousLights: int;
  51428. /**
  51429. * Default configuration related to image processing available in the Background Material.
  51430. */
  51431. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51432. /**
  51433. * Keep track of the image processing observer to allow dispose and replace.
  51434. */
  51435. private _imageProcessingObserver;
  51436. /**
  51437. * Attaches a new image processing configuration to the PBR Material.
  51438. * @param configuration (if null the scene configuration will be use)
  51439. */
  51440. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51441. /**
  51442. * Gets the image processing configuration used either in this material.
  51443. */
  51444. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51445. /**
  51446. * Sets the Default image processing configuration used either in the this material.
  51447. *
  51448. * If sets to null, the scene one is in use.
  51449. */
  51450. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51451. /**
  51452. * Gets wether the color curves effect is enabled.
  51453. */
  51454. get cameraColorCurvesEnabled(): boolean;
  51455. /**
  51456. * Sets wether the color curves effect is enabled.
  51457. */
  51458. set cameraColorCurvesEnabled(value: boolean);
  51459. /**
  51460. * Gets wether the color grading effect is enabled.
  51461. */
  51462. get cameraColorGradingEnabled(): boolean;
  51463. /**
  51464. * Gets wether the color grading effect is enabled.
  51465. */
  51466. set cameraColorGradingEnabled(value: boolean);
  51467. /**
  51468. * Gets wether tonemapping is enabled or not.
  51469. */
  51470. get cameraToneMappingEnabled(): boolean;
  51471. /**
  51472. * Sets wether tonemapping is enabled or not
  51473. */
  51474. set cameraToneMappingEnabled(value: boolean);
  51475. /**
  51476. * The camera exposure used on this material.
  51477. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51478. * This corresponds to a photographic exposure.
  51479. */
  51480. get cameraExposure(): float;
  51481. /**
  51482. * The camera exposure used on this material.
  51483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51484. * This corresponds to a photographic exposure.
  51485. */
  51486. set cameraExposure(value: float);
  51487. /**
  51488. * Gets The camera contrast used on this material.
  51489. */
  51490. get cameraContrast(): float;
  51491. /**
  51492. * Sets The camera contrast used on this material.
  51493. */
  51494. set cameraContrast(value: float);
  51495. /**
  51496. * Gets the Color Grading 2D Lookup Texture.
  51497. */
  51498. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51499. /**
  51500. * Sets the Color Grading 2D Lookup Texture.
  51501. */
  51502. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51503. /**
  51504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51506. * 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;
  51507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51508. */
  51509. get cameraColorCurves(): Nullable<ColorCurves>;
  51510. /**
  51511. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51512. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51513. * 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;
  51514. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51515. */
  51516. set cameraColorCurves(value: Nullable<ColorCurves>);
  51517. /**
  51518. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51519. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51520. */
  51521. switchToBGR: boolean;
  51522. private _renderTargets;
  51523. private _reflectionControls;
  51524. private _white;
  51525. private _primaryShadowColor;
  51526. private _primaryHighlightColor;
  51527. /**
  51528. * Instantiates a Background Material in the given scene
  51529. * @param name The friendly name of the material
  51530. * @param scene The scene to add the material to
  51531. */
  51532. constructor(name: string, scene: Scene);
  51533. /**
  51534. * Gets a boolean indicating that current material needs to register RTT
  51535. */
  51536. get hasRenderTargetTextures(): boolean;
  51537. /**
  51538. * The entire material has been created in order to prevent overdraw.
  51539. * @returns false
  51540. */
  51541. needAlphaTesting(): boolean;
  51542. /**
  51543. * The entire material has been created in order to prevent overdraw.
  51544. * @returns true if blending is enable
  51545. */
  51546. needAlphaBlending(): boolean;
  51547. /**
  51548. * Checks wether the material is ready to be rendered for a given mesh.
  51549. * @param mesh The mesh to render
  51550. * @param subMesh The submesh to check against
  51551. * @param useInstances Specify wether or not the material is used with instances
  51552. * @returns true if all the dependencies are ready (Textures, Effects...)
  51553. */
  51554. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51555. /**
  51556. * Compute the primary color according to the chosen perceptual color.
  51557. */
  51558. private _computePrimaryColorFromPerceptualColor;
  51559. /**
  51560. * Compute the highlights and shadow colors according to their chosen levels.
  51561. */
  51562. private _computePrimaryColors;
  51563. /**
  51564. * Build the uniform buffer used in the material.
  51565. */
  51566. buildUniformLayout(): void;
  51567. /**
  51568. * Unbind the material.
  51569. */
  51570. unbind(): void;
  51571. /**
  51572. * Bind only the world matrix to the material.
  51573. * @param world The world matrix to bind.
  51574. */
  51575. bindOnlyWorldMatrix(world: Matrix): void;
  51576. /**
  51577. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51578. * @param world The world matrix to bind.
  51579. * @param subMesh The submesh to bind for.
  51580. */
  51581. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51582. /**
  51583. * Checks to see if a texture is used in the material.
  51584. * @param texture - Base texture to use.
  51585. * @returns - Boolean specifying if a texture is used in the material.
  51586. */
  51587. hasTexture(texture: BaseTexture): boolean;
  51588. /**
  51589. * Dispose the material.
  51590. * @param forceDisposeEffect Force disposal of the associated effect.
  51591. * @param forceDisposeTextures Force disposal of the associated textures.
  51592. */
  51593. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51594. /**
  51595. * Clones the material.
  51596. * @param name The cloned name.
  51597. * @returns The cloned material.
  51598. */
  51599. clone(name: string): BackgroundMaterial;
  51600. /**
  51601. * Serializes the current material to its JSON representation.
  51602. * @returns The JSON representation.
  51603. */
  51604. serialize(): any;
  51605. /**
  51606. * Gets the class name of the material
  51607. * @returns "BackgroundMaterial"
  51608. */
  51609. getClassName(): string;
  51610. /**
  51611. * Parse a JSON input to create back a background material.
  51612. * @param source The JSON data to parse
  51613. * @param scene The scene to create the parsed material in
  51614. * @param rootUrl The root url of the assets the material depends upon
  51615. * @returns the instantiated BackgroundMaterial.
  51616. */
  51617. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51618. }
  51619. }
  51620. declare module "babylonjs/Helpers/environmentHelper" {
  51621. import { Observable } from "babylonjs/Misc/observable";
  51622. import { Nullable } from "babylonjs/types";
  51623. import { Scene } from "babylonjs/scene";
  51624. import { Vector3 } from "babylonjs/Maths/math.vector";
  51625. import { Color3 } from "babylonjs/Maths/math.color";
  51626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51627. import { Mesh } from "babylonjs/Meshes/mesh";
  51628. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51629. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51630. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51631. import "babylonjs/Meshes/Builders/planeBuilder";
  51632. import "babylonjs/Meshes/Builders/boxBuilder";
  51633. /**
  51634. * Represents the different options available during the creation of
  51635. * a Environment helper.
  51636. *
  51637. * This can control the default ground, skybox and image processing setup of your scene.
  51638. */
  51639. export interface IEnvironmentHelperOptions {
  51640. /**
  51641. * Specifies wether or not to create a ground.
  51642. * True by default.
  51643. */
  51644. createGround: boolean;
  51645. /**
  51646. * Specifies the ground size.
  51647. * 15 by default.
  51648. */
  51649. groundSize: number;
  51650. /**
  51651. * The texture used on the ground for the main color.
  51652. * Comes from the BabylonJS CDN by default.
  51653. *
  51654. * Remarks: Can be either a texture or a url.
  51655. */
  51656. groundTexture: string | BaseTexture;
  51657. /**
  51658. * The color mixed in the ground texture by default.
  51659. * BabylonJS clearColor by default.
  51660. */
  51661. groundColor: Color3;
  51662. /**
  51663. * Specifies the ground opacity.
  51664. * 1 by default.
  51665. */
  51666. groundOpacity: number;
  51667. /**
  51668. * Enables the ground to receive shadows.
  51669. * True by default.
  51670. */
  51671. enableGroundShadow: boolean;
  51672. /**
  51673. * Helps preventing the shadow to be fully black on the ground.
  51674. * 0.5 by default.
  51675. */
  51676. groundShadowLevel: number;
  51677. /**
  51678. * Creates a mirror texture attach to the ground.
  51679. * false by default.
  51680. */
  51681. enableGroundMirror: boolean;
  51682. /**
  51683. * Specifies the ground mirror size ratio.
  51684. * 0.3 by default as the default kernel is 64.
  51685. */
  51686. groundMirrorSizeRatio: number;
  51687. /**
  51688. * Specifies the ground mirror blur kernel size.
  51689. * 64 by default.
  51690. */
  51691. groundMirrorBlurKernel: number;
  51692. /**
  51693. * Specifies the ground mirror visibility amount.
  51694. * 1 by default
  51695. */
  51696. groundMirrorAmount: number;
  51697. /**
  51698. * Specifies the ground mirror reflectance weight.
  51699. * This uses the standard weight of the background material to setup the fresnel effect
  51700. * of the mirror.
  51701. * 1 by default.
  51702. */
  51703. groundMirrorFresnelWeight: number;
  51704. /**
  51705. * Specifies the ground mirror Falloff distance.
  51706. * This can helps reducing the size of the reflection.
  51707. * 0 by Default.
  51708. */
  51709. groundMirrorFallOffDistance: number;
  51710. /**
  51711. * Specifies the ground mirror texture type.
  51712. * Unsigned Int by Default.
  51713. */
  51714. groundMirrorTextureType: number;
  51715. /**
  51716. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51717. * the shown objects.
  51718. */
  51719. groundYBias: number;
  51720. /**
  51721. * Specifies wether or not to create a skybox.
  51722. * True by default.
  51723. */
  51724. createSkybox: boolean;
  51725. /**
  51726. * Specifies the skybox size.
  51727. * 20 by default.
  51728. */
  51729. skyboxSize: number;
  51730. /**
  51731. * The texture used on the skybox for the main color.
  51732. * Comes from the BabylonJS CDN by default.
  51733. *
  51734. * Remarks: Can be either a texture or a url.
  51735. */
  51736. skyboxTexture: string | BaseTexture;
  51737. /**
  51738. * The color mixed in the skybox texture by default.
  51739. * BabylonJS clearColor by default.
  51740. */
  51741. skyboxColor: Color3;
  51742. /**
  51743. * The background rotation around the Y axis of the scene.
  51744. * This helps aligning the key lights of your scene with the background.
  51745. * 0 by default.
  51746. */
  51747. backgroundYRotation: number;
  51748. /**
  51749. * Compute automatically the size of the elements to best fit with the scene.
  51750. */
  51751. sizeAuto: boolean;
  51752. /**
  51753. * Default position of the rootMesh if autoSize is not true.
  51754. */
  51755. rootPosition: Vector3;
  51756. /**
  51757. * Sets up the image processing in the scene.
  51758. * true by default.
  51759. */
  51760. setupImageProcessing: boolean;
  51761. /**
  51762. * The texture used as your environment texture in the scene.
  51763. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51764. *
  51765. * Remarks: Can be either a texture or a url.
  51766. */
  51767. environmentTexture: string | BaseTexture;
  51768. /**
  51769. * The value of the exposure to apply to the scene.
  51770. * 0.6 by default if setupImageProcessing is true.
  51771. */
  51772. cameraExposure: number;
  51773. /**
  51774. * The value of the contrast to apply to the scene.
  51775. * 1.6 by default if setupImageProcessing is true.
  51776. */
  51777. cameraContrast: number;
  51778. /**
  51779. * Specifies wether or not tonemapping should be enabled in the scene.
  51780. * true by default if setupImageProcessing is true.
  51781. */
  51782. toneMappingEnabled: boolean;
  51783. }
  51784. /**
  51785. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51786. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51787. * It also helps with the default setup of your imageProcessing configuration.
  51788. */
  51789. export class EnvironmentHelper {
  51790. /**
  51791. * Default ground texture URL.
  51792. */
  51793. private static _groundTextureCDNUrl;
  51794. /**
  51795. * Default skybox texture URL.
  51796. */
  51797. private static _skyboxTextureCDNUrl;
  51798. /**
  51799. * Default environment texture URL.
  51800. */
  51801. private static _environmentTextureCDNUrl;
  51802. /**
  51803. * Creates the default options for the helper.
  51804. */
  51805. private static _getDefaultOptions;
  51806. private _rootMesh;
  51807. /**
  51808. * Gets the root mesh created by the helper.
  51809. */
  51810. get rootMesh(): Mesh;
  51811. private _skybox;
  51812. /**
  51813. * Gets the skybox created by the helper.
  51814. */
  51815. get skybox(): Nullable<Mesh>;
  51816. private _skyboxTexture;
  51817. /**
  51818. * Gets the skybox texture created by the helper.
  51819. */
  51820. get skyboxTexture(): Nullable<BaseTexture>;
  51821. private _skyboxMaterial;
  51822. /**
  51823. * Gets the skybox material created by the helper.
  51824. */
  51825. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51826. private _ground;
  51827. /**
  51828. * Gets the ground mesh created by the helper.
  51829. */
  51830. get ground(): Nullable<Mesh>;
  51831. private _groundTexture;
  51832. /**
  51833. * Gets the ground texture created by the helper.
  51834. */
  51835. get groundTexture(): Nullable<BaseTexture>;
  51836. private _groundMirror;
  51837. /**
  51838. * Gets the ground mirror created by the helper.
  51839. */
  51840. get groundMirror(): Nullable<MirrorTexture>;
  51841. /**
  51842. * Gets the ground mirror render list to helps pushing the meshes
  51843. * you wish in the ground reflection.
  51844. */
  51845. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51846. private _groundMaterial;
  51847. /**
  51848. * Gets the ground material created by the helper.
  51849. */
  51850. get groundMaterial(): Nullable<BackgroundMaterial>;
  51851. /**
  51852. * Stores the creation options.
  51853. */
  51854. private readonly _scene;
  51855. private _options;
  51856. /**
  51857. * This observable will be notified with any error during the creation of the environment,
  51858. * mainly texture creation errors.
  51859. */
  51860. onErrorObservable: Observable<{
  51861. message?: string;
  51862. exception?: any;
  51863. }>;
  51864. /**
  51865. * constructor
  51866. * @param options Defines the options we want to customize the helper
  51867. * @param scene The scene to add the material to
  51868. */
  51869. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51870. /**
  51871. * Updates the background according to the new options
  51872. * @param options
  51873. */
  51874. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51875. /**
  51876. * Sets the primary color of all the available elements.
  51877. * @param color the main color to affect to the ground and the background
  51878. */
  51879. setMainColor(color: Color3): void;
  51880. /**
  51881. * Setup the image processing according to the specified options.
  51882. */
  51883. private _setupImageProcessing;
  51884. /**
  51885. * Setup the environment texture according to the specified options.
  51886. */
  51887. private _setupEnvironmentTexture;
  51888. /**
  51889. * Setup the background according to the specified options.
  51890. */
  51891. private _setupBackground;
  51892. /**
  51893. * Get the scene sizes according to the setup.
  51894. */
  51895. private _getSceneSize;
  51896. /**
  51897. * Setup the ground according to the specified options.
  51898. */
  51899. private _setupGround;
  51900. /**
  51901. * Setup the ground material according to the specified options.
  51902. */
  51903. private _setupGroundMaterial;
  51904. /**
  51905. * Setup the ground diffuse texture according to the specified options.
  51906. */
  51907. private _setupGroundDiffuseTexture;
  51908. /**
  51909. * Setup the ground mirror texture according to the specified options.
  51910. */
  51911. private _setupGroundMirrorTexture;
  51912. /**
  51913. * Setup the ground to receive the mirror texture.
  51914. */
  51915. private _setupMirrorInGroundMaterial;
  51916. /**
  51917. * Setup the skybox according to the specified options.
  51918. */
  51919. private _setupSkybox;
  51920. /**
  51921. * Setup the skybox material according to the specified options.
  51922. */
  51923. private _setupSkyboxMaterial;
  51924. /**
  51925. * Setup the skybox reflection texture according to the specified options.
  51926. */
  51927. private _setupSkyboxReflectionTexture;
  51928. private _errorHandler;
  51929. /**
  51930. * Dispose all the elements created by the Helper.
  51931. */
  51932. dispose(): void;
  51933. }
  51934. }
  51935. declare module "babylonjs/Helpers/photoDome" {
  51936. import { Observable } from "babylonjs/Misc/observable";
  51937. import { Nullable } from "babylonjs/types";
  51938. import { Scene } from "babylonjs/scene";
  51939. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51940. import { Mesh } from "babylonjs/Meshes/mesh";
  51941. import { Texture } from "babylonjs/Materials/Textures/texture";
  51942. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51943. import "babylonjs/Meshes/Builders/sphereBuilder";
  51944. /**
  51945. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51946. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51947. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51948. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51949. */
  51950. export class PhotoDome extends TransformNode {
  51951. /**
  51952. * Define the image as a Monoscopic panoramic 360 image.
  51953. */
  51954. static readonly MODE_MONOSCOPIC: number;
  51955. /**
  51956. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51957. */
  51958. static readonly MODE_TOPBOTTOM: number;
  51959. /**
  51960. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51961. */
  51962. static readonly MODE_SIDEBYSIDE: number;
  51963. private _useDirectMapping;
  51964. /**
  51965. * The texture being displayed on the sphere
  51966. */
  51967. protected _photoTexture: Texture;
  51968. /**
  51969. * Gets or sets the texture being displayed on the sphere
  51970. */
  51971. get photoTexture(): Texture;
  51972. set photoTexture(value: Texture);
  51973. /**
  51974. * Observable raised when an error occured while loading the 360 image
  51975. */
  51976. onLoadErrorObservable: Observable<string>;
  51977. /**
  51978. * The skybox material
  51979. */
  51980. protected _material: BackgroundMaterial;
  51981. /**
  51982. * The surface used for the skybox
  51983. */
  51984. protected _mesh: Mesh;
  51985. /**
  51986. * Gets the mesh used for the skybox.
  51987. */
  51988. get mesh(): Mesh;
  51989. /**
  51990. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51991. * Also see the options.resolution property.
  51992. */
  51993. get fovMultiplier(): number;
  51994. set fovMultiplier(value: number);
  51995. private _imageMode;
  51996. /**
  51997. * Gets or set the current video mode for the video. It can be:
  51998. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51999. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52000. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52001. */
  52002. get imageMode(): number;
  52003. set imageMode(value: number);
  52004. /**
  52005. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52006. * @param name Element's name, child elements will append suffixes for their own names.
  52007. * @param urlsOfPhoto defines the url of the photo to display
  52008. * @param options defines an object containing optional or exposed sub element properties
  52009. * @param onError defines a callback called when an error occured while loading the texture
  52010. */
  52011. constructor(name: string, urlOfPhoto: string, options: {
  52012. resolution?: number;
  52013. size?: number;
  52014. useDirectMapping?: boolean;
  52015. faceForward?: boolean;
  52016. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52017. private _onBeforeCameraRenderObserver;
  52018. private _changeImageMode;
  52019. /**
  52020. * Releases resources associated with this node.
  52021. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52022. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52023. */
  52024. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52025. }
  52026. }
  52027. declare module "babylonjs/Misc/rgbdTextureTools" {
  52028. import "babylonjs/Shaders/rgbdDecode.fragment";
  52029. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52030. import { Texture } from "babylonjs/Materials/Textures/texture";
  52031. /**
  52032. * Class used to host RGBD texture specific utilities
  52033. */
  52034. export class RGBDTextureTools {
  52035. /**
  52036. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52037. * @param texture the texture to expand.
  52038. */
  52039. static ExpandRGBDTexture(texture: Texture): void;
  52040. }
  52041. }
  52042. declare module "babylonjs/Misc/brdfTextureTools" {
  52043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52044. import { Scene } from "babylonjs/scene";
  52045. /**
  52046. * Class used to host texture specific utilities
  52047. */
  52048. export class BRDFTextureTools {
  52049. /**
  52050. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52051. * @param scene defines the hosting scene
  52052. * @returns the environment BRDF texture
  52053. */
  52054. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52055. private static _environmentBRDFBase64Texture;
  52056. }
  52057. }
  52058. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52059. import { Nullable } from "babylonjs/types";
  52060. import { Color3 } from "babylonjs/Maths/math.color";
  52061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52062. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52063. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52064. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52065. import { Engine } from "babylonjs/Engines/engine";
  52066. import { Scene } from "babylonjs/scene";
  52067. /**
  52068. * @hidden
  52069. */
  52070. export interface IMaterialClearCoatDefines {
  52071. CLEARCOAT: boolean;
  52072. CLEARCOAT_DEFAULTIOR: boolean;
  52073. CLEARCOAT_TEXTURE: boolean;
  52074. CLEARCOAT_TEXTUREDIRECTUV: number;
  52075. CLEARCOAT_BUMP: boolean;
  52076. CLEARCOAT_BUMPDIRECTUV: number;
  52077. CLEARCOAT_TINT: boolean;
  52078. CLEARCOAT_TINT_TEXTURE: boolean;
  52079. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52080. /** @hidden */
  52081. _areTexturesDirty: boolean;
  52082. }
  52083. /**
  52084. * Define the code related to the clear coat parameters of the pbr material.
  52085. */
  52086. export class PBRClearCoatConfiguration {
  52087. /**
  52088. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52089. * The default fits with a polyurethane material.
  52090. */
  52091. private static readonly _DefaultIndexOfRefraction;
  52092. private _isEnabled;
  52093. /**
  52094. * Defines if the clear coat is enabled in the material.
  52095. */
  52096. isEnabled: boolean;
  52097. /**
  52098. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52099. */
  52100. intensity: number;
  52101. /**
  52102. * Defines the clear coat layer roughness.
  52103. */
  52104. roughness: number;
  52105. private _indexOfRefraction;
  52106. /**
  52107. * Defines the index of refraction of the clear coat.
  52108. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52109. * The default fits with a polyurethane material.
  52110. * Changing the default value is more performance intensive.
  52111. */
  52112. indexOfRefraction: number;
  52113. private _texture;
  52114. /**
  52115. * Stores the clear coat values in a texture.
  52116. */
  52117. texture: Nullable<BaseTexture>;
  52118. private _bumpTexture;
  52119. /**
  52120. * Define the clear coat specific bump texture.
  52121. */
  52122. bumpTexture: Nullable<BaseTexture>;
  52123. private _isTintEnabled;
  52124. /**
  52125. * Defines if the clear coat tint is enabled in the material.
  52126. */
  52127. isTintEnabled: boolean;
  52128. /**
  52129. * Defines the clear coat tint of the material.
  52130. * This is only use if tint is enabled
  52131. */
  52132. tintColor: Color3;
  52133. /**
  52134. * Defines the distance at which the tint color should be found in the
  52135. * clear coat media.
  52136. * This is only use if tint is enabled
  52137. */
  52138. tintColorAtDistance: number;
  52139. /**
  52140. * Defines the clear coat layer thickness.
  52141. * This is only use if tint is enabled
  52142. */
  52143. tintThickness: number;
  52144. private _tintTexture;
  52145. /**
  52146. * Stores the clear tint values in a texture.
  52147. * rgb is tint
  52148. * a is a thickness factor
  52149. */
  52150. tintTexture: Nullable<BaseTexture>;
  52151. /** @hidden */
  52152. private _internalMarkAllSubMeshesAsTexturesDirty;
  52153. /** @hidden */
  52154. _markAllSubMeshesAsTexturesDirty(): void;
  52155. /**
  52156. * Instantiate a new istance of clear coat configuration.
  52157. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52158. */
  52159. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52160. /**
  52161. * Gets wehter the submesh is ready to be used or not.
  52162. * @param defines the list of "defines" to update.
  52163. * @param scene defines the scene the material belongs to.
  52164. * @param engine defines the engine the material belongs to.
  52165. * @param disableBumpMap defines wether the material disables bump or not.
  52166. * @returns - boolean indicating that the submesh is ready or not.
  52167. */
  52168. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52169. /**
  52170. * Checks to see if a texture is used in the material.
  52171. * @param defines the list of "defines" to update.
  52172. * @param scene defines the scene to the material belongs to.
  52173. */
  52174. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52175. /**
  52176. * Binds the material data.
  52177. * @param uniformBuffer defines the Uniform buffer to fill in.
  52178. * @param scene defines the scene the material belongs to.
  52179. * @param engine defines the engine the material belongs to.
  52180. * @param disableBumpMap defines wether the material disables bump or not.
  52181. * @param isFrozen defines wether the material is frozen or not.
  52182. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52183. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52184. */
  52185. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52186. /**
  52187. * Checks to see if a texture is used in the material.
  52188. * @param texture - Base texture to use.
  52189. * @returns - Boolean specifying if a texture is used in the material.
  52190. */
  52191. hasTexture(texture: BaseTexture): boolean;
  52192. /**
  52193. * Returns an array of the actively used textures.
  52194. * @param activeTextures Array of BaseTextures
  52195. */
  52196. getActiveTextures(activeTextures: BaseTexture[]): void;
  52197. /**
  52198. * Returns the animatable textures.
  52199. * @param animatables Array of animatable textures.
  52200. */
  52201. getAnimatables(animatables: IAnimatable[]): void;
  52202. /**
  52203. * Disposes the resources of the material.
  52204. * @param forceDisposeTextures - Forces the disposal of all textures.
  52205. */
  52206. dispose(forceDisposeTextures?: boolean): void;
  52207. /**
  52208. * Get the current class name of the texture useful for serialization or dynamic coding.
  52209. * @returns "PBRClearCoatConfiguration"
  52210. */
  52211. getClassName(): string;
  52212. /**
  52213. * Add fallbacks to the effect fallbacks list.
  52214. * @param defines defines the Base texture to use.
  52215. * @param fallbacks defines the current fallback list.
  52216. * @param currentRank defines the current fallback rank.
  52217. * @returns the new fallback rank.
  52218. */
  52219. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52220. /**
  52221. * Add the required uniforms to the current list.
  52222. * @param uniforms defines the current uniform list.
  52223. */
  52224. static AddUniforms(uniforms: string[]): void;
  52225. /**
  52226. * Add the required samplers to the current list.
  52227. * @param samplers defines the current sampler list.
  52228. */
  52229. static AddSamplers(samplers: string[]): void;
  52230. /**
  52231. * Add the required uniforms to the current buffer.
  52232. * @param uniformBuffer defines the current uniform buffer.
  52233. */
  52234. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52235. /**
  52236. * Makes a duplicate of the current configuration into another one.
  52237. * @param clearCoatConfiguration define the config where to copy the info
  52238. */
  52239. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52240. /**
  52241. * Serializes this clear coat configuration.
  52242. * @returns - An object with the serialized config.
  52243. */
  52244. serialize(): any;
  52245. /**
  52246. * Parses a anisotropy Configuration from a serialized object.
  52247. * @param source - Serialized object.
  52248. * @param scene Defines the scene we are parsing for
  52249. * @param rootUrl Defines the rootUrl to load from
  52250. */
  52251. parse(source: any, scene: Scene, rootUrl: string): void;
  52252. }
  52253. }
  52254. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52255. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52257. import { Vector2 } from "babylonjs/Maths/math.vector";
  52258. import { Scene } from "babylonjs/scene";
  52259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52260. import { Nullable } from "babylonjs/types";
  52261. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52262. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52263. /**
  52264. * @hidden
  52265. */
  52266. export interface IMaterialAnisotropicDefines {
  52267. ANISOTROPIC: boolean;
  52268. ANISOTROPIC_TEXTURE: boolean;
  52269. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52270. MAINUV1: boolean;
  52271. _areTexturesDirty: boolean;
  52272. _needUVs: boolean;
  52273. }
  52274. /**
  52275. * Define the code related to the anisotropic parameters of the pbr material.
  52276. */
  52277. export class PBRAnisotropicConfiguration {
  52278. private _isEnabled;
  52279. /**
  52280. * Defines if the anisotropy is enabled in the material.
  52281. */
  52282. isEnabled: boolean;
  52283. /**
  52284. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52285. */
  52286. intensity: number;
  52287. /**
  52288. * Defines if the effect is along the tangents, bitangents or in between.
  52289. * By default, the effect is "strectching" the highlights along the tangents.
  52290. */
  52291. direction: Vector2;
  52292. private _texture;
  52293. /**
  52294. * Stores the anisotropy values in a texture.
  52295. * rg is direction (like normal from -1 to 1)
  52296. * b is a intensity
  52297. */
  52298. texture: Nullable<BaseTexture>;
  52299. /** @hidden */
  52300. private _internalMarkAllSubMeshesAsTexturesDirty;
  52301. /** @hidden */
  52302. _markAllSubMeshesAsTexturesDirty(): void;
  52303. /**
  52304. * Instantiate a new istance of anisotropy configuration.
  52305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52306. */
  52307. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52308. /**
  52309. * Specifies that the submesh is ready to be used.
  52310. * @param defines the list of "defines" to update.
  52311. * @param scene defines the scene the material belongs to.
  52312. * @returns - boolean indicating that the submesh is ready or not.
  52313. */
  52314. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52315. /**
  52316. * Checks to see if a texture is used in the material.
  52317. * @param defines the list of "defines" to update.
  52318. * @param mesh the mesh we are preparing the defines for.
  52319. * @param scene defines the scene the material belongs to.
  52320. */
  52321. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52322. /**
  52323. * Binds the material data.
  52324. * @param uniformBuffer defines the Uniform buffer to fill in.
  52325. * @param scene defines the scene the material belongs to.
  52326. * @param isFrozen defines wether the material is frozen or not.
  52327. */
  52328. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52329. /**
  52330. * Checks to see if a texture is used in the material.
  52331. * @param texture - Base texture to use.
  52332. * @returns - Boolean specifying if a texture is used in the material.
  52333. */
  52334. hasTexture(texture: BaseTexture): boolean;
  52335. /**
  52336. * Returns an array of the actively used textures.
  52337. * @param activeTextures Array of BaseTextures
  52338. */
  52339. getActiveTextures(activeTextures: BaseTexture[]): void;
  52340. /**
  52341. * Returns the animatable textures.
  52342. * @param animatables Array of animatable textures.
  52343. */
  52344. getAnimatables(animatables: IAnimatable[]): void;
  52345. /**
  52346. * Disposes the resources of the material.
  52347. * @param forceDisposeTextures - Forces the disposal of all textures.
  52348. */
  52349. dispose(forceDisposeTextures?: boolean): void;
  52350. /**
  52351. * Get the current class name of the texture useful for serialization or dynamic coding.
  52352. * @returns "PBRAnisotropicConfiguration"
  52353. */
  52354. getClassName(): string;
  52355. /**
  52356. * Add fallbacks to the effect fallbacks list.
  52357. * @param defines defines the Base texture to use.
  52358. * @param fallbacks defines the current fallback list.
  52359. * @param currentRank defines the current fallback rank.
  52360. * @returns the new fallback rank.
  52361. */
  52362. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52363. /**
  52364. * Add the required uniforms to the current list.
  52365. * @param uniforms defines the current uniform list.
  52366. */
  52367. static AddUniforms(uniforms: string[]): void;
  52368. /**
  52369. * Add the required uniforms to the current buffer.
  52370. * @param uniformBuffer defines the current uniform buffer.
  52371. */
  52372. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52373. /**
  52374. * Add the required samplers to the current list.
  52375. * @param samplers defines the current sampler list.
  52376. */
  52377. static AddSamplers(samplers: string[]): void;
  52378. /**
  52379. * Makes a duplicate of the current configuration into another one.
  52380. * @param anisotropicConfiguration define the config where to copy the info
  52381. */
  52382. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52383. /**
  52384. * Serializes this anisotropy configuration.
  52385. * @returns - An object with the serialized config.
  52386. */
  52387. serialize(): any;
  52388. /**
  52389. * Parses a anisotropy Configuration from a serialized object.
  52390. * @param source - Serialized object.
  52391. * @param scene Defines the scene we are parsing for
  52392. * @param rootUrl Defines the rootUrl to load from
  52393. */
  52394. parse(source: any, scene: Scene, rootUrl: string): void;
  52395. }
  52396. }
  52397. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52398. import { Scene } from "babylonjs/scene";
  52399. /**
  52400. * @hidden
  52401. */
  52402. export interface IMaterialBRDFDefines {
  52403. BRDF_V_HEIGHT_CORRELATED: boolean;
  52404. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52405. SPHERICAL_HARMONICS: boolean;
  52406. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52407. /** @hidden */
  52408. _areMiscDirty: boolean;
  52409. }
  52410. /**
  52411. * Define the code related to the BRDF parameters of the pbr material.
  52412. */
  52413. export class PBRBRDFConfiguration {
  52414. /**
  52415. * Default value used for the energy conservation.
  52416. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52417. */
  52418. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52419. /**
  52420. * Default value used for the Smith Visibility Height Correlated mode.
  52421. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52422. */
  52423. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52424. /**
  52425. * Default value used for the IBL diffuse part.
  52426. * This can help switching back to the polynomials mode globally which is a tiny bit
  52427. * less GPU intensive at the drawback of a lower quality.
  52428. */
  52429. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52430. /**
  52431. * Default value used for activating energy conservation for the specular workflow.
  52432. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52433. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52434. */
  52435. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52436. private _useEnergyConservation;
  52437. /**
  52438. * Defines if the material uses energy conservation.
  52439. */
  52440. useEnergyConservation: boolean;
  52441. private _useSmithVisibilityHeightCorrelated;
  52442. /**
  52443. * LEGACY Mode set to false
  52444. * Defines if the material uses height smith correlated visibility term.
  52445. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52446. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52447. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52448. * Not relying on height correlated will also disable energy conservation.
  52449. */
  52450. useSmithVisibilityHeightCorrelated: boolean;
  52451. private _useSphericalHarmonics;
  52452. /**
  52453. * LEGACY Mode set to false
  52454. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52455. * diffuse part of the IBL.
  52456. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52457. * to the ground truth.
  52458. */
  52459. useSphericalHarmonics: boolean;
  52460. private _useSpecularGlossinessInputEnergyConservation;
  52461. /**
  52462. * Defines if the material uses energy conservation, when the specular workflow is active.
  52463. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52464. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52465. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52466. */
  52467. useSpecularGlossinessInputEnergyConservation: boolean;
  52468. /** @hidden */
  52469. private _internalMarkAllSubMeshesAsMiscDirty;
  52470. /** @hidden */
  52471. _markAllSubMeshesAsMiscDirty(): void;
  52472. /**
  52473. * Instantiate a new istance of clear coat configuration.
  52474. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52475. */
  52476. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52477. /**
  52478. * Checks to see if a texture is used in the material.
  52479. * @param defines the list of "defines" to update.
  52480. */
  52481. prepareDefines(defines: IMaterialBRDFDefines): void;
  52482. /**
  52483. * Get the current class name of the texture useful for serialization or dynamic coding.
  52484. * @returns "PBRClearCoatConfiguration"
  52485. */
  52486. getClassName(): string;
  52487. /**
  52488. * Makes a duplicate of the current configuration into another one.
  52489. * @param brdfConfiguration define the config where to copy the info
  52490. */
  52491. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52492. /**
  52493. * Serializes this BRDF configuration.
  52494. * @returns - An object with the serialized config.
  52495. */
  52496. serialize(): any;
  52497. /**
  52498. * Parses a anisotropy Configuration from a serialized object.
  52499. * @param source - Serialized object.
  52500. * @param scene Defines the scene we are parsing for
  52501. * @param rootUrl Defines the rootUrl to load from
  52502. */
  52503. parse(source: any, scene: Scene, rootUrl: string): void;
  52504. }
  52505. }
  52506. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52507. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52508. import { Color3 } from "babylonjs/Maths/math.color";
  52509. import { Scene } from "babylonjs/scene";
  52510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52511. import { Nullable } from "babylonjs/types";
  52512. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52513. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52514. /**
  52515. * @hidden
  52516. */
  52517. export interface IMaterialSheenDefines {
  52518. SHEEN: boolean;
  52519. SHEEN_TEXTURE: boolean;
  52520. SHEEN_TEXTUREDIRECTUV: number;
  52521. SHEEN_LINKWITHALBEDO: boolean;
  52522. /** @hidden */
  52523. _areTexturesDirty: boolean;
  52524. }
  52525. /**
  52526. * Define the code related to the Sheen parameters of the pbr material.
  52527. */
  52528. export class PBRSheenConfiguration {
  52529. private _isEnabled;
  52530. /**
  52531. * Defines if the material uses sheen.
  52532. */
  52533. isEnabled: boolean;
  52534. private _linkSheenWithAlbedo;
  52535. /**
  52536. * Defines if the sheen is linked to the sheen color.
  52537. */
  52538. linkSheenWithAlbedo: boolean;
  52539. /**
  52540. * Defines the sheen intensity.
  52541. */
  52542. intensity: number;
  52543. /**
  52544. * Defines the sheen color.
  52545. */
  52546. color: Color3;
  52547. private _texture;
  52548. /**
  52549. * Stores the sheen tint values in a texture.
  52550. * rgb is tint
  52551. * a is a intensity
  52552. */
  52553. texture: Nullable<BaseTexture>;
  52554. /** @hidden */
  52555. private _internalMarkAllSubMeshesAsTexturesDirty;
  52556. /** @hidden */
  52557. _markAllSubMeshesAsTexturesDirty(): void;
  52558. /**
  52559. * Instantiate a new istance of clear coat configuration.
  52560. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52561. */
  52562. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52563. /**
  52564. * Specifies that the submesh is ready to be used.
  52565. * @param defines the list of "defines" to update.
  52566. * @param scene defines the scene the material belongs to.
  52567. * @returns - boolean indicating that the submesh is ready or not.
  52568. */
  52569. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52570. /**
  52571. * Checks to see if a texture is used in the material.
  52572. * @param defines the list of "defines" to update.
  52573. * @param scene defines the scene the material belongs to.
  52574. */
  52575. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52576. /**
  52577. * Binds the material data.
  52578. * @param uniformBuffer defines the Uniform buffer to fill in.
  52579. * @param scene defines the scene the material belongs to.
  52580. * @param isFrozen defines wether the material is frozen or not.
  52581. */
  52582. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52583. /**
  52584. * Checks to see if a texture is used in the material.
  52585. * @param texture - Base texture to use.
  52586. * @returns - Boolean specifying if a texture is used in the material.
  52587. */
  52588. hasTexture(texture: BaseTexture): boolean;
  52589. /**
  52590. * Returns an array of the actively used textures.
  52591. * @param activeTextures Array of BaseTextures
  52592. */
  52593. getActiveTextures(activeTextures: BaseTexture[]): void;
  52594. /**
  52595. * Returns the animatable textures.
  52596. * @param animatables Array of animatable textures.
  52597. */
  52598. getAnimatables(animatables: IAnimatable[]): void;
  52599. /**
  52600. * Disposes the resources of the material.
  52601. * @param forceDisposeTextures - Forces the disposal of all textures.
  52602. */
  52603. dispose(forceDisposeTextures?: boolean): void;
  52604. /**
  52605. * Get the current class name of the texture useful for serialization or dynamic coding.
  52606. * @returns "PBRSheenConfiguration"
  52607. */
  52608. getClassName(): string;
  52609. /**
  52610. * Add fallbacks to the effect fallbacks list.
  52611. * @param defines defines the Base texture to use.
  52612. * @param fallbacks defines the current fallback list.
  52613. * @param currentRank defines the current fallback rank.
  52614. * @returns the new fallback rank.
  52615. */
  52616. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52617. /**
  52618. * Add the required uniforms to the current list.
  52619. * @param uniforms defines the current uniform list.
  52620. */
  52621. static AddUniforms(uniforms: string[]): void;
  52622. /**
  52623. * Add the required uniforms to the current buffer.
  52624. * @param uniformBuffer defines the current uniform buffer.
  52625. */
  52626. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52627. /**
  52628. * Add the required samplers to the current list.
  52629. * @param samplers defines the current sampler list.
  52630. */
  52631. static AddSamplers(samplers: string[]): void;
  52632. /**
  52633. * Makes a duplicate of the current configuration into another one.
  52634. * @param sheenConfiguration define the config where to copy the info
  52635. */
  52636. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52637. /**
  52638. * Serializes this BRDF configuration.
  52639. * @returns - An object with the serialized config.
  52640. */
  52641. serialize(): any;
  52642. /**
  52643. * Parses a anisotropy Configuration from a serialized object.
  52644. * @param source - Serialized object.
  52645. * @param scene Defines the scene we are parsing for
  52646. * @param rootUrl Defines the rootUrl to load from
  52647. */
  52648. parse(source: any, scene: Scene, rootUrl: string): void;
  52649. }
  52650. }
  52651. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52652. import { Nullable } from "babylonjs/types";
  52653. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52654. import { Color3 } from "babylonjs/Maths/math.color";
  52655. import { SmartArray } from "babylonjs/Misc/smartArray";
  52656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52657. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52658. import { Effect } from "babylonjs/Materials/effect";
  52659. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52660. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52661. import { Engine } from "babylonjs/Engines/engine";
  52662. import { Scene } from "babylonjs/scene";
  52663. /**
  52664. * @hidden
  52665. */
  52666. export interface IMaterialSubSurfaceDefines {
  52667. SUBSURFACE: boolean;
  52668. SS_REFRACTION: boolean;
  52669. SS_TRANSLUCENCY: boolean;
  52670. SS_SCATERRING: boolean;
  52671. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52672. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52673. SS_REFRACTIONMAP_3D: boolean;
  52674. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52675. SS_LODINREFRACTIONALPHA: boolean;
  52676. SS_GAMMAREFRACTION: boolean;
  52677. SS_RGBDREFRACTION: boolean;
  52678. SS_LINEARSPECULARREFRACTION: boolean;
  52679. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52680. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52681. /** @hidden */
  52682. _areTexturesDirty: boolean;
  52683. }
  52684. /**
  52685. * Define the code related to the sub surface parameters of the pbr material.
  52686. */
  52687. export class PBRSubSurfaceConfiguration {
  52688. private _isRefractionEnabled;
  52689. /**
  52690. * Defines if the refraction is enabled in the material.
  52691. */
  52692. isRefractionEnabled: boolean;
  52693. private _isTranslucencyEnabled;
  52694. /**
  52695. * Defines if the translucency is enabled in the material.
  52696. */
  52697. isTranslucencyEnabled: boolean;
  52698. private _isScatteringEnabled;
  52699. /**
  52700. * Defines the refraction intensity of the material.
  52701. * The refraction when enabled replaces the Diffuse part of the material.
  52702. * The intensity helps transitionning between diffuse and refraction.
  52703. */
  52704. refractionIntensity: number;
  52705. /**
  52706. * Defines the translucency intensity of the material.
  52707. * When translucency has been enabled, this defines how much of the "translucency"
  52708. * is addded to the diffuse part of the material.
  52709. */
  52710. translucencyIntensity: number;
  52711. /**
  52712. * Defines the scattering intensity of the material.
  52713. * When scattering has been enabled, this defines how much of the "scattered light"
  52714. * is addded to the diffuse part of the material.
  52715. */
  52716. scatteringIntensity: number;
  52717. private _thicknessTexture;
  52718. /**
  52719. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52720. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52721. * 0 would mean minimumThickness
  52722. * 1 would mean maximumThickness
  52723. * The other channels might be use as a mask to vary the different effects intensity.
  52724. */
  52725. thicknessTexture: Nullable<BaseTexture>;
  52726. private _refractionTexture;
  52727. /**
  52728. * Defines the texture to use for refraction.
  52729. */
  52730. refractionTexture: Nullable<BaseTexture>;
  52731. private _indexOfRefraction;
  52732. /**
  52733. * Defines the index of refraction used in the material.
  52734. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52735. */
  52736. indexOfRefraction: number;
  52737. private _invertRefractionY;
  52738. /**
  52739. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52740. */
  52741. invertRefractionY: boolean;
  52742. private _linkRefractionWithTransparency;
  52743. /**
  52744. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52745. * Materials half opaque for instance using refraction could benefit from this control.
  52746. */
  52747. linkRefractionWithTransparency: boolean;
  52748. /**
  52749. * Defines the minimum thickness stored in the thickness map.
  52750. * If no thickness map is defined, this value will be used to simulate thickness.
  52751. */
  52752. minimumThickness: number;
  52753. /**
  52754. * Defines the maximum thickness stored in the thickness map.
  52755. */
  52756. maximumThickness: number;
  52757. /**
  52758. * Defines the volume tint of the material.
  52759. * This is used for both translucency and scattering.
  52760. */
  52761. tintColor: Color3;
  52762. /**
  52763. * Defines the distance at which the tint color should be found in the media.
  52764. * This is used for refraction only.
  52765. */
  52766. tintColorAtDistance: number;
  52767. /**
  52768. * Defines how far each channel transmit through the media.
  52769. * It is defined as a color to simplify it selection.
  52770. */
  52771. diffusionDistance: Color3;
  52772. private _useMaskFromThicknessTexture;
  52773. /**
  52774. * Stores the intensity of the different subsurface effects in the thickness texture.
  52775. * * the green channel is the translucency intensity.
  52776. * * the blue channel is the scattering intensity.
  52777. * * the alpha channel is the refraction intensity.
  52778. */
  52779. useMaskFromThicknessTexture: boolean;
  52780. /** @hidden */
  52781. private _internalMarkAllSubMeshesAsTexturesDirty;
  52782. /** @hidden */
  52783. _markAllSubMeshesAsTexturesDirty(): void;
  52784. /**
  52785. * Instantiate a new istance of sub surface configuration.
  52786. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52787. */
  52788. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52789. /**
  52790. * Gets wehter the submesh is ready to be used or not.
  52791. * @param defines the list of "defines" to update.
  52792. * @param scene defines the scene the material belongs to.
  52793. * @returns - boolean indicating that the submesh is ready or not.
  52794. */
  52795. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52796. /**
  52797. * Checks to see if a texture is used in the material.
  52798. * @param defines the list of "defines" to update.
  52799. * @param scene defines the scene to the material belongs to.
  52800. */
  52801. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52802. /**
  52803. * Binds the material data.
  52804. * @param uniformBuffer defines the Uniform buffer to fill in.
  52805. * @param scene defines the scene the material belongs to.
  52806. * @param engine defines the engine the material belongs to.
  52807. * @param isFrozen defines wether the material is frozen or not.
  52808. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52809. */
  52810. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52811. /**
  52812. * Unbinds the material from the mesh.
  52813. * @param activeEffect defines the effect that should be unbound from.
  52814. * @returns true if unbound, otherwise false
  52815. */
  52816. unbind(activeEffect: Effect): boolean;
  52817. /**
  52818. * Returns the texture used for refraction or null if none is used.
  52819. * @param scene defines the scene the material belongs to.
  52820. * @returns - Refraction texture if present. If no refraction texture and refraction
  52821. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52822. */
  52823. private _getRefractionTexture;
  52824. /**
  52825. * Returns true if alpha blending should be disabled.
  52826. */
  52827. get disableAlphaBlending(): boolean;
  52828. /**
  52829. * Fills the list of render target textures.
  52830. * @param renderTargets the list of render targets to update
  52831. */
  52832. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52833. /**
  52834. * Checks to see if a texture is used in the material.
  52835. * @param texture - Base texture to use.
  52836. * @returns - Boolean specifying if a texture is used in the material.
  52837. */
  52838. hasTexture(texture: BaseTexture): boolean;
  52839. /**
  52840. * Gets a boolean indicating that current material needs to register RTT
  52841. * @returns true if this uses a render target otherwise false.
  52842. */
  52843. hasRenderTargetTextures(): boolean;
  52844. /**
  52845. * Returns an array of the actively used textures.
  52846. * @param activeTextures Array of BaseTextures
  52847. */
  52848. getActiveTextures(activeTextures: BaseTexture[]): void;
  52849. /**
  52850. * Returns the animatable textures.
  52851. * @param animatables Array of animatable textures.
  52852. */
  52853. getAnimatables(animatables: IAnimatable[]): void;
  52854. /**
  52855. * Disposes the resources of the material.
  52856. * @param forceDisposeTextures - Forces the disposal of all textures.
  52857. */
  52858. dispose(forceDisposeTextures?: boolean): void;
  52859. /**
  52860. * Get the current class name of the texture useful for serialization or dynamic coding.
  52861. * @returns "PBRSubSurfaceConfiguration"
  52862. */
  52863. getClassName(): string;
  52864. /**
  52865. * Add fallbacks to the effect fallbacks list.
  52866. * @param defines defines the Base texture to use.
  52867. * @param fallbacks defines the current fallback list.
  52868. * @param currentRank defines the current fallback rank.
  52869. * @returns the new fallback rank.
  52870. */
  52871. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52872. /**
  52873. * Add the required uniforms to the current list.
  52874. * @param uniforms defines the current uniform list.
  52875. */
  52876. static AddUniforms(uniforms: string[]): void;
  52877. /**
  52878. * Add the required samplers to the current list.
  52879. * @param samplers defines the current sampler list.
  52880. */
  52881. static AddSamplers(samplers: string[]): void;
  52882. /**
  52883. * Add the required uniforms to the current buffer.
  52884. * @param uniformBuffer defines the current uniform buffer.
  52885. */
  52886. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52887. /**
  52888. * Makes a duplicate of the current configuration into another one.
  52889. * @param configuration define the config where to copy the info
  52890. */
  52891. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52892. /**
  52893. * Serializes this Sub Surface configuration.
  52894. * @returns - An object with the serialized config.
  52895. */
  52896. serialize(): any;
  52897. /**
  52898. * Parses a anisotropy Configuration from a serialized object.
  52899. * @param source - Serialized object.
  52900. * @param scene Defines the scene we are parsing for
  52901. * @param rootUrl Defines the rootUrl to load from
  52902. */
  52903. parse(source: any, scene: Scene, rootUrl: string): void;
  52904. }
  52905. }
  52906. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52907. /** @hidden */
  52908. export var pbrFragmentDeclaration: {
  52909. name: string;
  52910. shader: string;
  52911. };
  52912. }
  52913. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52914. /** @hidden */
  52915. export var pbrUboDeclaration: {
  52916. name: string;
  52917. shader: string;
  52918. };
  52919. }
  52920. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52921. /** @hidden */
  52922. export var pbrFragmentExtraDeclaration: {
  52923. name: string;
  52924. shader: string;
  52925. };
  52926. }
  52927. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52928. /** @hidden */
  52929. export var pbrFragmentSamplersDeclaration: {
  52930. name: string;
  52931. shader: string;
  52932. };
  52933. }
  52934. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52935. /** @hidden */
  52936. export var pbrHelperFunctions: {
  52937. name: string;
  52938. shader: string;
  52939. };
  52940. }
  52941. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52942. /** @hidden */
  52943. export var harmonicsFunctions: {
  52944. name: string;
  52945. shader: string;
  52946. };
  52947. }
  52948. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52949. /** @hidden */
  52950. export var pbrDirectLightingSetupFunctions: {
  52951. name: string;
  52952. shader: string;
  52953. };
  52954. }
  52955. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52956. /** @hidden */
  52957. export var pbrDirectLightingFalloffFunctions: {
  52958. name: string;
  52959. shader: string;
  52960. };
  52961. }
  52962. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52963. /** @hidden */
  52964. export var pbrBRDFFunctions: {
  52965. name: string;
  52966. shader: string;
  52967. };
  52968. }
  52969. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52970. /** @hidden */
  52971. export var pbrDirectLightingFunctions: {
  52972. name: string;
  52973. shader: string;
  52974. };
  52975. }
  52976. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52977. /** @hidden */
  52978. export var pbrIBLFunctions: {
  52979. name: string;
  52980. shader: string;
  52981. };
  52982. }
  52983. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52984. /** @hidden */
  52985. export var pbrDebug: {
  52986. name: string;
  52987. shader: string;
  52988. };
  52989. }
  52990. declare module "babylonjs/Shaders/pbr.fragment" {
  52991. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52992. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52993. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52994. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52995. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52996. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52997. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52998. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52999. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53000. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53001. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53002. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53003. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53004. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53005. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53006. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53007. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53008. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53009. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53010. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53011. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53012. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53013. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53014. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53015. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53016. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53017. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53018. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53019. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53020. /** @hidden */
  53021. export var pbrPixelShader: {
  53022. name: string;
  53023. shader: string;
  53024. };
  53025. }
  53026. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53027. /** @hidden */
  53028. export var pbrVertexDeclaration: {
  53029. name: string;
  53030. shader: string;
  53031. };
  53032. }
  53033. declare module "babylonjs/Shaders/pbr.vertex" {
  53034. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53035. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53037. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53038. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53039. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53040. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53041. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53042. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53043. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53044. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53045. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53046. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53047. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53048. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53049. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53050. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53051. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53052. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53053. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53054. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53055. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53056. /** @hidden */
  53057. export var pbrVertexShader: {
  53058. name: string;
  53059. shader: string;
  53060. };
  53061. }
  53062. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53063. import { Nullable } from "babylonjs/types";
  53064. import { Scene } from "babylonjs/scene";
  53065. import { Matrix } from "babylonjs/Maths/math.vector";
  53066. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53068. import { Mesh } from "babylonjs/Meshes/mesh";
  53069. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53070. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53071. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53072. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53073. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53074. import { Color3 } from "babylonjs/Maths/math.color";
  53075. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53076. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53077. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53078. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53079. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53080. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53081. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53082. import "babylonjs/Shaders/pbr.fragment";
  53083. import "babylonjs/Shaders/pbr.vertex";
  53084. /**
  53085. * Manages the defines for the PBR Material.
  53086. * @hidden
  53087. */
  53088. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53089. PBR: boolean;
  53090. MAINUV1: boolean;
  53091. MAINUV2: boolean;
  53092. UV1: boolean;
  53093. UV2: boolean;
  53094. ALBEDO: boolean;
  53095. ALBEDODIRECTUV: number;
  53096. VERTEXCOLOR: boolean;
  53097. AMBIENT: boolean;
  53098. AMBIENTDIRECTUV: number;
  53099. AMBIENTINGRAYSCALE: boolean;
  53100. OPACITY: boolean;
  53101. VERTEXALPHA: boolean;
  53102. OPACITYDIRECTUV: number;
  53103. OPACITYRGB: boolean;
  53104. ALPHATEST: boolean;
  53105. DEPTHPREPASS: boolean;
  53106. ALPHABLEND: boolean;
  53107. ALPHAFROMALBEDO: boolean;
  53108. ALPHATESTVALUE: string;
  53109. SPECULAROVERALPHA: boolean;
  53110. RADIANCEOVERALPHA: boolean;
  53111. ALPHAFRESNEL: boolean;
  53112. LINEARALPHAFRESNEL: boolean;
  53113. PREMULTIPLYALPHA: boolean;
  53114. EMISSIVE: boolean;
  53115. EMISSIVEDIRECTUV: number;
  53116. REFLECTIVITY: boolean;
  53117. REFLECTIVITYDIRECTUV: number;
  53118. SPECULARTERM: boolean;
  53119. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53120. MICROSURFACEAUTOMATIC: boolean;
  53121. LODBASEDMICROSFURACE: boolean;
  53122. MICROSURFACEMAP: boolean;
  53123. MICROSURFACEMAPDIRECTUV: number;
  53124. METALLICWORKFLOW: boolean;
  53125. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53126. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53127. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53128. AOSTOREINMETALMAPRED: boolean;
  53129. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53130. ENVIRONMENTBRDF: boolean;
  53131. ENVIRONMENTBRDF_RGBD: boolean;
  53132. NORMAL: boolean;
  53133. TANGENT: boolean;
  53134. BUMP: boolean;
  53135. BUMPDIRECTUV: number;
  53136. OBJECTSPACE_NORMALMAP: boolean;
  53137. PARALLAX: boolean;
  53138. PARALLAXOCCLUSION: boolean;
  53139. NORMALXYSCALE: boolean;
  53140. LIGHTMAP: boolean;
  53141. LIGHTMAPDIRECTUV: number;
  53142. USELIGHTMAPASSHADOWMAP: boolean;
  53143. GAMMALIGHTMAP: boolean;
  53144. RGBDLIGHTMAP: boolean;
  53145. REFLECTION: boolean;
  53146. REFLECTIONMAP_3D: boolean;
  53147. REFLECTIONMAP_SPHERICAL: boolean;
  53148. REFLECTIONMAP_PLANAR: boolean;
  53149. REFLECTIONMAP_CUBIC: boolean;
  53150. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53151. REFLECTIONMAP_PROJECTION: boolean;
  53152. REFLECTIONMAP_SKYBOX: boolean;
  53153. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  53154. REFLECTIONMAP_EXPLICIT: boolean;
  53155. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53156. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53157. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53158. INVERTCUBICMAP: boolean;
  53159. USESPHERICALFROMREFLECTIONMAP: boolean;
  53160. USEIRRADIANCEMAP: boolean;
  53161. SPHERICAL_HARMONICS: boolean;
  53162. USESPHERICALINVERTEX: boolean;
  53163. REFLECTIONMAP_OPPOSITEZ: boolean;
  53164. LODINREFLECTIONALPHA: boolean;
  53165. GAMMAREFLECTION: boolean;
  53166. RGBDREFLECTION: boolean;
  53167. LINEARSPECULARREFLECTION: boolean;
  53168. RADIANCEOCCLUSION: boolean;
  53169. HORIZONOCCLUSION: boolean;
  53170. INSTANCES: boolean;
  53171. NUM_BONE_INFLUENCERS: number;
  53172. BonesPerMesh: number;
  53173. BONETEXTURE: boolean;
  53174. NONUNIFORMSCALING: boolean;
  53175. MORPHTARGETS: boolean;
  53176. MORPHTARGETS_NORMAL: boolean;
  53177. MORPHTARGETS_TANGENT: boolean;
  53178. MORPHTARGETS_UV: boolean;
  53179. NUM_MORPH_INFLUENCERS: number;
  53180. IMAGEPROCESSING: boolean;
  53181. VIGNETTE: boolean;
  53182. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53183. VIGNETTEBLENDMODEOPAQUE: boolean;
  53184. TONEMAPPING: boolean;
  53185. TONEMAPPING_ACES: boolean;
  53186. CONTRAST: boolean;
  53187. COLORCURVES: boolean;
  53188. COLORGRADING: boolean;
  53189. COLORGRADING3D: boolean;
  53190. SAMPLER3DGREENDEPTH: boolean;
  53191. SAMPLER3DBGRMAP: boolean;
  53192. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53193. EXPOSURE: boolean;
  53194. MULTIVIEW: boolean;
  53195. USEPHYSICALLIGHTFALLOFF: boolean;
  53196. USEGLTFLIGHTFALLOFF: boolean;
  53197. TWOSIDEDLIGHTING: boolean;
  53198. SHADOWFLOAT: boolean;
  53199. CLIPPLANE: boolean;
  53200. CLIPPLANE2: boolean;
  53201. CLIPPLANE3: boolean;
  53202. CLIPPLANE4: boolean;
  53203. CLIPPLANE5: boolean;
  53204. CLIPPLANE6: boolean;
  53205. POINTSIZE: boolean;
  53206. FOG: boolean;
  53207. LOGARITHMICDEPTH: boolean;
  53208. FORCENORMALFORWARD: boolean;
  53209. SPECULARAA: boolean;
  53210. CLEARCOAT: boolean;
  53211. CLEARCOAT_DEFAULTIOR: boolean;
  53212. CLEARCOAT_TEXTURE: boolean;
  53213. CLEARCOAT_TEXTUREDIRECTUV: number;
  53214. CLEARCOAT_BUMP: boolean;
  53215. CLEARCOAT_BUMPDIRECTUV: number;
  53216. CLEARCOAT_TINT: boolean;
  53217. CLEARCOAT_TINT_TEXTURE: boolean;
  53218. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53219. ANISOTROPIC: boolean;
  53220. ANISOTROPIC_TEXTURE: boolean;
  53221. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53222. BRDF_V_HEIGHT_CORRELATED: boolean;
  53223. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53224. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53225. SHEEN: boolean;
  53226. SHEEN_TEXTURE: boolean;
  53227. SHEEN_TEXTUREDIRECTUV: number;
  53228. SHEEN_LINKWITHALBEDO: boolean;
  53229. SUBSURFACE: boolean;
  53230. SS_REFRACTION: boolean;
  53231. SS_TRANSLUCENCY: boolean;
  53232. SS_SCATERRING: boolean;
  53233. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53234. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53235. SS_REFRACTIONMAP_3D: boolean;
  53236. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53237. SS_LODINREFRACTIONALPHA: boolean;
  53238. SS_GAMMAREFRACTION: boolean;
  53239. SS_RGBDREFRACTION: boolean;
  53240. SS_LINEARSPECULARREFRACTION: boolean;
  53241. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53242. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53243. UNLIT: boolean;
  53244. DEBUGMODE: number;
  53245. /**
  53246. * Initializes the PBR Material defines.
  53247. */
  53248. constructor();
  53249. /**
  53250. * Resets the PBR Material defines.
  53251. */
  53252. reset(): void;
  53253. }
  53254. /**
  53255. * The Physically based material base class of BJS.
  53256. *
  53257. * This offers the main features of a standard PBR material.
  53258. * For more information, please refer to the documentation :
  53259. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53260. */
  53261. export abstract class PBRBaseMaterial extends PushMaterial {
  53262. /**
  53263. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53264. */
  53265. static readonly PBRMATERIAL_OPAQUE: number;
  53266. /**
  53267. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53268. */
  53269. static readonly PBRMATERIAL_ALPHATEST: number;
  53270. /**
  53271. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53272. */
  53273. static readonly PBRMATERIAL_ALPHABLEND: number;
  53274. /**
  53275. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53276. * They are also discarded below the alpha cutoff threshold to improve performances.
  53277. */
  53278. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53279. /**
  53280. * Defines the default value of how much AO map is occluding the analytical lights
  53281. * (point spot...).
  53282. */
  53283. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53284. /**
  53285. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53286. */
  53287. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53288. /**
  53289. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53290. * to enhance interoperability with other engines.
  53291. */
  53292. static readonly LIGHTFALLOFF_GLTF: number;
  53293. /**
  53294. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53295. * to enhance interoperability with other materials.
  53296. */
  53297. static readonly LIGHTFALLOFF_STANDARD: number;
  53298. /**
  53299. * Intensity of the direct lights e.g. the four lights available in your scene.
  53300. * This impacts both the direct diffuse and specular highlights.
  53301. */
  53302. protected _directIntensity: number;
  53303. /**
  53304. * Intensity of the emissive part of the material.
  53305. * This helps controlling the emissive effect without modifying the emissive color.
  53306. */
  53307. protected _emissiveIntensity: number;
  53308. /**
  53309. * Intensity of the environment e.g. how much the environment will light the object
  53310. * either through harmonics for rough material or through the refelction for shiny ones.
  53311. */
  53312. protected _environmentIntensity: number;
  53313. /**
  53314. * This is a special control allowing the reduction of the specular highlights coming from the
  53315. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53316. */
  53317. protected _specularIntensity: number;
  53318. /**
  53319. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53320. */
  53321. private _lightingInfos;
  53322. /**
  53323. * Debug Control allowing disabling the bump map on this material.
  53324. */
  53325. protected _disableBumpMap: boolean;
  53326. /**
  53327. * AKA Diffuse Texture in standard nomenclature.
  53328. */
  53329. protected _albedoTexture: Nullable<BaseTexture>;
  53330. /**
  53331. * AKA Occlusion Texture in other nomenclature.
  53332. */
  53333. protected _ambientTexture: Nullable<BaseTexture>;
  53334. /**
  53335. * AKA Occlusion Texture Intensity in other nomenclature.
  53336. */
  53337. protected _ambientTextureStrength: number;
  53338. /**
  53339. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53340. * 1 means it completely occludes it
  53341. * 0 mean it has no impact
  53342. */
  53343. protected _ambientTextureImpactOnAnalyticalLights: number;
  53344. /**
  53345. * Stores the alpha values in a texture.
  53346. */
  53347. protected _opacityTexture: Nullable<BaseTexture>;
  53348. /**
  53349. * Stores the reflection values in a texture.
  53350. */
  53351. protected _reflectionTexture: Nullable<BaseTexture>;
  53352. /**
  53353. * Stores the emissive values in a texture.
  53354. */
  53355. protected _emissiveTexture: Nullable<BaseTexture>;
  53356. /**
  53357. * AKA Specular texture in other nomenclature.
  53358. */
  53359. protected _reflectivityTexture: Nullable<BaseTexture>;
  53360. /**
  53361. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53362. */
  53363. protected _metallicTexture: Nullable<BaseTexture>;
  53364. /**
  53365. * Specifies the metallic scalar of the metallic/roughness workflow.
  53366. * Can also be used to scale the metalness values of the metallic texture.
  53367. */
  53368. protected _metallic: Nullable<number>;
  53369. /**
  53370. * Specifies the roughness scalar of the metallic/roughness workflow.
  53371. * Can also be used to scale the roughness values of the metallic texture.
  53372. */
  53373. protected _roughness: Nullable<number>;
  53374. /**
  53375. * Specifies the an F0 factor to help configuring the material F0.
  53376. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53377. * to 0.5 the previously hard coded value stays the same.
  53378. * Can also be used to scale the F0 values of the metallic texture.
  53379. */
  53380. protected _metallicF0Factor: number;
  53381. /**
  53382. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53383. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53384. * your expectation as it multiplies with the texture data.
  53385. */
  53386. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53387. /**
  53388. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53389. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53390. */
  53391. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53392. /**
  53393. * Stores surface normal data used to displace a mesh in a texture.
  53394. */
  53395. protected _bumpTexture: Nullable<BaseTexture>;
  53396. /**
  53397. * Stores the pre-calculated light information of a mesh in a texture.
  53398. */
  53399. protected _lightmapTexture: Nullable<BaseTexture>;
  53400. /**
  53401. * The color of a material in ambient lighting.
  53402. */
  53403. protected _ambientColor: Color3;
  53404. /**
  53405. * AKA Diffuse Color in other nomenclature.
  53406. */
  53407. protected _albedoColor: Color3;
  53408. /**
  53409. * AKA Specular Color in other nomenclature.
  53410. */
  53411. protected _reflectivityColor: Color3;
  53412. /**
  53413. * The color applied when light is reflected from a material.
  53414. */
  53415. protected _reflectionColor: Color3;
  53416. /**
  53417. * The color applied when light is emitted from a material.
  53418. */
  53419. protected _emissiveColor: Color3;
  53420. /**
  53421. * AKA Glossiness in other nomenclature.
  53422. */
  53423. protected _microSurface: number;
  53424. /**
  53425. * Specifies that the material will use the light map as a show map.
  53426. */
  53427. protected _useLightmapAsShadowmap: boolean;
  53428. /**
  53429. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53430. * makes the reflect vector face the model (under horizon).
  53431. */
  53432. protected _useHorizonOcclusion: boolean;
  53433. /**
  53434. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53435. * too much the area relying on ambient texture to define their ambient occlusion.
  53436. */
  53437. protected _useRadianceOcclusion: boolean;
  53438. /**
  53439. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53440. */
  53441. protected _useAlphaFromAlbedoTexture: boolean;
  53442. /**
  53443. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53444. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53445. */
  53446. protected _useSpecularOverAlpha: boolean;
  53447. /**
  53448. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53449. */
  53450. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53451. /**
  53452. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53453. */
  53454. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53455. /**
  53456. * Specifies if the metallic texture contains the roughness information in its green channel.
  53457. */
  53458. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53459. /**
  53460. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53461. */
  53462. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53463. /**
  53464. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53465. */
  53466. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53467. /**
  53468. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53469. */
  53470. protected _useAmbientInGrayScale: boolean;
  53471. /**
  53472. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53473. * The material will try to infer what glossiness each pixel should be.
  53474. */
  53475. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53476. /**
  53477. * Defines the falloff type used in this material.
  53478. * It by default is Physical.
  53479. */
  53480. protected _lightFalloff: number;
  53481. /**
  53482. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53483. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53484. */
  53485. protected _useRadianceOverAlpha: boolean;
  53486. /**
  53487. * Allows using an object space normal map (instead of tangent space).
  53488. */
  53489. protected _useObjectSpaceNormalMap: boolean;
  53490. /**
  53491. * Allows using the bump map in parallax mode.
  53492. */
  53493. protected _useParallax: boolean;
  53494. /**
  53495. * Allows using the bump map in parallax occlusion mode.
  53496. */
  53497. protected _useParallaxOcclusion: boolean;
  53498. /**
  53499. * Controls the scale bias of the parallax mode.
  53500. */
  53501. protected _parallaxScaleBias: number;
  53502. /**
  53503. * If sets to true, disables all the lights affecting the material.
  53504. */
  53505. protected _disableLighting: boolean;
  53506. /**
  53507. * Number of Simultaneous lights allowed on the material.
  53508. */
  53509. protected _maxSimultaneousLights: number;
  53510. /**
  53511. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53512. */
  53513. protected _invertNormalMapX: boolean;
  53514. /**
  53515. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53516. */
  53517. protected _invertNormalMapY: boolean;
  53518. /**
  53519. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53520. */
  53521. protected _twoSidedLighting: boolean;
  53522. /**
  53523. * Defines the alpha limits in alpha test mode.
  53524. */
  53525. protected _alphaCutOff: number;
  53526. /**
  53527. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53528. */
  53529. protected _forceAlphaTest: boolean;
  53530. /**
  53531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53532. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53533. */
  53534. protected _useAlphaFresnel: boolean;
  53535. /**
  53536. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53537. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53538. */
  53539. protected _useLinearAlphaFresnel: boolean;
  53540. /**
  53541. * The transparency mode of the material.
  53542. */
  53543. protected _transparencyMode: Nullable<number>;
  53544. /**
  53545. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53546. * from cos thetav and roughness:
  53547. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53548. */
  53549. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53550. /**
  53551. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53552. */
  53553. protected _forceIrradianceInFragment: boolean;
  53554. /**
  53555. * Force normal to face away from face.
  53556. */
  53557. protected _forceNormalForward: boolean;
  53558. /**
  53559. * Enables specular anti aliasing in the PBR shader.
  53560. * It will both interacts on the Geometry for analytical and IBL lighting.
  53561. * It also prefilter the roughness map based on the bump values.
  53562. */
  53563. protected _enableSpecularAntiAliasing: boolean;
  53564. /**
  53565. * Default configuration related to image processing available in the PBR Material.
  53566. */
  53567. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53568. /**
  53569. * Keep track of the image processing observer to allow dispose and replace.
  53570. */
  53571. private _imageProcessingObserver;
  53572. /**
  53573. * Attaches a new image processing configuration to the PBR Material.
  53574. * @param configuration
  53575. */
  53576. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53577. /**
  53578. * Stores the available render targets.
  53579. */
  53580. private _renderTargets;
  53581. /**
  53582. * Sets the global ambient color for the material used in lighting calculations.
  53583. */
  53584. private _globalAmbientColor;
  53585. /**
  53586. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53587. */
  53588. private _useLogarithmicDepth;
  53589. /**
  53590. * If set to true, no lighting calculations will be applied.
  53591. */
  53592. private _unlit;
  53593. private _debugMode;
  53594. /**
  53595. * @hidden
  53596. * This is reserved for the inspector.
  53597. * Defines the material debug mode.
  53598. * It helps seeing only some components of the material while troubleshooting.
  53599. */
  53600. debugMode: number;
  53601. /**
  53602. * @hidden
  53603. * This is reserved for the inspector.
  53604. * Specify from where on screen the debug mode should start.
  53605. * The value goes from -1 (full screen) to 1 (not visible)
  53606. * It helps with side by side comparison against the final render
  53607. * This defaults to -1
  53608. */
  53609. private debugLimit;
  53610. /**
  53611. * @hidden
  53612. * This is reserved for the inspector.
  53613. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53614. * You can use the factor to better multiply the final value.
  53615. */
  53616. private debugFactor;
  53617. /**
  53618. * Defines the clear coat layer parameters for the material.
  53619. */
  53620. readonly clearCoat: PBRClearCoatConfiguration;
  53621. /**
  53622. * Defines the anisotropic parameters for the material.
  53623. */
  53624. readonly anisotropy: PBRAnisotropicConfiguration;
  53625. /**
  53626. * Defines the BRDF parameters for the material.
  53627. */
  53628. readonly brdf: PBRBRDFConfiguration;
  53629. /**
  53630. * Defines the Sheen parameters for the material.
  53631. */
  53632. readonly sheen: PBRSheenConfiguration;
  53633. /**
  53634. * Defines the SubSurface parameters for the material.
  53635. */
  53636. readonly subSurface: PBRSubSurfaceConfiguration;
  53637. /**
  53638. * Custom callback helping to override the default shader used in the material.
  53639. */
  53640. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53641. protected _rebuildInParallel: boolean;
  53642. /**
  53643. * Instantiates a new PBRMaterial instance.
  53644. *
  53645. * @param name The material name
  53646. * @param scene The scene the material will be use in.
  53647. */
  53648. constructor(name: string, scene: Scene);
  53649. /**
  53650. * Gets a boolean indicating that current material needs to register RTT
  53651. */
  53652. get hasRenderTargetTextures(): boolean;
  53653. /**
  53654. * Gets the name of the material class.
  53655. */
  53656. getClassName(): string;
  53657. /**
  53658. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53659. */
  53660. get useLogarithmicDepth(): boolean;
  53661. /**
  53662. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53663. */
  53664. set useLogarithmicDepth(value: boolean);
  53665. /**
  53666. * Gets the current transparency mode.
  53667. */
  53668. get transparencyMode(): Nullable<number>;
  53669. /**
  53670. * Sets the transparency mode of the material.
  53671. *
  53672. * | Value | Type | Description |
  53673. * | ----- | ----------------------------------- | ----------- |
  53674. * | 0 | OPAQUE | |
  53675. * | 1 | ALPHATEST | |
  53676. * | 2 | ALPHABLEND | |
  53677. * | 3 | ALPHATESTANDBLEND | |
  53678. *
  53679. */
  53680. set transparencyMode(value: Nullable<number>);
  53681. /**
  53682. * Returns true if alpha blending should be disabled.
  53683. */
  53684. private get _disableAlphaBlending();
  53685. /**
  53686. * Specifies whether or not this material should be rendered in alpha blend mode.
  53687. */
  53688. needAlphaBlending(): boolean;
  53689. /**
  53690. * Specifies if the mesh will require alpha blending.
  53691. * @param mesh - BJS mesh.
  53692. */
  53693. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53694. /**
  53695. * Specifies whether or not this material should be rendered in alpha test mode.
  53696. */
  53697. needAlphaTesting(): boolean;
  53698. /**
  53699. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53700. */
  53701. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53702. /**
  53703. * Gets the texture used for the alpha test.
  53704. */
  53705. getAlphaTestTexture(): Nullable<BaseTexture>;
  53706. /**
  53707. * Specifies that the submesh is ready to be used.
  53708. * @param mesh - BJS mesh.
  53709. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53710. * @param useInstances - Specifies that instances should be used.
  53711. * @returns - boolean indicating that the submesh is ready or not.
  53712. */
  53713. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53714. /**
  53715. * Specifies if the material uses metallic roughness workflow.
  53716. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53717. */
  53718. isMetallicWorkflow(): boolean;
  53719. private _prepareEffect;
  53720. private _prepareDefines;
  53721. /**
  53722. * Force shader compilation
  53723. */
  53724. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53725. /**
  53726. * Initializes the uniform buffer layout for the shader.
  53727. */
  53728. buildUniformLayout(): void;
  53729. /**
  53730. * Unbinds the material from the mesh
  53731. */
  53732. unbind(): void;
  53733. /**
  53734. * Binds the submesh data.
  53735. * @param world - The world matrix.
  53736. * @param mesh - The BJS mesh.
  53737. * @param subMesh - A submesh of the BJS mesh.
  53738. */
  53739. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53740. /**
  53741. * Returns the animatable textures.
  53742. * @returns - Array of animatable textures.
  53743. */
  53744. getAnimatables(): IAnimatable[];
  53745. /**
  53746. * Returns the texture used for reflections.
  53747. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53748. */
  53749. private _getReflectionTexture;
  53750. /**
  53751. * Returns an array of the actively used textures.
  53752. * @returns - Array of BaseTextures
  53753. */
  53754. getActiveTextures(): BaseTexture[];
  53755. /**
  53756. * Checks to see if a texture is used in the material.
  53757. * @param texture - Base texture to use.
  53758. * @returns - Boolean specifying if a texture is used in the material.
  53759. */
  53760. hasTexture(texture: BaseTexture): boolean;
  53761. /**
  53762. * Disposes the resources of the material.
  53763. * @param forceDisposeEffect - Forces the disposal of effects.
  53764. * @param forceDisposeTextures - Forces the disposal of all textures.
  53765. */
  53766. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53767. }
  53768. }
  53769. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53770. import { Nullable } from "babylonjs/types";
  53771. import { Scene } from "babylonjs/scene";
  53772. import { Color3 } from "babylonjs/Maths/math.color";
  53773. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53774. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53776. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53777. /**
  53778. * The Physically based material of BJS.
  53779. *
  53780. * This offers the main features of a standard PBR material.
  53781. * For more information, please refer to the documentation :
  53782. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53783. */
  53784. export class PBRMaterial extends PBRBaseMaterial {
  53785. /**
  53786. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53787. */
  53788. static readonly PBRMATERIAL_OPAQUE: number;
  53789. /**
  53790. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53791. */
  53792. static readonly PBRMATERIAL_ALPHATEST: number;
  53793. /**
  53794. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53795. */
  53796. static readonly PBRMATERIAL_ALPHABLEND: number;
  53797. /**
  53798. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53799. * They are also discarded below the alpha cutoff threshold to improve performances.
  53800. */
  53801. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53802. /**
  53803. * Defines the default value of how much AO map is occluding the analytical lights
  53804. * (point spot...).
  53805. */
  53806. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53807. /**
  53808. * Intensity of the direct lights e.g. the four lights available in your scene.
  53809. * This impacts both the direct diffuse and specular highlights.
  53810. */
  53811. directIntensity: number;
  53812. /**
  53813. * Intensity of the emissive part of the material.
  53814. * This helps controlling the emissive effect without modifying the emissive color.
  53815. */
  53816. emissiveIntensity: number;
  53817. /**
  53818. * Intensity of the environment e.g. how much the environment will light the object
  53819. * either through harmonics for rough material or through the refelction for shiny ones.
  53820. */
  53821. environmentIntensity: number;
  53822. /**
  53823. * This is a special control allowing the reduction of the specular highlights coming from the
  53824. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53825. */
  53826. specularIntensity: number;
  53827. /**
  53828. * Debug Control allowing disabling the bump map on this material.
  53829. */
  53830. disableBumpMap: boolean;
  53831. /**
  53832. * AKA Diffuse Texture in standard nomenclature.
  53833. */
  53834. albedoTexture: BaseTexture;
  53835. /**
  53836. * AKA Occlusion Texture in other nomenclature.
  53837. */
  53838. ambientTexture: BaseTexture;
  53839. /**
  53840. * AKA Occlusion Texture Intensity in other nomenclature.
  53841. */
  53842. ambientTextureStrength: number;
  53843. /**
  53844. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53845. * 1 means it completely occludes it
  53846. * 0 mean it has no impact
  53847. */
  53848. ambientTextureImpactOnAnalyticalLights: number;
  53849. /**
  53850. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53851. */
  53852. opacityTexture: BaseTexture;
  53853. /**
  53854. * Stores the reflection values in a texture.
  53855. */
  53856. reflectionTexture: Nullable<BaseTexture>;
  53857. /**
  53858. * Stores the emissive values in a texture.
  53859. */
  53860. emissiveTexture: BaseTexture;
  53861. /**
  53862. * AKA Specular texture in other nomenclature.
  53863. */
  53864. reflectivityTexture: BaseTexture;
  53865. /**
  53866. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53867. */
  53868. metallicTexture: BaseTexture;
  53869. /**
  53870. * Specifies the metallic scalar of the metallic/roughness workflow.
  53871. * Can also be used to scale the metalness values of the metallic texture.
  53872. */
  53873. metallic: Nullable<number>;
  53874. /**
  53875. * Specifies the roughness scalar of the metallic/roughness workflow.
  53876. * Can also be used to scale the roughness values of the metallic texture.
  53877. */
  53878. roughness: Nullable<number>;
  53879. /**
  53880. * Specifies the an F0 factor to help configuring the material F0.
  53881. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53882. * to 0.5 the previously hard coded value stays the same.
  53883. * Can also be used to scale the F0 values of the metallic texture.
  53884. */
  53885. metallicF0Factor: number;
  53886. /**
  53887. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53888. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53889. * your expectation as it multiplies with the texture data.
  53890. */
  53891. useMetallicF0FactorFromMetallicTexture: boolean;
  53892. /**
  53893. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53894. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53895. */
  53896. microSurfaceTexture: BaseTexture;
  53897. /**
  53898. * Stores surface normal data used to displace a mesh in a texture.
  53899. */
  53900. bumpTexture: BaseTexture;
  53901. /**
  53902. * Stores the pre-calculated light information of a mesh in a texture.
  53903. */
  53904. lightmapTexture: BaseTexture;
  53905. /**
  53906. * Stores the refracted light information in a texture.
  53907. */
  53908. get refractionTexture(): Nullable<BaseTexture>;
  53909. set refractionTexture(value: Nullable<BaseTexture>);
  53910. /**
  53911. * The color of a material in ambient lighting.
  53912. */
  53913. ambientColor: Color3;
  53914. /**
  53915. * AKA Diffuse Color in other nomenclature.
  53916. */
  53917. albedoColor: Color3;
  53918. /**
  53919. * AKA Specular Color in other nomenclature.
  53920. */
  53921. reflectivityColor: Color3;
  53922. /**
  53923. * The color reflected from the material.
  53924. */
  53925. reflectionColor: Color3;
  53926. /**
  53927. * The color emitted from the material.
  53928. */
  53929. emissiveColor: Color3;
  53930. /**
  53931. * AKA Glossiness in other nomenclature.
  53932. */
  53933. microSurface: number;
  53934. /**
  53935. * source material index of refraction (IOR)' / 'destination material IOR.
  53936. */
  53937. get indexOfRefraction(): number;
  53938. set indexOfRefraction(value: number);
  53939. /**
  53940. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53941. */
  53942. get invertRefractionY(): boolean;
  53943. set invertRefractionY(value: boolean);
  53944. /**
  53945. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53946. * Materials half opaque for instance using refraction could benefit from this control.
  53947. */
  53948. get linkRefractionWithTransparency(): boolean;
  53949. set linkRefractionWithTransparency(value: boolean);
  53950. /**
  53951. * If true, the light map contains occlusion information instead of lighting info.
  53952. */
  53953. useLightmapAsShadowmap: boolean;
  53954. /**
  53955. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53956. */
  53957. useAlphaFromAlbedoTexture: boolean;
  53958. /**
  53959. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53960. */
  53961. forceAlphaTest: boolean;
  53962. /**
  53963. * Defines the alpha limits in alpha test mode.
  53964. */
  53965. alphaCutOff: number;
  53966. /**
  53967. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53968. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53969. */
  53970. useSpecularOverAlpha: boolean;
  53971. /**
  53972. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53973. */
  53974. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53975. /**
  53976. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53977. */
  53978. useRoughnessFromMetallicTextureAlpha: boolean;
  53979. /**
  53980. * Specifies if the metallic texture contains the roughness information in its green channel.
  53981. */
  53982. useRoughnessFromMetallicTextureGreen: boolean;
  53983. /**
  53984. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53985. */
  53986. useMetallnessFromMetallicTextureBlue: boolean;
  53987. /**
  53988. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53989. */
  53990. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53991. /**
  53992. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53993. */
  53994. useAmbientInGrayScale: boolean;
  53995. /**
  53996. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53997. * The material will try to infer what glossiness each pixel should be.
  53998. */
  53999. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54000. /**
  54001. * BJS is using an harcoded light falloff based on a manually sets up range.
  54002. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54003. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54004. */
  54005. get usePhysicalLightFalloff(): boolean;
  54006. /**
  54007. * BJS is using an harcoded light falloff based on a manually sets up range.
  54008. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54009. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54010. */
  54011. set usePhysicalLightFalloff(value: boolean);
  54012. /**
  54013. * In order to support the falloff compatibility with gltf, a special mode has been added
  54014. * to reproduce the gltf light falloff.
  54015. */
  54016. get useGLTFLightFalloff(): boolean;
  54017. /**
  54018. * In order to support the falloff compatibility with gltf, a special mode has been added
  54019. * to reproduce the gltf light falloff.
  54020. */
  54021. set useGLTFLightFalloff(value: boolean);
  54022. /**
  54023. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54024. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54025. */
  54026. useRadianceOverAlpha: boolean;
  54027. /**
  54028. * Allows using an object space normal map (instead of tangent space).
  54029. */
  54030. useObjectSpaceNormalMap: boolean;
  54031. /**
  54032. * Allows using the bump map in parallax mode.
  54033. */
  54034. useParallax: boolean;
  54035. /**
  54036. * Allows using the bump map in parallax occlusion mode.
  54037. */
  54038. useParallaxOcclusion: boolean;
  54039. /**
  54040. * Controls the scale bias of the parallax mode.
  54041. */
  54042. parallaxScaleBias: number;
  54043. /**
  54044. * If sets to true, disables all the lights affecting the material.
  54045. */
  54046. disableLighting: boolean;
  54047. /**
  54048. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54049. */
  54050. forceIrradianceInFragment: boolean;
  54051. /**
  54052. * Number of Simultaneous lights allowed on the material.
  54053. */
  54054. maxSimultaneousLights: number;
  54055. /**
  54056. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54057. */
  54058. invertNormalMapX: boolean;
  54059. /**
  54060. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54061. */
  54062. invertNormalMapY: boolean;
  54063. /**
  54064. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54065. */
  54066. twoSidedLighting: boolean;
  54067. /**
  54068. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54069. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54070. */
  54071. useAlphaFresnel: boolean;
  54072. /**
  54073. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54074. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54075. */
  54076. useLinearAlphaFresnel: boolean;
  54077. /**
  54078. * Let user defines the brdf lookup texture used for IBL.
  54079. * A default 8bit version is embedded but you could point at :
  54080. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54081. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54082. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54083. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54084. */
  54085. environmentBRDFTexture: Nullable<BaseTexture>;
  54086. /**
  54087. * Force normal to face away from face.
  54088. */
  54089. forceNormalForward: boolean;
  54090. /**
  54091. * Enables specular anti aliasing in the PBR shader.
  54092. * It will both interacts on the Geometry for analytical and IBL lighting.
  54093. * It also prefilter the roughness map based on the bump values.
  54094. */
  54095. enableSpecularAntiAliasing: boolean;
  54096. /**
  54097. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54098. * makes the reflect vector face the model (under horizon).
  54099. */
  54100. useHorizonOcclusion: boolean;
  54101. /**
  54102. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54103. * too much the area relying on ambient texture to define their ambient occlusion.
  54104. */
  54105. useRadianceOcclusion: boolean;
  54106. /**
  54107. * If set to true, no lighting calculations will be applied.
  54108. */
  54109. unlit: boolean;
  54110. /**
  54111. * Gets the image processing configuration used either in this material.
  54112. */
  54113. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54114. /**
  54115. * Sets the Default image processing configuration used either in the this material.
  54116. *
  54117. * If sets to null, the scene one is in use.
  54118. */
  54119. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54120. /**
  54121. * Gets wether the color curves effect is enabled.
  54122. */
  54123. get cameraColorCurvesEnabled(): boolean;
  54124. /**
  54125. * Sets wether the color curves effect is enabled.
  54126. */
  54127. set cameraColorCurvesEnabled(value: boolean);
  54128. /**
  54129. * Gets wether the color grading effect is enabled.
  54130. */
  54131. get cameraColorGradingEnabled(): boolean;
  54132. /**
  54133. * Gets wether the color grading effect is enabled.
  54134. */
  54135. set cameraColorGradingEnabled(value: boolean);
  54136. /**
  54137. * Gets wether tonemapping is enabled or not.
  54138. */
  54139. get cameraToneMappingEnabled(): boolean;
  54140. /**
  54141. * Sets wether tonemapping is enabled or not
  54142. */
  54143. set cameraToneMappingEnabled(value: boolean);
  54144. /**
  54145. * The camera exposure used on this material.
  54146. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54147. * This corresponds to a photographic exposure.
  54148. */
  54149. get cameraExposure(): number;
  54150. /**
  54151. * The camera exposure used on this material.
  54152. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54153. * This corresponds to a photographic exposure.
  54154. */
  54155. set cameraExposure(value: number);
  54156. /**
  54157. * Gets The camera contrast used on this material.
  54158. */
  54159. get cameraContrast(): number;
  54160. /**
  54161. * Sets The camera contrast used on this material.
  54162. */
  54163. set cameraContrast(value: number);
  54164. /**
  54165. * Gets the Color Grading 2D Lookup Texture.
  54166. */
  54167. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54168. /**
  54169. * Sets the Color Grading 2D Lookup Texture.
  54170. */
  54171. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54172. /**
  54173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54175. * 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;
  54176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54177. */
  54178. get cameraColorCurves(): Nullable<ColorCurves>;
  54179. /**
  54180. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54181. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54182. * 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;
  54183. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54184. */
  54185. set cameraColorCurves(value: Nullable<ColorCurves>);
  54186. /**
  54187. * Instantiates a new PBRMaterial instance.
  54188. *
  54189. * @param name The material name
  54190. * @param scene The scene the material will be use in.
  54191. */
  54192. constructor(name: string, scene: Scene);
  54193. /**
  54194. * Returns the name of this material class.
  54195. */
  54196. getClassName(): string;
  54197. /**
  54198. * Makes a duplicate of the current material.
  54199. * @param name - name to use for the new material.
  54200. */
  54201. clone(name: string): PBRMaterial;
  54202. /**
  54203. * Serializes this PBR Material.
  54204. * @returns - An object with the serialized material.
  54205. */
  54206. serialize(): any;
  54207. /**
  54208. * Parses a PBR Material from a serialized object.
  54209. * @param source - Serialized object.
  54210. * @param scene - BJS scene instance.
  54211. * @param rootUrl - url for the scene object
  54212. * @returns - PBRMaterial
  54213. */
  54214. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54215. }
  54216. }
  54217. declare module "babylonjs/Misc/dds" {
  54218. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54219. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54220. import { Nullable } from "babylonjs/types";
  54221. import { Scene } from "babylonjs/scene";
  54222. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54223. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54224. /**
  54225. * Direct draw surface info
  54226. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54227. */
  54228. export interface DDSInfo {
  54229. /**
  54230. * Width of the texture
  54231. */
  54232. width: number;
  54233. /**
  54234. * Width of the texture
  54235. */
  54236. height: number;
  54237. /**
  54238. * Number of Mipmaps for the texture
  54239. * @see https://en.wikipedia.org/wiki/Mipmap
  54240. */
  54241. mipmapCount: number;
  54242. /**
  54243. * If the textures format is a known fourCC format
  54244. * @see https://www.fourcc.org/
  54245. */
  54246. isFourCC: boolean;
  54247. /**
  54248. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54249. */
  54250. isRGB: boolean;
  54251. /**
  54252. * If the texture is a lumincance format
  54253. */
  54254. isLuminance: boolean;
  54255. /**
  54256. * If this is a cube texture
  54257. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54258. */
  54259. isCube: boolean;
  54260. /**
  54261. * If the texture is a compressed format eg. FOURCC_DXT1
  54262. */
  54263. isCompressed: boolean;
  54264. /**
  54265. * The dxgiFormat of the texture
  54266. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54267. */
  54268. dxgiFormat: number;
  54269. /**
  54270. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54271. */
  54272. textureType: number;
  54273. /**
  54274. * Sphericle polynomial created for the dds texture
  54275. */
  54276. sphericalPolynomial?: SphericalPolynomial;
  54277. }
  54278. /**
  54279. * Class used to provide DDS decompression tools
  54280. */
  54281. export class DDSTools {
  54282. /**
  54283. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54284. */
  54285. static StoreLODInAlphaChannel: boolean;
  54286. /**
  54287. * Gets DDS information from an array buffer
  54288. * @param arrayBuffer defines the array buffer to read data from
  54289. * @returns the DDS information
  54290. */
  54291. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  54292. private static _FloatView;
  54293. private static _Int32View;
  54294. private static _ToHalfFloat;
  54295. private static _FromHalfFloat;
  54296. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54297. private static _GetHalfFloatRGBAArrayBuffer;
  54298. private static _GetFloatRGBAArrayBuffer;
  54299. private static _GetFloatAsUIntRGBAArrayBuffer;
  54300. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54301. private static _GetRGBAArrayBuffer;
  54302. private static _ExtractLongWordOrder;
  54303. private static _GetRGBArrayBuffer;
  54304. private static _GetLuminanceArrayBuffer;
  54305. /**
  54306. * Uploads DDS Levels to a Babylon Texture
  54307. * @hidden
  54308. */
  54309. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54310. }
  54311. module "babylonjs/Engines/thinEngine" {
  54312. interface ThinEngine {
  54313. /**
  54314. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54315. * @param rootUrl defines the url where the file to load is located
  54316. * @param scene defines the current scene
  54317. * @param lodScale defines scale to apply to the mip map selection
  54318. * @param lodOffset defines offset to apply to the mip map selection
  54319. * @param onLoad defines an optional callback raised when the texture is loaded
  54320. * @param onError defines an optional callback raised if there is an issue to load the texture
  54321. * @param format defines the format of the data
  54322. * @param forcedExtension defines the extension to use to pick the right loader
  54323. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54324. * @returns the cube texture as an InternalTexture
  54325. */
  54326. 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;
  54327. }
  54328. }
  54329. }
  54330. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54331. import { Nullable } from "babylonjs/types";
  54332. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54333. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54334. /**
  54335. * Implementation of the DDS Texture Loader.
  54336. * @hidden
  54337. */
  54338. export class _DDSTextureLoader implements IInternalTextureLoader {
  54339. /**
  54340. * Defines wether the loader supports cascade loading the different faces.
  54341. */
  54342. readonly supportCascades: boolean;
  54343. /**
  54344. * This returns if the loader support the current file information.
  54345. * @param extension defines the file extension of the file being loaded
  54346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54347. * @param fallback defines the fallback internal texture if any
  54348. * @param isBase64 defines whether the texture is encoded as a base64
  54349. * @param isBuffer defines whether the texture data are stored as a buffer
  54350. * @returns true if the loader can load the specified file
  54351. */
  54352. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54353. /**
  54354. * Transform the url before loading if required.
  54355. * @param rootUrl the url of the texture
  54356. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54357. * @returns the transformed texture
  54358. */
  54359. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54360. /**
  54361. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54362. * @param rootUrl the url of the texture
  54363. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54364. * @returns the fallback texture
  54365. */
  54366. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54367. /**
  54368. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54369. * @param data contains the texture data
  54370. * @param texture defines the BabylonJS internal texture
  54371. * @param createPolynomials will be true if polynomials have been requested
  54372. * @param onLoad defines the callback to trigger once the texture is ready
  54373. * @param onError defines the callback to trigger in case of error
  54374. */
  54375. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54376. /**
  54377. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54378. * @param data contains the texture data
  54379. * @param texture defines the BabylonJS internal texture
  54380. * @param callback defines the method to call once ready to upload
  54381. */
  54382. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54383. }
  54384. }
  54385. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54386. import { Nullable } from "babylonjs/types";
  54387. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54388. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54389. /**
  54390. * Implementation of the ENV Texture Loader.
  54391. * @hidden
  54392. */
  54393. export class _ENVTextureLoader implements IInternalTextureLoader {
  54394. /**
  54395. * Defines wether the loader supports cascade loading the different faces.
  54396. */
  54397. readonly supportCascades: boolean;
  54398. /**
  54399. * This returns if the loader support the current file information.
  54400. * @param extension defines the file extension of the file being loaded
  54401. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54402. * @param fallback defines the fallback internal texture if any
  54403. * @param isBase64 defines whether the texture is encoded as a base64
  54404. * @param isBuffer defines whether the texture data are stored as a buffer
  54405. * @returns true if the loader can load the specified file
  54406. */
  54407. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54408. /**
  54409. * Transform the url before loading if required.
  54410. * @param rootUrl the url of the texture
  54411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54412. * @returns the transformed texture
  54413. */
  54414. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54415. /**
  54416. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54417. * @param rootUrl the url of the texture
  54418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54419. * @returns the fallback texture
  54420. */
  54421. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54422. /**
  54423. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54424. * @param data contains the texture data
  54425. * @param texture defines the BabylonJS internal texture
  54426. * @param createPolynomials will be true if polynomials have been requested
  54427. * @param onLoad defines the callback to trigger once the texture is ready
  54428. * @param onError defines the callback to trigger in case of error
  54429. */
  54430. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54431. /**
  54432. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54433. * @param data contains the texture data
  54434. * @param texture defines the BabylonJS internal texture
  54435. * @param callback defines the method to call once ready to upload
  54436. */
  54437. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54438. }
  54439. }
  54440. declare module "babylonjs/Misc/khronosTextureContainer" {
  54441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54442. /**
  54443. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54444. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54445. */
  54446. export class KhronosTextureContainer {
  54447. /** contents of the KTX container file */
  54448. arrayBuffer: any;
  54449. private static HEADER_LEN;
  54450. private static COMPRESSED_2D;
  54451. private static COMPRESSED_3D;
  54452. private static TEX_2D;
  54453. private static TEX_3D;
  54454. /**
  54455. * Gets the openGL type
  54456. */
  54457. glType: number;
  54458. /**
  54459. * Gets the openGL type size
  54460. */
  54461. glTypeSize: number;
  54462. /**
  54463. * Gets the openGL format
  54464. */
  54465. glFormat: number;
  54466. /**
  54467. * Gets the openGL internal format
  54468. */
  54469. glInternalFormat: number;
  54470. /**
  54471. * Gets the base internal format
  54472. */
  54473. glBaseInternalFormat: number;
  54474. /**
  54475. * Gets image width in pixel
  54476. */
  54477. pixelWidth: number;
  54478. /**
  54479. * Gets image height in pixel
  54480. */
  54481. pixelHeight: number;
  54482. /**
  54483. * Gets image depth in pixels
  54484. */
  54485. pixelDepth: number;
  54486. /**
  54487. * Gets the number of array elements
  54488. */
  54489. numberOfArrayElements: number;
  54490. /**
  54491. * Gets the number of faces
  54492. */
  54493. numberOfFaces: number;
  54494. /**
  54495. * Gets the number of mipmap levels
  54496. */
  54497. numberOfMipmapLevels: number;
  54498. /**
  54499. * Gets the bytes of key value data
  54500. */
  54501. bytesOfKeyValueData: number;
  54502. /**
  54503. * Gets the load type
  54504. */
  54505. loadType: number;
  54506. /**
  54507. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54508. */
  54509. isInvalid: boolean;
  54510. /**
  54511. * Creates a new KhronosTextureContainer
  54512. * @param arrayBuffer contents of the KTX container file
  54513. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54514. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54515. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54516. */
  54517. constructor(
  54518. /** contents of the KTX container file */
  54519. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54520. /**
  54521. * Uploads KTX content to a Babylon Texture.
  54522. * It is assumed that the texture has already been created & is currently bound
  54523. * @hidden
  54524. */
  54525. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54526. private _upload2DCompressedLevels;
  54527. }
  54528. }
  54529. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54530. import { Nullable } from "babylonjs/types";
  54531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54532. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54533. /**
  54534. * Implementation of the KTX Texture Loader.
  54535. * @hidden
  54536. */
  54537. export class _KTXTextureLoader implements IInternalTextureLoader {
  54538. /**
  54539. * Defines wether the loader supports cascade loading the different faces.
  54540. */
  54541. readonly supportCascades: boolean;
  54542. /**
  54543. * This returns if the loader support the current file information.
  54544. * @param extension defines the file extension of the file being loaded
  54545. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54546. * @param fallback defines the fallback internal texture if any
  54547. * @param isBase64 defines whether the texture is encoded as a base64
  54548. * @param isBuffer defines whether the texture data are stored as a buffer
  54549. * @returns true if the loader can load the specified file
  54550. */
  54551. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54552. /**
  54553. * Transform the url before loading if required.
  54554. * @param rootUrl the url of the texture
  54555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54556. * @returns the transformed texture
  54557. */
  54558. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54559. /**
  54560. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54561. * @param rootUrl the url of the texture
  54562. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54563. * @returns the fallback texture
  54564. */
  54565. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54566. /**
  54567. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54568. * @param data contains the texture data
  54569. * @param texture defines the BabylonJS internal texture
  54570. * @param createPolynomials will be true if polynomials have been requested
  54571. * @param onLoad defines the callback to trigger once the texture is ready
  54572. * @param onError defines the callback to trigger in case of error
  54573. */
  54574. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54575. /**
  54576. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54577. * @param data contains the texture data
  54578. * @param texture defines the BabylonJS internal texture
  54579. * @param callback defines the method to call once ready to upload
  54580. */
  54581. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54582. }
  54583. }
  54584. declare module "babylonjs/Helpers/sceneHelpers" {
  54585. import { Nullable } from "babylonjs/types";
  54586. import { Mesh } from "babylonjs/Meshes/mesh";
  54587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54588. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54589. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54590. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54591. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54592. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54593. import "babylonjs/Meshes/Builders/boxBuilder";
  54594. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  54595. /** @hidden */
  54596. export var _forceSceneHelpersToBundle: boolean;
  54597. module "babylonjs/scene" {
  54598. interface Scene {
  54599. /**
  54600. * Creates a default light for the scene.
  54601. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54602. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54603. */
  54604. createDefaultLight(replace?: boolean): void;
  54605. /**
  54606. * Creates a default camera for the scene.
  54607. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54608. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54609. * @param replace has default false, when true replaces the active camera in the scene
  54610. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54611. */
  54612. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54613. /**
  54614. * Creates a default camera and a default light.
  54615. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54616. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54617. * @param replace has the default false, when true replaces the active camera/light in the scene
  54618. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54619. */
  54620. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54621. /**
  54622. * Creates a new sky box
  54623. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54624. * @param environmentTexture defines the texture to use as environment texture
  54625. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54626. * @param scale defines the overall scale of the skybox
  54627. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54628. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54629. * @returns a new mesh holding the sky box
  54630. */
  54631. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54632. /**
  54633. * Creates a new environment
  54634. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54635. * @param options defines the options you can use to configure the environment
  54636. * @returns the new EnvironmentHelper
  54637. */
  54638. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54639. /**
  54640. * Creates a new VREXperienceHelper
  54641. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54642. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54643. * @returns a new VREXperienceHelper
  54644. */
  54645. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54646. /**
  54647. * Creates a new WebXRDefaultExperience
  54648. * @see http://doc.babylonjs.com/how_to/webxr
  54649. * @param options experience options
  54650. * @returns a promise for a new WebXRDefaultExperience
  54651. */
  54652. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54653. }
  54654. }
  54655. }
  54656. declare module "babylonjs/Helpers/videoDome" {
  54657. import { Scene } from "babylonjs/scene";
  54658. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54659. import { Mesh } from "babylonjs/Meshes/mesh";
  54660. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54661. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54662. import "babylonjs/Meshes/Builders/sphereBuilder";
  54663. /**
  54664. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54665. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54666. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54667. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54668. */
  54669. export class VideoDome extends TransformNode {
  54670. /**
  54671. * Define the video source as a Monoscopic panoramic 360 video.
  54672. */
  54673. static readonly MODE_MONOSCOPIC: number;
  54674. /**
  54675. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54676. */
  54677. static readonly MODE_TOPBOTTOM: number;
  54678. /**
  54679. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54680. */
  54681. static readonly MODE_SIDEBYSIDE: number;
  54682. private _halfDome;
  54683. private _useDirectMapping;
  54684. /**
  54685. * The video texture being displayed on the sphere
  54686. */
  54687. protected _videoTexture: VideoTexture;
  54688. /**
  54689. * Gets the video texture being displayed on the sphere
  54690. */
  54691. get videoTexture(): VideoTexture;
  54692. /**
  54693. * The skybox material
  54694. */
  54695. protected _material: BackgroundMaterial;
  54696. /**
  54697. * The surface used for the skybox
  54698. */
  54699. protected _mesh: Mesh;
  54700. /**
  54701. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54702. */
  54703. private _halfDomeMask;
  54704. /**
  54705. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54706. * Also see the options.resolution property.
  54707. */
  54708. get fovMultiplier(): number;
  54709. set fovMultiplier(value: number);
  54710. private _videoMode;
  54711. /**
  54712. * Gets or set the current video mode for the video. It can be:
  54713. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54714. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54715. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54716. */
  54717. get videoMode(): number;
  54718. set videoMode(value: number);
  54719. /**
  54720. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54721. *
  54722. */
  54723. get halfDome(): boolean;
  54724. /**
  54725. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54726. */
  54727. set halfDome(enabled: boolean);
  54728. /**
  54729. * Oberserver used in Stereoscopic VR Mode.
  54730. */
  54731. private _onBeforeCameraRenderObserver;
  54732. /**
  54733. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54734. * @param name Element's name, child elements will append suffixes for their own names.
  54735. * @param urlsOrVideo defines the url(s) or the video element to use
  54736. * @param options An object containing optional or exposed sub element properties
  54737. */
  54738. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54739. resolution?: number;
  54740. clickToPlay?: boolean;
  54741. autoPlay?: boolean;
  54742. loop?: boolean;
  54743. size?: number;
  54744. poster?: string;
  54745. faceForward?: boolean;
  54746. useDirectMapping?: boolean;
  54747. halfDomeMode?: boolean;
  54748. }, scene: Scene);
  54749. private _changeVideoMode;
  54750. /**
  54751. * Releases resources associated with this node.
  54752. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54753. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54754. */
  54755. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54756. }
  54757. }
  54758. declare module "babylonjs/Helpers/index" {
  54759. export * from "babylonjs/Helpers/environmentHelper";
  54760. export * from "babylonjs/Helpers/photoDome";
  54761. export * from "babylonjs/Helpers/sceneHelpers";
  54762. export * from "babylonjs/Helpers/videoDome";
  54763. }
  54764. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54765. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54766. import { IDisposable } from "babylonjs/scene";
  54767. import { Engine } from "babylonjs/Engines/engine";
  54768. /**
  54769. * This class can be used to get instrumentation data from a Babylon engine
  54770. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54771. */
  54772. export class EngineInstrumentation implements IDisposable {
  54773. /**
  54774. * Define the instrumented engine.
  54775. */
  54776. engine: Engine;
  54777. private _captureGPUFrameTime;
  54778. private _gpuFrameTimeToken;
  54779. private _gpuFrameTime;
  54780. private _captureShaderCompilationTime;
  54781. private _shaderCompilationTime;
  54782. private _onBeginFrameObserver;
  54783. private _onEndFrameObserver;
  54784. private _onBeforeShaderCompilationObserver;
  54785. private _onAfterShaderCompilationObserver;
  54786. /**
  54787. * Gets the perf counter used for GPU frame time
  54788. */
  54789. get gpuFrameTimeCounter(): PerfCounter;
  54790. /**
  54791. * Gets the GPU frame time capture status
  54792. */
  54793. get captureGPUFrameTime(): boolean;
  54794. /**
  54795. * Enable or disable the GPU frame time capture
  54796. */
  54797. set captureGPUFrameTime(value: boolean);
  54798. /**
  54799. * Gets the perf counter used for shader compilation time
  54800. */
  54801. get shaderCompilationTimeCounter(): PerfCounter;
  54802. /**
  54803. * Gets the shader compilation time capture status
  54804. */
  54805. get captureShaderCompilationTime(): boolean;
  54806. /**
  54807. * Enable or disable the shader compilation time capture
  54808. */
  54809. set captureShaderCompilationTime(value: boolean);
  54810. /**
  54811. * Instantiates a new engine instrumentation.
  54812. * This class can be used to get instrumentation data from a Babylon engine
  54813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54814. * @param engine Defines the engine to instrument
  54815. */
  54816. constructor(
  54817. /**
  54818. * Define the instrumented engine.
  54819. */
  54820. engine: Engine);
  54821. /**
  54822. * Dispose and release associated resources.
  54823. */
  54824. dispose(): void;
  54825. }
  54826. }
  54827. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54828. import { Scene, IDisposable } from "babylonjs/scene";
  54829. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54830. /**
  54831. * This class can be used to get instrumentation data from a Babylon engine
  54832. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54833. */
  54834. export class SceneInstrumentation implements IDisposable {
  54835. /**
  54836. * Defines the scene to instrument
  54837. */
  54838. scene: Scene;
  54839. private _captureActiveMeshesEvaluationTime;
  54840. private _activeMeshesEvaluationTime;
  54841. private _captureRenderTargetsRenderTime;
  54842. private _renderTargetsRenderTime;
  54843. private _captureFrameTime;
  54844. private _frameTime;
  54845. private _captureRenderTime;
  54846. private _renderTime;
  54847. private _captureInterFrameTime;
  54848. private _interFrameTime;
  54849. private _captureParticlesRenderTime;
  54850. private _particlesRenderTime;
  54851. private _captureSpritesRenderTime;
  54852. private _spritesRenderTime;
  54853. private _capturePhysicsTime;
  54854. private _physicsTime;
  54855. private _captureAnimationsTime;
  54856. private _animationsTime;
  54857. private _captureCameraRenderTime;
  54858. private _cameraRenderTime;
  54859. private _onBeforeActiveMeshesEvaluationObserver;
  54860. private _onAfterActiveMeshesEvaluationObserver;
  54861. private _onBeforeRenderTargetsRenderObserver;
  54862. private _onAfterRenderTargetsRenderObserver;
  54863. private _onAfterRenderObserver;
  54864. private _onBeforeDrawPhaseObserver;
  54865. private _onAfterDrawPhaseObserver;
  54866. private _onBeforeAnimationsObserver;
  54867. private _onBeforeParticlesRenderingObserver;
  54868. private _onAfterParticlesRenderingObserver;
  54869. private _onBeforeSpritesRenderingObserver;
  54870. private _onAfterSpritesRenderingObserver;
  54871. private _onBeforePhysicsObserver;
  54872. private _onAfterPhysicsObserver;
  54873. private _onAfterAnimationsObserver;
  54874. private _onBeforeCameraRenderObserver;
  54875. private _onAfterCameraRenderObserver;
  54876. /**
  54877. * Gets the perf counter used for active meshes evaluation time
  54878. */
  54879. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54880. /**
  54881. * Gets the active meshes evaluation time capture status
  54882. */
  54883. get captureActiveMeshesEvaluationTime(): boolean;
  54884. /**
  54885. * Enable or disable the active meshes evaluation time capture
  54886. */
  54887. set captureActiveMeshesEvaluationTime(value: boolean);
  54888. /**
  54889. * Gets the perf counter used for render targets render time
  54890. */
  54891. get renderTargetsRenderTimeCounter(): PerfCounter;
  54892. /**
  54893. * Gets the render targets render time capture status
  54894. */
  54895. get captureRenderTargetsRenderTime(): boolean;
  54896. /**
  54897. * Enable or disable the render targets render time capture
  54898. */
  54899. set captureRenderTargetsRenderTime(value: boolean);
  54900. /**
  54901. * Gets the perf counter used for particles render time
  54902. */
  54903. get particlesRenderTimeCounter(): PerfCounter;
  54904. /**
  54905. * Gets the particles render time capture status
  54906. */
  54907. get captureParticlesRenderTime(): boolean;
  54908. /**
  54909. * Enable or disable the particles render time capture
  54910. */
  54911. set captureParticlesRenderTime(value: boolean);
  54912. /**
  54913. * Gets the perf counter used for sprites render time
  54914. */
  54915. get spritesRenderTimeCounter(): PerfCounter;
  54916. /**
  54917. * Gets the sprites render time capture status
  54918. */
  54919. get captureSpritesRenderTime(): boolean;
  54920. /**
  54921. * Enable or disable the sprites render time capture
  54922. */
  54923. set captureSpritesRenderTime(value: boolean);
  54924. /**
  54925. * Gets the perf counter used for physics time
  54926. */
  54927. get physicsTimeCounter(): PerfCounter;
  54928. /**
  54929. * Gets the physics time capture status
  54930. */
  54931. get capturePhysicsTime(): boolean;
  54932. /**
  54933. * Enable or disable the physics time capture
  54934. */
  54935. set capturePhysicsTime(value: boolean);
  54936. /**
  54937. * Gets the perf counter used for animations time
  54938. */
  54939. get animationsTimeCounter(): PerfCounter;
  54940. /**
  54941. * Gets the animations time capture status
  54942. */
  54943. get captureAnimationsTime(): boolean;
  54944. /**
  54945. * Enable or disable the animations time capture
  54946. */
  54947. set captureAnimationsTime(value: boolean);
  54948. /**
  54949. * Gets the perf counter used for frame time capture
  54950. */
  54951. get frameTimeCounter(): PerfCounter;
  54952. /**
  54953. * Gets the frame time capture status
  54954. */
  54955. get captureFrameTime(): boolean;
  54956. /**
  54957. * Enable or disable the frame time capture
  54958. */
  54959. set captureFrameTime(value: boolean);
  54960. /**
  54961. * Gets the perf counter used for inter-frames time capture
  54962. */
  54963. get interFrameTimeCounter(): PerfCounter;
  54964. /**
  54965. * Gets the inter-frames time capture status
  54966. */
  54967. get captureInterFrameTime(): boolean;
  54968. /**
  54969. * Enable or disable the inter-frames time capture
  54970. */
  54971. set captureInterFrameTime(value: boolean);
  54972. /**
  54973. * Gets the perf counter used for render time capture
  54974. */
  54975. get renderTimeCounter(): PerfCounter;
  54976. /**
  54977. * Gets the render time capture status
  54978. */
  54979. get captureRenderTime(): boolean;
  54980. /**
  54981. * Enable or disable the render time capture
  54982. */
  54983. set captureRenderTime(value: boolean);
  54984. /**
  54985. * Gets the perf counter used for camera render time capture
  54986. */
  54987. get cameraRenderTimeCounter(): PerfCounter;
  54988. /**
  54989. * Gets the camera render time capture status
  54990. */
  54991. get captureCameraRenderTime(): boolean;
  54992. /**
  54993. * Enable or disable the camera render time capture
  54994. */
  54995. set captureCameraRenderTime(value: boolean);
  54996. /**
  54997. * Gets the perf counter used for draw calls
  54998. */
  54999. get drawCallsCounter(): PerfCounter;
  55000. /**
  55001. * Instantiates a new scene instrumentation.
  55002. * This class can be used to get instrumentation data from a Babylon engine
  55003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55004. * @param scene Defines the scene to instrument
  55005. */
  55006. constructor(
  55007. /**
  55008. * Defines the scene to instrument
  55009. */
  55010. scene: Scene);
  55011. /**
  55012. * Dispose and release associated resources.
  55013. */
  55014. dispose(): void;
  55015. }
  55016. }
  55017. declare module "babylonjs/Instrumentation/index" {
  55018. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55019. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55020. export * from "babylonjs/Instrumentation/timeToken";
  55021. }
  55022. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55023. /** @hidden */
  55024. export var glowMapGenerationPixelShader: {
  55025. name: string;
  55026. shader: string;
  55027. };
  55028. }
  55029. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55030. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55031. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55032. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55033. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55034. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55035. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55036. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55037. /** @hidden */
  55038. export var glowMapGenerationVertexShader: {
  55039. name: string;
  55040. shader: string;
  55041. };
  55042. }
  55043. declare module "babylonjs/Layers/effectLayer" {
  55044. import { Observable } from "babylonjs/Misc/observable";
  55045. import { Nullable } from "babylonjs/types";
  55046. import { Camera } from "babylonjs/Cameras/camera";
  55047. import { Scene } from "babylonjs/scene";
  55048. import { ISize } from "babylonjs/Maths/math.size";
  55049. import { Color4 } from "babylonjs/Maths/math.color";
  55050. import { Engine } from "babylonjs/Engines/engine";
  55051. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55053. import { Mesh } from "babylonjs/Meshes/mesh";
  55054. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55056. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55057. import { Effect } from "babylonjs/Materials/effect";
  55058. import { Material } from "babylonjs/Materials/material";
  55059. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55060. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55061. /**
  55062. * Effect layer options. This helps customizing the behaviour
  55063. * of the effect layer.
  55064. */
  55065. export interface IEffectLayerOptions {
  55066. /**
  55067. * Multiplication factor apply to the canvas size to compute the render target size
  55068. * used to generated the objects (the smaller the faster).
  55069. */
  55070. mainTextureRatio: number;
  55071. /**
  55072. * Enforces a fixed size texture to ensure effect stability across devices.
  55073. */
  55074. mainTextureFixedSize?: number;
  55075. /**
  55076. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55077. */
  55078. alphaBlendingMode: number;
  55079. /**
  55080. * The camera attached to the layer.
  55081. */
  55082. camera: Nullable<Camera>;
  55083. /**
  55084. * The rendering group to draw the layer in.
  55085. */
  55086. renderingGroupId: number;
  55087. }
  55088. /**
  55089. * The effect layer Helps adding post process effect blended with the main pass.
  55090. *
  55091. * This can be for instance use to generate glow or higlight effects on the scene.
  55092. *
  55093. * The effect layer class can not be used directly and is intented to inherited from to be
  55094. * customized per effects.
  55095. */
  55096. export abstract class EffectLayer {
  55097. private _vertexBuffers;
  55098. private _indexBuffer;
  55099. private _cachedDefines;
  55100. private _effectLayerMapGenerationEffect;
  55101. private _effectLayerOptions;
  55102. private _mergeEffect;
  55103. protected _scene: Scene;
  55104. protected _engine: Engine;
  55105. protected _maxSize: number;
  55106. protected _mainTextureDesiredSize: ISize;
  55107. protected _mainTexture: RenderTargetTexture;
  55108. protected _shouldRender: boolean;
  55109. protected _postProcesses: PostProcess[];
  55110. protected _textures: BaseTexture[];
  55111. protected _emissiveTextureAndColor: {
  55112. texture: Nullable<BaseTexture>;
  55113. color: Color4;
  55114. };
  55115. /**
  55116. * The name of the layer
  55117. */
  55118. name: string;
  55119. /**
  55120. * The clear color of the texture used to generate the glow map.
  55121. */
  55122. neutralColor: Color4;
  55123. /**
  55124. * Specifies wether the highlight layer is enabled or not.
  55125. */
  55126. isEnabled: boolean;
  55127. /**
  55128. * Gets the camera attached to the layer.
  55129. */
  55130. get camera(): Nullable<Camera>;
  55131. /**
  55132. * Gets the rendering group id the layer should render in.
  55133. */
  55134. get renderingGroupId(): number;
  55135. set renderingGroupId(renderingGroupId: number);
  55136. /**
  55137. * An event triggered when the effect layer has been disposed.
  55138. */
  55139. onDisposeObservable: Observable<EffectLayer>;
  55140. /**
  55141. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55142. */
  55143. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55144. /**
  55145. * An event triggered when the generated texture is being merged in the scene.
  55146. */
  55147. onBeforeComposeObservable: Observable<EffectLayer>;
  55148. /**
  55149. * An event triggered when the mesh is rendered into the effect render target.
  55150. */
  55151. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55152. /**
  55153. * An event triggered after the mesh has been rendered into the effect render target.
  55154. */
  55155. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55156. /**
  55157. * An event triggered when the generated texture has been merged in the scene.
  55158. */
  55159. onAfterComposeObservable: Observable<EffectLayer>;
  55160. /**
  55161. * An event triggered when the efffect layer changes its size.
  55162. */
  55163. onSizeChangedObservable: Observable<EffectLayer>;
  55164. /** @hidden */
  55165. static _SceneComponentInitialization: (scene: Scene) => void;
  55166. /**
  55167. * Instantiates a new effect Layer and references it in the scene.
  55168. * @param name The name of the layer
  55169. * @param scene The scene to use the layer in
  55170. */
  55171. constructor(
  55172. /** The Friendly of the effect in the scene */
  55173. name: string, scene: Scene);
  55174. /**
  55175. * Get the effect name of the layer.
  55176. * @return The effect name
  55177. */
  55178. abstract getEffectName(): string;
  55179. /**
  55180. * Checks for the readiness of the element composing the layer.
  55181. * @param subMesh the mesh to check for
  55182. * @param useInstances specify wether or not to use instances to render the mesh
  55183. * @return true if ready otherwise, false
  55184. */
  55185. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55186. /**
  55187. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55188. * @returns true if the effect requires stencil during the main canvas render pass.
  55189. */
  55190. abstract needStencil(): boolean;
  55191. /**
  55192. * Create the merge effect. This is the shader use to blit the information back
  55193. * to the main canvas at the end of the scene rendering.
  55194. * @returns The effect containing the shader used to merge the effect on the main canvas
  55195. */
  55196. protected abstract _createMergeEffect(): Effect;
  55197. /**
  55198. * Creates the render target textures and post processes used in the effect layer.
  55199. */
  55200. protected abstract _createTextureAndPostProcesses(): void;
  55201. /**
  55202. * Implementation specific of rendering the generating effect on the main canvas.
  55203. * @param effect The effect used to render through
  55204. */
  55205. protected abstract _internalRender(effect: Effect): void;
  55206. /**
  55207. * Sets the required values for both the emissive texture and and the main color.
  55208. */
  55209. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55210. /**
  55211. * Free any resources and references associated to a mesh.
  55212. * Internal use
  55213. * @param mesh The mesh to free.
  55214. */
  55215. abstract _disposeMesh(mesh: Mesh): void;
  55216. /**
  55217. * Serializes this layer (Glow or Highlight for example)
  55218. * @returns a serialized layer object
  55219. */
  55220. abstract serialize?(): any;
  55221. /**
  55222. * Initializes the effect layer with the required options.
  55223. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55224. */
  55225. protected _init(options: Partial<IEffectLayerOptions>): void;
  55226. /**
  55227. * Generates the index buffer of the full screen quad blending to the main canvas.
  55228. */
  55229. private _generateIndexBuffer;
  55230. /**
  55231. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55232. */
  55233. private _generateVertexBuffer;
  55234. /**
  55235. * Sets the main texture desired size which is the closest power of two
  55236. * of the engine canvas size.
  55237. */
  55238. private _setMainTextureSize;
  55239. /**
  55240. * Creates the main texture for the effect layer.
  55241. */
  55242. protected _createMainTexture(): void;
  55243. /**
  55244. * Adds specific effects defines.
  55245. * @param defines The defines to add specifics to.
  55246. */
  55247. protected _addCustomEffectDefines(defines: string[]): void;
  55248. /**
  55249. * Checks for the readiness of the element composing the layer.
  55250. * @param subMesh the mesh to check for
  55251. * @param useInstances specify wether or not to use instances to render the mesh
  55252. * @param emissiveTexture the associated emissive texture used to generate the glow
  55253. * @return true if ready otherwise, false
  55254. */
  55255. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55256. /**
  55257. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55258. */
  55259. render(): void;
  55260. /**
  55261. * Determine if a given mesh will be used in the current effect.
  55262. * @param mesh mesh to test
  55263. * @returns true if the mesh will be used
  55264. */
  55265. hasMesh(mesh: AbstractMesh): boolean;
  55266. /**
  55267. * Returns true if the layer contains information to display, otherwise false.
  55268. * @returns true if the glow layer should be rendered
  55269. */
  55270. shouldRender(): boolean;
  55271. /**
  55272. * Returns true if the mesh should render, otherwise false.
  55273. * @param mesh The mesh to render
  55274. * @returns true if it should render otherwise false
  55275. */
  55276. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55277. /**
  55278. * Returns true if the mesh can be rendered, otherwise false.
  55279. * @param mesh The mesh to render
  55280. * @param material The material used on the mesh
  55281. * @returns true if it can be rendered otherwise false
  55282. */
  55283. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55284. /**
  55285. * Returns true if the mesh should render, otherwise false.
  55286. * @param mesh The mesh to render
  55287. * @returns true if it should render otherwise false
  55288. */
  55289. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55290. /**
  55291. * Renders the submesh passed in parameter to the generation map.
  55292. */
  55293. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55294. /**
  55295. * Defines wether the current material of the mesh should be use to render the effect.
  55296. * @param mesh defines the current mesh to render
  55297. */
  55298. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55299. /**
  55300. * Rebuild the required buffers.
  55301. * @hidden Internal use only.
  55302. */
  55303. _rebuild(): void;
  55304. /**
  55305. * Dispose only the render target textures and post process.
  55306. */
  55307. private _disposeTextureAndPostProcesses;
  55308. /**
  55309. * Dispose the highlight layer and free resources.
  55310. */
  55311. dispose(): void;
  55312. /**
  55313. * Gets the class name of the effect layer
  55314. * @returns the string with the class name of the effect layer
  55315. */
  55316. getClassName(): string;
  55317. /**
  55318. * Creates an effect layer from parsed effect layer data
  55319. * @param parsedEffectLayer defines effect layer data
  55320. * @param scene defines the current scene
  55321. * @param rootUrl defines the root URL containing the effect layer information
  55322. * @returns a parsed effect Layer
  55323. */
  55324. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55325. }
  55326. }
  55327. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55328. import { Scene } from "babylonjs/scene";
  55329. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55330. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55331. import { AbstractScene } from "babylonjs/abstractScene";
  55332. module "babylonjs/abstractScene" {
  55333. interface AbstractScene {
  55334. /**
  55335. * The list of effect layers (highlights/glow) added to the scene
  55336. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55337. * @see http://doc.babylonjs.com/how_to/glow_layer
  55338. */
  55339. effectLayers: Array<EffectLayer>;
  55340. /**
  55341. * Removes the given effect layer from this scene.
  55342. * @param toRemove defines the effect layer to remove
  55343. * @returns the index of the removed effect layer
  55344. */
  55345. removeEffectLayer(toRemove: EffectLayer): number;
  55346. /**
  55347. * Adds the given effect layer to this scene
  55348. * @param newEffectLayer defines the effect layer to add
  55349. */
  55350. addEffectLayer(newEffectLayer: EffectLayer): void;
  55351. }
  55352. }
  55353. /**
  55354. * Defines the layer scene component responsible to manage any effect layers
  55355. * in a given scene.
  55356. */
  55357. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55358. /**
  55359. * The component name helpfull to identify the component in the list of scene components.
  55360. */
  55361. readonly name: string;
  55362. /**
  55363. * The scene the component belongs to.
  55364. */
  55365. scene: Scene;
  55366. private _engine;
  55367. private _renderEffects;
  55368. private _needStencil;
  55369. private _previousStencilState;
  55370. /**
  55371. * Creates a new instance of the component for the given scene
  55372. * @param scene Defines the scene to register the component in
  55373. */
  55374. constructor(scene: Scene);
  55375. /**
  55376. * Registers the component in a given scene
  55377. */
  55378. register(): void;
  55379. /**
  55380. * Rebuilds the elements related to this component in case of
  55381. * context lost for instance.
  55382. */
  55383. rebuild(): void;
  55384. /**
  55385. * Serializes the component data to the specified json object
  55386. * @param serializationObject The object to serialize to
  55387. */
  55388. serialize(serializationObject: any): void;
  55389. /**
  55390. * Adds all the elements from the container to the scene
  55391. * @param container the container holding the elements
  55392. */
  55393. addFromContainer(container: AbstractScene): void;
  55394. /**
  55395. * Removes all the elements in the container from the scene
  55396. * @param container contains the elements to remove
  55397. * @param dispose if the removed element should be disposed (default: false)
  55398. */
  55399. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55400. /**
  55401. * Disposes the component and the associated ressources.
  55402. */
  55403. dispose(): void;
  55404. private _isReadyForMesh;
  55405. private _renderMainTexture;
  55406. private _setStencil;
  55407. private _setStencilBack;
  55408. private _draw;
  55409. private _drawCamera;
  55410. private _drawRenderingGroup;
  55411. }
  55412. }
  55413. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55414. /** @hidden */
  55415. export var glowMapMergePixelShader: {
  55416. name: string;
  55417. shader: string;
  55418. };
  55419. }
  55420. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55421. /** @hidden */
  55422. export var glowMapMergeVertexShader: {
  55423. name: string;
  55424. shader: string;
  55425. };
  55426. }
  55427. declare module "babylonjs/Layers/glowLayer" {
  55428. import { Nullable } from "babylonjs/types";
  55429. import { Camera } from "babylonjs/Cameras/camera";
  55430. import { Scene } from "babylonjs/scene";
  55431. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55433. import { Mesh } from "babylonjs/Meshes/mesh";
  55434. import { Texture } from "babylonjs/Materials/Textures/texture";
  55435. import { Effect } from "babylonjs/Materials/effect";
  55436. import { Material } from "babylonjs/Materials/material";
  55437. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55438. import { Color4 } from "babylonjs/Maths/math.color";
  55439. import "babylonjs/Shaders/glowMapMerge.fragment";
  55440. import "babylonjs/Shaders/glowMapMerge.vertex";
  55441. import "babylonjs/Layers/effectLayerSceneComponent";
  55442. module "babylonjs/abstractScene" {
  55443. interface AbstractScene {
  55444. /**
  55445. * Return a the first highlight layer of the scene with a given name.
  55446. * @param name The name of the highlight layer to look for.
  55447. * @return The highlight layer if found otherwise null.
  55448. */
  55449. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55450. }
  55451. }
  55452. /**
  55453. * Glow layer options. This helps customizing the behaviour
  55454. * of the glow layer.
  55455. */
  55456. export interface IGlowLayerOptions {
  55457. /**
  55458. * Multiplication factor apply to the canvas size to compute the render target size
  55459. * used to generated the glowing objects (the smaller the faster).
  55460. */
  55461. mainTextureRatio: number;
  55462. /**
  55463. * Enforces a fixed size texture to ensure resize independant blur.
  55464. */
  55465. mainTextureFixedSize?: number;
  55466. /**
  55467. * How big is the kernel of the blur texture.
  55468. */
  55469. blurKernelSize: number;
  55470. /**
  55471. * The camera attached to the layer.
  55472. */
  55473. camera: Nullable<Camera>;
  55474. /**
  55475. * Enable MSAA by chosing the number of samples.
  55476. */
  55477. mainTextureSamples?: number;
  55478. /**
  55479. * The rendering group to draw the layer in.
  55480. */
  55481. renderingGroupId: number;
  55482. }
  55483. /**
  55484. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55485. *
  55486. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55487. *
  55488. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55489. */
  55490. export class GlowLayer extends EffectLayer {
  55491. /**
  55492. * Effect Name of the layer.
  55493. */
  55494. static readonly EffectName: string;
  55495. /**
  55496. * The default blur kernel size used for the glow.
  55497. */
  55498. static DefaultBlurKernelSize: number;
  55499. /**
  55500. * The default texture size ratio used for the glow.
  55501. */
  55502. static DefaultTextureRatio: number;
  55503. /**
  55504. * Sets the kernel size of the blur.
  55505. */
  55506. set blurKernelSize(value: number);
  55507. /**
  55508. * Gets the kernel size of the blur.
  55509. */
  55510. get blurKernelSize(): number;
  55511. /**
  55512. * Sets the glow intensity.
  55513. */
  55514. set intensity(value: number);
  55515. /**
  55516. * Gets the glow intensity.
  55517. */
  55518. get intensity(): number;
  55519. private _options;
  55520. private _intensity;
  55521. private _horizontalBlurPostprocess1;
  55522. private _verticalBlurPostprocess1;
  55523. private _horizontalBlurPostprocess2;
  55524. private _verticalBlurPostprocess2;
  55525. private _blurTexture1;
  55526. private _blurTexture2;
  55527. private _postProcesses1;
  55528. private _postProcesses2;
  55529. private _includedOnlyMeshes;
  55530. private _excludedMeshes;
  55531. private _meshesUsingTheirOwnMaterials;
  55532. /**
  55533. * Callback used to let the user override the color selection on a per mesh basis
  55534. */
  55535. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55536. /**
  55537. * Callback used to let the user override the texture selection on a per mesh basis
  55538. */
  55539. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55540. /**
  55541. * Instantiates a new glow Layer and references it to the scene.
  55542. * @param name The name of the layer
  55543. * @param scene The scene to use the layer in
  55544. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55545. */
  55546. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55547. /**
  55548. * Get the effect name of the layer.
  55549. * @return The effect name
  55550. */
  55551. getEffectName(): string;
  55552. /**
  55553. * Create the merge effect. This is the shader use to blit the information back
  55554. * to the main canvas at the end of the scene rendering.
  55555. */
  55556. protected _createMergeEffect(): Effect;
  55557. /**
  55558. * Creates the render target textures and post processes used in the glow layer.
  55559. */
  55560. protected _createTextureAndPostProcesses(): void;
  55561. /**
  55562. * Checks for the readiness of the element composing the layer.
  55563. * @param subMesh the mesh to check for
  55564. * @param useInstances specify wether or not to use instances to render the mesh
  55565. * @param emissiveTexture the associated emissive texture used to generate the glow
  55566. * @return true if ready otherwise, false
  55567. */
  55568. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55569. /**
  55570. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55571. */
  55572. needStencil(): boolean;
  55573. /**
  55574. * Returns true if the mesh can be rendered, otherwise false.
  55575. * @param mesh The mesh to render
  55576. * @param material The material used on the mesh
  55577. * @returns true if it can be rendered otherwise false
  55578. */
  55579. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55580. /**
  55581. * Implementation specific of rendering the generating effect on the main canvas.
  55582. * @param effect The effect used to render through
  55583. */
  55584. protected _internalRender(effect: Effect): void;
  55585. /**
  55586. * Sets the required values for both the emissive texture and and the main color.
  55587. */
  55588. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55589. /**
  55590. * Returns true if the mesh should render, otherwise false.
  55591. * @param mesh The mesh to render
  55592. * @returns true if it should render otherwise false
  55593. */
  55594. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55595. /**
  55596. * Adds specific effects defines.
  55597. * @param defines The defines to add specifics to.
  55598. */
  55599. protected _addCustomEffectDefines(defines: string[]): void;
  55600. /**
  55601. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55602. * @param mesh The mesh to exclude from the glow layer
  55603. */
  55604. addExcludedMesh(mesh: Mesh): void;
  55605. /**
  55606. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55607. * @param mesh The mesh to remove
  55608. */
  55609. removeExcludedMesh(mesh: Mesh): void;
  55610. /**
  55611. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55612. * @param mesh The mesh to include in the glow layer
  55613. */
  55614. addIncludedOnlyMesh(mesh: Mesh): void;
  55615. /**
  55616. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55617. * @param mesh The mesh to remove
  55618. */
  55619. removeIncludedOnlyMesh(mesh: Mesh): void;
  55620. /**
  55621. * Determine if a given mesh will be used in the glow layer
  55622. * @param mesh The mesh to test
  55623. * @returns true if the mesh will be highlighted by the current glow layer
  55624. */
  55625. hasMesh(mesh: AbstractMesh): boolean;
  55626. /**
  55627. * Defines wether the current material of the mesh should be use to render the effect.
  55628. * @param mesh defines the current mesh to render
  55629. */
  55630. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55631. /**
  55632. * Add a mesh to be rendered through its own material and not with emissive only.
  55633. * @param mesh The mesh for which we need to use its material
  55634. */
  55635. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55636. /**
  55637. * Remove a mesh from being rendered through its own material and not with emissive only.
  55638. * @param mesh The mesh for which we need to not use its material
  55639. */
  55640. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55641. /**
  55642. * Free any resources and references associated to a mesh.
  55643. * Internal use
  55644. * @param mesh The mesh to free.
  55645. * @hidden
  55646. */
  55647. _disposeMesh(mesh: Mesh): void;
  55648. /**
  55649. * Gets the class name of the effect layer
  55650. * @returns the string with the class name of the effect layer
  55651. */
  55652. getClassName(): string;
  55653. /**
  55654. * Serializes this glow layer
  55655. * @returns a serialized glow layer object
  55656. */
  55657. serialize(): any;
  55658. /**
  55659. * Creates a Glow Layer from parsed glow layer data
  55660. * @param parsedGlowLayer defines glow layer data
  55661. * @param scene defines the current scene
  55662. * @param rootUrl defines the root URL containing the glow layer information
  55663. * @returns a parsed Glow Layer
  55664. */
  55665. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55666. }
  55667. }
  55668. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55669. /** @hidden */
  55670. export var glowBlurPostProcessPixelShader: {
  55671. name: string;
  55672. shader: string;
  55673. };
  55674. }
  55675. declare module "babylonjs/Layers/highlightLayer" {
  55676. import { Observable } from "babylonjs/Misc/observable";
  55677. import { Nullable } from "babylonjs/types";
  55678. import { Camera } from "babylonjs/Cameras/camera";
  55679. import { Scene } from "babylonjs/scene";
  55680. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55682. import { Mesh } from "babylonjs/Meshes/mesh";
  55683. import { Effect } from "babylonjs/Materials/effect";
  55684. import { Material } from "babylonjs/Materials/material";
  55685. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55686. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55687. import "babylonjs/Shaders/glowMapMerge.fragment";
  55688. import "babylonjs/Shaders/glowMapMerge.vertex";
  55689. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55690. module "babylonjs/abstractScene" {
  55691. interface AbstractScene {
  55692. /**
  55693. * Return a the first highlight layer of the scene with a given name.
  55694. * @param name The name of the highlight layer to look for.
  55695. * @return The highlight layer if found otherwise null.
  55696. */
  55697. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55698. }
  55699. }
  55700. /**
  55701. * Highlight layer options. This helps customizing the behaviour
  55702. * of the highlight layer.
  55703. */
  55704. export interface IHighlightLayerOptions {
  55705. /**
  55706. * Multiplication factor apply to the canvas size to compute the render target size
  55707. * used to generated the glowing objects (the smaller the faster).
  55708. */
  55709. mainTextureRatio: number;
  55710. /**
  55711. * Enforces a fixed size texture to ensure resize independant blur.
  55712. */
  55713. mainTextureFixedSize?: number;
  55714. /**
  55715. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55716. * of the picture to blur (the smaller the faster).
  55717. */
  55718. blurTextureSizeRatio: number;
  55719. /**
  55720. * How big in texel of the blur texture is the vertical blur.
  55721. */
  55722. blurVerticalSize: number;
  55723. /**
  55724. * How big in texel of the blur texture is the horizontal blur.
  55725. */
  55726. blurHorizontalSize: number;
  55727. /**
  55728. * Alpha blending mode used to apply the blur. Default is combine.
  55729. */
  55730. alphaBlendingMode: number;
  55731. /**
  55732. * The camera attached to the layer.
  55733. */
  55734. camera: Nullable<Camera>;
  55735. /**
  55736. * Should we display highlight as a solid stroke?
  55737. */
  55738. isStroke?: boolean;
  55739. /**
  55740. * The rendering group to draw the layer in.
  55741. */
  55742. renderingGroupId: number;
  55743. }
  55744. /**
  55745. * The highlight layer Helps adding a glow effect around a mesh.
  55746. *
  55747. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55748. * glowy meshes to your scene.
  55749. *
  55750. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55751. */
  55752. export class HighlightLayer extends EffectLayer {
  55753. name: string;
  55754. /**
  55755. * Effect Name of the highlight layer.
  55756. */
  55757. static readonly EffectName: string;
  55758. /**
  55759. * The neutral color used during the preparation of the glow effect.
  55760. * This is black by default as the blend operation is a blend operation.
  55761. */
  55762. static NeutralColor: Color4;
  55763. /**
  55764. * Stencil value used for glowing meshes.
  55765. */
  55766. static GlowingMeshStencilReference: number;
  55767. /**
  55768. * Stencil value used for the other meshes in the scene.
  55769. */
  55770. static NormalMeshStencilReference: number;
  55771. /**
  55772. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55773. */
  55774. innerGlow: boolean;
  55775. /**
  55776. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55777. */
  55778. outerGlow: boolean;
  55779. /**
  55780. * Specifies the horizontal size of the blur.
  55781. */
  55782. set blurHorizontalSize(value: number);
  55783. /**
  55784. * Specifies the vertical size of the blur.
  55785. */
  55786. set blurVerticalSize(value: number);
  55787. /**
  55788. * Gets the horizontal size of the blur.
  55789. */
  55790. get blurHorizontalSize(): number;
  55791. /**
  55792. * Gets the vertical size of the blur.
  55793. */
  55794. get blurVerticalSize(): number;
  55795. /**
  55796. * An event triggered when the highlight layer is being blurred.
  55797. */
  55798. onBeforeBlurObservable: Observable<HighlightLayer>;
  55799. /**
  55800. * An event triggered when the highlight layer has been blurred.
  55801. */
  55802. onAfterBlurObservable: Observable<HighlightLayer>;
  55803. private _instanceGlowingMeshStencilReference;
  55804. private _options;
  55805. private _downSamplePostprocess;
  55806. private _horizontalBlurPostprocess;
  55807. private _verticalBlurPostprocess;
  55808. private _blurTexture;
  55809. private _meshes;
  55810. private _excludedMeshes;
  55811. /**
  55812. * Instantiates a new highlight Layer and references it to the scene..
  55813. * @param name The name of the layer
  55814. * @param scene The scene to use the layer in
  55815. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55816. */
  55817. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55818. /**
  55819. * Get the effect name of the layer.
  55820. * @return The effect name
  55821. */
  55822. getEffectName(): string;
  55823. /**
  55824. * Create the merge effect. This is the shader use to blit the information back
  55825. * to the main canvas at the end of the scene rendering.
  55826. */
  55827. protected _createMergeEffect(): Effect;
  55828. /**
  55829. * Creates the render target textures and post processes used in the highlight layer.
  55830. */
  55831. protected _createTextureAndPostProcesses(): void;
  55832. /**
  55833. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55834. */
  55835. needStencil(): boolean;
  55836. /**
  55837. * Checks for the readiness of the element composing the layer.
  55838. * @param subMesh the mesh to check for
  55839. * @param useInstances specify wether or not to use instances to render the mesh
  55840. * @param emissiveTexture the associated emissive texture used to generate the glow
  55841. * @return true if ready otherwise, false
  55842. */
  55843. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55844. /**
  55845. * Implementation specific of rendering the generating effect on the main canvas.
  55846. * @param effect The effect used to render through
  55847. */
  55848. protected _internalRender(effect: Effect): void;
  55849. /**
  55850. * Returns true if the layer contains information to display, otherwise false.
  55851. */
  55852. shouldRender(): boolean;
  55853. /**
  55854. * Returns true if the mesh should render, otherwise false.
  55855. * @param mesh The mesh to render
  55856. * @returns true if it should render otherwise false
  55857. */
  55858. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55859. /**
  55860. * Sets the required values for both the emissive texture and and the main color.
  55861. */
  55862. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55863. /**
  55864. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55865. * @param mesh The mesh to exclude from the highlight layer
  55866. */
  55867. addExcludedMesh(mesh: Mesh): void;
  55868. /**
  55869. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55870. * @param mesh The mesh to highlight
  55871. */
  55872. removeExcludedMesh(mesh: Mesh): void;
  55873. /**
  55874. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55875. * @param mesh mesh to test
  55876. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55877. */
  55878. hasMesh(mesh: AbstractMesh): boolean;
  55879. /**
  55880. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55881. * @param mesh The mesh to highlight
  55882. * @param color The color of the highlight
  55883. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55884. */
  55885. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55886. /**
  55887. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55888. * @param mesh The mesh to highlight
  55889. */
  55890. removeMesh(mesh: Mesh): void;
  55891. /**
  55892. * Force the stencil to the normal expected value for none glowing parts
  55893. */
  55894. private _defaultStencilReference;
  55895. /**
  55896. * Free any resources and references associated to a mesh.
  55897. * Internal use
  55898. * @param mesh The mesh to free.
  55899. * @hidden
  55900. */
  55901. _disposeMesh(mesh: Mesh): void;
  55902. /**
  55903. * Dispose the highlight layer and free resources.
  55904. */
  55905. dispose(): void;
  55906. /**
  55907. * Gets the class name of the effect layer
  55908. * @returns the string with the class name of the effect layer
  55909. */
  55910. getClassName(): string;
  55911. /**
  55912. * Serializes this Highlight layer
  55913. * @returns a serialized Highlight layer object
  55914. */
  55915. serialize(): any;
  55916. /**
  55917. * Creates a Highlight layer from parsed Highlight layer data
  55918. * @param parsedHightlightLayer defines the Highlight layer data
  55919. * @param scene defines the current scene
  55920. * @param rootUrl defines the root URL containing the Highlight layer information
  55921. * @returns a parsed Highlight layer
  55922. */
  55923. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55924. }
  55925. }
  55926. declare module "babylonjs/Layers/layerSceneComponent" {
  55927. import { Scene } from "babylonjs/scene";
  55928. import { ISceneComponent } from "babylonjs/sceneComponent";
  55929. import { Layer } from "babylonjs/Layers/layer";
  55930. import { AbstractScene } from "babylonjs/abstractScene";
  55931. module "babylonjs/abstractScene" {
  55932. interface AbstractScene {
  55933. /**
  55934. * The list of layers (background and foreground) of the scene
  55935. */
  55936. layers: Array<Layer>;
  55937. }
  55938. }
  55939. /**
  55940. * Defines the layer scene component responsible to manage any layers
  55941. * in a given scene.
  55942. */
  55943. export class LayerSceneComponent implements ISceneComponent {
  55944. /**
  55945. * The component name helpfull to identify the component in the list of scene components.
  55946. */
  55947. readonly name: string;
  55948. /**
  55949. * The scene the component belongs to.
  55950. */
  55951. scene: Scene;
  55952. private _engine;
  55953. /**
  55954. * Creates a new instance of the component for the given scene
  55955. * @param scene Defines the scene to register the component in
  55956. */
  55957. constructor(scene: Scene);
  55958. /**
  55959. * Registers the component in a given scene
  55960. */
  55961. register(): void;
  55962. /**
  55963. * Rebuilds the elements related to this component in case of
  55964. * context lost for instance.
  55965. */
  55966. rebuild(): void;
  55967. /**
  55968. * Disposes the component and the associated ressources.
  55969. */
  55970. dispose(): void;
  55971. private _draw;
  55972. private _drawCameraPredicate;
  55973. private _drawCameraBackground;
  55974. private _drawCameraForeground;
  55975. private _drawRenderTargetPredicate;
  55976. private _drawRenderTargetBackground;
  55977. private _drawRenderTargetForeground;
  55978. /**
  55979. * Adds all the elements from the container to the scene
  55980. * @param container the container holding the elements
  55981. */
  55982. addFromContainer(container: AbstractScene): void;
  55983. /**
  55984. * Removes all the elements in the container from the scene
  55985. * @param container contains the elements to remove
  55986. * @param dispose if the removed element should be disposed (default: false)
  55987. */
  55988. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55989. }
  55990. }
  55991. declare module "babylonjs/Shaders/layer.fragment" {
  55992. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55993. /** @hidden */
  55994. export var layerPixelShader: {
  55995. name: string;
  55996. shader: string;
  55997. };
  55998. }
  55999. declare module "babylonjs/Shaders/layer.vertex" {
  56000. /** @hidden */
  56001. export var layerVertexShader: {
  56002. name: string;
  56003. shader: string;
  56004. };
  56005. }
  56006. declare module "babylonjs/Layers/layer" {
  56007. import { Observable } from "babylonjs/Misc/observable";
  56008. import { Nullable } from "babylonjs/types";
  56009. import { Scene } from "babylonjs/scene";
  56010. import { Vector2 } from "babylonjs/Maths/math.vector";
  56011. import { Color4 } from "babylonjs/Maths/math.color";
  56012. import { Texture } from "babylonjs/Materials/Textures/texture";
  56013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56014. import "babylonjs/Shaders/layer.fragment";
  56015. import "babylonjs/Shaders/layer.vertex";
  56016. /**
  56017. * This represents a full screen 2d layer.
  56018. * This can be useful to display a picture in the background of your scene for instance.
  56019. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56020. */
  56021. export class Layer {
  56022. /**
  56023. * Define the name of the layer.
  56024. */
  56025. name: string;
  56026. /**
  56027. * Define the texture the layer should display.
  56028. */
  56029. texture: Nullable<Texture>;
  56030. /**
  56031. * Is the layer in background or foreground.
  56032. */
  56033. isBackground: boolean;
  56034. /**
  56035. * Define the color of the layer (instead of texture).
  56036. */
  56037. color: Color4;
  56038. /**
  56039. * Define the scale of the layer in order to zoom in out of the texture.
  56040. */
  56041. scale: Vector2;
  56042. /**
  56043. * Define an offset for the layer in order to shift the texture.
  56044. */
  56045. offset: Vector2;
  56046. /**
  56047. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56048. */
  56049. alphaBlendingMode: number;
  56050. /**
  56051. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56052. * Alpha test will not mix with the background color in case of transparency.
  56053. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56054. */
  56055. alphaTest: boolean;
  56056. /**
  56057. * Define a mask to restrict the layer to only some of the scene cameras.
  56058. */
  56059. layerMask: number;
  56060. /**
  56061. * Define the list of render target the layer is visible into.
  56062. */
  56063. renderTargetTextures: RenderTargetTexture[];
  56064. /**
  56065. * Define if the layer is only used in renderTarget or if it also
  56066. * renders in the main frame buffer of the canvas.
  56067. */
  56068. renderOnlyInRenderTargetTextures: boolean;
  56069. private _scene;
  56070. private _vertexBuffers;
  56071. private _indexBuffer;
  56072. private _effect;
  56073. private _previousDefines;
  56074. /**
  56075. * An event triggered when the layer is disposed.
  56076. */
  56077. onDisposeObservable: Observable<Layer>;
  56078. private _onDisposeObserver;
  56079. /**
  56080. * Back compatibility with callback before the onDisposeObservable existed.
  56081. * The set callback will be triggered when the layer has been disposed.
  56082. */
  56083. set onDispose(callback: () => void);
  56084. /**
  56085. * An event triggered before rendering the scene
  56086. */
  56087. onBeforeRenderObservable: Observable<Layer>;
  56088. private _onBeforeRenderObserver;
  56089. /**
  56090. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56091. * The set callback will be triggered just before rendering the layer.
  56092. */
  56093. set onBeforeRender(callback: () => void);
  56094. /**
  56095. * An event triggered after rendering the scene
  56096. */
  56097. onAfterRenderObservable: Observable<Layer>;
  56098. private _onAfterRenderObserver;
  56099. /**
  56100. * Back compatibility with callback before the onAfterRenderObservable existed.
  56101. * The set callback will be triggered just after rendering the layer.
  56102. */
  56103. set onAfterRender(callback: () => void);
  56104. /**
  56105. * Instantiates a new layer.
  56106. * This represents a full screen 2d layer.
  56107. * This can be useful to display a picture in the background of your scene for instance.
  56108. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56109. * @param name Define the name of the layer in the scene
  56110. * @param imgUrl Define the url of the texture to display in the layer
  56111. * @param scene Define the scene the layer belongs to
  56112. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56113. * @param color Defines a color for the layer
  56114. */
  56115. constructor(
  56116. /**
  56117. * Define the name of the layer.
  56118. */
  56119. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56120. private _createIndexBuffer;
  56121. /** @hidden */
  56122. _rebuild(): void;
  56123. /**
  56124. * Renders the layer in the scene.
  56125. */
  56126. render(): void;
  56127. /**
  56128. * Disposes and releases the associated ressources.
  56129. */
  56130. dispose(): void;
  56131. }
  56132. }
  56133. declare module "babylonjs/Layers/index" {
  56134. export * from "babylonjs/Layers/effectLayer";
  56135. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56136. export * from "babylonjs/Layers/glowLayer";
  56137. export * from "babylonjs/Layers/highlightLayer";
  56138. export * from "babylonjs/Layers/layer";
  56139. export * from "babylonjs/Layers/layerSceneComponent";
  56140. }
  56141. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56142. /** @hidden */
  56143. export var lensFlarePixelShader: {
  56144. name: string;
  56145. shader: string;
  56146. };
  56147. }
  56148. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56149. /** @hidden */
  56150. export var lensFlareVertexShader: {
  56151. name: string;
  56152. shader: string;
  56153. };
  56154. }
  56155. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56156. import { Scene } from "babylonjs/scene";
  56157. import { Vector3 } from "babylonjs/Maths/math.vector";
  56158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56159. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56160. import "babylonjs/Shaders/lensFlare.fragment";
  56161. import "babylonjs/Shaders/lensFlare.vertex";
  56162. import { Viewport } from "babylonjs/Maths/math.viewport";
  56163. /**
  56164. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56165. * It is usually composed of several `lensFlare`.
  56166. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56167. */
  56168. export class LensFlareSystem {
  56169. /**
  56170. * Define the name of the lens flare system
  56171. */
  56172. name: string;
  56173. /**
  56174. * List of lens flares used in this system.
  56175. */
  56176. lensFlares: LensFlare[];
  56177. /**
  56178. * Define a limit from the border the lens flare can be visible.
  56179. */
  56180. borderLimit: number;
  56181. /**
  56182. * Define a viewport border we do not want to see the lens flare in.
  56183. */
  56184. viewportBorder: number;
  56185. /**
  56186. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56187. */
  56188. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56189. /**
  56190. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56191. */
  56192. layerMask: number;
  56193. /**
  56194. * Define the id of the lens flare system in the scene.
  56195. * (equal to name by default)
  56196. */
  56197. id: string;
  56198. private _scene;
  56199. private _emitter;
  56200. private _vertexBuffers;
  56201. private _indexBuffer;
  56202. private _effect;
  56203. private _positionX;
  56204. private _positionY;
  56205. private _isEnabled;
  56206. /** @hidden */
  56207. static _SceneComponentInitialization: (scene: Scene) => void;
  56208. /**
  56209. * Instantiates a lens flare system.
  56210. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56211. * It is usually composed of several `lensFlare`.
  56212. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56213. * @param name Define the name of the lens flare system in the scene
  56214. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56215. * @param scene Define the scene the lens flare system belongs to
  56216. */
  56217. constructor(
  56218. /**
  56219. * Define the name of the lens flare system
  56220. */
  56221. name: string, emitter: any, scene: Scene);
  56222. /**
  56223. * Define if the lens flare system is enabled.
  56224. */
  56225. get isEnabled(): boolean;
  56226. set isEnabled(value: boolean);
  56227. /**
  56228. * Get the scene the effects belongs to.
  56229. * @returns the scene holding the lens flare system
  56230. */
  56231. getScene(): Scene;
  56232. /**
  56233. * Get the emitter of the lens flare system.
  56234. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56235. * @returns the emitter of the lens flare system
  56236. */
  56237. getEmitter(): any;
  56238. /**
  56239. * Set the emitter of the lens flare system.
  56240. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56241. * @param newEmitter Define the new emitter of the system
  56242. */
  56243. setEmitter(newEmitter: any): void;
  56244. /**
  56245. * Get the lens flare system emitter position.
  56246. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56247. * @returns the position
  56248. */
  56249. getEmitterPosition(): Vector3;
  56250. /**
  56251. * @hidden
  56252. */
  56253. computeEffectivePosition(globalViewport: Viewport): boolean;
  56254. /** @hidden */
  56255. _isVisible(): boolean;
  56256. /**
  56257. * @hidden
  56258. */
  56259. render(): boolean;
  56260. /**
  56261. * Dispose and release the lens flare with its associated resources.
  56262. */
  56263. dispose(): void;
  56264. /**
  56265. * Parse a lens flare system from a JSON repressentation
  56266. * @param parsedLensFlareSystem Define the JSON to parse
  56267. * @param scene Define the scene the parsed system should be instantiated in
  56268. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56269. * @returns the parsed system
  56270. */
  56271. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56272. /**
  56273. * Serialize the current Lens Flare System into a JSON representation.
  56274. * @returns the serialized JSON
  56275. */
  56276. serialize(): any;
  56277. }
  56278. }
  56279. declare module "babylonjs/LensFlares/lensFlare" {
  56280. import { Nullable } from "babylonjs/types";
  56281. import { Color3 } from "babylonjs/Maths/math.color";
  56282. import { Texture } from "babylonjs/Materials/Textures/texture";
  56283. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56284. /**
  56285. * This represents one of the lens effect in a `lensFlareSystem`.
  56286. * It controls one of the indiviual texture used in the effect.
  56287. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56288. */
  56289. export class LensFlare {
  56290. /**
  56291. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56292. */
  56293. size: number;
  56294. /**
  56295. * 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.
  56296. */
  56297. position: number;
  56298. /**
  56299. * Define the lens color.
  56300. */
  56301. color: Color3;
  56302. /**
  56303. * Define the lens texture.
  56304. */
  56305. texture: Nullable<Texture>;
  56306. /**
  56307. * Define the alpha mode to render this particular lens.
  56308. */
  56309. alphaMode: number;
  56310. private _system;
  56311. /**
  56312. * Creates a new Lens Flare.
  56313. * This represents one of the lens effect in a `lensFlareSystem`.
  56314. * It controls one of the indiviual texture used in the effect.
  56315. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56316. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56317. * @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.
  56318. * @param color Define the lens color
  56319. * @param imgUrl Define the lens texture url
  56320. * @param system Define the `lensFlareSystem` this flare is part of
  56321. * @returns The newly created Lens Flare
  56322. */
  56323. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56324. /**
  56325. * Instantiates a new Lens Flare.
  56326. * This represents one of the lens effect in a `lensFlareSystem`.
  56327. * It controls one of the indiviual texture used in the effect.
  56328. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56329. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56330. * @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.
  56331. * @param color Define the lens color
  56332. * @param imgUrl Define the lens texture url
  56333. * @param system Define the `lensFlareSystem` this flare is part of
  56334. */
  56335. constructor(
  56336. /**
  56337. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56338. */
  56339. size: number,
  56340. /**
  56341. * 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.
  56342. */
  56343. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56344. /**
  56345. * Dispose and release the lens flare with its associated resources.
  56346. */
  56347. dispose(): void;
  56348. }
  56349. }
  56350. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56351. import { Nullable } from "babylonjs/types";
  56352. import { Scene } from "babylonjs/scene";
  56353. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56354. import { AbstractScene } from "babylonjs/abstractScene";
  56355. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56356. module "babylonjs/abstractScene" {
  56357. interface AbstractScene {
  56358. /**
  56359. * The list of lens flare system added to the scene
  56360. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56361. */
  56362. lensFlareSystems: Array<LensFlareSystem>;
  56363. /**
  56364. * Removes the given lens flare system from this scene.
  56365. * @param toRemove The lens flare system to remove
  56366. * @returns The index of the removed lens flare system
  56367. */
  56368. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56369. /**
  56370. * Adds the given lens flare system to this scene
  56371. * @param newLensFlareSystem The lens flare system to add
  56372. */
  56373. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56374. /**
  56375. * Gets a lens flare system using its name
  56376. * @param name defines the name to look for
  56377. * @returns the lens flare system or null if not found
  56378. */
  56379. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56380. /**
  56381. * Gets a lens flare system using its id
  56382. * @param id defines the id to look for
  56383. * @returns the lens flare system or null if not found
  56384. */
  56385. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56386. }
  56387. }
  56388. /**
  56389. * Defines the lens flare scene component responsible to manage any lens flares
  56390. * in a given scene.
  56391. */
  56392. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56393. /**
  56394. * The component name helpfull to identify the component in the list of scene components.
  56395. */
  56396. readonly name: string;
  56397. /**
  56398. * The scene the component belongs to.
  56399. */
  56400. scene: Scene;
  56401. /**
  56402. * Creates a new instance of the component for the given scene
  56403. * @param scene Defines the scene to register the component in
  56404. */
  56405. constructor(scene: Scene);
  56406. /**
  56407. * Registers the component in a given scene
  56408. */
  56409. register(): void;
  56410. /**
  56411. * Rebuilds the elements related to this component in case of
  56412. * context lost for instance.
  56413. */
  56414. rebuild(): void;
  56415. /**
  56416. * Adds all the elements from the container to the scene
  56417. * @param container the container holding the elements
  56418. */
  56419. addFromContainer(container: AbstractScene): void;
  56420. /**
  56421. * Removes all the elements in the container from the scene
  56422. * @param container contains the elements to remove
  56423. * @param dispose if the removed element should be disposed (default: false)
  56424. */
  56425. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56426. /**
  56427. * Serializes the component data to the specified json object
  56428. * @param serializationObject The object to serialize to
  56429. */
  56430. serialize(serializationObject: any): void;
  56431. /**
  56432. * Disposes the component and the associated ressources.
  56433. */
  56434. dispose(): void;
  56435. private _draw;
  56436. }
  56437. }
  56438. declare module "babylonjs/LensFlares/index" {
  56439. export * from "babylonjs/LensFlares/lensFlare";
  56440. export * from "babylonjs/LensFlares/lensFlareSystem";
  56441. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56442. }
  56443. declare module "babylonjs/Shaders/depth.fragment" {
  56444. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56445. /** @hidden */
  56446. export var depthPixelShader: {
  56447. name: string;
  56448. shader: string;
  56449. };
  56450. }
  56451. declare module "babylonjs/Shaders/depth.vertex" {
  56452. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56455. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56457. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56458. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56459. /** @hidden */
  56460. export var depthVertexShader: {
  56461. name: string;
  56462. shader: string;
  56463. };
  56464. }
  56465. declare module "babylonjs/Rendering/depthRenderer" {
  56466. import { Nullable } from "babylonjs/types";
  56467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56468. import { Scene } from "babylonjs/scene";
  56469. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56470. import { Camera } from "babylonjs/Cameras/camera";
  56471. import "babylonjs/Shaders/depth.fragment";
  56472. import "babylonjs/Shaders/depth.vertex";
  56473. /**
  56474. * This represents a depth renderer in Babylon.
  56475. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56476. */
  56477. export class DepthRenderer {
  56478. private _scene;
  56479. private _depthMap;
  56480. private _effect;
  56481. private readonly _storeNonLinearDepth;
  56482. private readonly _clearColor;
  56483. /** Get if the depth renderer is using packed depth or not */
  56484. readonly isPacked: boolean;
  56485. private _cachedDefines;
  56486. private _camera;
  56487. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56488. enabled: boolean;
  56489. /**
  56490. * Specifiess that the depth renderer will only be used within
  56491. * the camera it is created for.
  56492. * This can help forcing its rendering during the camera processing.
  56493. */
  56494. useOnlyInActiveCamera: boolean;
  56495. /** @hidden */
  56496. static _SceneComponentInitialization: (scene: Scene) => void;
  56497. /**
  56498. * Instantiates a depth renderer
  56499. * @param scene The scene the renderer belongs to
  56500. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56501. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56502. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56503. */
  56504. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56505. /**
  56506. * Creates the depth rendering effect and checks if the effect is ready.
  56507. * @param subMesh The submesh to be used to render the depth map of
  56508. * @param useInstances If multiple world instances should be used
  56509. * @returns if the depth renderer is ready to render the depth map
  56510. */
  56511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56512. /**
  56513. * Gets the texture which the depth map will be written to.
  56514. * @returns The depth map texture
  56515. */
  56516. getDepthMap(): RenderTargetTexture;
  56517. /**
  56518. * Disposes of the depth renderer.
  56519. */
  56520. dispose(): void;
  56521. }
  56522. }
  56523. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56524. /** @hidden */
  56525. export var minmaxReduxPixelShader: {
  56526. name: string;
  56527. shader: string;
  56528. };
  56529. }
  56530. declare module "babylonjs/Misc/minMaxReducer" {
  56531. import { Nullable } from "babylonjs/types";
  56532. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56533. import { Camera } from "babylonjs/Cameras/camera";
  56534. import { Observer } from "babylonjs/Misc/observable";
  56535. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56536. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56537. import { Observable } from "babylonjs/Misc/observable";
  56538. import "babylonjs/Shaders/minmaxRedux.fragment";
  56539. /**
  56540. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56541. * and maximum values from all values of the texture.
  56542. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56543. * The source values are read from the red channel of the texture.
  56544. */
  56545. export class MinMaxReducer {
  56546. /**
  56547. * Observable triggered when the computation has been performed
  56548. */
  56549. onAfterReductionPerformed: Observable<{
  56550. min: number;
  56551. max: number;
  56552. }>;
  56553. protected _camera: Camera;
  56554. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56555. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56556. protected _postProcessManager: PostProcessManager;
  56557. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56558. protected _forceFullscreenViewport: boolean;
  56559. /**
  56560. * Creates a min/max reducer
  56561. * @param camera The camera to use for the post processes
  56562. */
  56563. constructor(camera: Camera);
  56564. /**
  56565. * Gets the texture used to read the values from.
  56566. */
  56567. get sourceTexture(): Nullable<RenderTargetTexture>;
  56568. /**
  56569. * Sets the source texture to read the values from.
  56570. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56571. * because in such textures '1' value must not be taken into account to compute the maximum
  56572. * as this value is used to clear the texture.
  56573. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56574. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56575. * @param depthRedux Indicates if the texture is a depth texture or not
  56576. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56577. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56578. */
  56579. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56580. /**
  56581. * Defines the refresh rate of the computation.
  56582. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56583. */
  56584. get refreshRate(): number;
  56585. set refreshRate(value: number);
  56586. protected _activated: boolean;
  56587. /**
  56588. * Gets the activation status of the reducer
  56589. */
  56590. get activated(): boolean;
  56591. /**
  56592. * Activates the reduction computation.
  56593. * When activated, the observers registered in onAfterReductionPerformed are
  56594. * called after the compuation is performed
  56595. */
  56596. activate(): void;
  56597. /**
  56598. * Deactivates the reduction computation.
  56599. */
  56600. deactivate(): void;
  56601. /**
  56602. * Disposes the min/max reducer
  56603. * @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.
  56604. */
  56605. dispose(disposeAll?: boolean): void;
  56606. }
  56607. }
  56608. declare module "babylonjs/Misc/depthReducer" {
  56609. import { Nullable } from "babylonjs/types";
  56610. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56611. import { Camera } from "babylonjs/Cameras/camera";
  56612. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56613. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56614. /**
  56615. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56616. */
  56617. export class DepthReducer extends MinMaxReducer {
  56618. private _depthRenderer;
  56619. private _depthRendererId;
  56620. /**
  56621. * Gets the depth renderer used for the computation.
  56622. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56623. */
  56624. get depthRenderer(): Nullable<DepthRenderer>;
  56625. /**
  56626. * Creates a depth reducer
  56627. * @param camera The camera used to render the depth texture
  56628. */
  56629. constructor(camera: Camera);
  56630. /**
  56631. * Sets the depth renderer to use to generate the depth map
  56632. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56633. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56634. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56635. */
  56636. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56637. /** @hidden */
  56638. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56639. /**
  56640. * Activates the reduction computation.
  56641. * When activated, the observers registered in onAfterReductionPerformed are
  56642. * called after the compuation is performed
  56643. */
  56644. activate(): void;
  56645. /**
  56646. * Deactivates the reduction computation.
  56647. */
  56648. deactivate(): void;
  56649. /**
  56650. * Disposes the depth reducer
  56651. * @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.
  56652. */
  56653. dispose(disposeAll?: boolean): void;
  56654. }
  56655. }
  56656. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56657. import { Nullable } from "babylonjs/types";
  56658. import { Scene } from "babylonjs/scene";
  56659. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56660. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56662. import { Mesh } from "babylonjs/Meshes/mesh";
  56663. import { Effect } from "babylonjs/Materials/effect";
  56664. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56665. import "babylonjs/Shaders/shadowMap.fragment";
  56666. import "babylonjs/Shaders/shadowMap.vertex";
  56667. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56668. import { Observable } from "babylonjs/Misc/observable";
  56669. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56670. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56671. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56672. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56673. /**
  56674. * A CSM implementation allowing casting shadows on large scenes.
  56675. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56676. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56677. */
  56678. export class CascadedShadowGenerator implements IShadowGenerator {
  56679. private static readonly frustumCornersNDCSpace;
  56680. /**
  56681. * Defines the default number of cascades used by the CSM.
  56682. */
  56683. static readonly DEFAULT_CASCADES_COUNT: number;
  56684. /**
  56685. * Defines the minimum number of cascades used by the CSM.
  56686. */
  56687. static readonly MIN_CASCADES_COUNT: number;
  56688. /**
  56689. * Defines the maximum number of cascades used by the CSM.
  56690. */
  56691. static readonly MAX_CASCADES_COUNT: number;
  56692. /**
  56693. * Shadow generator mode None: no filtering applied.
  56694. */
  56695. static readonly FILTER_NONE: number;
  56696. /**
  56697. * Shadow generator mode PCF: Percentage Closer Filtering
  56698. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  56699. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  56700. */
  56701. static readonly FILTER_PCF: number;
  56702. /**
  56703. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  56704. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  56705. * Contact Hardening
  56706. */
  56707. static readonly FILTER_PCSS: number;
  56708. /**
  56709. * Reserved for PCF and PCSS
  56710. * Highest Quality.
  56711. *
  56712. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  56713. *
  56714. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  56715. */
  56716. static readonly QUALITY_HIGH: number;
  56717. /**
  56718. * Reserved for PCF and PCSS
  56719. * Good tradeoff for quality/perf cross devices
  56720. *
  56721. * Execute PCF on a 3*3 kernel.
  56722. *
  56723. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  56724. */
  56725. static readonly QUALITY_MEDIUM: number;
  56726. /**
  56727. * Reserved for PCF and PCSS
  56728. * The lowest quality but the fastest.
  56729. *
  56730. * Execute PCF on a 1*1 kernel.
  56731. *
  56732. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  56733. */
  56734. static readonly QUALITY_LOW: number;
  56735. private static readonly _CLEARONE;
  56736. /**
  56737. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  56738. */
  56739. onBeforeShadowMapRenderObservable: Observable<Effect>;
  56740. /**
  56741. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  56742. */
  56743. onAfterShadowMapRenderObservable: Observable<Effect>;
  56744. /**
  56745. * Observable triggered before a mesh is rendered in the shadow map.
  56746. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  56747. */
  56748. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  56749. /**
  56750. * Observable triggered after a mesh is rendered in the shadow map.
  56751. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  56752. */
  56753. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  56754. private _bias;
  56755. /**
  56756. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  56757. */
  56758. get bias(): number;
  56759. /**
  56760. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  56761. */
  56762. set bias(bias: number);
  56763. private _normalBias;
  56764. /**
  56765. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  56766. */
  56767. get normalBias(): number;
  56768. /**
  56769. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  56770. */
  56771. set normalBias(normalBias: number);
  56772. private _filter;
  56773. /**
  56774. * Gets the current mode of the shadow generator (normal, PCF, PCSS...).
  56775. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  56776. */
  56777. get filter(): number;
  56778. /**
  56779. * Sets the current mode of the shadow generator (normal, PCF, PCSS...).
  56780. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  56781. */
  56782. set filter(value: number);
  56783. /**
  56784. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  56785. */
  56786. get usePercentageCloserFiltering(): boolean;
  56787. /**
  56788. * Sets the current filter to "PCF" (percentage closer filtering).
  56789. */
  56790. set usePercentageCloserFiltering(value: boolean);
  56791. private _filteringQuality;
  56792. /**
  56793. * Gets the PCF or PCSS Quality.
  56794. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  56795. */
  56796. get filteringQuality(): number;
  56797. /**
  56798. * Sets the PCF or PCSS Quality.
  56799. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  56800. */
  56801. set filteringQuality(filteringQuality: number);
  56802. /**
  56803. * Gets if the current filter is set to "PCSS" (contact hardening).
  56804. */
  56805. get useContactHardeningShadow(): boolean;
  56806. /**
  56807. * Sets the current filter to "PCSS" (contact hardening).
  56808. */
  56809. set useContactHardeningShadow(value: boolean);
  56810. private _contactHardeningLightSizeUVRatio;
  56811. /**
  56812. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  56813. * Using a ratio helps keeping shape stability independently of the map size.
  56814. *
  56815. * It does not account for the light projection as it was having too much
  56816. * instability during the light setup or during light position changes.
  56817. *
  56818. * Only valid if useContactHardeningShadow is true.
  56819. */
  56820. get contactHardeningLightSizeUVRatio(): number;
  56821. /**
  56822. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  56823. * Using a ratio helps keeping shape stability independently of the map size.
  56824. *
  56825. * It does not account for the light projection as it was having too much
  56826. * instability during the light setup or during light position changes.
  56827. *
  56828. * Only valid if useContactHardeningShadow is true.
  56829. */
  56830. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  56831. private _darkness;
  56832. /** Gets or sets the actual darkness of a shadow */
  56833. get darkness(): number;
  56834. set darkness(value: number);
  56835. /**
  56836. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  56837. * 0 means strongest and 1 would means no shadow.
  56838. * @returns the darkness.
  56839. */
  56840. getDarkness(): number;
  56841. /**
  56842. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  56843. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  56844. * @returns the shadow generator allowing fluent coding.
  56845. */
  56846. setDarkness(darkness: number): CascadedShadowGenerator;
  56847. /**
  56848. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56849. */
  56850. penumbraDarkness: number;
  56851. private _transparencyShadow;
  56852. /** Gets or sets the ability to have transparent shadow */
  56853. get transparencyShadow(): boolean;
  56854. set transparencyShadow(value: boolean);
  56855. /**
  56856. * Sets the ability to have transparent shadow (boolean).
  56857. * @param transparent True if transparent else False
  56858. * @returns the shadow generator allowing fluent coding
  56859. */
  56860. setTransparencyShadow(transparent: boolean): CascadedShadowGenerator;
  56861. private _numCascades;
  56862. /**
  56863. * Gets or set the number of cascades used by the CSM.
  56864. */
  56865. get numCascades(): number;
  56866. set numCascades(value: number);
  56867. /**
  56868. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56869. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56870. */
  56871. stabilizeCascades: boolean;
  56872. private _shadowMap;
  56873. /**
  56874. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  56875. * @returns The render target texture if present otherwise, null
  56876. */
  56877. getShadowMap(): Nullable<RenderTargetTexture>;
  56878. protected _freezeShadowCastersBoundingInfo: boolean;
  56879. private _freezeShadowCastersBoundingInfoObservable;
  56880. /**
  56881. * Enables or disables the shadow casters bounding info computation.
  56882. * If your shadow casters don't move, you can disable this feature.
  56883. * If it is enabled, the bounding box computation is done every frame.
  56884. */
  56885. get freezeShadowCastersBoundingInfo(): boolean;
  56886. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56887. private _scbiMin;
  56888. private _scbiMax;
  56889. protected _computeShadowCastersBoundingInfo(): void;
  56890. protected _shadowCastersBoundingInfo: BoundingInfo;
  56891. /**
  56892. * Gets or sets the shadow casters bounding info.
  56893. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56894. * so that the system won't overwrite the bounds you provide
  56895. */
  56896. get shadowCastersBoundingInfo(): BoundingInfo;
  56897. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56898. protected _breaksAreDirty: boolean;
  56899. protected _minDistance: number;
  56900. protected _maxDistance: number;
  56901. /**
  56902. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56903. *
  56904. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56905. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56906. * @param min minimal distance for the breaks (default to 0.)
  56907. * @param max maximal distance for the breaks (default to 1.)
  56908. */
  56909. setMinMaxDistance(min: number, max: number): void;
  56910. /**
  56911. * Gets the class name of that object
  56912. * @returns "ShadowGenerator"
  56913. */
  56914. getClassName(): string;
  56915. /**
  56916. * Helper function to add a mesh and its descendants to the list of shadow casters.
  56917. * @param mesh Mesh to add
  56918. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  56919. * @returns the Shadow Generator itself
  56920. */
  56921. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  56922. /**
  56923. * Helper function to remove a mesh and its descendants from the list of shadow casters
  56924. * @param mesh Mesh to remove
  56925. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  56926. * @returns the Shadow Generator itself
  56927. */
  56928. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  56929. /**
  56930. * Controls the extent to which the shadows fade out at the edge of the frustum
  56931. */
  56932. frustumEdgeFalloff: number;
  56933. private _light;
  56934. /**
  56935. * Returns the associated light object.
  56936. * @returns the light generating the shadow
  56937. */
  56938. getLight(): DirectionalLight;
  56939. /**
  56940. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  56941. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  56942. * It might on the other hand introduce peter panning.
  56943. */
  56944. forceBackFacesOnly: boolean;
  56945. private _cascadeMinExtents;
  56946. private _cascadeMaxExtents;
  56947. /**
  56948. * Gets a cascade minimum extents
  56949. * @param cascadeIndex index of the cascade
  56950. * @returns the minimum cascade extents
  56951. */
  56952. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56953. /**
  56954. * Gets a cascade maximum extents
  56955. * @param cascadeIndex index of the cascade
  56956. * @returns the maximum cascade extents
  56957. */
  56958. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56959. private _scene;
  56960. private _lightDirection;
  56961. private _effect;
  56962. private _cascades;
  56963. private _cachedPosition;
  56964. private _cachedDirection;
  56965. private _cachedDefines;
  56966. private _currentRenderID;
  56967. private _mapSize;
  56968. private _currentLayer;
  56969. private _textureType;
  56970. private _defaultTextureMatrix;
  56971. private _storedUniqueId;
  56972. private _viewSpaceFrustumsZ;
  56973. private _viewMatrices;
  56974. private _projectionMatrices;
  56975. private _transformMatrices;
  56976. private _transformMatricesAsArray;
  56977. private _frustumLengths;
  56978. private _lightSizeUVCorrection;
  56979. private _depthCorrection;
  56980. private _frustumCornersWorldSpace;
  56981. private _frustumCenter;
  56982. private _shadowCameraPos;
  56983. private _shadowMaxZ;
  56984. /**
  56985. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56986. * It defaults to camera.maxZ
  56987. */
  56988. get shadowMaxZ(): number;
  56989. /**
  56990. * Sets the shadow max z distance.
  56991. */
  56992. set shadowMaxZ(value: number);
  56993. protected _debug: boolean;
  56994. /**
  56995. * Gets or sets the debug flag.
  56996. * When enabled, the cascades are materialized by different colors on the screen.
  56997. */
  56998. get debug(): boolean;
  56999. set debug(dbg: boolean);
  57000. private _depthClamp;
  57001. /**
  57002. * Gets or sets the depth clamping value.
  57003. *
  57004. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57005. * to account for the shadow casters far away.
  57006. *
  57007. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57008. */
  57009. get depthClamp(): boolean;
  57010. set depthClamp(value: boolean);
  57011. /**
  57012. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57013. * It defaults to 0.1 (10% blending).
  57014. */
  57015. cascadeBlendPercentage: number;
  57016. private _lambda;
  57017. /**
  57018. * Gets or set the lambda parameter.
  57019. * This parameter is used to split the camera frustum and create the cascades.
  57020. * 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.
  57021. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57022. */
  57023. get lambda(): number;
  57024. set lambda(value: number);
  57025. /**
  57026. * Gets the view matrix corresponding to a given cascade
  57027. * @param cascadeNum cascade to retrieve the view matrix from
  57028. * @returns the cascade view matrix
  57029. */
  57030. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57031. private _depthRenderer;
  57032. /**
  57033. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57034. *
  57035. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57036. *
  57037. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57038. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57039. * @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
  57040. */
  57041. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57042. private _depthReducer;
  57043. private _autoCalcDepthBounds;
  57044. /**
  57045. * Gets or sets the autoCalcDepthBounds property.
  57046. *
  57047. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57048. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57049. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57050. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57051. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57052. */
  57053. get autoCalcDepthBounds(): boolean;
  57054. set autoCalcDepthBounds(value: boolean);
  57055. /**
  57056. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57057. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57058. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57059. * for setting the refresh rate on the renderer yourself!
  57060. */
  57061. get autoCalcDepthBoundsRefreshRate(): number;
  57062. set autoCalcDepthBoundsRefreshRate(value: number);
  57063. /**
  57064. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57065. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57066. * you change the camera near/far planes!
  57067. */
  57068. splitFrustum(): void;
  57069. private _splitFrustum;
  57070. /**
  57071. * Gets the CSM transformation matrix used to project the meshes into the map from the light point of view.
  57072. * (eq to view projection * shadow projection matrices)
  57073. * @param cascadeIndex index number of the cascaded shadow map
  57074. * @returns The transform matrix used to create the CSM shadow map
  57075. */
  57076. getCSMTransformMatrix(cascadeIndex: number): Matrix;
  57077. private _computeFrustumInWorldSpace;
  57078. private _computeCascadeFrustum;
  57079. /** @hidden */
  57080. static _SceneComponentInitialization: (scene: Scene) => void;
  57081. /**
  57082. * Creates a Cascaded Shadow Generator object.
  57083. * A ShadowGenerator is the required tool to use the shadows.
  57084. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57085. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57086. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57087. * @param light The directional light object generating the shadows.
  57088. * @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.
  57089. */
  57090. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57091. private _initializeGenerator;
  57092. private _initializeShadowMap;
  57093. private _renderForShadowMap;
  57094. private _renderSubMeshForShadowMap;
  57095. private _applyFilterValues;
  57096. /**
  57097. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  57098. * @param onCompiled Callback triggered at the and of the effects compilation
  57099. * @param options Sets of optional options forcing the compilation with different modes
  57100. */
  57101. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  57102. useInstances: boolean;
  57103. }>): void;
  57104. /**
  57105. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  57106. * @param options Sets of optional options forcing the compilation with different modes
  57107. * @returns A promise that resolves when the compilation completes
  57108. */
  57109. forceCompilationAsync(options?: Partial<{
  57110. useInstances: boolean;
  57111. }>): Promise<void>;
  57112. /**
  57113. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  57114. * @param subMesh The submesh we want to render in the shadow map
  57115. * @param useInstances Defines wether will draw in the map using instances
  57116. * @returns true if ready otherwise, false
  57117. */
  57118. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57119. /**
  57120. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57121. * @param defines Defines of the material we want to update
  57122. * @param lightIndex Index of the light in the enabled light list of the material
  57123. */
  57124. prepareDefines(defines: any, lightIndex: number): void;
  57125. /**
  57126. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57127. * defined in the generator but impacting the effect).
  57128. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57129. * @param effect The effect we are binfing the information for
  57130. */
  57131. bindShadowLight(lightIndex: string, effect: Effect): void;
  57132. /**
  57133. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57134. * (eq to view projection * shadow projection matrices)
  57135. * @returns The transform matrix used to create the shadow map
  57136. */
  57137. getTransformMatrix(): Matrix;
  57138. /**
  57139. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  57140. * Cube and 2D textures for instance.
  57141. */
  57142. recreateShadowMap(): void;
  57143. private _disposeRTT;
  57144. /**
  57145. * Disposes the ShadowGenerator.
  57146. * Returns nothing.
  57147. */
  57148. dispose(): void;
  57149. /**
  57150. * Serializes the shadow generator setup to a json object.
  57151. * @returns The serialized JSON object
  57152. */
  57153. serialize(): any;
  57154. /**
  57155. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57156. * @param parsedShadowGenerator The JSON object to parse
  57157. * @param scene The scene to create the shadow map for
  57158. * @returns The parsed shadow generator
  57159. */
  57160. static Parse(parsedShadowGenerator: any, scene: Scene): CascadedShadowGenerator;
  57161. }
  57162. }
  57163. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57164. import { Scene } from "babylonjs/scene";
  57165. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57166. import { AbstractScene } from "babylonjs/abstractScene";
  57167. /**
  57168. * Defines the shadow generator component responsible to manage any shadow generators
  57169. * in a given scene.
  57170. */
  57171. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57172. /**
  57173. * The component name helpfull to identify the component in the list of scene components.
  57174. */
  57175. readonly name: string;
  57176. /**
  57177. * The scene the component belongs to.
  57178. */
  57179. scene: Scene;
  57180. /**
  57181. * Creates a new instance of the component for the given scene
  57182. * @param scene Defines the scene to register the component in
  57183. */
  57184. constructor(scene: Scene);
  57185. /**
  57186. * Registers the component in a given scene
  57187. */
  57188. register(): void;
  57189. /**
  57190. * Rebuilds the elements related to this component in case of
  57191. * context lost for instance.
  57192. */
  57193. rebuild(): void;
  57194. /**
  57195. * Serializes the component data to the specified json object
  57196. * @param serializationObject The object to serialize to
  57197. */
  57198. serialize(serializationObject: any): void;
  57199. /**
  57200. * Adds all the elements from the container to the scene
  57201. * @param container the container holding the elements
  57202. */
  57203. addFromContainer(container: AbstractScene): void;
  57204. /**
  57205. * Removes all the elements in the container from the scene
  57206. * @param container contains the elements to remove
  57207. * @param dispose if the removed element should be disposed (default: false)
  57208. */
  57209. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57210. /**
  57211. * Rebuilds the elements related to this component in case of
  57212. * context lost for instance.
  57213. */
  57214. dispose(): void;
  57215. private _gatherRenderTargets;
  57216. }
  57217. }
  57218. declare module "babylonjs/Lights/Shadows/index" {
  57219. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57220. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57221. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57222. }
  57223. declare module "babylonjs/Lights/pointLight" {
  57224. import { Scene } from "babylonjs/scene";
  57225. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57227. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57228. import { Effect } from "babylonjs/Materials/effect";
  57229. /**
  57230. * A point light is a light defined by an unique point in world space.
  57231. * The light is emitted in every direction from this point.
  57232. * A good example of a point light is a standard light bulb.
  57233. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57234. */
  57235. export class PointLight extends ShadowLight {
  57236. private _shadowAngle;
  57237. /**
  57238. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57239. * This specifies what angle the shadow will use to be created.
  57240. *
  57241. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57242. */
  57243. get shadowAngle(): number;
  57244. /**
  57245. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57246. * This specifies what angle the shadow will use to be created.
  57247. *
  57248. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57249. */
  57250. set shadowAngle(value: number);
  57251. /**
  57252. * Gets the direction if it has been set.
  57253. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57254. */
  57255. get direction(): Vector3;
  57256. /**
  57257. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57258. */
  57259. set direction(value: Vector3);
  57260. /**
  57261. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57262. * A PointLight emits the light in every direction.
  57263. * It can cast shadows.
  57264. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57265. * ```javascript
  57266. * var pointLight = new PointLight("pl", camera.position, scene);
  57267. * ```
  57268. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57269. * @param name The light friendly name
  57270. * @param position The position of the point light in the scene
  57271. * @param scene The scene the lights belongs to
  57272. */
  57273. constructor(name: string, position: Vector3, scene: Scene);
  57274. /**
  57275. * Returns the string "PointLight"
  57276. * @returns the class name
  57277. */
  57278. getClassName(): string;
  57279. /**
  57280. * Returns the integer 0.
  57281. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57282. */
  57283. getTypeID(): number;
  57284. /**
  57285. * Specifies wether or not the shadowmap should be a cube texture.
  57286. * @returns true if the shadowmap needs to be a cube texture.
  57287. */
  57288. needCube(): boolean;
  57289. /**
  57290. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57291. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57292. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57293. */
  57294. getShadowDirection(faceIndex?: number): Vector3;
  57295. /**
  57296. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57297. * - fov = PI / 2
  57298. * - aspect ratio : 1.0
  57299. * - z-near and far equal to the active camera minZ and maxZ.
  57300. * Returns the PointLight.
  57301. */
  57302. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57303. protected _buildUniformLayout(): void;
  57304. /**
  57305. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57306. * @param effect The effect to update
  57307. * @param lightIndex The index of the light in the effect to update
  57308. * @returns The point light
  57309. */
  57310. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57311. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57312. /**
  57313. * Prepares the list of defines specific to the light type.
  57314. * @param defines the list of defines
  57315. * @param lightIndex defines the index of the light for the effect
  57316. */
  57317. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57318. }
  57319. }
  57320. declare module "babylonjs/Lights/index" {
  57321. export * from "babylonjs/Lights/light";
  57322. export * from "babylonjs/Lights/shadowLight";
  57323. export * from "babylonjs/Lights/Shadows/index";
  57324. export * from "babylonjs/Lights/directionalLight";
  57325. export * from "babylonjs/Lights/hemisphericLight";
  57326. export * from "babylonjs/Lights/pointLight";
  57327. export * from "babylonjs/Lights/spotLight";
  57328. }
  57329. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57330. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57331. /**
  57332. * Header information of HDR texture files.
  57333. */
  57334. export interface HDRInfo {
  57335. /**
  57336. * The height of the texture in pixels.
  57337. */
  57338. height: number;
  57339. /**
  57340. * The width of the texture in pixels.
  57341. */
  57342. width: number;
  57343. /**
  57344. * The index of the beginning of the data in the binary file.
  57345. */
  57346. dataPosition: number;
  57347. }
  57348. /**
  57349. * This groups tools to convert HDR texture to native colors array.
  57350. */
  57351. export class HDRTools {
  57352. private static Ldexp;
  57353. private static Rgbe2float;
  57354. private static readStringLine;
  57355. /**
  57356. * Reads header information from an RGBE texture stored in a native array.
  57357. * More information on this format are available here:
  57358. * https://en.wikipedia.org/wiki/RGBE_image_format
  57359. *
  57360. * @param uint8array The binary file stored in native array.
  57361. * @return The header information.
  57362. */
  57363. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57364. /**
  57365. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57366. * This RGBE texture needs to store the information as a panorama.
  57367. *
  57368. * More information on this format are available here:
  57369. * https://en.wikipedia.org/wiki/RGBE_image_format
  57370. *
  57371. * @param buffer The binary file stored in an array buffer.
  57372. * @param size The expected size of the extracted cubemap.
  57373. * @return The Cube Map information.
  57374. */
  57375. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57376. /**
  57377. * Returns the pixels data extracted from an RGBE texture.
  57378. * This pixels will be stored left to right up to down in the R G B order in one array.
  57379. *
  57380. * More information on this format are available here:
  57381. * https://en.wikipedia.org/wiki/RGBE_image_format
  57382. *
  57383. * @param uint8array The binary file stored in an array buffer.
  57384. * @param hdrInfo The header information of the file.
  57385. * @return The pixels data in RGB right to left up to down order.
  57386. */
  57387. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57388. private static RGBE_ReadPixels_RLE;
  57389. }
  57390. }
  57391. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57392. import { Nullable } from "babylonjs/types";
  57393. import { Scene } from "babylonjs/scene";
  57394. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57395. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57396. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57397. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57398. /**
  57399. * This represents a texture coming from an HDR input.
  57400. *
  57401. * The only supported format is currently panorama picture stored in RGBE format.
  57402. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57403. */
  57404. export class HDRCubeTexture extends BaseTexture {
  57405. private static _facesMapping;
  57406. private _generateHarmonics;
  57407. private _noMipmap;
  57408. private _textureMatrix;
  57409. private _size;
  57410. private _onLoad;
  57411. private _onError;
  57412. /**
  57413. * The texture URL.
  57414. */
  57415. url: string;
  57416. /**
  57417. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57418. */
  57419. coordinatesMode: number;
  57420. protected _isBlocking: boolean;
  57421. /**
  57422. * Sets wether or not the texture is blocking during loading.
  57423. */
  57424. set isBlocking(value: boolean);
  57425. /**
  57426. * Gets wether or not the texture is blocking during loading.
  57427. */
  57428. get isBlocking(): boolean;
  57429. protected _rotationY: number;
  57430. /**
  57431. * Sets texture matrix rotation angle around Y axis in radians.
  57432. */
  57433. set rotationY(value: number);
  57434. /**
  57435. * Gets texture matrix rotation angle around Y axis radians.
  57436. */
  57437. get rotationY(): number;
  57438. /**
  57439. * Gets or sets the center of the bounding box associated with the cube texture
  57440. * It must define where the camera used to render the texture was set
  57441. */
  57442. boundingBoxPosition: Vector3;
  57443. private _boundingBoxSize;
  57444. /**
  57445. * Gets or sets the size of the bounding box associated with the cube texture
  57446. * When defined, the cubemap will switch to local mode
  57447. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57448. * @example https://www.babylonjs-playground.com/#RNASML
  57449. */
  57450. set boundingBoxSize(value: Vector3);
  57451. get boundingBoxSize(): Vector3;
  57452. /**
  57453. * Instantiates an HDRTexture from the following parameters.
  57454. *
  57455. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57456. * @param scene The scene the texture will be used in
  57457. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57458. * @param noMipmap Forces to not generate the mipmap if true
  57459. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57460. * @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)
  57461. * @param reserved Reserved flag for internal use.
  57462. */
  57463. 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>);
  57464. /**
  57465. * Get the current class name of the texture useful for serialization or dynamic coding.
  57466. * @returns "HDRCubeTexture"
  57467. */
  57468. getClassName(): string;
  57469. /**
  57470. * Occurs when the file is raw .hdr file.
  57471. */
  57472. private loadTexture;
  57473. clone(): HDRCubeTexture;
  57474. delayLoad(): void;
  57475. /**
  57476. * Get the texture reflection matrix used to rotate/transform the reflection.
  57477. * @returns the reflection matrix
  57478. */
  57479. getReflectionTextureMatrix(): Matrix;
  57480. /**
  57481. * Set the texture reflection matrix used to rotate/transform the reflection.
  57482. * @param value Define the reflection matrix to set
  57483. */
  57484. setReflectionTextureMatrix(value: Matrix): void;
  57485. /**
  57486. * Parses a JSON representation of an HDR Texture in order to create the texture
  57487. * @param parsedTexture Define the JSON representation
  57488. * @param scene Define the scene the texture should be created in
  57489. * @param rootUrl Define the root url in case we need to load relative dependencies
  57490. * @returns the newly created texture after parsing
  57491. */
  57492. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57493. serialize(): any;
  57494. }
  57495. }
  57496. declare module "babylonjs/Physics/physicsEngine" {
  57497. import { Nullable } from "babylonjs/types";
  57498. import { Vector3 } from "babylonjs/Maths/math.vector";
  57499. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57500. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57501. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57502. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57503. /**
  57504. * Class used to control physics engine
  57505. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57506. */
  57507. export class PhysicsEngine implements IPhysicsEngine {
  57508. private _physicsPlugin;
  57509. /**
  57510. * Global value used to control the smallest number supported by the simulation
  57511. */
  57512. static Epsilon: number;
  57513. private _impostors;
  57514. private _joints;
  57515. private _subTimeStep;
  57516. /**
  57517. * Gets the gravity vector used by the simulation
  57518. */
  57519. gravity: Vector3;
  57520. /**
  57521. * Factory used to create the default physics plugin.
  57522. * @returns The default physics plugin
  57523. */
  57524. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57525. /**
  57526. * Creates a new Physics Engine
  57527. * @param gravity defines the gravity vector used by the simulation
  57528. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57529. */
  57530. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57531. /**
  57532. * Sets the gravity vector used by the simulation
  57533. * @param gravity defines the gravity vector to use
  57534. */
  57535. setGravity(gravity: Vector3): void;
  57536. /**
  57537. * Set the time step of the physics engine.
  57538. * Default is 1/60.
  57539. * To slow it down, enter 1/600 for example.
  57540. * To speed it up, 1/30
  57541. * @param newTimeStep defines the new timestep to apply to this world.
  57542. */
  57543. setTimeStep(newTimeStep?: number): void;
  57544. /**
  57545. * Get the time step of the physics engine.
  57546. * @returns the current time step
  57547. */
  57548. getTimeStep(): number;
  57549. /**
  57550. * Set the sub time step of the physics engine.
  57551. * Default is 0 meaning there is no sub steps
  57552. * To increase physics resolution precision, set a small value (like 1 ms)
  57553. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57554. */
  57555. setSubTimeStep(subTimeStep?: number): void;
  57556. /**
  57557. * Get the sub time step of the physics engine.
  57558. * @returns the current sub time step
  57559. */
  57560. getSubTimeStep(): number;
  57561. /**
  57562. * Release all resources
  57563. */
  57564. dispose(): void;
  57565. /**
  57566. * Gets the name of the current physics plugin
  57567. * @returns the name of the plugin
  57568. */
  57569. getPhysicsPluginName(): string;
  57570. /**
  57571. * Adding a new impostor for the impostor tracking.
  57572. * This will be done by the impostor itself.
  57573. * @param impostor the impostor to add
  57574. */
  57575. addImpostor(impostor: PhysicsImpostor): void;
  57576. /**
  57577. * Remove an impostor from the engine.
  57578. * This impostor and its mesh will not longer be updated by the physics engine.
  57579. * @param impostor the impostor to remove
  57580. */
  57581. removeImpostor(impostor: PhysicsImpostor): void;
  57582. /**
  57583. * Add a joint to the physics engine
  57584. * @param mainImpostor defines the main impostor to which the joint is added.
  57585. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57586. * @param joint defines the joint that will connect both impostors.
  57587. */
  57588. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57589. /**
  57590. * Removes a joint from the simulation
  57591. * @param mainImpostor defines the impostor used with the joint
  57592. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57593. * @param joint defines the joint to remove
  57594. */
  57595. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57596. /**
  57597. * Called by the scene. No need to call it.
  57598. * @param delta defines the timespam between frames
  57599. */
  57600. _step(delta: number): void;
  57601. /**
  57602. * Gets the current plugin used to run the simulation
  57603. * @returns current plugin
  57604. */
  57605. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57606. /**
  57607. * Gets the list of physic impostors
  57608. * @returns an array of PhysicsImpostor
  57609. */
  57610. getImpostors(): Array<PhysicsImpostor>;
  57611. /**
  57612. * Gets the impostor for a physics enabled object
  57613. * @param object defines the object impersonated by the impostor
  57614. * @returns the PhysicsImpostor or null if not found
  57615. */
  57616. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57617. /**
  57618. * Gets the impostor for a physics body object
  57619. * @param body defines physics body used by the impostor
  57620. * @returns the PhysicsImpostor or null if not found
  57621. */
  57622. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57623. /**
  57624. * Does a raycast in the physics world
  57625. * @param from when should the ray start?
  57626. * @param to when should the ray end?
  57627. * @returns PhysicsRaycastResult
  57628. */
  57629. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57630. }
  57631. }
  57632. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57633. import { Nullable } from "babylonjs/types";
  57634. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57636. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57637. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57638. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57639. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57640. /** @hidden */
  57641. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57642. private _useDeltaForWorldStep;
  57643. world: any;
  57644. name: string;
  57645. private _physicsMaterials;
  57646. private _fixedTimeStep;
  57647. private _cannonRaycastResult;
  57648. private _raycastResult;
  57649. private _physicsBodysToRemoveAfterStep;
  57650. BJSCANNON: any;
  57651. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57652. setGravity(gravity: Vector3): void;
  57653. setTimeStep(timeStep: number): void;
  57654. getTimeStep(): number;
  57655. executeStep(delta: number): void;
  57656. private _removeMarkedPhysicsBodiesFromWorld;
  57657. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57658. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57659. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57660. private _processChildMeshes;
  57661. removePhysicsBody(impostor: PhysicsImpostor): void;
  57662. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57663. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57664. private _addMaterial;
  57665. private _checkWithEpsilon;
  57666. private _createShape;
  57667. private _createHeightmap;
  57668. private _minus90X;
  57669. private _plus90X;
  57670. private _tmpPosition;
  57671. private _tmpDeltaPosition;
  57672. private _tmpUnityRotation;
  57673. private _updatePhysicsBodyTransformation;
  57674. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57675. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57676. isSupported(): boolean;
  57677. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57678. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57679. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57680. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57681. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57682. getBodyMass(impostor: PhysicsImpostor): number;
  57683. getBodyFriction(impostor: PhysicsImpostor): number;
  57684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57685. getBodyRestitution(impostor: PhysicsImpostor): number;
  57686. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57687. sleepBody(impostor: PhysicsImpostor): void;
  57688. wakeUpBody(impostor: PhysicsImpostor): void;
  57689. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57690. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57691. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57692. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57693. getRadius(impostor: PhysicsImpostor): number;
  57694. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57695. dispose(): void;
  57696. private _extendNamespace;
  57697. /**
  57698. * Does a raycast in the physics world
  57699. * @param from when should the ray start?
  57700. * @param to when should the ray end?
  57701. * @returns PhysicsRaycastResult
  57702. */
  57703. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57704. }
  57705. }
  57706. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57707. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57708. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57709. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57711. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57712. import { Nullable } from "babylonjs/types";
  57713. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57714. /** @hidden */
  57715. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57716. world: any;
  57717. name: string;
  57718. BJSOIMO: any;
  57719. private _raycastResult;
  57720. constructor(iterations?: number, oimoInjection?: any);
  57721. setGravity(gravity: Vector3): void;
  57722. setTimeStep(timeStep: number): void;
  57723. getTimeStep(): number;
  57724. private _tmpImpostorsArray;
  57725. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57726. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57727. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57728. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57729. private _tmpPositionVector;
  57730. removePhysicsBody(impostor: PhysicsImpostor): void;
  57731. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57732. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57733. isSupported(): boolean;
  57734. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57735. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57736. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57737. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57738. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57739. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57740. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57741. getBodyMass(impostor: PhysicsImpostor): number;
  57742. getBodyFriction(impostor: PhysicsImpostor): number;
  57743. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57744. getBodyRestitution(impostor: PhysicsImpostor): number;
  57745. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57746. sleepBody(impostor: PhysicsImpostor): void;
  57747. wakeUpBody(impostor: PhysicsImpostor): void;
  57748. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57749. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57750. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57751. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57752. getRadius(impostor: PhysicsImpostor): number;
  57753. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57754. dispose(): void;
  57755. /**
  57756. * Does a raycast in the physics world
  57757. * @param from when should the ray start?
  57758. * @param to when should the ray end?
  57759. * @returns PhysicsRaycastResult
  57760. */
  57761. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57762. }
  57763. }
  57764. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57765. import { Nullable } from "babylonjs/types";
  57766. import { Scene } from "babylonjs/scene";
  57767. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57768. import { Color4 } from "babylonjs/Maths/math.color";
  57769. import { Mesh } from "babylonjs/Meshes/mesh";
  57770. /**
  57771. * Class containing static functions to help procedurally build meshes
  57772. */
  57773. export class RibbonBuilder {
  57774. /**
  57775. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57776. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57777. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57778. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57779. * * 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
  57780. * * 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
  57781. * * 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
  57782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57785. * * 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
  57786. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57787. * * 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
  57788. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57790. * @param name defines the name of the mesh
  57791. * @param options defines the options used to create the mesh
  57792. * @param scene defines the hosting scene
  57793. * @returns the ribbon mesh
  57794. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57795. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57796. */
  57797. static CreateRibbon(name: string, options: {
  57798. pathArray: Vector3[][];
  57799. closeArray?: boolean;
  57800. closePath?: boolean;
  57801. offset?: number;
  57802. updatable?: boolean;
  57803. sideOrientation?: number;
  57804. frontUVs?: Vector4;
  57805. backUVs?: Vector4;
  57806. instance?: Mesh;
  57807. invertUV?: boolean;
  57808. uvs?: Vector2[];
  57809. colors?: Color4[];
  57810. }, scene?: Nullable<Scene>): Mesh;
  57811. }
  57812. }
  57813. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57814. import { Nullable } from "babylonjs/types";
  57815. import { Scene } from "babylonjs/scene";
  57816. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57817. import { Mesh } from "babylonjs/Meshes/mesh";
  57818. /**
  57819. * Class containing static functions to help procedurally build meshes
  57820. */
  57821. export class ShapeBuilder {
  57822. /**
  57823. * 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.
  57824. * * 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.
  57825. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57826. * * 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.
  57827. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57828. * * 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
  57829. * * 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
  57830. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57833. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57835. * @param name defines the name of the mesh
  57836. * @param options defines the options used to create the mesh
  57837. * @param scene defines the hosting scene
  57838. * @returns the extruded shape mesh
  57839. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57840. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57841. */
  57842. static ExtrudeShape(name: string, options: {
  57843. shape: Vector3[];
  57844. path: Vector3[];
  57845. scale?: number;
  57846. rotation?: number;
  57847. cap?: number;
  57848. updatable?: boolean;
  57849. sideOrientation?: number;
  57850. frontUVs?: Vector4;
  57851. backUVs?: Vector4;
  57852. instance?: Mesh;
  57853. invertUV?: boolean;
  57854. }, scene?: Nullable<Scene>): Mesh;
  57855. /**
  57856. * Creates an custom extruded shape mesh.
  57857. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57858. * * 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.
  57859. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57860. * * 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
  57861. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57862. * * 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
  57863. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57864. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57865. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57866. * * 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
  57867. * * 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
  57868. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57871. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57873. * @param name defines the name of the mesh
  57874. * @param options defines the options used to create the mesh
  57875. * @param scene defines the hosting scene
  57876. * @returns the custom extruded shape mesh
  57877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57880. */
  57881. static ExtrudeShapeCustom(name: string, options: {
  57882. shape: Vector3[];
  57883. path: Vector3[];
  57884. scaleFunction?: any;
  57885. rotationFunction?: any;
  57886. ribbonCloseArray?: boolean;
  57887. ribbonClosePath?: boolean;
  57888. cap?: number;
  57889. updatable?: boolean;
  57890. sideOrientation?: number;
  57891. frontUVs?: Vector4;
  57892. backUVs?: Vector4;
  57893. instance?: Mesh;
  57894. invertUV?: boolean;
  57895. }, scene?: Nullable<Scene>): Mesh;
  57896. private static _ExtrudeShapeGeneric;
  57897. }
  57898. }
  57899. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57900. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57901. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57902. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57903. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57904. import { Nullable } from "babylonjs/types";
  57905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57906. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57907. /**
  57908. * AmmoJS Physics plugin
  57909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57910. * @see https://github.com/kripken/ammo.js/
  57911. */
  57912. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57913. private _useDeltaForWorldStep;
  57914. /**
  57915. * Reference to the Ammo library
  57916. */
  57917. bjsAMMO: any;
  57918. /**
  57919. * Created ammoJS world which physics bodies are added to
  57920. */
  57921. world: any;
  57922. /**
  57923. * Name of the plugin
  57924. */
  57925. name: string;
  57926. private _timeStep;
  57927. private _fixedTimeStep;
  57928. private _maxSteps;
  57929. private _tmpQuaternion;
  57930. private _tmpAmmoTransform;
  57931. private _tmpAmmoQuaternion;
  57932. private _tmpAmmoConcreteContactResultCallback;
  57933. private _collisionConfiguration;
  57934. private _dispatcher;
  57935. private _overlappingPairCache;
  57936. private _solver;
  57937. private _softBodySolver;
  57938. private _tmpAmmoVectorA;
  57939. private _tmpAmmoVectorB;
  57940. private _tmpAmmoVectorC;
  57941. private _tmpAmmoVectorD;
  57942. private _tmpContactCallbackResult;
  57943. private _tmpAmmoVectorRCA;
  57944. private _tmpAmmoVectorRCB;
  57945. private _raycastResult;
  57946. private static readonly DISABLE_COLLISION_FLAG;
  57947. private static readonly KINEMATIC_FLAG;
  57948. private static readonly DISABLE_DEACTIVATION_FLAG;
  57949. /**
  57950. * Initializes the ammoJS plugin
  57951. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57952. * @param ammoInjection can be used to inject your own ammo reference
  57953. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57954. */
  57955. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57956. /**
  57957. * Sets the gravity of the physics world (m/(s^2))
  57958. * @param gravity Gravity to set
  57959. */
  57960. setGravity(gravity: Vector3): void;
  57961. /**
  57962. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57963. * @param timeStep timestep to use in seconds
  57964. */
  57965. setTimeStep(timeStep: number): void;
  57966. /**
  57967. * 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)
  57968. * @param fixedTimeStep fixedTimeStep to use in seconds
  57969. */
  57970. setFixedTimeStep(fixedTimeStep: number): void;
  57971. /**
  57972. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57973. * @param maxSteps the maximum number of steps by the physics engine per frame
  57974. */
  57975. setMaxSteps(maxSteps: number): void;
  57976. /**
  57977. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57978. * @returns the current timestep in seconds
  57979. */
  57980. getTimeStep(): number;
  57981. /**
  57982. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57983. */
  57984. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57985. private _isImpostorInContact;
  57986. private _isImpostorPairInContact;
  57987. private _stepSimulation;
  57988. /**
  57989. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57990. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57991. * After the step the babylon meshes are set to the position of the physics imposters
  57992. * @param delta amount of time to step forward
  57993. * @param impostors array of imposters to update before/after the step
  57994. */
  57995. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57996. /**
  57997. * Update babylon mesh to match physics world object
  57998. * @param impostor imposter to match
  57999. */
  58000. private _afterSoftStep;
  58001. /**
  58002. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58003. * @param impostor imposter to match
  58004. */
  58005. private _ropeStep;
  58006. /**
  58007. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58008. * @param impostor imposter to match
  58009. */
  58010. private _softbodyOrClothStep;
  58011. private _tmpVector;
  58012. private _tmpMatrix;
  58013. /**
  58014. * Applies an impulse on the imposter
  58015. * @param impostor imposter to apply impulse to
  58016. * @param force amount of force to be applied to the imposter
  58017. * @param contactPoint the location to apply the impulse on the imposter
  58018. */
  58019. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58020. /**
  58021. * Applies a force on the imposter
  58022. * @param impostor imposter to apply force
  58023. * @param force amount of force to be applied to the imposter
  58024. * @param contactPoint the location to apply the force on the imposter
  58025. */
  58026. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58027. /**
  58028. * Creates a physics body using the plugin
  58029. * @param impostor the imposter to create the physics body on
  58030. */
  58031. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58032. /**
  58033. * Removes the physics body from the imposter and disposes of the body's memory
  58034. * @param impostor imposter to remove the physics body from
  58035. */
  58036. removePhysicsBody(impostor: PhysicsImpostor): void;
  58037. /**
  58038. * Generates a joint
  58039. * @param impostorJoint the imposter joint to create the joint with
  58040. */
  58041. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58042. /**
  58043. * Removes a joint
  58044. * @param impostorJoint the imposter joint to remove the joint from
  58045. */
  58046. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58047. private _addMeshVerts;
  58048. /**
  58049. * Initialise the soft body vertices to match its object's (mesh) vertices
  58050. * Softbody vertices (nodes) are in world space and to match this
  58051. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58052. * @param impostor to create the softbody for
  58053. */
  58054. private _softVertexData;
  58055. /**
  58056. * Create an impostor's soft body
  58057. * @param impostor to create the softbody for
  58058. */
  58059. private _createSoftbody;
  58060. /**
  58061. * Create cloth for an impostor
  58062. * @param impostor to create the softbody for
  58063. */
  58064. private _createCloth;
  58065. /**
  58066. * Create rope for an impostor
  58067. * @param impostor to create the softbody for
  58068. */
  58069. private _createRope;
  58070. /**
  58071. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58072. * @param impostor to create the custom physics shape for
  58073. */
  58074. private _createCustom;
  58075. private _addHullVerts;
  58076. private _createShape;
  58077. /**
  58078. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58079. * @param impostor imposter containing the physics body and babylon object
  58080. */
  58081. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58082. /**
  58083. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58084. * @param impostor imposter containing the physics body and babylon object
  58085. * @param newPosition new position
  58086. * @param newRotation new rotation
  58087. */
  58088. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58089. /**
  58090. * If this plugin is supported
  58091. * @returns true if its supported
  58092. */
  58093. isSupported(): boolean;
  58094. /**
  58095. * Sets the linear velocity of the physics body
  58096. * @param impostor imposter to set the velocity on
  58097. * @param velocity velocity to set
  58098. */
  58099. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58100. /**
  58101. * Sets the angular velocity of the physics body
  58102. * @param impostor imposter to set the velocity on
  58103. * @param velocity velocity to set
  58104. */
  58105. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58106. /**
  58107. * gets the linear velocity
  58108. * @param impostor imposter to get linear velocity from
  58109. * @returns linear velocity
  58110. */
  58111. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58112. /**
  58113. * gets the angular velocity
  58114. * @param impostor imposter to get angular velocity from
  58115. * @returns angular velocity
  58116. */
  58117. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58118. /**
  58119. * Sets the mass of physics body
  58120. * @param impostor imposter to set the mass on
  58121. * @param mass mass to set
  58122. */
  58123. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58124. /**
  58125. * Gets the mass of the physics body
  58126. * @param impostor imposter to get the mass from
  58127. * @returns mass
  58128. */
  58129. getBodyMass(impostor: PhysicsImpostor): number;
  58130. /**
  58131. * Gets friction of the impostor
  58132. * @param impostor impostor to get friction from
  58133. * @returns friction value
  58134. */
  58135. getBodyFriction(impostor: PhysicsImpostor): number;
  58136. /**
  58137. * Sets friction of the impostor
  58138. * @param impostor impostor to set friction on
  58139. * @param friction friction value
  58140. */
  58141. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58142. /**
  58143. * Gets restitution of the impostor
  58144. * @param impostor impostor to get restitution from
  58145. * @returns restitution value
  58146. */
  58147. getBodyRestitution(impostor: PhysicsImpostor): number;
  58148. /**
  58149. * Sets resitution of the impostor
  58150. * @param impostor impostor to set resitution on
  58151. * @param restitution resitution value
  58152. */
  58153. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58154. /**
  58155. * Gets pressure inside the impostor
  58156. * @param impostor impostor to get pressure from
  58157. * @returns pressure value
  58158. */
  58159. getBodyPressure(impostor: PhysicsImpostor): number;
  58160. /**
  58161. * Sets pressure inside a soft body impostor
  58162. * Cloth and rope must remain 0 pressure
  58163. * @param impostor impostor to set pressure on
  58164. * @param pressure pressure value
  58165. */
  58166. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58167. /**
  58168. * Gets stiffness of the impostor
  58169. * @param impostor impostor to get stiffness from
  58170. * @returns pressure value
  58171. */
  58172. getBodyStiffness(impostor: PhysicsImpostor): number;
  58173. /**
  58174. * Sets stiffness of the impostor
  58175. * @param impostor impostor to set stiffness on
  58176. * @param stiffness stiffness value from 0 to 1
  58177. */
  58178. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58179. /**
  58180. * Gets velocityIterations of the impostor
  58181. * @param impostor impostor to get velocity iterations from
  58182. * @returns velocityIterations value
  58183. */
  58184. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58185. /**
  58186. * Sets velocityIterations of the impostor
  58187. * @param impostor impostor to set velocity iterations on
  58188. * @param velocityIterations velocityIterations value
  58189. */
  58190. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58191. /**
  58192. * Gets positionIterations of the impostor
  58193. * @param impostor impostor to get position iterations from
  58194. * @returns positionIterations value
  58195. */
  58196. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58197. /**
  58198. * Sets positionIterations of the impostor
  58199. * @param impostor impostor to set position on
  58200. * @param positionIterations positionIterations value
  58201. */
  58202. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58203. /**
  58204. * Append an anchor to a cloth object
  58205. * @param impostor is the cloth impostor to add anchor to
  58206. * @param otherImpostor is the rigid impostor to anchor to
  58207. * @param width ratio across width from 0 to 1
  58208. * @param height ratio up height from 0 to 1
  58209. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58210. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58211. */
  58212. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58213. /**
  58214. * Append an hook to a rope object
  58215. * @param impostor is the rope impostor to add hook to
  58216. * @param otherImpostor is the rigid impostor to hook to
  58217. * @param length ratio along the rope from 0 to 1
  58218. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58219. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58220. */
  58221. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58222. /**
  58223. * Sleeps the physics body and stops it from being active
  58224. * @param impostor impostor to sleep
  58225. */
  58226. sleepBody(impostor: PhysicsImpostor): void;
  58227. /**
  58228. * Activates the physics body
  58229. * @param impostor impostor to activate
  58230. */
  58231. wakeUpBody(impostor: PhysicsImpostor): void;
  58232. /**
  58233. * Updates the distance parameters of the joint
  58234. * @param joint joint to update
  58235. * @param maxDistance maximum distance of the joint
  58236. * @param minDistance minimum distance of the joint
  58237. */
  58238. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58239. /**
  58240. * Sets a motor on the joint
  58241. * @param joint joint to set motor on
  58242. * @param speed speed of the motor
  58243. * @param maxForce maximum force of the motor
  58244. * @param motorIndex index of the motor
  58245. */
  58246. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58247. /**
  58248. * Sets the motors limit
  58249. * @param joint joint to set limit on
  58250. * @param upperLimit upper limit
  58251. * @param lowerLimit lower limit
  58252. */
  58253. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58254. /**
  58255. * Syncs the position and rotation of a mesh with the impostor
  58256. * @param mesh mesh to sync
  58257. * @param impostor impostor to update the mesh with
  58258. */
  58259. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58260. /**
  58261. * Gets the radius of the impostor
  58262. * @param impostor impostor to get radius from
  58263. * @returns the radius
  58264. */
  58265. getRadius(impostor: PhysicsImpostor): number;
  58266. /**
  58267. * Gets the box size of the impostor
  58268. * @param impostor impostor to get box size from
  58269. * @param result the resulting box size
  58270. */
  58271. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58272. /**
  58273. * Disposes of the impostor
  58274. */
  58275. dispose(): void;
  58276. /**
  58277. * Does a raycast in the physics world
  58278. * @param from when should the ray start?
  58279. * @param to when should the ray end?
  58280. * @returns PhysicsRaycastResult
  58281. */
  58282. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58283. }
  58284. }
  58285. declare module "babylonjs/Probes/reflectionProbe" {
  58286. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58287. import { Vector3 } from "babylonjs/Maths/math.vector";
  58288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58289. import { Nullable } from "babylonjs/types";
  58290. import { Scene } from "babylonjs/scene";
  58291. module "babylonjs/abstractScene" {
  58292. interface AbstractScene {
  58293. /**
  58294. * The list of reflection probes added to the scene
  58295. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58296. */
  58297. reflectionProbes: Array<ReflectionProbe>;
  58298. /**
  58299. * Removes the given reflection probe from this scene.
  58300. * @param toRemove The reflection probe to remove
  58301. * @returns The index of the removed reflection probe
  58302. */
  58303. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58304. /**
  58305. * Adds the given reflection probe to this scene.
  58306. * @param newReflectionProbe The reflection probe to add
  58307. */
  58308. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58309. }
  58310. }
  58311. /**
  58312. * Class used to generate realtime reflection / refraction cube textures
  58313. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58314. */
  58315. export class ReflectionProbe {
  58316. /** defines the name of the probe */
  58317. name: string;
  58318. private _scene;
  58319. private _renderTargetTexture;
  58320. private _projectionMatrix;
  58321. private _viewMatrix;
  58322. private _target;
  58323. private _add;
  58324. private _attachedMesh;
  58325. private _invertYAxis;
  58326. /** Gets or sets probe position (center of the cube map) */
  58327. position: Vector3;
  58328. /**
  58329. * Creates a new reflection probe
  58330. * @param name defines the name of the probe
  58331. * @param size defines the texture resolution (for each face)
  58332. * @param scene defines the hosting scene
  58333. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58334. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58335. */
  58336. constructor(
  58337. /** defines the name of the probe */
  58338. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58339. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58340. get samples(): number;
  58341. set samples(value: number);
  58342. /** Gets or sets the refresh rate to use (on every frame by default) */
  58343. get refreshRate(): number;
  58344. set refreshRate(value: number);
  58345. /**
  58346. * Gets the hosting scene
  58347. * @returns a Scene
  58348. */
  58349. getScene(): Scene;
  58350. /** Gets the internal CubeTexture used to render to */
  58351. get cubeTexture(): RenderTargetTexture;
  58352. /** Gets the list of meshes to render */
  58353. get renderList(): Nullable<AbstractMesh[]>;
  58354. /**
  58355. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58356. * @param mesh defines the mesh to attach to
  58357. */
  58358. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58359. /**
  58360. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58361. * @param renderingGroupId The rendering group id corresponding to its index
  58362. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58363. */
  58364. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58365. /**
  58366. * Clean all associated resources
  58367. */
  58368. dispose(): void;
  58369. /**
  58370. * Converts the reflection probe information to a readable string for debug purpose.
  58371. * @param fullDetails Supports for multiple levels of logging within scene loading
  58372. * @returns the human readable reflection probe info
  58373. */
  58374. toString(fullDetails?: boolean): string;
  58375. /**
  58376. * Get the class name of the relfection probe.
  58377. * @returns "ReflectionProbe"
  58378. */
  58379. getClassName(): string;
  58380. /**
  58381. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58382. * @returns The JSON representation of the texture
  58383. */
  58384. serialize(): any;
  58385. /**
  58386. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58387. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58388. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58389. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58390. * @returns The parsed reflection probe if successful
  58391. */
  58392. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58393. }
  58394. }
  58395. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58396. /** @hidden */
  58397. export var _BabylonLoaderRegistered: boolean;
  58398. /**
  58399. * Helps setting up some configuration for the babylon file loader.
  58400. */
  58401. export class BabylonFileLoaderConfiguration {
  58402. /**
  58403. * The loader does not allow injecting custom physix engine into the plugins.
  58404. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58405. * So you could set this variable to your engine import to make it work.
  58406. */
  58407. static LoaderInjectedPhysicsEngine: any;
  58408. }
  58409. }
  58410. declare module "babylonjs/Loading/Plugins/index" {
  58411. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58412. }
  58413. declare module "babylonjs/Loading/index" {
  58414. export * from "babylonjs/Loading/loadingScreen";
  58415. export * from "babylonjs/Loading/Plugins/index";
  58416. export * from "babylonjs/Loading/sceneLoader";
  58417. export * from "babylonjs/Loading/sceneLoaderFlags";
  58418. }
  58419. declare module "babylonjs/Materials/Background/index" {
  58420. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58421. }
  58422. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58423. import { Scene } from "babylonjs/scene";
  58424. import { Color3 } from "babylonjs/Maths/math.color";
  58425. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58427. /**
  58428. * The Physically based simple base material of BJS.
  58429. *
  58430. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58431. * It is used as the base class for both the specGloss and metalRough conventions.
  58432. */
  58433. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58434. /**
  58435. * Number of Simultaneous lights allowed on the material.
  58436. */
  58437. maxSimultaneousLights: number;
  58438. /**
  58439. * If sets to true, disables all the lights affecting the material.
  58440. */
  58441. disableLighting: boolean;
  58442. /**
  58443. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58444. */
  58445. environmentTexture: BaseTexture;
  58446. /**
  58447. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58448. */
  58449. invertNormalMapX: boolean;
  58450. /**
  58451. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58452. */
  58453. invertNormalMapY: boolean;
  58454. /**
  58455. * Normal map used in the model.
  58456. */
  58457. normalTexture: BaseTexture;
  58458. /**
  58459. * Emissivie color used to self-illuminate the model.
  58460. */
  58461. emissiveColor: Color3;
  58462. /**
  58463. * Emissivie texture used to self-illuminate the model.
  58464. */
  58465. emissiveTexture: BaseTexture;
  58466. /**
  58467. * Occlusion Channel Strenght.
  58468. */
  58469. occlusionStrength: number;
  58470. /**
  58471. * Occlusion Texture of the material (adding extra occlusion effects).
  58472. */
  58473. occlusionTexture: BaseTexture;
  58474. /**
  58475. * Defines the alpha limits in alpha test mode.
  58476. */
  58477. alphaCutOff: number;
  58478. /**
  58479. * Gets the current double sided mode.
  58480. */
  58481. get doubleSided(): boolean;
  58482. /**
  58483. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58484. */
  58485. set doubleSided(value: boolean);
  58486. /**
  58487. * Stores the pre-calculated light information of a mesh in a texture.
  58488. */
  58489. lightmapTexture: BaseTexture;
  58490. /**
  58491. * If true, the light map contains occlusion information instead of lighting info.
  58492. */
  58493. useLightmapAsShadowmap: boolean;
  58494. /**
  58495. * Instantiates a new PBRMaterial instance.
  58496. *
  58497. * @param name The material name
  58498. * @param scene The scene the material will be use in.
  58499. */
  58500. constructor(name: string, scene: Scene);
  58501. getClassName(): string;
  58502. }
  58503. }
  58504. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58505. import { Scene } from "babylonjs/scene";
  58506. import { Color3 } from "babylonjs/Maths/math.color";
  58507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58508. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58509. /**
  58510. * The PBR material of BJS following the metal roughness convention.
  58511. *
  58512. * This fits to the PBR convention in the GLTF definition:
  58513. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58514. */
  58515. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58516. /**
  58517. * The base color has two different interpretations depending on the value of metalness.
  58518. * When the material is a metal, the base color is the specific measured reflectance value
  58519. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58520. * of the material.
  58521. */
  58522. baseColor: Color3;
  58523. /**
  58524. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58525. * well as opacity information in the alpha channel.
  58526. */
  58527. baseTexture: BaseTexture;
  58528. /**
  58529. * Specifies the metallic scalar value of the material.
  58530. * Can also be used to scale the metalness values of the metallic texture.
  58531. */
  58532. metallic: number;
  58533. /**
  58534. * Specifies the roughness scalar value of the material.
  58535. * Can also be used to scale the roughness values of the metallic texture.
  58536. */
  58537. roughness: number;
  58538. /**
  58539. * Texture containing both the metallic value in the B channel and the
  58540. * roughness value in the G channel to keep better precision.
  58541. */
  58542. metallicRoughnessTexture: BaseTexture;
  58543. /**
  58544. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58545. *
  58546. * @param name The material name
  58547. * @param scene The scene the material will be use in.
  58548. */
  58549. constructor(name: string, scene: Scene);
  58550. /**
  58551. * Return the currrent class name of the material.
  58552. */
  58553. getClassName(): string;
  58554. /**
  58555. * Makes a duplicate of the current material.
  58556. * @param name - name to use for the new material.
  58557. */
  58558. clone(name: string): PBRMetallicRoughnessMaterial;
  58559. /**
  58560. * Serialize the material to a parsable JSON object.
  58561. */
  58562. serialize(): any;
  58563. /**
  58564. * Parses a JSON object correponding to the serialize function.
  58565. */
  58566. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58567. }
  58568. }
  58569. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58570. import { Scene } from "babylonjs/scene";
  58571. import { Color3 } from "babylonjs/Maths/math.color";
  58572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58573. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58574. /**
  58575. * The PBR material of BJS following the specular glossiness convention.
  58576. *
  58577. * This fits to the PBR convention in the GLTF definition:
  58578. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58579. */
  58580. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58581. /**
  58582. * Specifies the diffuse color of the material.
  58583. */
  58584. diffuseColor: Color3;
  58585. /**
  58586. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58587. * channel.
  58588. */
  58589. diffuseTexture: BaseTexture;
  58590. /**
  58591. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58592. */
  58593. specularColor: Color3;
  58594. /**
  58595. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58596. */
  58597. glossiness: number;
  58598. /**
  58599. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58600. */
  58601. specularGlossinessTexture: BaseTexture;
  58602. /**
  58603. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58604. *
  58605. * @param name The material name
  58606. * @param scene The scene the material will be use in.
  58607. */
  58608. constructor(name: string, scene: Scene);
  58609. /**
  58610. * Return the currrent class name of the material.
  58611. */
  58612. getClassName(): string;
  58613. /**
  58614. * Makes a duplicate of the current material.
  58615. * @param name - name to use for the new material.
  58616. */
  58617. clone(name: string): PBRSpecularGlossinessMaterial;
  58618. /**
  58619. * Serialize the material to a parsable JSON object.
  58620. */
  58621. serialize(): any;
  58622. /**
  58623. * Parses a JSON object correponding to the serialize function.
  58624. */
  58625. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58626. }
  58627. }
  58628. declare module "babylonjs/Materials/PBR/index" {
  58629. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58630. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58631. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58632. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58633. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58634. }
  58635. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58636. import { Nullable } from "babylonjs/types";
  58637. import { Scene } from "babylonjs/scene";
  58638. import { Matrix } from "babylonjs/Maths/math.vector";
  58639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58640. /**
  58641. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58642. * It can help converting any input color in a desired output one. This can then be used to create effects
  58643. * from sepia, black and white to sixties or futuristic rendering...
  58644. *
  58645. * The only supported format is currently 3dl.
  58646. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58647. */
  58648. export class ColorGradingTexture extends BaseTexture {
  58649. /**
  58650. * The current texture matrix. (will always be identity in color grading texture)
  58651. */
  58652. private _textureMatrix;
  58653. /**
  58654. * The texture URL.
  58655. */
  58656. url: string;
  58657. /**
  58658. * Empty line regex stored for GC.
  58659. */
  58660. private static _noneEmptyLineRegex;
  58661. private _engine;
  58662. /**
  58663. * Instantiates a ColorGradingTexture from the following parameters.
  58664. *
  58665. * @param url The location of the color gradind data (currently only supporting 3dl)
  58666. * @param scene The scene the texture will be used in
  58667. */
  58668. constructor(url: string, scene: Scene);
  58669. /**
  58670. * Returns the texture matrix used in most of the material.
  58671. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58672. */
  58673. getTextureMatrix(): Matrix;
  58674. /**
  58675. * Occurs when the file being loaded is a .3dl LUT file.
  58676. */
  58677. private load3dlTexture;
  58678. /**
  58679. * Starts the loading process of the texture.
  58680. */
  58681. private loadTexture;
  58682. /**
  58683. * Clones the color gradind texture.
  58684. */
  58685. clone(): ColorGradingTexture;
  58686. /**
  58687. * Called during delayed load for textures.
  58688. */
  58689. delayLoad(): void;
  58690. /**
  58691. * Parses a color grading texture serialized by Babylon.
  58692. * @param parsedTexture The texture information being parsedTexture
  58693. * @param scene The scene to load the texture in
  58694. * @param rootUrl The root url of the data assets to load
  58695. * @return A color gradind texture
  58696. */
  58697. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58698. /**
  58699. * Serializes the LUT texture to json format.
  58700. */
  58701. serialize(): any;
  58702. }
  58703. }
  58704. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58706. import { Scene } from "babylonjs/scene";
  58707. import { Nullable } from "babylonjs/types";
  58708. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58709. /**
  58710. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58711. */
  58712. export class EquiRectangularCubeTexture extends BaseTexture {
  58713. /** The six faces of the cube. */
  58714. private static _FacesMapping;
  58715. private _noMipmap;
  58716. private _onLoad;
  58717. private _onError;
  58718. /** The size of the cubemap. */
  58719. private _size;
  58720. /** The buffer of the image. */
  58721. private _buffer;
  58722. /** The width of the input image. */
  58723. private _width;
  58724. /** The height of the input image. */
  58725. private _height;
  58726. /** The URL to the image. */
  58727. url: string;
  58728. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58729. coordinatesMode: number;
  58730. /**
  58731. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58732. * @param url The location of the image
  58733. * @param scene The scene the texture will be used in
  58734. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58735. * @param noMipmap Forces to not generate the mipmap if true
  58736. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58737. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58738. * @param onLoad — defines a callback called when texture is loaded
  58739. * @param onError — defines a callback called if there is an error
  58740. */
  58741. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58742. /**
  58743. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58744. */
  58745. private loadImage;
  58746. /**
  58747. * Convert the image buffer into a cubemap and create a CubeTexture.
  58748. */
  58749. private loadTexture;
  58750. /**
  58751. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58752. * @param buffer The ArrayBuffer that should be converted.
  58753. * @returns The buffer as Float32Array.
  58754. */
  58755. private getFloat32ArrayFromArrayBuffer;
  58756. /**
  58757. * Get the current class name of the texture useful for serialization or dynamic coding.
  58758. * @returns "EquiRectangularCubeTexture"
  58759. */
  58760. getClassName(): string;
  58761. /**
  58762. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58763. * @returns A clone of the current EquiRectangularCubeTexture.
  58764. */
  58765. clone(): EquiRectangularCubeTexture;
  58766. }
  58767. }
  58768. declare module "babylonjs/Misc/tga" {
  58769. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58770. /**
  58771. * Based on jsTGALoader - Javascript loader for TGA file
  58772. * By Vincent Thibault
  58773. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58774. */
  58775. export class TGATools {
  58776. private static _TYPE_INDEXED;
  58777. private static _TYPE_RGB;
  58778. private static _TYPE_GREY;
  58779. private static _TYPE_RLE_INDEXED;
  58780. private static _TYPE_RLE_RGB;
  58781. private static _TYPE_RLE_GREY;
  58782. private static _ORIGIN_MASK;
  58783. private static _ORIGIN_SHIFT;
  58784. private static _ORIGIN_BL;
  58785. private static _ORIGIN_BR;
  58786. private static _ORIGIN_UL;
  58787. private static _ORIGIN_UR;
  58788. /**
  58789. * Gets the header of a TGA file
  58790. * @param data defines the TGA data
  58791. * @returns the header
  58792. */
  58793. static GetTGAHeader(data: Uint8Array): any;
  58794. /**
  58795. * Uploads TGA content to a Babylon Texture
  58796. * @hidden
  58797. */
  58798. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58799. /** @hidden */
  58800. 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;
  58801. /** @hidden */
  58802. 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;
  58803. /** @hidden */
  58804. 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;
  58805. /** @hidden */
  58806. 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;
  58807. /** @hidden */
  58808. 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;
  58809. /** @hidden */
  58810. 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;
  58811. }
  58812. }
  58813. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58814. import { Nullable } from "babylonjs/types";
  58815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58816. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58817. /**
  58818. * Implementation of the TGA Texture Loader.
  58819. * @hidden
  58820. */
  58821. export class _TGATextureLoader implements IInternalTextureLoader {
  58822. /**
  58823. * Defines wether the loader supports cascade loading the different faces.
  58824. */
  58825. readonly supportCascades: boolean;
  58826. /**
  58827. * This returns if the loader support the current file information.
  58828. * @param extension defines the file extension of the file being loaded
  58829. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58830. * @param fallback defines the fallback internal texture if any
  58831. * @param isBase64 defines whether the texture is encoded as a base64
  58832. * @param isBuffer defines whether the texture data are stored as a buffer
  58833. * @returns true if the loader can load the specified file
  58834. */
  58835. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58836. /**
  58837. * Transform the url before loading if required.
  58838. * @param rootUrl the url of the texture
  58839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58840. * @returns the transformed texture
  58841. */
  58842. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58843. /**
  58844. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58845. * @param rootUrl the url of the texture
  58846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58847. * @returns the fallback texture
  58848. */
  58849. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58850. /**
  58851. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58852. * @param data contains the texture data
  58853. * @param texture defines the BabylonJS internal texture
  58854. * @param createPolynomials will be true if polynomials have been requested
  58855. * @param onLoad defines the callback to trigger once the texture is ready
  58856. * @param onError defines the callback to trigger in case of error
  58857. */
  58858. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58859. /**
  58860. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58861. * @param data contains the texture data
  58862. * @param texture defines the BabylonJS internal texture
  58863. * @param callback defines the method to call once ready to upload
  58864. */
  58865. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58866. }
  58867. }
  58868. declare module "babylonjs/Misc/basis" {
  58869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58870. /**
  58871. * Info about the .basis files
  58872. */
  58873. class BasisFileInfo {
  58874. /**
  58875. * If the file has alpha
  58876. */
  58877. hasAlpha: boolean;
  58878. /**
  58879. * Info about each image of the basis file
  58880. */
  58881. images: Array<{
  58882. levels: Array<{
  58883. width: number;
  58884. height: number;
  58885. transcodedPixels: ArrayBufferView;
  58886. }>;
  58887. }>;
  58888. }
  58889. /**
  58890. * Result of transcoding a basis file
  58891. */
  58892. class TranscodeResult {
  58893. /**
  58894. * Info about the .basis file
  58895. */
  58896. fileInfo: BasisFileInfo;
  58897. /**
  58898. * Format to use when loading the file
  58899. */
  58900. format: number;
  58901. }
  58902. /**
  58903. * Configuration options for the Basis transcoder
  58904. */
  58905. export class BasisTranscodeConfiguration {
  58906. /**
  58907. * Supported compression formats used to determine the supported output format of the transcoder
  58908. */
  58909. supportedCompressionFormats?: {
  58910. /**
  58911. * etc1 compression format
  58912. */
  58913. etc1?: boolean;
  58914. /**
  58915. * s3tc compression format
  58916. */
  58917. s3tc?: boolean;
  58918. /**
  58919. * pvrtc compression format
  58920. */
  58921. pvrtc?: boolean;
  58922. /**
  58923. * etc2 compression format
  58924. */
  58925. etc2?: boolean;
  58926. };
  58927. /**
  58928. * If mipmap levels should be loaded for transcoded images (Default: true)
  58929. */
  58930. loadMipmapLevels?: boolean;
  58931. /**
  58932. * Index of a single image to load (Default: all images)
  58933. */
  58934. loadSingleImage?: number;
  58935. }
  58936. /**
  58937. * Used to load .Basis files
  58938. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58939. */
  58940. export class BasisTools {
  58941. private static _IgnoreSupportedFormats;
  58942. /**
  58943. * URL to use when loading the basis transcoder
  58944. */
  58945. static JSModuleURL: string;
  58946. /**
  58947. * URL to use when loading the wasm module for the transcoder
  58948. */
  58949. static WasmModuleURL: string;
  58950. /**
  58951. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58952. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58953. * @returns internal format corresponding to the Basis format
  58954. */
  58955. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58956. private static _WorkerPromise;
  58957. private static _Worker;
  58958. private static _actionId;
  58959. private static _CreateWorkerAsync;
  58960. /**
  58961. * Transcodes a loaded image file to compressed pixel data
  58962. * @param imageData image data to transcode
  58963. * @param config configuration options for the transcoding
  58964. * @returns a promise resulting in the transcoded image
  58965. */
  58966. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58967. /**
  58968. * Loads a texture from the transcode result
  58969. * @param texture texture load to
  58970. * @param transcodeResult the result of transcoding the basis file to load from
  58971. */
  58972. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58973. }
  58974. }
  58975. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58976. import { Nullable } from "babylonjs/types";
  58977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58978. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58979. /**
  58980. * Loader for .basis file format
  58981. */
  58982. export class _BasisTextureLoader implements IInternalTextureLoader {
  58983. /**
  58984. * Defines whether the loader supports cascade loading the different faces.
  58985. */
  58986. readonly supportCascades: boolean;
  58987. /**
  58988. * This returns if the loader support the current file information.
  58989. * @param extension defines the file extension of the file being loaded
  58990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58991. * @param fallback defines the fallback internal texture if any
  58992. * @param isBase64 defines whether the texture is encoded as a base64
  58993. * @param isBuffer defines whether the texture data are stored as a buffer
  58994. * @returns true if the loader can load the specified file
  58995. */
  58996. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58997. /**
  58998. * Transform the url before loading if required.
  58999. * @param rootUrl the url of the texture
  59000. * @param textureFormatInUse defines the current compressed format in use iun the engine
  59001. * @returns the transformed texture
  59002. */
  59003. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  59004. /**
  59005. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  59006. * @param rootUrl the url of the texture
  59007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  59008. * @returns the fallback texture
  59009. */
  59010. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  59011. /**
  59012. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  59013. * @param data contains the texture data
  59014. * @param texture defines the BabylonJS internal texture
  59015. * @param createPolynomials will be true if polynomials have been requested
  59016. * @param onLoad defines the callback to trigger once the texture is ready
  59017. * @param onError defines the callback to trigger in case of error
  59018. */
  59019. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59020. /**
  59021. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  59022. * @param data contains the texture data
  59023. * @param texture defines the BabylonJS internal texture
  59024. * @param callback defines the method to call once ready to upload
  59025. */
  59026. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59027. }
  59028. }
  59029. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59030. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59031. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59032. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59033. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59034. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59035. }
  59036. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59037. import { Scene } from "babylonjs/scene";
  59038. import { Texture } from "babylonjs/Materials/Textures/texture";
  59039. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59040. /**
  59041. * 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.
  59042. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59043. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59044. */
  59045. export class CustomProceduralTexture extends ProceduralTexture {
  59046. private _animate;
  59047. private _time;
  59048. private _config;
  59049. private _texturePath;
  59050. /**
  59051. * Instantiates a new Custom Procedural Texture.
  59052. * 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.
  59053. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59054. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59055. * @param name Define the name of the texture
  59056. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59057. * @param size Define the size of the texture to create
  59058. * @param scene Define the scene the texture belongs to
  59059. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59060. * @param generateMipMaps Define if the texture should creates mip maps or not
  59061. */
  59062. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59063. private _loadJson;
  59064. /**
  59065. * Is the texture ready to be used ? (rendered at least once)
  59066. * @returns true if ready, otherwise, false.
  59067. */
  59068. isReady(): boolean;
  59069. /**
  59070. * Render the texture to its associated render target.
  59071. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59072. */
  59073. render(useCameraPostProcess?: boolean): void;
  59074. /**
  59075. * Update the list of dependant textures samplers in the shader.
  59076. */
  59077. updateTextures(): void;
  59078. /**
  59079. * Update the uniform values of the procedural texture in the shader.
  59080. */
  59081. updateShaderUniforms(): void;
  59082. /**
  59083. * Define if the texture animates or not.
  59084. */
  59085. get animate(): boolean;
  59086. set animate(value: boolean);
  59087. }
  59088. }
  59089. declare module "babylonjs/Shaders/noise.fragment" {
  59090. /** @hidden */
  59091. export var noisePixelShader: {
  59092. name: string;
  59093. shader: string;
  59094. };
  59095. }
  59096. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59097. import { Nullable } from "babylonjs/types";
  59098. import { Scene } from "babylonjs/scene";
  59099. import { Texture } from "babylonjs/Materials/Textures/texture";
  59100. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59101. import "babylonjs/Shaders/noise.fragment";
  59102. /**
  59103. * Class used to generate noise procedural textures
  59104. */
  59105. export class NoiseProceduralTexture extends ProceduralTexture {
  59106. private _time;
  59107. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59108. brightness: number;
  59109. /** Defines the number of octaves to process */
  59110. octaves: number;
  59111. /** Defines the level of persistence (0.8 by default) */
  59112. persistence: number;
  59113. /** Gets or sets animation speed factor (default is 1) */
  59114. animationSpeedFactor: number;
  59115. /**
  59116. * Creates a new NoiseProceduralTexture
  59117. * @param name defines the name fo the texture
  59118. * @param size defines the size of the texture (default is 256)
  59119. * @param scene defines the hosting scene
  59120. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59121. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59122. */
  59123. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59124. private _updateShaderUniforms;
  59125. protected _getDefines(): string;
  59126. /** Generate the current state of the procedural texture */
  59127. render(useCameraPostProcess?: boolean): void;
  59128. /**
  59129. * Serializes this noise procedural texture
  59130. * @returns a serialized noise procedural texture object
  59131. */
  59132. serialize(): any;
  59133. /**
  59134. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59135. * @param parsedTexture defines parsed texture data
  59136. * @param scene defines the current scene
  59137. * @param rootUrl defines the root URL containing noise procedural texture information
  59138. * @returns a parsed NoiseProceduralTexture
  59139. */
  59140. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59141. }
  59142. }
  59143. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59144. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59145. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59146. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59147. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59148. }
  59149. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59150. import { Nullable } from "babylonjs/types";
  59151. import { Scene } from "babylonjs/scene";
  59152. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59154. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59155. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59156. /**
  59157. * Raw cube texture where the raw buffers are passed in
  59158. */
  59159. export class RawCubeTexture extends CubeTexture {
  59160. /**
  59161. * Creates a cube texture where the raw buffers are passed in.
  59162. * @param scene defines the scene the texture is attached to
  59163. * @param data defines the array of data to use to create each face
  59164. * @param size defines the size of the textures
  59165. * @param format defines the format of the data
  59166. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59167. * @param generateMipMaps defines if the engine should generate the mip levels
  59168. * @param invertY defines if data must be stored with Y axis inverted
  59169. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59170. * @param compression defines the compression used (null by default)
  59171. */
  59172. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59173. /**
  59174. * Updates the raw cube texture.
  59175. * @param data defines the data to store
  59176. * @param format defines the data format
  59177. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59178. * @param invertY defines if data must be stored with Y axis inverted
  59179. * @param compression defines the compression used (null by default)
  59180. * @param level defines which level of the texture to update
  59181. */
  59182. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59183. /**
  59184. * Updates a raw cube texture with RGBD encoded data.
  59185. * @param data defines the array of data [mipmap][face] to use to create each face
  59186. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59187. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59188. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59189. * @returns a promsie that resolves when the operation is complete
  59190. */
  59191. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59192. /**
  59193. * Clones the raw cube texture.
  59194. * @return a new cube texture
  59195. */
  59196. clone(): CubeTexture;
  59197. /** @hidden */
  59198. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59199. }
  59200. }
  59201. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59202. import { Scene } from "babylonjs/scene";
  59203. import { Texture } from "babylonjs/Materials/Textures/texture";
  59204. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59205. /**
  59206. * Class used to store 3D textures containing user data
  59207. */
  59208. export class RawTexture3D extends Texture {
  59209. /** Gets or sets the texture format to use */
  59210. format: number;
  59211. private _engine;
  59212. /**
  59213. * Create a new RawTexture3D
  59214. * @param data defines the data of the texture
  59215. * @param width defines the width of the texture
  59216. * @param height defines the height of the texture
  59217. * @param depth defines the depth of the texture
  59218. * @param format defines the texture format to use
  59219. * @param scene defines the hosting scene
  59220. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59221. * @param invertY defines if texture must be stored with Y axis inverted
  59222. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59223. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59224. */
  59225. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59226. /** Gets or sets the texture format to use */
  59227. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59228. /**
  59229. * Update the texture with new data
  59230. * @param data defines the data to store in the texture
  59231. */
  59232. update(data: ArrayBufferView): void;
  59233. }
  59234. }
  59235. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59236. import { Scene } from "babylonjs/scene";
  59237. import { Texture } from "babylonjs/Materials/Textures/texture";
  59238. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59239. /**
  59240. * Class used to store 2D array textures containing user data
  59241. */
  59242. export class RawTexture2DArray extends Texture {
  59243. /** Gets or sets the texture format to use */
  59244. format: number;
  59245. private _engine;
  59246. /**
  59247. * Create a new RawTexture2DArray
  59248. * @param data defines the data of the texture
  59249. * @param width defines the width of the texture
  59250. * @param height defines the height of the texture
  59251. * @param depth defines the number of layers of the texture
  59252. * @param format defines the texture format to use
  59253. * @param scene defines the hosting scene
  59254. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59255. * @param invertY defines if texture must be stored with Y axis inverted
  59256. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59257. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59258. */
  59259. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59260. /** Gets or sets the texture format to use */
  59261. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59262. /**
  59263. * Update the texture with new data
  59264. * @param data defines the data to store in the texture
  59265. */
  59266. update(data: ArrayBufferView): void;
  59267. }
  59268. }
  59269. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59270. import { Scene } from "babylonjs/scene";
  59271. import { Plane } from "babylonjs/Maths/math.plane";
  59272. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59273. /**
  59274. * Creates a refraction texture used by refraction channel of the standard material.
  59275. * It is like a mirror but to see through a material.
  59276. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59277. */
  59278. export class RefractionTexture extends RenderTargetTexture {
  59279. /**
  59280. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59281. * 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.
  59282. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59283. */
  59284. refractionPlane: Plane;
  59285. /**
  59286. * Define how deep under the surface we should see.
  59287. */
  59288. depth: number;
  59289. /**
  59290. * Creates a refraction texture used by refraction channel of the standard material.
  59291. * It is like a mirror but to see through a material.
  59292. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59293. * @param name Define the texture name
  59294. * @param size Define the size of the underlying texture
  59295. * @param scene Define the scene the refraction belongs to
  59296. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59297. */
  59298. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59299. /**
  59300. * Clone the refraction texture.
  59301. * @returns the cloned texture
  59302. */
  59303. clone(): RefractionTexture;
  59304. /**
  59305. * Serialize the texture to a JSON representation you could use in Parse later on
  59306. * @returns the serialized JSON representation
  59307. */
  59308. serialize(): any;
  59309. }
  59310. }
  59311. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59312. import { Nullable } from "babylonjs/types";
  59313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59314. import { Matrix } from "babylonjs/Maths/math.vector";
  59315. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59316. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59317. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59318. import { Scene } from "babylonjs/scene";
  59319. /**
  59320. * Defines the options related to the creation of an HtmlElementTexture
  59321. */
  59322. export interface IHtmlElementTextureOptions {
  59323. /**
  59324. * Defines wether mip maps should be created or not.
  59325. */
  59326. generateMipMaps?: boolean;
  59327. /**
  59328. * Defines the sampling mode of the texture.
  59329. */
  59330. samplingMode?: number;
  59331. /**
  59332. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59333. */
  59334. engine: Nullable<ThinEngine>;
  59335. /**
  59336. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59337. */
  59338. scene: Nullable<Scene>;
  59339. }
  59340. /**
  59341. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59342. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59343. * is automatically managed.
  59344. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59345. * in your application.
  59346. *
  59347. * As the update is not automatic, you need to call them manually.
  59348. */
  59349. export class HtmlElementTexture extends BaseTexture {
  59350. /**
  59351. * The texture URL.
  59352. */
  59353. element: HTMLVideoElement | HTMLCanvasElement;
  59354. private static readonly DefaultOptions;
  59355. private _textureMatrix;
  59356. private _engine;
  59357. private _isVideo;
  59358. private _generateMipMaps;
  59359. private _samplingMode;
  59360. /**
  59361. * Instantiates a HtmlElementTexture from the following parameters.
  59362. *
  59363. * @param name Defines the name of the texture
  59364. * @param element Defines the video or canvas the texture is filled with
  59365. * @param options Defines the other none mandatory texture creation options
  59366. */
  59367. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59368. private _createInternalTexture;
  59369. /**
  59370. * Returns the texture matrix used in most of the material.
  59371. */
  59372. getTextureMatrix(): Matrix;
  59373. /**
  59374. * Updates the content of the texture.
  59375. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59376. */
  59377. update(invertY?: Nullable<boolean>): void;
  59378. }
  59379. }
  59380. declare module "babylonjs/Materials/Textures/index" {
  59381. export * from "babylonjs/Materials/Textures/baseTexture";
  59382. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59383. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59384. export * from "babylonjs/Materials/Textures/cubeTexture";
  59385. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59386. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59387. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59388. export * from "babylonjs/Materials/Textures/internalTexture";
  59389. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59390. export * from "babylonjs/Materials/Textures/Loaders/index";
  59391. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59392. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59393. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59394. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59395. export * from "babylonjs/Materials/Textures/rawTexture";
  59396. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59397. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59398. export * from "babylonjs/Materials/Textures/refractionTexture";
  59399. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59400. export * from "babylonjs/Materials/Textures/texture";
  59401. export * from "babylonjs/Materials/Textures/videoTexture";
  59402. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59403. }
  59404. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59405. /**
  59406. * Enum used to define the target of a block
  59407. */
  59408. export enum NodeMaterialBlockTargets {
  59409. /** Vertex shader */
  59410. Vertex = 1,
  59411. /** Fragment shader */
  59412. Fragment = 2,
  59413. /** Neutral */
  59414. Neutral = 4,
  59415. /** Vertex and Fragment */
  59416. VertexAndFragment = 3
  59417. }
  59418. }
  59419. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59420. /**
  59421. * Defines the kind of connection point for node based material
  59422. */
  59423. export enum NodeMaterialBlockConnectionPointTypes {
  59424. /** Float */
  59425. Float = 1,
  59426. /** Int */
  59427. Int = 2,
  59428. /** Vector2 */
  59429. Vector2 = 4,
  59430. /** Vector3 */
  59431. Vector3 = 8,
  59432. /** Vector4 */
  59433. Vector4 = 16,
  59434. /** Color3 */
  59435. Color3 = 32,
  59436. /** Color4 */
  59437. Color4 = 64,
  59438. /** Matrix */
  59439. Matrix = 128,
  59440. /** Detect type based on connection */
  59441. AutoDetect = 1024,
  59442. /** Output type that will be defined by input type */
  59443. BasedOnInput = 2048
  59444. }
  59445. }
  59446. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59447. /**
  59448. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59449. */
  59450. export enum NodeMaterialBlockConnectionPointMode {
  59451. /** Value is an uniform */
  59452. Uniform = 0,
  59453. /** Value is a mesh attribute */
  59454. Attribute = 1,
  59455. /** Value is a varying between vertex and fragment shaders */
  59456. Varying = 2,
  59457. /** Mode is undefined */
  59458. Undefined = 3
  59459. }
  59460. }
  59461. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59462. /**
  59463. * Enum used to define system values e.g. values automatically provided by the system
  59464. */
  59465. export enum NodeMaterialSystemValues {
  59466. /** World */
  59467. World = 1,
  59468. /** View */
  59469. View = 2,
  59470. /** Projection */
  59471. Projection = 3,
  59472. /** ViewProjection */
  59473. ViewProjection = 4,
  59474. /** WorldView */
  59475. WorldView = 5,
  59476. /** WorldViewProjection */
  59477. WorldViewProjection = 6,
  59478. /** CameraPosition */
  59479. CameraPosition = 7,
  59480. /** Fog Color */
  59481. FogColor = 8,
  59482. /** Delta time */
  59483. DeltaTime = 9
  59484. }
  59485. }
  59486. declare module "babylonjs/Materials/Node/Enums/index" {
  59487. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59488. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59489. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59490. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59491. }
  59492. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59494. /**
  59495. * Root class for all node material optimizers
  59496. */
  59497. export class NodeMaterialOptimizer {
  59498. /**
  59499. * Function used to optimize a NodeMaterial graph
  59500. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59501. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59502. */
  59503. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59504. }
  59505. }
  59506. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59510. import { Scene } from "babylonjs/scene";
  59511. /**
  59512. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59513. */
  59514. export class TransformBlock extends NodeMaterialBlock {
  59515. /**
  59516. * Defines the value to use to complement W value to transform it to a Vector4
  59517. */
  59518. complementW: number;
  59519. /**
  59520. * Defines the value to use to complement z value to transform it to a Vector4
  59521. */
  59522. complementZ: number;
  59523. /**
  59524. * Creates a new TransformBlock
  59525. * @param name defines the block name
  59526. */
  59527. constructor(name: string);
  59528. /**
  59529. * Gets the current class name
  59530. * @returns the class name
  59531. */
  59532. getClassName(): string;
  59533. /**
  59534. * Gets the vector input
  59535. */
  59536. get vector(): NodeMaterialConnectionPoint;
  59537. /**
  59538. * Gets the output component
  59539. */
  59540. get output(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Gets the matrix transform input
  59543. */
  59544. get transform(): NodeMaterialConnectionPoint;
  59545. protected _buildBlock(state: NodeMaterialBuildState): this;
  59546. serialize(): any;
  59547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59548. protected _dumpPropertiesCode(): string;
  59549. }
  59550. }
  59551. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59555. /**
  59556. * Block used to output the vertex position
  59557. */
  59558. export class VertexOutputBlock extends NodeMaterialBlock {
  59559. /**
  59560. * Creates a new VertexOutputBlock
  59561. * @param name defines the block name
  59562. */
  59563. constructor(name: string);
  59564. /**
  59565. * Gets the current class name
  59566. * @returns the class name
  59567. */
  59568. getClassName(): string;
  59569. /**
  59570. * Gets the vector input component
  59571. */
  59572. get vector(): NodeMaterialConnectionPoint;
  59573. protected _buildBlock(state: NodeMaterialBuildState): this;
  59574. }
  59575. }
  59576. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59580. /**
  59581. * Block used to output the final color
  59582. */
  59583. export class FragmentOutputBlock extends NodeMaterialBlock {
  59584. /**
  59585. * Create a new FragmentOutputBlock
  59586. * @param name defines the block name
  59587. */
  59588. constructor(name: string);
  59589. /**
  59590. * Gets the current class name
  59591. * @returns the class name
  59592. */
  59593. getClassName(): string;
  59594. /**
  59595. * Gets the rgba input component
  59596. */
  59597. get rgba(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the rgb input component
  59600. */
  59601. get rgb(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the a input component
  59604. */
  59605. get a(): NodeMaterialConnectionPoint;
  59606. protected _buildBlock(state: NodeMaterialBuildState): this;
  59607. }
  59608. }
  59609. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59615. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59616. import { Effect } from "babylonjs/Materials/effect";
  59617. import { Mesh } from "babylonjs/Meshes/mesh";
  59618. import { Nullable } from "babylonjs/types";
  59619. import { Scene } from "babylonjs/scene";
  59620. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59621. /**
  59622. * Block used to read a reflection texture from a sampler
  59623. */
  59624. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59625. private _define3DName;
  59626. private _defineCubicName;
  59627. private _defineExplicitName;
  59628. private _defineProjectionName;
  59629. private _defineLocalCubicName;
  59630. private _defineSphericalName;
  59631. private _definePlanarName;
  59632. private _defineEquirectangularName;
  59633. private _defineMirroredEquirectangularFixedName;
  59634. private _defineEquirectangularFixedName;
  59635. private _defineSkyboxName;
  59636. private _cubeSamplerName;
  59637. private _2DSamplerName;
  59638. private _positionUVWName;
  59639. private _directionWName;
  59640. private _reflectionCoordsName;
  59641. private _reflection2DCoordsName;
  59642. private _reflectionColorName;
  59643. private _reflectionMatrixName;
  59644. /**
  59645. * Gets or sets the texture associated with the node
  59646. */
  59647. texture: Nullable<BaseTexture>;
  59648. /**
  59649. * Create a new TextureBlock
  59650. * @param name defines the block name
  59651. */
  59652. constructor(name: string);
  59653. /**
  59654. * Gets the current class name
  59655. * @returns the class name
  59656. */
  59657. getClassName(): string;
  59658. /**
  59659. * Gets the world position input component
  59660. */
  59661. get position(): NodeMaterialConnectionPoint;
  59662. /**
  59663. * Gets the world position input component
  59664. */
  59665. get worldPosition(): NodeMaterialConnectionPoint;
  59666. /**
  59667. * Gets the world normal input component
  59668. */
  59669. get worldNormal(): NodeMaterialConnectionPoint;
  59670. /**
  59671. * Gets the world input component
  59672. */
  59673. get world(): NodeMaterialConnectionPoint;
  59674. /**
  59675. * Gets the camera (or eye) position component
  59676. */
  59677. get cameraPosition(): NodeMaterialConnectionPoint;
  59678. /**
  59679. * Gets the view input component
  59680. */
  59681. get view(): NodeMaterialConnectionPoint;
  59682. /**
  59683. * Gets the rgb output component
  59684. */
  59685. get rgb(): NodeMaterialConnectionPoint;
  59686. /**
  59687. * Gets the r output component
  59688. */
  59689. get r(): NodeMaterialConnectionPoint;
  59690. /**
  59691. * Gets the g output component
  59692. */
  59693. get g(): NodeMaterialConnectionPoint;
  59694. /**
  59695. * Gets the b output component
  59696. */
  59697. get b(): NodeMaterialConnectionPoint;
  59698. autoConfigure(material: NodeMaterial): void;
  59699. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59700. isReady(): boolean;
  59701. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59702. private _injectVertexCode;
  59703. private _writeOutput;
  59704. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59705. protected _dumpPropertiesCode(): string;
  59706. serialize(): any;
  59707. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59708. }
  59709. }
  59710. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59712. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59713. import { Scene } from "babylonjs/scene";
  59714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59715. import { Matrix } from "babylonjs/Maths/math.vector";
  59716. import { Mesh } from "babylonjs/Meshes/mesh";
  59717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59718. import { Observable } from "babylonjs/Misc/observable";
  59719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59720. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59721. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59722. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59723. import { Nullable } from "babylonjs/types";
  59724. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59725. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59726. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59727. /**
  59728. * Interface used to configure the node material editor
  59729. */
  59730. export interface INodeMaterialEditorOptions {
  59731. /** Define the URl to load node editor script */
  59732. editorURL?: string;
  59733. }
  59734. /** @hidden */
  59735. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59736. /** BONES */
  59737. NUM_BONE_INFLUENCERS: number;
  59738. BonesPerMesh: number;
  59739. BONETEXTURE: boolean;
  59740. /** MORPH TARGETS */
  59741. MORPHTARGETS: boolean;
  59742. MORPHTARGETS_NORMAL: boolean;
  59743. MORPHTARGETS_TANGENT: boolean;
  59744. MORPHTARGETS_UV: boolean;
  59745. NUM_MORPH_INFLUENCERS: number;
  59746. /** IMAGE PROCESSING */
  59747. IMAGEPROCESSING: boolean;
  59748. VIGNETTE: boolean;
  59749. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59750. VIGNETTEBLENDMODEOPAQUE: boolean;
  59751. TONEMAPPING: boolean;
  59752. TONEMAPPING_ACES: boolean;
  59753. CONTRAST: boolean;
  59754. EXPOSURE: boolean;
  59755. COLORCURVES: boolean;
  59756. COLORGRADING: boolean;
  59757. COLORGRADING3D: boolean;
  59758. SAMPLER3DGREENDEPTH: boolean;
  59759. SAMPLER3DBGRMAP: boolean;
  59760. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59761. /** MISC. */
  59762. BUMPDIRECTUV: number;
  59763. constructor();
  59764. setValue(name: string, value: boolean): void;
  59765. }
  59766. /**
  59767. * Class used to configure NodeMaterial
  59768. */
  59769. export interface INodeMaterialOptions {
  59770. /**
  59771. * Defines if blocks should emit comments
  59772. */
  59773. emitComments: boolean;
  59774. }
  59775. /**
  59776. * Class used to create a node based material built by assembling shader blocks
  59777. */
  59778. export class NodeMaterial extends PushMaterial {
  59779. private static _BuildIdGenerator;
  59780. private _options;
  59781. private _vertexCompilationState;
  59782. private _fragmentCompilationState;
  59783. private _sharedData;
  59784. private _buildId;
  59785. private _buildWasSuccessful;
  59786. private _cachedWorldViewMatrix;
  59787. private _cachedWorldViewProjectionMatrix;
  59788. private _optimizers;
  59789. private _animationFrame;
  59790. /** Define the URl to load node editor script */
  59791. static EditorURL: string;
  59792. private BJSNODEMATERIALEDITOR;
  59793. /** Get the inspector from bundle or global */
  59794. private _getGlobalNodeMaterialEditor;
  59795. /**
  59796. * Gets or sets data used by visual editor
  59797. * @see https://nme.babylonjs.com
  59798. */
  59799. editorData: any;
  59800. /**
  59801. * 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)
  59802. */
  59803. ignoreAlpha: boolean;
  59804. /**
  59805. * Defines the maximum number of lights that can be used in the material
  59806. */
  59807. maxSimultaneousLights: number;
  59808. /**
  59809. * Observable raised when the material is built
  59810. */
  59811. onBuildObservable: Observable<NodeMaterial>;
  59812. /**
  59813. * Gets or sets the root nodes of the material vertex shader
  59814. */
  59815. _vertexOutputNodes: NodeMaterialBlock[];
  59816. /**
  59817. * Gets or sets the root nodes of the material fragment (pixel) shader
  59818. */
  59819. _fragmentOutputNodes: NodeMaterialBlock[];
  59820. /** Gets or sets options to control the node material overall behavior */
  59821. get options(): INodeMaterialOptions;
  59822. set options(options: INodeMaterialOptions);
  59823. /**
  59824. * Default configuration related to image processing available in the standard Material.
  59825. */
  59826. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59827. /**
  59828. * Gets the image processing configuration used either in this material.
  59829. */
  59830. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59831. /**
  59832. * Sets the Default image processing configuration used either in the this material.
  59833. *
  59834. * If sets to null, the scene one is in use.
  59835. */
  59836. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59837. /**
  59838. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59839. */
  59840. attachedBlocks: NodeMaterialBlock[];
  59841. /**
  59842. * Create a new node based material
  59843. * @param name defines the material name
  59844. * @param scene defines the hosting scene
  59845. * @param options defines creation option
  59846. */
  59847. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59848. /**
  59849. * Gets the current class name of the material e.g. "NodeMaterial"
  59850. * @returns the class name
  59851. */
  59852. getClassName(): string;
  59853. /**
  59854. * Keep track of the image processing observer to allow dispose and replace.
  59855. */
  59856. private _imageProcessingObserver;
  59857. /**
  59858. * Attaches a new image processing configuration to the Standard Material.
  59859. * @param configuration
  59860. */
  59861. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59862. /**
  59863. * Get a block by its name
  59864. * @param name defines the name of the block to retrieve
  59865. * @returns the required block or null if not found
  59866. */
  59867. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59868. /**
  59869. * Get a block by its name
  59870. * @param predicate defines the predicate used to find the good candidate
  59871. * @returns the required block or null if not found
  59872. */
  59873. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59874. /**
  59875. * Get an input block by its name
  59876. * @param predicate defines the predicate used to find the good candidate
  59877. * @returns the required input block or null if not found
  59878. */
  59879. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59880. /**
  59881. * Gets the list of input blocks attached to this material
  59882. * @returns an array of InputBlocks
  59883. */
  59884. getInputBlocks(): InputBlock[];
  59885. /**
  59886. * Adds a new optimizer to the list of optimizers
  59887. * @param optimizer defines the optimizers to add
  59888. * @returns the current material
  59889. */
  59890. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59891. /**
  59892. * Remove an optimizer from the list of optimizers
  59893. * @param optimizer defines the optimizers to remove
  59894. * @returns the current material
  59895. */
  59896. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59897. /**
  59898. * Add a new block to the list of output nodes
  59899. * @param node defines the node to add
  59900. * @returns the current material
  59901. */
  59902. addOutputNode(node: NodeMaterialBlock): this;
  59903. /**
  59904. * Remove a block from the list of root nodes
  59905. * @param node defines the node to remove
  59906. * @returns the current material
  59907. */
  59908. removeOutputNode(node: NodeMaterialBlock): this;
  59909. private _addVertexOutputNode;
  59910. private _removeVertexOutputNode;
  59911. private _addFragmentOutputNode;
  59912. private _removeFragmentOutputNode;
  59913. /**
  59914. * Specifies if the material will require alpha blending
  59915. * @returns a boolean specifying if alpha blending is needed
  59916. */
  59917. needAlphaBlending(): boolean;
  59918. /**
  59919. * Specifies if this material should be rendered in alpha test mode
  59920. * @returns a boolean specifying if an alpha test is needed.
  59921. */
  59922. needAlphaTesting(): boolean;
  59923. private _initializeBlock;
  59924. private _resetDualBlocks;
  59925. /**
  59926. * Remove a block from the current node material
  59927. * @param block defines the block to remove
  59928. */
  59929. removeBlock(block: NodeMaterialBlock): void;
  59930. /**
  59931. * Build the material and generates the inner effect
  59932. * @param verbose defines if the build should log activity
  59933. */
  59934. build(verbose?: boolean): void;
  59935. /**
  59936. * Runs an otpimization phase to try to improve the shader code
  59937. */
  59938. optimize(): void;
  59939. private _prepareDefinesForAttributes;
  59940. /**
  59941. * Get if the submesh is ready to be used and all its information available.
  59942. * Child classes can use it to update shaders
  59943. * @param mesh defines the mesh to check
  59944. * @param subMesh defines which submesh to check
  59945. * @param useInstances specifies that instances should be used
  59946. * @returns a boolean indicating that the submesh is ready or not
  59947. */
  59948. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59949. /**
  59950. * Get a string representing the shaders built by the current node graph
  59951. */
  59952. get compiledShaders(): string;
  59953. /**
  59954. * Binds the world matrix to the material
  59955. * @param world defines the world transformation matrix
  59956. */
  59957. bindOnlyWorldMatrix(world: Matrix): void;
  59958. /**
  59959. * Binds the submesh to this material by preparing the effect and shader to draw
  59960. * @param world defines the world transformation matrix
  59961. * @param mesh defines the mesh containing the submesh
  59962. * @param subMesh defines the submesh to bind the material to
  59963. */
  59964. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59965. /**
  59966. * Gets the active textures from the material
  59967. * @returns an array of textures
  59968. */
  59969. getActiveTextures(): BaseTexture[];
  59970. /**
  59971. * Gets the list of texture blocks
  59972. * @returns an array of texture blocks
  59973. */
  59974. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59975. /**
  59976. * Specifies if the material uses a texture
  59977. * @param texture defines the texture to check against the material
  59978. * @returns a boolean specifying if the material uses the texture
  59979. */
  59980. hasTexture(texture: BaseTexture): boolean;
  59981. /**
  59982. * Disposes the material
  59983. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59984. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59985. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59986. */
  59987. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59988. /** Creates the node editor window. */
  59989. private _createNodeEditor;
  59990. /**
  59991. * Launch the node material editor
  59992. * @param config Define the configuration of the editor
  59993. * @return a promise fulfilled when the node editor is visible
  59994. */
  59995. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59996. /**
  59997. * Clear the current material
  59998. */
  59999. clear(): void;
  60000. /**
  60001. * Clear the current material and set it to a default state
  60002. */
  60003. setToDefault(): void;
  60004. /**
  60005. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60006. * @param url defines the url to load from
  60007. * @returns a promise that will fullfil when the material is fully loaded
  60008. */
  60009. loadAsync(url: string): Promise<void>;
  60010. private _gatherBlocks;
  60011. /**
  60012. * Generate a string containing the code declaration required to create an equivalent of this material
  60013. * @returns a string
  60014. */
  60015. generateCode(): string;
  60016. /**
  60017. * Serializes this material in a JSON representation
  60018. * @returns the serialized material object
  60019. */
  60020. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60021. private _restoreConnections;
  60022. /**
  60023. * Clear the current graph and load a new one from a serialization object
  60024. * @param source defines the JSON representation of the material
  60025. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60026. */
  60027. loadFromSerialization(source: any, rootUrl?: string): void;
  60028. /**
  60029. * Creates a node material from parsed material data
  60030. * @param source defines the JSON representation of the material
  60031. * @param scene defines the hosting scene
  60032. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60033. * @returns a new node material
  60034. */
  60035. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60036. /**
  60037. * Creates a new node material set to default basic configuration
  60038. * @param name defines the name of the material
  60039. * @param scene defines the hosting scene
  60040. * @returns a new NodeMaterial
  60041. */
  60042. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60043. }
  60044. }
  60045. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60048. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60051. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60052. import { Effect } from "babylonjs/Materials/effect";
  60053. import { Mesh } from "babylonjs/Meshes/mesh";
  60054. import { Nullable } from "babylonjs/types";
  60055. import { Texture } from "babylonjs/Materials/Textures/texture";
  60056. import { Scene } from "babylonjs/scene";
  60057. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60058. /**
  60059. * Block used to read a texture from a sampler
  60060. */
  60061. export class TextureBlock extends NodeMaterialBlock {
  60062. private _defineName;
  60063. private _linearDefineName;
  60064. private _tempTextureRead;
  60065. private _samplerName;
  60066. private _transformedUVName;
  60067. private _textureTransformName;
  60068. private _textureInfoName;
  60069. private _mainUVName;
  60070. private _mainUVDefineName;
  60071. /**
  60072. * Gets or sets the texture associated with the node
  60073. */
  60074. texture: Nullable<Texture>;
  60075. /**
  60076. * Create a new TextureBlock
  60077. * @param name defines the block name
  60078. */
  60079. constructor(name: string);
  60080. /**
  60081. * Gets the current class name
  60082. * @returns the class name
  60083. */
  60084. getClassName(): string;
  60085. /**
  60086. * Gets the uv input component
  60087. */
  60088. get uv(): NodeMaterialConnectionPoint;
  60089. /**
  60090. * Gets the rgba output component
  60091. */
  60092. get rgba(): NodeMaterialConnectionPoint;
  60093. /**
  60094. * Gets the rgb output component
  60095. */
  60096. get rgb(): NodeMaterialConnectionPoint;
  60097. /**
  60098. * Gets the r output component
  60099. */
  60100. get r(): NodeMaterialConnectionPoint;
  60101. /**
  60102. * Gets the g output component
  60103. */
  60104. get g(): NodeMaterialConnectionPoint;
  60105. /**
  60106. * Gets the b output component
  60107. */
  60108. get b(): NodeMaterialConnectionPoint;
  60109. /**
  60110. * Gets the a output component
  60111. */
  60112. get a(): NodeMaterialConnectionPoint;
  60113. get target(): NodeMaterialBlockTargets;
  60114. autoConfigure(material: NodeMaterial): void;
  60115. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60117. private _getTextureBase;
  60118. isReady(): boolean;
  60119. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60120. private get _isMixed();
  60121. private _injectVertexCode;
  60122. private _writeTextureRead;
  60123. private _writeOutput;
  60124. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60125. protected _dumpPropertiesCode(): string;
  60126. serialize(): any;
  60127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60128. }
  60129. }
  60130. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60133. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60134. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60135. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60136. import { Scene } from "babylonjs/scene";
  60137. /**
  60138. * Class used to store shared data between 2 NodeMaterialBuildState
  60139. */
  60140. export class NodeMaterialBuildStateSharedData {
  60141. /**
  60142. * Gets the list of emitted varyings
  60143. */
  60144. temps: string[];
  60145. /**
  60146. * Gets the list of emitted varyings
  60147. */
  60148. varyings: string[];
  60149. /**
  60150. * Gets the varying declaration string
  60151. */
  60152. varyingDeclaration: string;
  60153. /**
  60154. * Input blocks
  60155. */
  60156. inputBlocks: InputBlock[];
  60157. /**
  60158. * Input blocks
  60159. */
  60160. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60161. /**
  60162. * Bindable blocks (Blocks that need to set data to the effect)
  60163. */
  60164. bindableBlocks: NodeMaterialBlock[];
  60165. /**
  60166. * List of blocks that can provide a compilation fallback
  60167. */
  60168. blocksWithFallbacks: NodeMaterialBlock[];
  60169. /**
  60170. * List of blocks that can provide a define update
  60171. */
  60172. blocksWithDefines: NodeMaterialBlock[];
  60173. /**
  60174. * List of blocks that can provide a repeatable content
  60175. */
  60176. repeatableContentBlocks: NodeMaterialBlock[];
  60177. /**
  60178. * List of blocks that can provide a dynamic list of uniforms
  60179. */
  60180. dynamicUniformBlocks: NodeMaterialBlock[];
  60181. /**
  60182. * List of blocks that can block the isReady function for the material
  60183. */
  60184. blockingBlocks: NodeMaterialBlock[];
  60185. /**
  60186. * Gets the list of animated inputs
  60187. */
  60188. animatedInputs: InputBlock[];
  60189. /**
  60190. * Build Id used to avoid multiple recompilations
  60191. */
  60192. buildId: number;
  60193. /** List of emitted variables */
  60194. variableNames: {
  60195. [key: string]: number;
  60196. };
  60197. /** List of emitted defines */
  60198. defineNames: {
  60199. [key: string]: number;
  60200. };
  60201. /** Should emit comments? */
  60202. emitComments: boolean;
  60203. /** Emit build activity */
  60204. verbose: boolean;
  60205. /** Gets or sets the hosting scene */
  60206. scene: Scene;
  60207. /**
  60208. * Gets the compilation hints emitted at compilation time
  60209. */
  60210. hints: {
  60211. needWorldViewMatrix: boolean;
  60212. needWorldViewProjectionMatrix: boolean;
  60213. needAlphaBlending: boolean;
  60214. needAlphaTesting: boolean;
  60215. };
  60216. /**
  60217. * List of compilation checks
  60218. */
  60219. checks: {
  60220. emitVertex: boolean;
  60221. emitFragment: boolean;
  60222. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60223. };
  60224. /** Creates a new shared data */
  60225. constructor();
  60226. /**
  60227. * Emits console errors and exceptions if there is a failing check
  60228. */
  60229. emitErrors(): void;
  60230. }
  60231. }
  60232. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60233. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60234. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60235. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60236. /**
  60237. * Class used to store node based material build state
  60238. */
  60239. export class NodeMaterialBuildState {
  60240. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60241. supportUniformBuffers: boolean;
  60242. /**
  60243. * Gets the list of emitted attributes
  60244. */
  60245. attributes: string[];
  60246. /**
  60247. * Gets the list of emitted uniforms
  60248. */
  60249. uniforms: string[];
  60250. /**
  60251. * Gets the list of emitted constants
  60252. */
  60253. constants: string[];
  60254. /**
  60255. * Gets the list of emitted samplers
  60256. */
  60257. samplers: string[];
  60258. /**
  60259. * Gets the list of emitted functions
  60260. */
  60261. functions: {
  60262. [key: string]: string;
  60263. };
  60264. /**
  60265. * Gets the list of emitted extensions
  60266. */
  60267. extensions: {
  60268. [key: string]: string;
  60269. };
  60270. /**
  60271. * Gets the target of the compilation state
  60272. */
  60273. target: NodeMaterialBlockTargets;
  60274. /**
  60275. * Gets the list of emitted counters
  60276. */
  60277. counters: {
  60278. [key: string]: number;
  60279. };
  60280. /**
  60281. * Shared data between multiple NodeMaterialBuildState instances
  60282. */
  60283. sharedData: NodeMaterialBuildStateSharedData;
  60284. /** @hidden */
  60285. _vertexState: NodeMaterialBuildState;
  60286. /** @hidden */
  60287. _attributeDeclaration: string;
  60288. /** @hidden */
  60289. _uniformDeclaration: string;
  60290. /** @hidden */
  60291. _constantDeclaration: string;
  60292. /** @hidden */
  60293. _samplerDeclaration: string;
  60294. /** @hidden */
  60295. _varyingTransfer: string;
  60296. private _repeatableContentAnchorIndex;
  60297. /** @hidden */
  60298. _builtCompilationString: string;
  60299. /**
  60300. * Gets the emitted compilation strings
  60301. */
  60302. compilationString: string;
  60303. /**
  60304. * Finalize the compilation strings
  60305. * @param state defines the current compilation state
  60306. */
  60307. finalize(state: NodeMaterialBuildState): void;
  60308. /** @hidden */
  60309. get _repeatableContentAnchor(): string;
  60310. /** @hidden */
  60311. _getFreeVariableName(prefix: string): string;
  60312. /** @hidden */
  60313. _getFreeDefineName(prefix: string): string;
  60314. /** @hidden */
  60315. _excludeVariableName(name: string): void;
  60316. /** @hidden */
  60317. _emit2DSampler(name: string): void;
  60318. /** @hidden */
  60319. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60320. /** @hidden */
  60321. _emitExtension(name: string, extension: string): void;
  60322. /** @hidden */
  60323. _emitFunction(name: string, code: string, comments: string): void;
  60324. /** @hidden */
  60325. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60326. replaceStrings?: {
  60327. search: RegExp;
  60328. replace: string;
  60329. }[];
  60330. repeatKey?: string;
  60331. }): string;
  60332. /** @hidden */
  60333. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60334. repeatKey?: string;
  60335. removeAttributes?: boolean;
  60336. removeUniforms?: boolean;
  60337. removeVaryings?: boolean;
  60338. removeIfDef?: boolean;
  60339. replaceStrings?: {
  60340. search: RegExp;
  60341. replace: string;
  60342. }[];
  60343. }, storeKey?: string): void;
  60344. /** @hidden */
  60345. _registerTempVariable(name: string): boolean;
  60346. /** @hidden */
  60347. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60348. /** @hidden */
  60349. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60350. /** @hidden */
  60351. _emitFloat(value: number): string;
  60352. }
  60353. }
  60354. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60355. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60357. import { Nullable } from "babylonjs/types";
  60358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60359. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60360. import { Effect } from "babylonjs/Materials/effect";
  60361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60362. import { Mesh } from "babylonjs/Meshes/mesh";
  60363. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60364. import { Scene } from "babylonjs/scene";
  60365. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60366. /**
  60367. * Defines a block that can be used inside a node based material
  60368. */
  60369. export class NodeMaterialBlock {
  60370. private _buildId;
  60371. private _buildTarget;
  60372. private _target;
  60373. private _isFinalMerger;
  60374. private _isInput;
  60375. protected _isUnique: boolean;
  60376. /** @hidden */
  60377. _codeVariableName: string;
  60378. /** @hidden */
  60379. _inputs: NodeMaterialConnectionPoint[];
  60380. /** @hidden */
  60381. _outputs: NodeMaterialConnectionPoint[];
  60382. /** @hidden */
  60383. _preparationId: number;
  60384. /**
  60385. * Gets or sets the name of the block
  60386. */
  60387. name: string;
  60388. /**
  60389. * Gets or sets the unique id of the node
  60390. */
  60391. uniqueId: number;
  60392. /**
  60393. * Gets or sets the comments associated with this block
  60394. */
  60395. comments: string;
  60396. /**
  60397. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60398. */
  60399. get isUnique(): boolean;
  60400. /**
  60401. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60402. */
  60403. get isFinalMerger(): boolean;
  60404. /**
  60405. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60406. */
  60407. get isInput(): boolean;
  60408. /**
  60409. * Gets or sets the build Id
  60410. */
  60411. get buildId(): number;
  60412. set buildId(value: number);
  60413. /**
  60414. * Gets or sets the target of the block
  60415. */
  60416. get target(): NodeMaterialBlockTargets;
  60417. set target(value: NodeMaterialBlockTargets);
  60418. /**
  60419. * Gets the list of input points
  60420. */
  60421. get inputs(): NodeMaterialConnectionPoint[];
  60422. /** Gets the list of output points */
  60423. get outputs(): NodeMaterialConnectionPoint[];
  60424. /**
  60425. * Find an input by its name
  60426. * @param name defines the name of the input to look for
  60427. * @returns the input or null if not found
  60428. */
  60429. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60430. /**
  60431. * Find an output by its name
  60432. * @param name defines the name of the outputto look for
  60433. * @returns the output or null if not found
  60434. */
  60435. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60436. /**
  60437. * Creates a new NodeMaterialBlock
  60438. * @param name defines the block name
  60439. * @param target defines the target of that block (Vertex by default)
  60440. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60441. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60442. */
  60443. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60444. /**
  60445. * Initialize the block and prepare the context for build
  60446. * @param state defines the state that will be used for the build
  60447. */
  60448. initialize(state: NodeMaterialBuildState): void;
  60449. /**
  60450. * Bind data to effect. Will only be called for blocks with isBindable === true
  60451. * @param effect defines the effect to bind data to
  60452. * @param nodeMaterial defines the hosting NodeMaterial
  60453. * @param mesh defines the mesh that will be rendered
  60454. */
  60455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60456. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60457. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60458. protected _writeFloat(value: number): string;
  60459. /**
  60460. * Gets the current class name e.g. "NodeMaterialBlock"
  60461. * @returns the class name
  60462. */
  60463. getClassName(): string;
  60464. /**
  60465. * Register a new input. Must be called inside a block constructor
  60466. * @param name defines the connection point name
  60467. * @param type defines the connection point type
  60468. * @param isOptional defines a boolean indicating that this input can be omitted
  60469. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60470. * @returns the current block
  60471. */
  60472. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60473. /**
  60474. * Register a new output. Must be called inside a block constructor
  60475. * @param name defines the connection point name
  60476. * @param type defines the connection point type
  60477. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60478. * @returns the current block
  60479. */
  60480. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60481. /**
  60482. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60483. * @param forOutput defines an optional connection point to check compatibility with
  60484. * @returns the first available input or null
  60485. */
  60486. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60487. /**
  60488. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60489. * @param forBlock defines an optional block to check compatibility with
  60490. * @returns the first available input or null
  60491. */
  60492. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60493. /**
  60494. * Gets the sibling of the given output
  60495. * @param current defines the current output
  60496. * @returns the next output in the list or null
  60497. */
  60498. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60499. /**
  60500. * Connect current block with another block
  60501. * @param other defines the block to connect with
  60502. * @param options define the various options to help pick the right connections
  60503. * @returns the current block
  60504. */
  60505. connectTo(other: NodeMaterialBlock, options?: {
  60506. input?: string;
  60507. output?: string;
  60508. outputSwizzle?: string;
  60509. }): this | undefined;
  60510. protected _buildBlock(state: NodeMaterialBuildState): void;
  60511. /**
  60512. * Add uniforms, samplers and uniform buffers at compilation time
  60513. * @param state defines the state to update
  60514. * @param nodeMaterial defines the node material requesting the update
  60515. * @param defines defines the material defines to update
  60516. * @param uniformBuffers defines the list of uniform buffer names
  60517. */
  60518. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60519. /**
  60520. * Add potential fallbacks if shader compilation fails
  60521. * @param mesh defines the mesh to be rendered
  60522. * @param fallbacks defines the current prioritized list of fallbacks
  60523. */
  60524. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60525. /**
  60526. * Initialize defines for shader compilation
  60527. * @param mesh defines the mesh to be rendered
  60528. * @param nodeMaterial defines the node material requesting the update
  60529. * @param defines defines the material defines to update
  60530. * @param useInstances specifies that instances should be used
  60531. */
  60532. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60533. /**
  60534. * Update defines for shader compilation
  60535. * @param mesh defines the mesh to be rendered
  60536. * @param nodeMaterial defines the node material requesting the update
  60537. * @param defines defines the material defines to update
  60538. * @param useInstances specifies that instances should be used
  60539. */
  60540. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60541. /**
  60542. * Lets the block try to connect some inputs automatically
  60543. * @param material defines the hosting NodeMaterial
  60544. */
  60545. autoConfigure(material: NodeMaterial): void;
  60546. /**
  60547. * Function called when a block is declared as repeatable content generator
  60548. * @param vertexShaderState defines the current compilation state for the vertex shader
  60549. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60550. * @param mesh defines the mesh to be rendered
  60551. * @param defines defines the material defines to update
  60552. */
  60553. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60554. /**
  60555. * Checks if the block is ready
  60556. * @param mesh defines the mesh to be rendered
  60557. * @param nodeMaterial defines the node material requesting the update
  60558. * @param defines defines the material defines to update
  60559. * @param useInstances specifies that instances should be used
  60560. * @returns true if the block is ready
  60561. */
  60562. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60563. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60564. private _processBuild;
  60565. /**
  60566. * Compile the current node and generate the shader code
  60567. * @param state defines the current compilation state (uniforms, samplers, current string)
  60568. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60569. * @returns true if already built
  60570. */
  60571. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60572. protected _inputRename(name: string): string;
  60573. protected _outputRename(name: string): string;
  60574. protected _dumpPropertiesCode(): string;
  60575. /** @hidden */
  60576. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60577. /** @hidden */
  60578. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60579. /**
  60580. * Clone the current block to a new identical block
  60581. * @param scene defines the hosting scene
  60582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60583. * @returns a copy of the current block
  60584. */
  60585. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60586. /**
  60587. * Serializes this block in a JSON representation
  60588. * @returns the serialized block object
  60589. */
  60590. serialize(): any;
  60591. /** @hidden */
  60592. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60593. /**
  60594. * Release resources
  60595. */
  60596. dispose(): void;
  60597. }
  60598. }
  60599. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60600. /**
  60601. * Enum defining the type of animations supported by InputBlock
  60602. */
  60603. export enum AnimatedInputBlockTypes {
  60604. /** No animation */
  60605. None = 0,
  60606. /** Time based animation. Will only work for floats */
  60607. Time = 1
  60608. }
  60609. }
  60610. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60612. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60613. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60614. import { Nullable } from "babylonjs/types";
  60615. import { Effect } from "babylonjs/Materials/effect";
  60616. import { Matrix } from "babylonjs/Maths/math.vector";
  60617. import { Scene } from "babylonjs/scene";
  60618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60620. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60621. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60622. /**
  60623. * Block used to expose an input value
  60624. */
  60625. export class InputBlock extends NodeMaterialBlock {
  60626. private _mode;
  60627. private _associatedVariableName;
  60628. private _storedValue;
  60629. private _valueCallback;
  60630. private _type;
  60631. private _animationType;
  60632. /** Gets or set a value used to limit the range of float values */
  60633. min: number;
  60634. /** Gets or set a value used to limit the range of float values */
  60635. max: number;
  60636. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60637. matrixMode: number;
  60638. /** @hidden */
  60639. _systemValue: Nullable<NodeMaterialSystemValues>;
  60640. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60641. visibleInInspector: boolean;
  60642. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60643. isConstant: boolean;
  60644. /** Gets or sets the group to use to display this block in the Inspector */
  60645. groupInInspector: string;
  60646. /**
  60647. * Gets or sets the connection point type (default is float)
  60648. */
  60649. get type(): NodeMaterialBlockConnectionPointTypes;
  60650. /**
  60651. * Creates a new InputBlock
  60652. * @param name defines the block name
  60653. * @param target defines the target of that block (Vertex by default)
  60654. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60655. */
  60656. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60657. /**
  60658. * Gets the output component
  60659. */
  60660. get output(): NodeMaterialConnectionPoint;
  60661. /**
  60662. * Set the source of this connection point to a vertex attribute
  60663. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60664. * @returns the current connection point
  60665. */
  60666. setAsAttribute(attributeName?: string): InputBlock;
  60667. /**
  60668. * Set the source of this connection point to a system value
  60669. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60670. * @returns the current connection point
  60671. */
  60672. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60673. /**
  60674. * Gets or sets the value of that point.
  60675. * Please note that this value will be ignored if valueCallback is defined
  60676. */
  60677. get value(): any;
  60678. set value(value: any);
  60679. /**
  60680. * Gets or sets a callback used to get the value of that point.
  60681. * Please note that setting this value will force the connection point to ignore the value property
  60682. */
  60683. get valueCallback(): () => any;
  60684. set valueCallback(value: () => any);
  60685. /**
  60686. * Gets or sets the associated variable name in the shader
  60687. */
  60688. get associatedVariableName(): string;
  60689. set associatedVariableName(value: string);
  60690. /** Gets or sets the type of animation applied to the input */
  60691. get animationType(): AnimatedInputBlockTypes;
  60692. set animationType(value: AnimatedInputBlockTypes);
  60693. /**
  60694. * Gets a boolean indicating that this connection point not defined yet
  60695. */
  60696. get isUndefined(): boolean;
  60697. /**
  60698. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60699. * In this case the connection point name must be the name of the uniform to use.
  60700. * Can only be set on inputs
  60701. */
  60702. get isUniform(): boolean;
  60703. set isUniform(value: boolean);
  60704. /**
  60705. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60706. * In this case the connection point name must be the name of the attribute to use
  60707. * Can only be set on inputs
  60708. */
  60709. get isAttribute(): boolean;
  60710. set isAttribute(value: boolean);
  60711. /**
  60712. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60713. * Can only be set on exit points
  60714. */
  60715. get isVarying(): boolean;
  60716. set isVarying(value: boolean);
  60717. /**
  60718. * Gets a boolean indicating that the current connection point is a system value
  60719. */
  60720. get isSystemValue(): boolean;
  60721. /**
  60722. * Gets or sets the current well known value or null if not defined as a system value
  60723. */
  60724. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60725. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60726. /**
  60727. * Gets the current class name
  60728. * @returns the class name
  60729. */
  60730. getClassName(): string;
  60731. /**
  60732. * Animate the input if animationType !== None
  60733. * @param scene defines the rendering scene
  60734. */
  60735. animate(scene: Scene): void;
  60736. private _emitDefine;
  60737. initialize(state: NodeMaterialBuildState): void;
  60738. /**
  60739. * Set the input block to its default value (based on its type)
  60740. */
  60741. setDefaultValue(): void;
  60742. private _emitConstant;
  60743. private _emit;
  60744. /** @hidden */
  60745. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60746. /** @hidden */
  60747. _transmit(effect: Effect, scene: Scene): void;
  60748. protected _buildBlock(state: NodeMaterialBuildState): void;
  60749. protected _dumpPropertiesCode(): string;
  60750. serialize(): any;
  60751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60752. }
  60753. }
  60754. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60755. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60756. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60757. import { Nullable } from "babylonjs/types";
  60758. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60759. import { Observable } from "babylonjs/Misc/observable";
  60760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60761. /**
  60762. * Enum used to define the compatibility state between two connection points
  60763. */
  60764. export enum NodeMaterialConnectionPointCompatibilityStates {
  60765. /** Points are compatibles */
  60766. Compatible = 0,
  60767. /** Points are incompatible because of their types */
  60768. TypeIncompatible = 1,
  60769. /** Points are incompatible because of their targets (vertex vs fragment) */
  60770. TargetIncompatible = 2
  60771. }
  60772. /**
  60773. * Defines the direction of a connection point
  60774. */
  60775. export enum NodeMaterialConnectionPointDirection {
  60776. /** Input */
  60777. Input = 0,
  60778. /** Output */
  60779. Output = 1
  60780. }
  60781. /**
  60782. * Defines a connection point for a block
  60783. */
  60784. export class NodeMaterialConnectionPoint {
  60785. /** @hidden */
  60786. _ownerBlock: NodeMaterialBlock;
  60787. /** @hidden */
  60788. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60789. private _endpoints;
  60790. private _associatedVariableName;
  60791. private _direction;
  60792. /** @hidden */
  60793. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60794. /** @hidden */
  60795. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60796. private _type;
  60797. /** @hidden */
  60798. _enforceAssociatedVariableName: boolean;
  60799. /** Gets the direction of the point */
  60800. get direction(): NodeMaterialConnectionPointDirection;
  60801. /**
  60802. * Gets or sets the additional types supported by this connection point
  60803. */
  60804. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60805. /**
  60806. * Gets or sets the additional types excluded by this connection point
  60807. */
  60808. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60809. /**
  60810. * Observable triggered when this point is connected
  60811. */
  60812. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60813. /**
  60814. * Gets or sets the associated variable name in the shader
  60815. */
  60816. get associatedVariableName(): string;
  60817. set associatedVariableName(value: string);
  60818. /**
  60819. * Gets or sets the connection point type (default is float)
  60820. */
  60821. get type(): NodeMaterialBlockConnectionPointTypes;
  60822. set type(value: NodeMaterialBlockConnectionPointTypes);
  60823. /**
  60824. * Gets or sets the connection point name
  60825. */
  60826. name: string;
  60827. /**
  60828. * Gets or sets a boolean indicating that this connection point can be omitted
  60829. */
  60830. isOptional: boolean;
  60831. /**
  60832. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60833. */
  60834. define: string;
  60835. /** @hidden */
  60836. _prioritizeVertex: boolean;
  60837. private _target;
  60838. /** Gets or sets the target of that connection point */
  60839. get target(): NodeMaterialBlockTargets;
  60840. set target(value: NodeMaterialBlockTargets);
  60841. /**
  60842. * Gets a boolean indicating that the current point is connected
  60843. */
  60844. get isConnected(): boolean;
  60845. /**
  60846. * Gets a boolean indicating that the current point is connected to an input block
  60847. */
  60848. get isConnectedToInputBlock(): boolean;
  60849. /**
  60850. * Gets a the connected input block (if any)
  60851. */
  60852. get connectInputBlock(): Nullable<InputBlock>;
  60853. /** Get the other side of the connection (if any) */
  60854. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60855. /** Get the block that owns this connection point */
  60856. get ownerBlock(): NodeMaterialBlock;
  60857. /** Get the block connected on the other side of this connection (if any) */
  60858. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60859. /** Get the block connected on the endpoints of this connection (if any) */
  60860. get connectedBlocks(): Array<NodeMaterialBlock>;
  60861. /** Gets the list of connected endpoints */
  60862. get endpoints(): NodeMaterialConnectionPoint[];
  60863. /** Gets a boolean indicating if that output point is connected to at least one input */
  60864. get hasEndpoints(): boolean;
  60865. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60866. get isConnectedInVertexShader(): boolean;
  60867. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60868. get isConnectedInFragmentShader(): boolean;
  60869. /**
  60870. * Creates a new connection point
  60871. * @param name defines the connection point name
  60872. * @param ownerBlock defines the block hosting this connection point
  60873. * @param direction defines the direction of the connection point
  60874. */
  60875. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60876. /**
  60877. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60878. * @returns the class name
  60879. */
  60880. getClassName(): string;
  60881. /**
  60882. * Gets a boolean indicating if the current point can be connected to another point
  60883. * @param connectionPoint defines the other connection point
  60884. * @returns a boolean
  60885. */
  60886. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60887. /**
  60888. * Gets a number indicating if the current point can be connected to another point
  60889. * @param connectionPoint defines the other connection point
  60890. * @returns a number defining the compatibility state
  60891. */
  60892. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60893. /**
  60894. * Connect this point to another connection point
  60895. * @param connectionPoint defines the other connection point
  60896. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60897. * @returns the current connection point
  60898. */
  60899. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60900. /**
  60901. * Disconnect this point from one of his endpoint
  60902. * @param endpoint defines the other connection point
  60903. * @returns the current connection point
  60904. */
  60905. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60906. /**
  60907. * Serializes this point in a JSON representation
  60908. * @returns the serialized point object
  60909. */
  60910. serialize(): any;
  60911. /**
  60912. * Release resources
  60913. */
  60914. dispose(): void;
  60915. }
  60916. }
  60917. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60921. import { Mesh } from "babylonjs/Meshes/mesh";
  60922. import { Effect } from "babylonjs/Materials/effect";
  60923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60924. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60925. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60926. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60927. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60928. /**
  60929. * Block used to add support for vertex skinning (bones)
  60930. */
  60931. export class BonesBlock extends NodeMaterialBlock {
  60932. /**
  60933. * Creates a new BonesBlock
  60934. * @param name defines the block name
  60935. */
  60936. constructor(name: string);
  60937. /**
  60938. * Initialize the block and prepare the context for build
  60939. * @param state defines the state that will be used for the build
  60940. */
  60941. initialize(state: NodeMaterialBuildState): void;
  60942. /**
  60943. * Gets the current class name
  60944. * @returns the class name
  60945. */
  60946. getClassName(): string;
  60947. /**
  60948. * Gets the matrix indices input component
  60949. */
  60950. get matricesIndices(): NodeMaterialConnectionPoint;
  60951. /**
  60952. * Gets the matrix weights input component
  60953. */
  60954. get matricesWeights(): NodeMaterialConnectionPoint;
  60955. /**
  60956. * Gets the extra matrix indices input component
  60957. */
  60958. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60959. /**
  60960. * Gets the extra matrix weights input component
  60961. */
  60962. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60963. /**
  60964. * Gets the world input component
  60965. */
  60966. get world(): NodeMaterialConnectionPoint;
  60967. /**
  60968. * Gets the output component
  60969. */
  60970. get output(): NodeMaterialConnectionPoint;
  60971. autoConfigure(material: NodeMaterial): void;
  60972. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60973. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60975. protected _buildBlock(state: NodeMaterialBuildState): this;
  60976. }
  60977. }
  60978. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60983. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60984. /**
  60985. * Block used to add support for instances
  60986. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60987. */
  60988. export class InstancesBlock extends NodeMaterialBlock {
  60989. /**
  60990. * Creates a new InstancesBlock
  60991. * @param name defines the block name
  60992. */
  60993. constructor(name: string);
  60994. /**
  60995. * Gets the current class name
  60996. * @returns the class name
  60997. */
  60998. getClassName(): string;
  60999. /**
  61000. * Gets the first world row input component
  61001. */
  61002. get world0(): NodeMaterialConnectionPoint;
  61003. /**
  61004. * Gets the second world row input component
  61005. */
  61006. get world1(): NodeMaterialConnectionPoint;
  61007. /**
  61008. * Gets the third world row input component
  61009. */
  61010. get world2(): NodeMaterialConnectionPoint;
  61011. /**
  61012. * Gets the forth world row input component
  61013. */
  61014. get world3(): NodeMaterialConnectionPoint;
  61015. /**
  61016. * Gets the world input component
  61017. */
  61018. get world(): NodeMaterialConnectionPoint;
  61019. /**
  61020. * Gets the output component
  61021. */
  61022. get output(): NodeMaterialConnectionPoint;
  61023. autoConfigure(material: NodeMaterial): void;
  61024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61025. protected _buildBlock(state: NodeMaterialBuildState): this;
  61026. }
  61027. }
  61028. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61033. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61034. import { Effect } from "babylonjs/Materials/effect";
  61035. import { Mesh } from "babylonjs/Meshes/mesh";
  61036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61038. /**
  61039. * Block used to add morph targets support to vertex shader
  61040. */
  61041. export class MorphTargetsBlock extends NodeMaterialBlock {
  61042. private _repeatableContentAnchor;
  61043. private _repeatebleContentGenerated;
  61044. /**
  61045. * Create a new MorphTargetsBlock
  61046. * @param name defines the block name
  61047. */
  61048. constructor(name: string);
  61049. /**
  61050. * Gets the current class name
  61051. * @returns the class name
  61052. */
  61053. getClassName(): string;
  61054. /**
  61055. * Gets the position input component
  61056. */
  61057. get position(): NodeMaterialConnectionPoint;
  61058. /**
  61059. * Gets the normal input component
  61060. */
  61061. get normal(): NodeMaterialConnectionPoint;
  61062. /**
  61063. * Gets the tangent input component
  61064. */
  61065. get tangent(): NodeMaterialConnectionPoint;
  61066. /**
  61067. * Gets the tangent input component
  61068. */
  61069. get uv(): NodeMaterialConnectionPoint;
  61070. /**
  61071. * Gets the position output component
  61072. */
  61073. get positionOutput(): NodeMaterialConnectionPoint;
  61074. /**
  61075. * Gets the normal output component
  61076. */
  61077. get normalOutput(): NodeMaterialConnectionPoint;
  61078. /**
  61079. * Gets the tangent output component
  61080. */
  61081. get tangentOutput(): NodeMaterialConnectionPoint;
  61082. /**
  61083. * Gets the tangent output component
  61084. */
  61085. get uvOutput(): NodeMaterialConnectionPoint;
  61086. initialize(state: NodeMaterialBuildState): void;
  61087. autoConfigure(material: NodeMaterial): void;
  61088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61090. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61091. protected _buildBlock(state: NodeMaterialBuildState): this;
  61092. }
  61093. }
  61094. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61098. import { Nullable } from "babylonjs/types";
  61099. import { Scene } from "babylonjs/scene";
  61100. import { Effect } from "babylonjs/Materials/effect";
  61101. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61102. import { Mesh } from "babylonjs/Meshes/mesh";
  61103. import { Light } from "babylonjs/Lights/light";
  61104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61105. /**
  61106. * Block used to get data information from a light
  61107. */
  61108. export class LightInformationBlock extends NodeMaterialBlock {
  61109. private _lightDataUniformName;
  61110. private _lightColorUniformName;
  61111. private _lightTypeDefineName;
  61112. /**
  61113. * Gets or sets the light associated with this block
  61114. */
  61115. light: Nullable<Light>;
  61116. /**
  61117. * Creates a new LightInformationBlock
  61118. * @param name defines the block name
  61119. */
  61120. constructor(name: string);
  61121. /**
  61122. * Gets the current class name
  61123. * @returns the class name
  61124. */
  61125. getClassName(): string;
  61126. /**
  61127. * Gets the world position input component
  61128. */
  61129. get worldPosition(): NodeMaterialConnectionPoint;
  61130. /**
  61131. * Gets the direction output component
  61132. */
  61133. get direction(): NodeMaterialConnectionPoint;
  61134. /**
  61135. * Gets the direction output component
  61136. */
  61137. get color(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the direction output component
  61140. */
  61141. get intensity(): NodeMaterialConnectionPoint;
  61142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61144. protected _buildBlock(state: NodeMaterialBuildState): this;
  61145. serialize(): any;
  61146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61147. }
  61148. }
  61149. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61150. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61151. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61152. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61153. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61154. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61155. }
  61156. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  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. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61161. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61162. import { Effect } from "babylonjs/Materials/effect";
  61163. import { Mesh } from "babylonjs/Meshes/mesh";
  61164. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61165. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61166. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61167. /**
  61168. * Block used to add image processing support to fragment shader
  61169. */
  61170. export class ImageProcessingBlock extends NodeMaterialBlock {
  61171. /**
  61172. * Create a new ImageProcessingBlock
  61173. * @param name defines the block name
  61174. */
  61175. constructor(name: string);
  61176. /**
  61177. * Gets the current class name
  61178. * @returns the class name
  61179. */
  61180. getClassName(): string;
  61181. /**
  61182. * Gets the color input component
  61183. */
  61184. get color(): NodeMaterialConnectionPoint;
  61185. /**
  61186. * Gets the output component
  61187. */
  61188. get output(): NodeMaterialConnectionPoint;
  61189. /**
  61190. * Initialize the block and prepare the context for build
  61191. * @param state defines the state that will be used for the build
  61192. */
  61193. initialize(state: NodeMaterialBuildState): void;
  61194. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61197. protected _buildBlock(state: NodeMaterialBuildState): this;
  61198. }
  61199. }
  61200. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61204. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61206. import { Effect } from "babylonjs/Materials/effect";
  61207. import { Mesh } from "babylonjs/Meshes/mesh";
  61208. import { Scene } from "babylonjs/scene";
  61209. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61210. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61211. /**
  61212. * Block used to pertub normals based on a normal map
  61213. */
  61214. export class PerturbNormalBlock extends NodeMaterialBlock {
  61215. private _tangentSpaceParameterName;
  61216. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61217. invertX: boolean;
  61218. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61219. invertY: boolean;
  61220. /**
  61221. * Create a new PerturbNormalBlock
  61222. * @param name defines the block name
  61223. */
  61224. constructor(name: string);
  61225. /**
  61226. * Gets the current class name
  61227. * @returns the class name
  61228. */
  61229. getClassName(): string;
  61230. /**
  61231. * Gets the world position input component
  61232. */
  61233. get worldPosition(): NodeMaterialConnectionPoint;
  61234. /**
  61235. * Gets the world normal input component
  61236. */
  61237. get worldNormal(): NodeMaterialConnectionPoint;
  61238. /**
  61239. * Gets the uv input component
  61240. */
  61241. get uv(): NodeMaterialConnectionPoint;
  61242. /**
  61243. * Gets the normal map color input component
  61244. */
  61245. get normalMapColor(): NodeMaterialConnectionPoint;
  61246. /**
  61247. * Gets the strength input component
  61248. */
  61249. get strength(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the output component
  61252. */
  61253. get output(): NodeMaterialConnectionPoint;
  61254. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61255. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61256. autoConfigure(material: NodeMaterial): void;
  61257. protected _buildBlock(state: NodeMaterialBuildState): this;
  61258. protected _dumpPropertiesCode(): string;
  61259. serialize(): any;
  61260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61261. }
  61262. }
  61263. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61267. /**
  61268. * Block used to discard a pixel if a value is smaller than a cutoff
  61269. */
  61270. export class DiscardBlock extends NodeMaterialBlock {
  61271. /**
  61272. * Create a new DiscardBlock
  61273. * @param name defines the block name
  61274. */
  61275. constructor(name: string);
  61276. /**
  61277. * Gets the current class name
  61278. * @returns the class name
  61279. */
  61280. getClassName(): string;
  61281. /**
  61282. * Gets the color input component
  61283. */
  61284. get value(): NodeMaterialConnectionPoint;
  61285. /**
  61286. * Gets the cutoff input component
  61287. */
  61288. get cutoff(): NodeMaterialConnectionPoint;
  61289. protected _buildBlock(state: NodeMaterialBuildState): this;
  61290. }
  61291. }
  61292. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61296. /**
  61297. * Block used to test if the fragment shader is front facing
  61298. */
  61299. export class FrontFacingBlock extends NodeMaterialBlock {
  61300. /**
  61301. * Creates a new FrontFacingBlock
  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 output component
  61312. */
  61313. get output(): NodeMaterialConnectionPoint;
  61314. protected _buildBlock(state: NodeMaterialBuildState): this;
  61315. }
  61316. }
  61317. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61321. /**
  61322. * Block used to get the derivative value on x and y of a given input
  61323. */
  61324. export class DerivativeBlock extends NodeMaterialBlock {
  61325. /**
  61326. * Create a new DerivativeBlock
  61327. * @param name defines the block name
  61328. */
  61329. constructor(name: string);
  61330. /**
  61331. * Gets the current class name
  61332. * @returns the class name
  61333. */
  61334. getClassName(): string;
  61335. /**
  61336. * Gets the input component
  61337. */
  61338. get input(): NodeMaterialConnectionPoint;
  61339. /**
  61340. * Gets the derivative output on x
  61341. */
  61342. get dx(): NodeMaterialConnectionPoint;
  61343. /**
  61344. * Gets the derivative output on y
  61345. */
  61346. get dy(): NodeMaterialConnectionPoint;
  61347. protected _buildBlock(state: NodeMaterialBuildState): this;
  61348. }
  61349. }
  61350. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61351. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61352. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61353. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61354. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61355. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61356. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61357. }
  61358. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61361. import { Mesh } from "babylonjs/Meshes/mesh";
  61362. import { Effect } from "babylonjs/Materials/effect";
  61363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61365. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61366. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61367. /**
  61368. * Block used to add support for scene fog
  61369. */
  61370. export class FogBlock extends NodeMaterialBlock {
  61371. private _fogDistanceName;
  61372. private _fogParameters;
  61373. /**
  61374. * Create a new FogBlock
  61375. * @param name defines the block name
  61376. */
  61377. constructor(name: string);
  61378. /**
  61379. * Gets the current class name
  61380. * @returns the class name
  61381. */
  61382. getClassName(): string;
  61383. /**
  61384. * Gets the world position input component
  61385. */
  61386. get worldPosition(): NodeMaterialConnectionPoint;
  61387. /**
  61388. * Gets the view input component
  61389. */
  61390. get view(): NodeMaterialConnectionPoint;
  61391. /**
  61392. * Gets the color input component
  61393. */
  61394. get input(): NodeMaterialConnectionPoint;
  61395. /**
  61396. * Gets the fog color input component
  61397. */
  61398. get fogColor(): NodeMaterialConnectionPoint;
  61399. /**
  61400. * Gets the output component
  61401. */
  61402. get output(): NodeMaterialConnectionPoint;
  61403. autoConfigure(material: NodeMaterial): void;
  61404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61405. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61406. protected _buildBlock(state: NodeMaterialBuildState): this;
  61407. }
  61408. }
  61409. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61414. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61415. import { Effect } from "babylonjs/Materials/effect";
  61416. import { Mesh } from "babylonjs/Meshes/mesh";
  61417. import { Light } from "babylonjs/Lights/light";
  61418. import { Nullable } from "babylonjs/types";
  61419. import { Scene } from "babylonjs/scene";
  61420. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61421. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61422. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61423. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61424. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61425. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61426. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61427. /**
  61428. * Block used to add light in the fragment shader
  61429. */
  61430. export class LightBlock extends NodeMaterialBlock {
  61431. private _lightId;
  61432. /**
  61433. * Gets or sets the light associated with this block
  61434. */
  61435. light: Nullable<Light>;
  61436. /**
  61437. * Create a new LightBlock
  61438. * @param name defines the block name
  61439. */
  61440. constructor(name: string);
  61441. /**
  61442. * Gets the current class name
  61443. * @returns the class name
  61444. */
  61445. getClassName(): string;
  61446. /**
  61447. * Gets the world position input component
  61448. */
  61449. get worldPosition(): NodeMaterialConnectionPoint;
  61450. /**
  61451. * Gets the world normal input component
  61452. */
  61453. get worldNormal(): NodeMaterialConnectionPoint;
  61454. /**
  61455. * Gets the camera (or eye) position component
  61456. */
  61457. get cameraPosition(): NodeMaterialConnectionPoint;
  61458. /**
  61459. * Gets the glossiness component
  61460. */
  61461. get glossiness(): NodeMaterialConnectionPoint;
  61462. /**
  61463. * Gets the glossinness power component
  61464. */
  61465. get glossPower(): NodeMaterialConnectionPoint;
  61466. /**
  61467. * Gets the diffuse color component
  61468. */
  61469. get diffuseColor(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the specular color component
  61472. */
  61473. get specularColor(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the diffuse output component
  61476. */
  61477. get diffuseOutput(): NodeMaterialConnectionPoint;
  61478. /**
  61479. * Gets the specular output component
  61480. */
  61481. get specularOutput(): NodeMaterialConnectionPoint;
  61482. /**
  61483. * Gets the shadow output component
  61484. */
  61485. get shadow(): NodeMaterialConnectionPoint;
  61486. autoConfigure(material: NodeMaterial): void;
  61487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61488. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61489. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61490. private _injectVertexCode;
  61491. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61492. serialize(): any;
  61493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61494. }
  61495. }
  61496. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61497. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61498. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61499. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61500. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61501. }
  61502. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61503. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61504. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61505. }
  61506. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  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 multiply 2 values
  61512. */
  61513. export class MultiplyBlock extends NodeMaterialBlock {
  61514. /**
  61515. * Creates a new MultiplyBlock
  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/addBlock" {
  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 add 2 vectors
  61545. */
  61546. export class AddBlock extends NodeMaterialBlock {
  61547. /**
  61548. * Creates a new AddBlock
  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/scaleBlock" {
  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. /**
  61577. * Block used to scale a vector by a float
  61578. */
  61579. export class ScaleBlock extends NodeMaterialBlock {
  61580. /**
  61581. * Creates a new ScaleBlock
  61582. * @param name defines the block name
  61583. */
  61584. constructor(name: string);
  61585. /**
  61586. * Gets the current class name
  61587. * @returns the class name
  61588. */
  61589. getClassName(): string;
  61590. /**
  61591. * Gets the input component
  61592. */
  61593. get input(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the factor input component
  61596. */
  61597. get factor(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the output component
  61600. */
  61601. get output(): NodeMaterialConnectionPoint;
  61602. protected _buildBlock(state: NodeMaterialBuildState): this;
  61603. }
  61604. }
  61605. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61609. import { Scene } from "babylonjs/scene";
  61610. /**
  61611. * Block used to clamp a float
  61612. */
  61613. export class ClampBlock extends NodeMaterialBlock {
  61614. /** Gets or sets the minimum range */
  61615. minimum: number;
  61616. /** Gets or sets the maximum range */
  61617. maximum: number;
  61618. /**
  61619. * Creates a new ClampBlock
  61620. * @param name defines the block name
  61621. */
  61622. constructor(name: string);
  61623. /**
  61624. * Gets the current class name
  61625. * @returns the class name
  61626. */
  61627. getClassName(): string;
  61628. /**
  61629. * Gets the value input component
  61630. */
  61631. get value(): NodeMaterialConnectionPoint;
  61632. /**
  61633. * Gets the output component
  61634. */
  61635. get output(): NodeMaterialConnectionPoint;
  61636. protected _buildBlock(state: NodeMaterialBuildState): this;
  61637. protected _dumpPropertiesCode(): string;
  61638. serialize(): any;
  61639. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61640. }
  61641. }
  61642. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61646. /**
  61647. * Block used to apply a cross product between 2 vectors
  61648. */
  61649. export class CrossBlock extends NodeMaterialBlock {
  61650. /**
  61651. * Creates a new CrossBlock
  61652. * @param name defines the block name
  61653. */
  61654. constructor(name: string);
  61655. /**
  61656. * Gets the current class name
  61657. * @returns the class name
  61658. */
  61659. getClassName(): string;
  61660. /**
  61661. * Gets the left operand input component
  61662. */
  61663. get left(): NodeMaterialConnectionPoint;
  61664. /**
  61665. * Gets the right operand input component
  61666. */
  61667. get right(): NodeMaterialConnectionPoint;
  61668. /**
  61669. * Gets the output component
  61670. */
  61671. get output(): NodeMaterialConnectionPoint;
  61672. protected _buildBlock(state: NodeMaterialBuildState): this;
  61673. }
  61674. }
  61675. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61679. /**
  61680. * Block used to apply a dot product between 2 vectors
  61681. */
  61682. export class DotBlock extends NodeMaterialBlock {
  61683. /**
  61684. * Creates a new DotBlock
  61685. * @param name defines the block name
  61686. */
  61687. constructor(name: string);
  61688. /**
  61689. * Gets the current class name
  61690. * @returns the class name
  61691. */
  61692. getClassName(): string;
  61693. /**
  61694. * Gets the left operand input component
  61695. */
  61696. get left(): NodeMaterialConnectionPoint;
  61697. /**
  61698. * Gets the right operand input component
  61699. */
  61700. get right(): NodeMaterialConnectionPoint;
  61701. /**
  61702. * Gets the output component
  61703. */
  61704. get output(): NodeMaterialConnectionPoint;
  61705. protected _buildBlock(state: NodeMaterialBuildState): this;
  61706. }
  61707. }
  61708. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61712. import { Vector2 } from "babylonjs/Maths/math.vector";
  61713. import { Scene } from "babylonjs/scene";
  61714. /**
  61715. * Block used to remap a float from a range to a new one
  61716. */
  61717. export class RemapBlock extends NodeMaterialBlock {
  61718. /**
  61719. * Gets or sets the source range
  61720. */
  61721. sourceRange: Vector2;
  61722. /**
  61723. * Gets or sets the target range
  61724. */
  61725. targetRange: Vector2;
  61726. /**
  61727. * Creates a new RemapBlock
  61728. * @param name defines the block name
  61729. */
  61730. constructor(name: string);
  61731. /**
  61732. * Gets the current class name
  61733. * @returns the class name
  61734. */
  61735. getClassName(): string;
  61736. /**
  61737. * Gets the input component
  61738. */
  61739. get input(): NodeMaterialConnectionPoint;
  61740. /**
  61741. * Gets the source min input component
  61742. */
  61743. get sourceMin(): NodeMaterialConnectionPoint;
  61744. /**
  61745. * Gets the source max input component
  61746. */
  61747. get sourceMax(): NodeMaterialConnectionPoint;
  61748. /**
  61749. * Gets the target min input component
  61750. */
  61751. get targetMin(): NodeMaterialConnectionPoint;
  61752. /**
  61753. * Gets the target max input component
  61754. */
  61755. get targetMax(): NodeMaterialConnectionPoint;
  61756. /**
  61757. * Gets the output component
  61758. */
  61759. get output(): NodeMaterialConnectionPoint;
  61760. protected _buildBlock(state: NodeMaterialBuildState): this;
  61761. protected _dumpPropertiesCode(): string;
  61762. serialize(): any;
  61763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61764. }
  61765. }
  61766. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61770. /**
  61771. * Block used to normalize a vector
  61772. */
  61773. export class NormalizeBlock extends NodeMaterialBlock {
  61774. /**
  61775. * Creates a new NormalizeBlock
  61776. * @param name defines the block name
  61777. */
  61778. constructor(name: string);
  61779. /**
  61780. * Gets the current class name
  61781. * @returns the class name
  61782. */
  61783. getClassName(): string;
  61784. /**
  61785. * Gets the input component
  61786. */
  61787. get input(): NodeMaterialConnectionPoint;
  61788. /**
  61789. * Gets the output component
  61790. */
  61791. get output(): NodeMaterialConnectionPoint;
  61792. protected _buildBlock(state: NodeMaterialBuildState): this;
  61793. }
  61794. }
  61795. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61799. import { Scene } from "babylonjs/scene";
  61800. /**
  61801. * Operations supported by the Trigonometry block
  61802. */
  61803. export enum TrigonometryBlockOperations {
  61804. /** Cos */
  61805. Cos = 0,
  61806. /** Sin */
  61807. Sin = 1,
  61808. /** Abs */
  61809. Abs = 2,
  61810. /** Exp */
  61811. Exp = 3,
  61812. /** Exp2 */
  61813. Exp2 = 4,
  61814. /** Round */
  61815. Round = 5,
  61816. /** Floor */
  61817. Floor = 6,
  61818. /** Ceiling */
  61819. Ceiling = 7,
  61820. /** Square root */
  61821. Sqrt = 8,
  61822. /** Log */
  61823. Log = 9,
  61824. /** Tangent */
  61825. Tan = 10,
  61826. /** Arc tangent */
  61827. ArcTan = 11,
  61828. /** Arc cosinus */
  61829. ArcCos = 12,
  61830. /** Arc sinus */
  61831. ArcSin = 13,
  61832. /** Fraction */
  61833. Fract = 14,
  61834. /** Sign */
  61835. Sign = 15,
  61836. /** To radians (from degrees) */
  61837. Radians = 16,
  61838. /** To degrees (from radians) */
  61839. Degrees = 17
  61840. }
  61841. /**
  61842. * Block used to apply trigonometry operation to floats
  61843. */
  61844. export class TrigonometryBlock extends NodeMaterialBlock {
  61845. /**
  61846. * Gets or sets the operation applied by the block
  61847. */
  61848. operation: TrigonometryBlockOperations;
  61849. /**
  61850. * Creates a new TrigonometryBlock
  61851. * @param name defines the block name
  61852. */
  61853. constructor(name: string);
  61854. /**
  61855. * Gets the current class name
  61856. * @returns the class name
  61857. */
  61858. getClassName(): string;
  61859. /**
  61860. * Gets the input component
  61861. */
  61862. get input(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the output component
  61865. */
  61866. get output(): NodeMaterialConnectionPoint;
  61867. protected _buildBlock(state: NodeMaterialBuildState): this;
  61868. serialize(): any;
  61869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61870. protected _dumpPropertiesCode(): string;
  61871. }
  61872. }
  61873. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61877. /**
  61878. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61879. */
  61880. export class ColorMergerBlock extends NodeMaterialBlock {
  61881. /**
  61882. * Create a new ColorMergerBlock
  61883. * @param name defines the block name
  61884. */
  61885. constructor(name: string);
  61886. /**
  61887. * Gets the current class name
  61888. * @returns the class name
  61889. */
  61890. getClassName(): string;
  61891. /**
  61892. * Gets the rgb component (input)
  61893. */
  61894. get rgbIn(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the r component (input)
  61897. */
  61898. get r(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the g component (input)
  61901. */
  61902. get g(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the b component (input)
  61905. */
  61906. get b(): NodeMaterialConnectionPoint;
  61907. /**
  61908. * Gets the a component (input)
  61909. */
  61910. get a(): NodeMaterialConnectionPoint;
  61911. /**
  61912. * Gets the rgba component (output)
  61913. */
  61914. get rgba(): NodeMaterialConnectionPoint;
  61915. /**
  61916. * Gets the rgb component (output)
  61917. */
  61918. get rgbOut(): NodeMaterialConnectionPoint;
  61919. /**
  61920. * Gets the rgb component (output)
  61921. * @deprecated Please use rgbOut instead.
  61922. */
  61923. get rgb(): NodeMaterialConnectionPoint;
  61924. protected _buildBlock(state: NodeMaterialBuildState): this;
  61925. }
  61926. }
  61927. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61931. /**
  61932. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61933. */
  61934. export class VectorMergerBlock extends NodeMaterialBlock {
  61935. /**
  61936. * Create a new VectorMergerBlock
  61937. * @param name defines the block name
  61938. */
  61939. constructor(name: string);
  61940. /**
  61941. * Gets the current class name
  61942. * @returns the class name
  61943. */
  61944. getClassName(): string;
  61945. /**
  61946. * Gets the xyz component (input)
  61947. */
  61948. get xyzIn(): NodeMaterialConnectionPoint;
  61949. /**
  61950. * Gets the xy component (input)
  61951. */
  61952. get xyIn(): NodeMaterialConnectionPoint;
  61953. /**
  61954. * Gets the x component (input)
  61955. */
  61956. get x(): NodeMaterialConnectionPoint;
  61957. /**
  61958. * Gets the y component (input)
  61959. */
  61960. get y(): NodeMaterialConnectionPoint;
  61961. /**
  61962. * Gets the z component (input)
  61963. */
  61964. get z(): NodeMaterialConnectionPoint;
  61965. /**
  61966. * Gets the w component (input)
  61967. */
  61968. get w(): NodeMaterialConnectionPoint;
  61969. /**
  61970. * Gets the xyzw component (output)
  61971. */
  61972. get xyzw(): NodeMaterialConnectionPoint;
  61973. /**
  61974. * Gets the xyz component (output)
  61975. */
  61976. get xyzOut(): NodeMaterialConnectionPoint;
  61977. /**
  61978. * Gets the xy component (output)
  61979. */
  61980. get xyOut(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the xy component (output)
  61983. * @deprecated Please use xyOut instead.
  61984. */
  61985. get xy(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the xyz component (output)
  61988. * @deprecated Please use xyzOut instead.
  61989. */
  61990. get xyz(): NodeMaterialConnectionPoint;
  61991. protected _buildBlock(state: NodeMaterialBuildState): this;
  61992. }
  61993. }
  61994. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61998. /**
  61999. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62000. */
  62001. export class ColorSplitterBlock extends NodeMaterialBlock {
  62002. /**
  62003. * Create a new ColorSplitterBlock
  62004. * @param name defines the block name
  62005. */
  62006. constructor(name: string);
  62007. /**
  62008. * Gets the current class name
  62009. * @returns the class name
  62010. */
  62011. getClassName(): string;
  62012. /**
  62013. * Gets the rgba component (input)
  62014. */
  62015. get rgba(): NodeMaterialConnectionPoint;
  62016. /**
  62017. * Gets the rgb component (input)
  62018. */
  62019. get rgbIn(): NodeMaterialConnectionPoint;
  62020. /**
  62021. * Gets the rgb component (output)
  62022. */
  62023. get rgbOut(): NodeMaterialConnectionPoint;
  62024. /**
  62025. * Gets the r component (output)
  62026. */
  62027. get r(): NodeMaterialConnectionPoint;
  62028. /**
  62029. * Gets the g component (output)
  62030. */
  62031. get g(): NodeMaterialConnectionPoint;
  62032. /**
  62033. * Gets the b component (output)
  62034. */
  62035. get b(): NodeMaterialConnectionPoint;
  62036. /**
  62037. * Gets the a component (output)
  62038. */
  62039. get a(): NodeMaterialConnectionPoint;
  62040. protected _inputRename(name: string): string;
  62041. protected _outputRename(name: string): string;
  62042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62043. }
  62044. }
  62045. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62049. /**
  62050. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62051. */
  62052. export class VectorSplitterBlock extends NodeMaterialBlock {
  62053. /**
  62054. * Create a new VectorSplitterBlock
  62055. * @param name defines the block name
  62056. */
  62057. constructor(name: string);
  62058. /**
  62059. * Gets the current class name
  62060. * @returns the class name
  62061. */
  62062. getClassName(): string;
  62063. /**
  62064. * Gets the xyzw component (input)
  62065. */
  62066. get xyzw(): NodeMaterialConnectionPoint;
  62067. /**
  62068. * Gets the xyz component (input)
  62069. */
  62070. get xyzIn(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the xy component (input)
  62073. */
  62074. get xyIn(): NodeMaterialConnectionPoint;
  62075. /**
  62076. * Gets the xyz component (output)
  62077. */
  62078. get xyzOut(): NodeMaterialConnectionPoint;
  62079. /**
  62080. * Gets the xy component (output)
  62081. */
  62082. get xyOut(): NodeMaterialConnectionPoint;
  62083. /**
  62084. * Gets the x component (output)
  62085. */
  62086. get x(): NodeMaterialConnectionPoint;
  62087. /**
  62088. * Gets the y component (output)
  62089. */
  62090. get y(): NodeMaterialConnectionPoint;
  62091. /**
  62092. * Gets the z component (output)
  62093. */
  62094. get z(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the w component (output)
  62097. */
  62098. get w(): NodeMaterialConnectionPoint;
  62099. protected _inputRename(name: string): string;
  62100. protected _outputRename(name: string): string;
  62101. protected _buildBlock(state: NodeMaterialBuildState): this;
  62102. }
  62103. }
  62104. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  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 lerp between 2 values
  62110. */
  62111. export class LerpBlock extends NodeMaterialBlock {
  62112. /**
  62113. * Creates a new LerpBlock
  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 left operand input component
  62124. */
  62125. get left(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the right operand input component
  62128. */
  62129. get right(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the gradient operand input component
  62132. */
  62133. get gradient(): NodeMaterialConnectionPoint;
  62134. /**
  62135. * Gets the output component
  62136. */
  62137. get output(): NodeMaterialConnectionPoint;
  62138. protected _buildBlock(state: NodeMaterialBuildState): this;
  62139. }
  62140. }
  62141. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62145. /**
  62146. * Block used to divide 2 vectors
  62147. */
  62148. export class DivideBlock extends NodeMaterialBlock {
  62149. /**
  62150. * Creates a new DivideBlock
  62151. * @param name defines the block name
  62152. */
  62153. constructor(name: string);
  62154. /**
  62155. * Gets the current class name
  62156. * @returns the class name
  62157. */
  62158. getClassName(): string;
  62159. /**
  62160. * Gets the left operand input component
  62161. */
  62162. get left(): NodeMaterialConnectionPoint;
  62163. /**
  62164. * Gets the right operand input component
  62165. */
  62166. get right(): NodeMaterialConnectionPoint;
  62167. /**
  62168. * Gets the output component
  62169. */
  62170. get output(): NodeMaterialConnectionPoint;
  62171. protected _buildBlock(state: NodeMaterialBuildState): this;
  62172. }
  62173. }
  62174. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62178. /**
  62179. * Block used to subtract 2 vectors
  62180. */
  62181. export class SubtractBlock extends NodeMaterialBlock {
  62182. /**
  62183. * Creates a new SubtractBlock
  62184. * @param name defines the block name
  62185. */
  62186. constructor(name: string);
  62187. /**
  62188. * Gets the current class name
  62189. * @returns the class name
  62190. */
  62191. getClassName(): string;
  62192. /**
  62193. * Gets the left operand input component
  62194. */
  62195. get left(): NodeMaterialConnectionPoint;
  62196. /**
  62197. * Gets the right operand input component
  62198. */
  62199. get right(): NodeMaterialConnectionPoint;
  62200. /**
  62201. * Gets the output component
  62202. */
  62203. get output(): NodeMaterialConnectionPoint;
  62204. protected _buildBlock(state: NodeMaterialBuildState): this;
  62205. }
  62206. }
  62207. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62211. /**
  62212. * Block used to step a value
  62213. */
  62214. export class StepBlock extends NodeMaterialBlock {
  62215. /**
  62216. * Creates a new StepBlock
  62217. * @param name defines the block name
  62218. */
  62219. constructor(name: string);
  62220. /**
  62221. * Gets the current class name
  62222. * @returns the class name
  62223. */
  62224. getClassName(): string;
  62225. /**
  62226. * Gets the value operand input component
  62227. */
  62228. get value(): NodeMaterialConnectionPoint;
  62229. /**
  62230. * Gets the edge operand input component
  62231. */
  62232. get edge(): NodeMaterialConnectionPoint;
  62233. /**
  62234. * Gets the output component
  62235. */
  62236. get output(): NodeMaterialConnectionPoint;
  62237. protected _buildBlock(state: NodeMaterialBuildState): this;
  62238. }
  62239. }
  62240. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62244. /**
  62245. * Block used to get the opposite (1 - x) of a value
  62246. */
  62247. export class OneMinusBlock extends NodeMaterialBlock {
  62248. /**
  62249. * Creates a new OneMinusBlock
  62250. * @param name defines the block name
  62251. */
  62252. constructor(name: string);
  62253. /**
  62254. * Gets the current class name
  62255. * @returns the class name
  62256. */
  62257. getClassName(): string;
  62258. /**
  62259. * Gets the input component
  62260. */
  62261. get input(): NodeMaterialConnectionPoint;
  62262. /**
  62263. * Gets the output component
  62264. */
  62265. get output(): NodeMaterialConnectionPoint;
  62266. protected _buildBlock(state: NodeMaterialBuildState): this;
  62267. }
  62268. }
  62269. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62273. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62274. /**
  62275. * Block used to get the view direction
  62276. */
  62277. export class ViewDirectionBlock extends NodeMaterialBlock {
  62278. /**
  62279. * Creates a new ViewDirectionBlock
  62280. * @param name defines the block name
  62281. */
  62282. constructor(name: string);
  62283. /**
  62284. * Gets the current class name
  62285. * @returns the class name
  62286. */
  62287. getClassName(): string;
  62288. /**
  62289. * Gets the world position component
  62290. */
  62291. get worldPosition(): NodeMaterialConnectionPoint;
  62292. /**
  62293. * Gets the camera position component
  62294. */
  62295. get cameraPosition(): NodeMaterialConnectionPoint;
  62296. /**
  62297. * Gets the output component
  62298. */
  62299. get output(): NodeMaterialConnectionPoint;
  62300. autoConfigure(material: NodeMaterial): void;
  62301. protected _buildBlock(state: NodeMaterialBuildState): this;
  62302. }
  62303. }
  62304. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62308. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62309. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62310. /**
  62311. * Block used to compute fresnel value
  62312. */
  62313. export class FresnelBlock extends NodeMaterialBlock {
  62314. /**
  62315. * Create a new FresnelBlock
  62316. * @param name defines the block name
  62317. */
  62318. constructor(name: string);
  62319. /**
  62320. * Gets the current class name
  62321. * @returns the class name
  62322. */
  62323. getClassName(): string;
  62324. /**
  62325. * Gets the world normal input component
  62326. */
  62327. get worldNormal(): NodeMaterialConnectionPoint;
  62328. /**
  62329. * Gets the view direction input component
  62330. */
  62331. get viewDirection(): NodeMaterialConnectionPoint;
  62332. /**
  62333. * Gets the bias input component
  62334. */
  62335. get bias(): NodeMaterialConnectionPoint;
  62336. /**
  62337. * Gets the camera (or eye) position component
  62338. */
  62339. get power(): NodeMaterialConnectionPoint;
  62340. /**
  62341. * Gets the fresnel output component
  62342. */
  62343. get fresnel(): NodeMaterialConnectionPoint;
  62344. autoConfigure(material: NodeMaterial): void;
  62345. protected _buildBlock(state: NodeMaterialBuildState): this;
  62346. }
  62347. }
  62348. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62352. /**
  62353. * Block used to get the max of 2 values
  62354. */
  62355. export class MaxBlock extends NodeMaterialBlock {
  62356. /**
  62357. * Creates a new MaxBlock
  62358. * @param name defines the block name
  62359. */
  62360. constructor(name: string);
  62361. /**
  62362. * Gets the current class name
  62363. * @returns the class name
  62364. */
  62365. getClassName(): string;
  62366. /**
  62367. * Gets the left operand input component
  62368. */
  62369. get left(): NodeMaterialConnectionPoint;
  62370. /**
  62371. * Gets the right operand input component
  62372. */
  62373. get right(): NodeMaterialConnectionPoint;
  62374. /**
  62375. * Gets the output component
  62376. */
  62377. get output(): NodeMaterialConnectionPoint;
  62378. protected _buildBlock(state: NodeMaterialBuildState): this;
  62379. }
  62380. }
  62381. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62385. /**
  62386. * Block used to get the min of 2 values
  62387. */
  62388. export class MinBlock extends NodeMaterialBlock {
  62389. /**
  62390. * Creates a new MinBlock
  62391. * @param name defines the block name
  62392. */
  62393. constructor(name: string);
  62394. /**
  62395. * Gets the current class name
  62396. * @returns the class name
  62397. */
  62398. getClassName(): string;
  62399. /**
  62400. * Gets the left operand input component
  62401. */
  62402. get left(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the right operand input component
  62405. */
  62406. get right(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the output component
  62409. */
  62410. get output(): NodeMaterialConnectionPoint;
  62411. protected _buildBlock(state: NodeMaterialBuildState): this;
  62412. }
  62413. }
  62414. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62418. /**
  62419. * Block used to get the distance between 2 values
  62420. */
  62421. export class DistanceBlock extends NodeMaterialBlock {
  62422. /**
  62423. * Creates a new DistanceBlock
  62424. * @param name defines the block name
  62425. */
  62426. constructor(name: string);
  62427. /**
  62428. * Gets the current class name
  62429. * @returns the class name
  62430. */
  62431. getClassName(): string;
  62432. /**
  62433. * Gets the left operand input component
  62434. */
  62435. get left(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the right operand input component
  62438. */
  62439. get right(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the output component
  62442. */
  62443. get output(): NodeMaterialConnectionPoint;
  62444. protected _buildBlock(state: NodeMaterialBuildState): this;
  62445. }
  62446. }
  62447. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62451. /**
  62452. * Block used to get the length of a vector
  62453. */
  62454. export class LengthBlock extends NodeMaterialBlock {
  62455. /**
  62456. * Creates a new LengthBlock
  62457. * @param name defines the block name
  62458. */
  62459. constructor(name: string);
  62460. /**
  62461. * Gets the current class name
  62462. * @returns the class name
  62463. */
  62464. getClassName(): string;
  62465. /**
  62466. * Gets the value input component
  62467. */
  62468. get value(): NodeMaterialConnectionPoint;
  62469. /**
  62470. * Gets the output component
  62471. */
  62472. get output(): NodeMaterialConnectionPoint;
  62473. protected _buildBlock(state: NodeMaterialBuildState): this;
  62474. }
  62475. }
  62476. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62480. /**
  62481. * Block used to get negative version of a value (i.e. x * -1)
  62482. */
  62483. export class NegateBlock extends NodeMaterialBlock {
  62484. /**
  62485. * Creates a new NegateBlock
  62486. * @param name defines the block name
  62487. */
  62488. constructor(name: string);
  62489. /**
  62490. * Gets the current class name
  62491. * @returns the class name
  62492. */
  62493. getClassName(): string;
  62494. /**
  62495. * Gets the value input component
  62496. */
  62497. get value(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the output component
  62500. */
  62501. get output(): NodeMaterialConnectionPoint;
  62502. protected _buildBlock(state: NodeMaterialBuildState): this;
  62503. }
  62504. }
  62505. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62509. /**
  62510. * Block used to get the value of the first parameter raised to the power of the second
  62511. */
  62512. export class PowBlock extends NodeMaterialBlock {
  62513. /**
  62514. * Creates a new PowBlock
  62515. * @param name defines the block name
  62516. */
  62517. constructor(name: string);
  62518. /**
  62519. * Gets the current class name
  62520. * @returns the class name
  62521. */
  62522. getClassName(): string;
  62523. /**
  62524. * Gets the value operand input component
  62525. */
  62526. get value(): NodeMaterialConnectionPoint;
  62527. /**
  62528. * Gets the power operand input component
  62529. */
  62530. get power(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the output component
  62533. */
  62534. get output(): NodeMaterialConnectionPoint;
  62535. protected _buildBlock(state: NodeMaterialBuildState): this;
  62536. }
  62537. }
  62538. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62542. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62543. /**
  62544. * Block used to get a random number
  62545. */
  62546. export class RandomNumberBlock extends NodeMaterialBlock {
  62547. /**
  62548. * Creates a new RandomNumberBlock
  62549. * @param name defines the block name
  62550. */
  62551. constructor(name: string);
  62552. /**
  62553. * Gets the current class name
  62554. * @returns the class name
  62555. */
  62556. getClassName(): string;
  62557. /**
  62558. * Gets the seed input component
  62559. */
  62560. get seed(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the output component
  62563. */
  62564. get output(): NodeMaterialConnectionPoint;
  62565. protected _buildBlock(state: NodeMaterialBuildState): this;
  62566. }
  62567. }
  62568. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62572. /**
  62573. * Block used to compute arc tangent of 2 values
  62574. */
  62575. export class ArcTan2Block extends NodeMaterialBlock {
  62576. /**
  62577. * Creates a new ArcTan2Block
  62578. * @param name defines the block name
  62579. */
  62580. constructor(name: string);
  62581. /**
  62582. * Gets the current class name
  62583. * @returns the class name
  62584. */
  62585. getClassName(): string;
  62586. /**
  62587. * Gets the x operand input component
  62588. */
  62589. get x(): NodeMaterialConnectionPoint;
  62590. /**
  62591. * Gets the y operand input component
  62592. */
  62593. get y(): NodeMaterialConnectionPoint;
  62594. /**
  62595. * Gets the output component
  62596. */
  62597. get output(): NodeMaterialConnectionPoint;
  62598. protected _buildBlock(state: NodeMaterialBuildState): this;
  62599. }
  62600. }
  62601. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62605. /**
  62606. * Block used to smooth step a value
  62607. */
  62608. export class SmoothStepBlock extends NodeMaterialBlock {
  62609. /**
  62610. * Creates a new SmoothStepBlock
  62611. * @param name defines the block name
  62612. */
  62613. constructor(name: string);
  62614. /**
  62615. * Gets the current class name
  62616. * @returns the class name
  62617. */
  62618. getClassName(): string;
  62619. /**
  62620. * Gets the value operand input component
  62621. */
  62622. get value(): NodeMaterialConnectionPoint;
  62623. /**
  62624. * Gets the first edge operand input component
  62625. */
  62626. get edge0(): NodeMaterialConnectionPoint;
  62627. /**
  62628. * Gets the second edge operand input component
  62629. */
  62630. get edge1(): NodeMaterialConnectionPoint;
  62631. /**
  62632. * Gets the output component
  62633. */
  62634. get output(): NodeMaterialConnectionPoint;
  62635. protected _buildBlock(state: NodeMaterialBuildState): this;
  62636. }
  62637. }
  62638. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62642. /**
  62643. * Block used to get the reciprocal (1 / x) of a value
  62644. */
  62645. export class ReciprocalBlock extends NodeMaterialBlock {
  62646. /**
  62647. * Creates a new ReciprocalBlock
  62648. * @param name defines the block name
  62649. */
  62650. constructor(name: string);
  62651. /**
  62652. * Gets the current class name
  62653. * @returns the class name
  62654. */
  62655. getClassName(): string;
  62656. /**
  62657. * Gets the input component
  62658. */
  62659. get input(): NodeMaterialConnectionPoint;
  62660. /**
  62661. * Gets the output component
  62662. */
  62663. get output(): NodeMaterialConnectionPoint;
  62664. protected _buildBlock(state: NodeMaterialBuildState): this;
  62665. }
  62666. }
  62667. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62671. /**
  62672. * Block used to replace a color by another one
  62673. */
  62674. export class ReplaceColorBlock extends NodeMaterialBlock {
  62675. /**
  62676. * Creates a new ReplaceColorBlock
  62677. * @param name defines the block name
  62678. */
  62679. constructor(name: string);
  62680. /**
  62681. * Gets the current class name
  62682. * @returns the class name
  62683. */
  62684. getClassName(): string;
  62685. /**
  62686. * Gets the value input component
  62687. */
  62688. get value(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the reference input component
  62691. */
  62692. get reference(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the distance input component
  62695. */
  62696. get distance(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the replacement input component
  62699. */
  62700. get replacement(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the output component
  62703. */
  62704. get output(): NodeMaterialConnectionPoint;
  62705. protected _buildBlock(state: NodeMaterialBuildState): this;
  62706. }
  62707. }
  62708. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62712. /**
  62713. * Block used to posterize a value
  62714. * @see https://en.wikipedia.org/wiki/Posterization
  62715. */
  62716. export class PosterizeBlock extends NodeMaterialBlock {
  62717. /**
  62718. * Creates a new PosterizeBlock
  62719. * @param name defines the block name
  62720. */
  62721. constructor(name: string);
  62722. /**
  62723. * Gets the current class name
  62724. * @returns the class name
  62725. */
  62726. getClassName(): string;
  62727. /**
  62728. * Gets the value input component
  62729. */
  62730. get value(): NodeMaterialConnectionPoint;
  62731. /**
  62732. * Gets the steps input component
  62733. */
  62734. get steps(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the output component
  62737. */
  62738. get output(): NodeMaterialConnectionPoint;
  62739. protected _buildBlock(state: NodeMaterialBuildState): this;
  62740. }
  62741. }
  62742. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62746. import { Scene } from "babylonjs/scene";
  62747. /**
  62748. * Operations supported by the Wave block
  62749. */
  62750. export enum WaveBlockKind {
  62751. /** SawTooth */
  62752. SawTooth = 0,
  62753. /** Square */
  62754. Square = 1,
  62755. /** Triangle */
  62756. Triangle = 2
  62757. }
  62758. /**
  62759. * Block used to apply wave operation to floats
  62760. */
  62761. export class WaveBlock extends NodeMaterialBlock {
  62762. /**
  62763. * Gets or sets the kibnd of wave to be applied by the block
  62764. */
  62765. kind: WaveBlockKind;
  62766. /**
  62767. * Creates a new WaveBlock
  62768. * @param name defines the block name
  62769. */
  62770. constructor(name: string);
  62771. /**
  62772. * Gets the current class name
  62773. * @returns the class name
  62774. */
  62775. getClassName(): string;
  62776. /**
  62777. * Gets the input component
  62778. */
  62779. get input(): NodeMaterialConnectionPoint;
  62780. /**
  62781. * Gets the output component
  62782. */
  62783. get output(): NodeMaterialConnectionPoint;
  62784. protected _buildBlock(state: NodeMaterialBuildState): this;
  62785. serialize(): any;
  62786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62787. }
  62788. }
  62789. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62793. import { Color3 } from "babylonjs/Maths/math.color";
  62794. import { Scene } from "babylonjs/scene";
  62795. /**
  62796. * Class used to store a color step for the GradientBlock
  62797. */
  62798. export class GradientBlockColorStep {
  62799. /**
  62800. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62801. */
  62802. step: number;
  62803. /**
  62804. * Gets or sets the color associated with this step
  62805. */
  62806. color: Color3;
  62807. /**
  62808. * Creates a new GradientBlockColorStep
  62809. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62810. * @param color defines the color associated with this step
  62811. */
  62812. constructor(
  62813. /**
  62814. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62815. */
  62816. step: number,
  62817. /**
  62818. * Gets or sets the color associated with this step
  62819. */
  62820. color: Color3);
  62821. }
  62822. /**
  62823. * Block used to return a color from a gradient based on an input value between 0 and 1
  62824. */
  62825. export class GradientBlock extends NodeMaterialBlock {
  62826. /**
  62827. * Gets or sets the list of color steps
  62828. */
  62829. colorSteps: GradientBlockColorStep[];
  62830. /**
  62831. * Creates a new GradientBlock
  62832. * @param name defines the block name
  62833. */
  62834. constructor(name: string);
  62835. /**
  62836. * Gets the current class name
  62837. * @returns the class name
  62838. */
  62839. getClassName(): string;
  62840. /**
  62841. * Gets the gradient input component
  62842. */
  62843. get gradient(): NodeMaterialConnectionPoint;
  62844. /**
  62845. * Gets the output component
  62846. */
  62847. get output(): NodeMaterialConnectionPoint;
  62848. private _writeColorConstant;
  62849. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62850. serialize(): any;
  62851. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62852. protected _dumpPropertiesCode(): string;
  62853. }
  62854. }
  62855. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62859. /**
  62860. * Block used to normalize lerp between 2 values
  62861. */
  62862. export class NLerpBlock extends NodeMaterialBlock {
  62863. /**
  62864. * Creates a new NLerpBlock
  62865. * @param name defines the block name
  62866. */
  62867. constructor(name: string);
  62868. /**
  62869. * Gets the current class name
  62870. * @returns the class name
  62871. */
  62872. getClassName(): string;
  62873. /**
  62874. * Gets the left operand input component
  62875. */
  62876. get left(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the right operand input component
  62879. */
  62880. get right(): NodeMaterialConnectionPoint;
  62881. /**
  62882. * Gets the gradient operand input component
  62883. */
  62884. get gradient(): NodeMaterialConnectionPoint;
  62885. /**
  62886. * Gets the output component
  62887. */
  62888. get output(): NodeMaterialConnectionPoint;
  62889. protected _buildBlock(state: NodeMaterialBuildState): this;
  62890. }
  62891. }
  62892. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62896. import { Scene } from "babylonjs/scene";
  62897. /**
  62898. * block used to Generate a Worley Noise 3D Noise Pattern
  62899. */
  62900. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62901. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62902. manhattanDistance: boolean;
  62903. /**
  62904. * Creates a new WorleyNoise3DBlock
  62905. * @param name defines the block name
  62906. */
  62907. constructor(name: string);
  62908. /**
  62909. * Gets the current class name
  62910. * @returns the class name
  62911. */
  62912. getClassName(): string;
  62913. /**
  62914. * Gets the seed input component
  62915. */
  62916. get seed(): NodeMaterialConnectionPoint;
  62917. /**
  62918. * Gets the jitter input component
  62919. */
  62920. get jitter(): NodeMaterialConnectionPoint;
  62921. /**
  62922. * Gets the output component
  62923. */
  62924. get output(): NodeMaterialConnectionPoint;
  62925. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62926. /**
  62927. * Exposes the properties to the UI?
  62928. */
  62929. protected _dumpPropertiesCode(): string;
  62930. /**
  62931. * Exposes the properties to the Seralize?
  62932. */
  62933. serialize(): any;
  62934. /**
  62935. * Exposes the properties to the deseralize?
  62936. */
  62937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62938. }
  62939. }
  62940. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62944. /**
  62945. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62946. */
  62947. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62948. /**
  62949. * Creates a new SimplexPerlin3DBlock
  62950. * @param name defines the block name
  62951. */
  62952. constructor(name: string);
  62953. /**
  62954. * Gets the current class name
  62955. * @returns the class name
  62956. */
  62957. getClassName(): string;
  62958. /**
  62959. * Gets the seed operand input component
  62960. */
  62961. get seed(): NodeMaterialConnectionPoint;
  62962. /**
  62963. * Gets the output component
  62964. */
  62965. get output(): NodeMaterialConnectionPoint;
  62966. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62967. }
  62968. }
  62969. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62973. /**
  62974. * Block used to blend normals
  62975. */
  62976. export class NormalBlendBlock extends NodeMaterialBlock {
  62977. /**
  62978. * Creates a new NormalBlendBlock
  62979. * @param name defines the block name
  62980. */
  62981. constructor(name: string);
  62982. /**
  62983. * Gets the current class name
  62984. * @returns the class name
  62985. */
  62986. getClassName(): string;
  62987. /**
  62988. * Gets the first input component
  62989. */
  62990. get normalMap0(): NodeMaterialConnectionPoint;
  62991. /**
  62992. * Gets the second input component
  62993. */
  62994. get normalMap1(): NodeMaterialConnectionPoint;
  62995. /**
  62996. * Gets the output component
  62997. */
  62998. get output(): NodeMaterialConnectionPoint;
  62999. protected _buildBlock(state: NodeMaterialBuildState): this;
  63000. }
  63001. }
  63002. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63006. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63007. /**
  63008. * Block used to rotate a 2d vector by a given angle
  63009. */
  63010. export class Rotate2dBlock extends NodeMaterialBlock {
  63011. /**
  63012. * Creates a new Rotate2dBlock
  63013. * @param name defines the block name
  63014. */
  63015. constructor(name: string);
  63016. /**
  63017. * Gets the current class name
  63018. * @returns the class name
  63019. */
  63020. getClassName(): string;
  63021. /**
  63022. * Gets the input vector
  63023. */
  63024. get input(): NodeMaterialConnectionPoint;
  63025. /**
  63026. * Gets the input angle
  63027. */
  63028. get angle(): NodeMaterialConnectionPoint;
  63029. /**
  63030. * Gets the output component
  63031. */
  63032. get output(): NodeMaterialConnectionPoint;
  63033. autoConfigure(material: NodeMaterial): void;
  63034. protected _buildBlock(state: NodeMaterialBuildState): this;
  63035. }
  63036. }
  63037. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63041. /**
  63042. * Block used to get the reflected vector from a direction and a normal
  63043. */
  63044. export class ReflectBlock extends NodeMaterialBlock {
  63045. /**
  63046. * Creates a new ReflectBlock
  63047. * @param name defines the block name
  63048. */
  63049. constructor(name: string);
  63050. /**
  63051. * Gets the current class name
  63052. * @returns the class name
  63053. */
  63054. getClassName(): string;
  63055. /**
  63056. * Gets the incident component
  63057. */
  63058. get incident(): NodeMaterialConnectionPoint;
  63059. /**
  63060. * Gets the normal component
  63061. */
  63062. get normal(): NodeMaterialConnectionPoint;
  63063. /**
  63064. * Gets the output component
  63065. */
  63066. get output(): NodeMaterialConnectionPoint;
  63067. protected _buildBlock(state: NodeMaterialBuildState): this;
  63068. }
  63069. }
  63070. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63074. /**
  63075. * Block used to get the refracted vector from a direction and a normal
  63076. */
  63077. export class RefractBlock extends NodeMaterialBlock {
  63078. /**
  63079. * Creates a new RefractBlock
  63080. * @param name defines the block name
  63081. */
  63082. constructor(name: string);
  63083. /**
  63084. * Gets the current class name
  63085. * @returns the class name
  63086. */
  63087. getClassName(): string;
  63088. /**
  63089. * Gets the incident component
  63090. */
  63091. get incident(): NodeMaterialConnectionPoint;
  63092. /**
  63093. * Gets the normal component
  63094. */
  63095. get normal(): NodeMaterialConnectionPoint;
  63096. /**
  63097. * Gets the index of refraction component
  63098. */
  63099. get ior(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the output component
  63102. */
  63103. get output(): NodeMaterialConnectionPoint;
  63104. protected _buildBlock(state: NodeMaterialBuildState): this;
  63105. }
  63106. }
  63107. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63111. /**
  63112. * Block used to desaturate a color
  63113. */
  63114. export class DesaturateBlock extends NodeMaterialBlock {
  63115. /**
  63116. * Creates a new DesaturateBlock
  63117. * @param name defines the block name
  63118. */
  63119. constructor(name: string);
  63120. /**
  63121. * Gets the current class name
  63122. * @returns the class name
  63123. */
  63124. getClassName(): string;
  63125. /**
  63126. * Gets the color operand input component
  63127. */
  63128. get color(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the level operand input component
  63131. */
  63132. get level(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the output component
  63135. */
  63136. get output(): NodeMaterialConnectionPoint;
  63137. protected _buildBlock(state: NodeMaterialBuildState): this;
  63138. }
  63139. }
  63140. declare module "babylonjs/Materials/Node/Blocks/index" {
  63141. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63142. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63143. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63144. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63145. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63146. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63147. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63148. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63149. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63150. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63151. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63152. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63153. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63154. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63155. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63156. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63157. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63158. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63159. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63160. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63161. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63162. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63163. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63164. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63165. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63166. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63167. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63168. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63169. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63170. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63171. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63172. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63173. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63174. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63175. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63176. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63177. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63178. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63179. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63180. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63181. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63182. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63183. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63184. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63185. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63186. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63187. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63188. }
  63189. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63190. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63191. }
  63192. declare module "babylonjs/Materials/Node/index" {
  63193. export * from "babylonjs/Materials/Node/Enums/index";
  63194. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63195. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63196. export * from "babylonjs/Materials/Node/nodeMaterial";
  63197. export * from "babylonjs/Materials/Node/Blocks/index";
  63198. export * from "babylonjs/Materials/Node/Optimizers/index";
  63199. }
  63200. declare module "babylonjs/Materials/effectRenderer" {
  63201. import { Nullable } from "babylonjs/types";
  63202. import { Texture } from "babylonjs/Materials/Textures/texture";
  63203. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63204. import { Viewport } from "babylonjs/Maths/math.viewport";
  63205. import { Observable } from "babylonjs/Misc/observable";
  63206. import { Effect } from "babylonjs/Materials/effect";
  63207. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63208. import "babylonjs/Shaders/postprocess.vertex";
  63209. /**
  63210. * Effect Render Options
  63211. */
  63212. export interface IEffectRendererOptions {
  63213. /**
  63214. * Defines the vertices positions.
  63215. */
  63216. positions?: number[];
  63217. /**
  63218. * Defines the indices.
  63219. */
  63220. indices?: number[];
  63221. }
  63222. /**
  63223. * Helper class to render one or more effects
  63224. */
  63225. export class EffectRenderer {
  63226. private engine;
  63227. private static _DefaultOptions;
  63228. private _vertexBuffers;
  63229. private _indexBuffer;
  63230. private _ringBufferIndex;
  63231. private _ringScreenBuffer;
  63232. private _fullscreenViewport;
  63233. private _getNextFrameBuffer;
  63234. /**
  63235. * Creates an effect renderer
  63236. * @param engine the engine to use for rendering
  63237. * @param options defines the options of the effect renderer
  63238. */
  63239. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63240. /**
  63241. * Sets the current viewport in normalized coordinates 0-1
  63242. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63243. */
  63244. setViewport(viewport?: Viewport): void;
  63245. /**
  63246. * Binds the embedded attributes buffer to the effect.
  63247. * @param effect Defines the effect to bind the attributes for
  63248. */
  63249. bindBuffers(effect: Effect): void;
  63250. /**
  63251. * Sets the current effect wrapper to use during draw.
  63252. * The effect needs to be ready before calling this api.
  63253. * This also sets the default full screen position attribute.
  63254. * @param effectWrapper Defines the effect to draw with
  63255. */
  63256. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63257. /**
  63258. * Draws a full screen quad.
  63259. */
  63260. draw(): void;
  63261. /**
  63262. * renders one or more effects to a specified texture
  63263. * @param effectWrappers list of effects to renderer
  63264. * @param outputTexture texture to draw to, if null it will render to the screen
  63265. */
  63266. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63267. /**
  63268. * Disposes of the effect renderer
  63269. */
  63270. dispose(): void;
  63271. }
  63272. /**
  63273. * Options to create an EffectWrapper
  63274. */
  63275. interface EffectWrapperCreationOptions {
  63276. /**
  63277. * Engine to use to create the effect
  63278. */
  63279. engine: ThinEngine;
  63280. /**
  63281. * Fragment shader for the effect
  63282. */
  63283. fragmentShader: string;
  63284. /**
  63285. * Vertex shader for the effect
  63286. */
  63287. vertexShader?: string;
  63288. /**
  63289. * Attributes to use in the shader
  63290. */
  63291. attributeNames?: Array<string>;
  63292. /**
  63293. * Uniforms to use in the shader
  63294. */
  63295. uniformNames?: Array<string>;
  63296. /**
  63297. * Texture sampler names to use in the shader
  63298. */
  63299. samplerNames?: Array<string>;
  63300. /**
  63301. * The friendly name of the effect displayed in Spector.
  63302. */
  63303. name?: string;
  63304. }
  63305. /**
  63306. * Wraps an effect to be used for rendering
  63307. */
  63308. export class EffectWrapper {
  63309. /**
  63310. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63311. */
  63312. onApplyObservable: Observable<{}>;
  63313. /**
  63314. * The underlying effect
  63315. */
  63316. effect: Effect;
  63317. /**
  63318. * Creates an effect to be renderer
  63319. * @param creationOptions options to create the effect
  63320. */
  63321. constructor(creationOptions: EffectWrapperCreationOptions);
  63322. /**
  63323. * Disposes of the effect wrapper
  63324. */
  63325. dispose(): void;
  63326. }
  63327. }
  63328. declare module "babylonjs/Materials/index" {
  63329. export * from "babylonjs/Materials/Background/index";
  63330. export * from "babylonjs/Materials/colorCurves";
  63331. export * from "babylonjs/Materials/iEffectFallbacks";
  63332. export * from "babylonjs/Materials/effectFallbacks";
  63333. export * from "babylonjs/Materials/effect";
  63334. export * from "babylonjs/Materials/fresnelParameters";
  63335. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63336. export * from "babylonjs/Materials/material";
  63337. export * from "babylonjs/Materials/materialDefines";
  63338. export * from "babylonjs/Materials/materialHelper";
  63339. export * from "babylonjs/Materials/multiMaterial";
  63340. export * from "babylonjs/Materials/PBR/index";
  63341. export * from "babylonjs/Materials/pushMaterial";
  63342. export * from "babylonjs/Materials/shaderMaterial";
  63343. export * from "babylonjs/Materials/standardMaterial";
  63344. export * from "babylonjs/Materials/Textures/index";
  63345. export * from "babylonjs/Materials/uniformBuffer";
  63346. export * from "babylonjs/Materials/materialFlags";
  63347. export * from "babylonjs/Materials/Node/index";
  63348. export * from "babylonjs/Materials/effectRenderer";
  63349. }
  63350. declare module "babylonjs/Maths/index" {
  63351. export * from "babylonjs/Maths/math.scalar";
  63352. export * from "babylonjs/Maths/math";
  63353. export * from "babylonjs/Maths/sphericalPolynomial";
  63354. }
  63355. declare module "babylonjs/Misc/workerPool" {
  63356. import { IDisposable } from "babylonjs/scene";
  63357. /**
  63358. * Helper class to push actions to a pool of workers.
  63359. */
  63360. export class WorkerPool implements IDisposable {
  63361. private _workerInfos;
  63362. private _pendingActions;
  63363. /**
  63364. * Constructor
  63365. * @param workers Array of workers to use for actions
  63366. */
  63367. constructor(workers: Array<Worker>);
  63368. /**
  63369. * Terminates all workers and clears any pending actions.
  63370. */
  63371. dispose(): void;
  63372. /**
  63373. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63374. * pended until a worker has completed its action.
  63375. * @param action The action to perform. Call onComplete when the action is complete.
  63376. */
  63377. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63378. private _execute;
  63379. }
  63380. }
  63381. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63382. import { IDisposable } from "babylonjs/scene";
  63383. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63384. /**
  63385. * Configuration for Draco compression
  63386. */
  63387. export interface IDracoCompressionConfiguration {
  63388. /**
  63389. * Configuration for the decoder.
  63390. */
  63391. decoder: {
  63392. /**
  63393. * The url to the WebAssembly module.
  63394. */
  63395. wasmUrl?: string;
  63396. /**
  63397. * The url to the WebAssembly binary.
  63398. */
  63399. wasmBinaryUrl?: string;
  63400. /**
  63401. * The url to the fallback JavaScript module.
  63402. */
  63403. fallbackUrl?: string;
  63404. };
  63405. }
  63406. /**
  63407. * Draco compression (https://google.github.io/draco/)
  63408. *
  63409. * This class wraps the Draco module.
  63410. *
  63411. * **Encoder**
  63412. *
  63413. * The encoder is not currently implemented.
  63414. *
  63415. * **Decoder**
  63416. *
  63417. * 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.
  63418. *
  63419. * To update the configuration, use the following code:
  63420. * ```javascript
  63421. * DracoCompression.Configuration = {
  63422. * decoder: {
  63423. * wasmUrl: "<url to the WebAssembly library>",
  63424. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63425. * fallbackUrl: "<url to the fallback JavaScript library>",
  63426. * }
  63427. * };
  63428. * ```
  63429. *
  63430. * 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.
  63431. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63432. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63433. *
  63434. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63435. * ```javascript
  63436. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63437. * ```
  63438. *
  63439. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63440. */
  63441. export class DracoCompression implements IDisposable {
  63442. private _workerPoolPromise?;
  63443. private _decoderModulePromise?;
  63444. /**
  63445. * The configuration. Defaults to the following urls:
  63446. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63447. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63448. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63449. */
  63450. static Configuration: IDracoCompressionConfiguration;
  63451. /**
  63452. * Returns true if the decoder configuration is available.
  63453. */
  63454. static get DecoderAvailable(): boolean;
  63455. /**
  63456. * Default number of workers to create when creating the draco compression object.
  63457. */
  63458. static DefaultNumWorkers: number;
  63459. private static GetDefaultNumWorkers;
  63460. private static _Default;
  63461. /**
  63462. * Default instance for the draco compression object.
  63463. */
  63464. static get Default(): DracoCompression;
  63465. /**
  63466. * Constructor
  63467. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63468. */
  63469. constructor(numWorkers?: number);
  63470. /**
  63471. * Stop all async operations and release resources.
  63472. */
  63473. dispose(): void;
  63474. /**
  63475. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63476. * @returns a promise that resolves when ready
  63477. */
  63478. whenReadyAsync(): Promise<void>;
  63479. /**
  63480. * Decode Draco compressed mesh data to vertex data.
  63481. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63482. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63483. * @returns A promise that resolves with the decoded vertex data
  63484. */
  63485. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63486. [kind: string]: number;
  63487. }): Promise<VertexData>;
  63488. }
  63489. }
  63490. declare module "babylonjs/Meshes/Compression/index" {
  63491. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63492. }
  63493. declare module "babylonjs/Meshes/csg" {
  63494. import { Nullable } from "babylonjs/types";
  63495. import { Scene } from "babylonjs/scene";
  63496. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63497. import { Mesh } from "babylonjs/Meshes/mesh";
  63498. import { Material } from "babylonjs/Materials/material";
  63499. /**
  63500. * Class for building Constructive Solid Geometry
  63501. */
  63502. export class CSG {
  63503. private polygons;
  63504. /**
  63505. * The world matrix
  63506. */
  63507. matrix: Matrix;
  63508. /**
  63509. * Stores the position
  63510. */
  63511. position: Vector3;
  63512. /**
  63513. * Stores the rotation
  63514. */
  63515. rotation: Vector3;
  63516. /**
  63517. * Stores the rotation quaternion
  63518. */
  63519. rotationQuaternion: Nullable<Quaternion>;
  63520. /**
  63521. * Stores the scaling vector
  63522. */
  63523. scaling: Vector3;
  63524. /**
  63525. * Convert the Mesh to CSG
  63526. * @param mesh The Mesh to convert to CSG
  63527. * @returns A new CSG from the Mesh
  63528. */
  63529. static FromMesh(mesh: Mesh): CSG;
  63530. /**
  63531. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63532. * @param polygons Polygons used to construct a CSG solid
  63533. */
  63534. private static FromPolygons;
  63535. /**
  63536. * Clones, or makes a deep copy, of the CSG
  63537. * @returns A new CSG
  63538. */
  63539. clone(): CSG;
  63540. /**
  63541. * Unions this CSG with another CSG
  63542. * @param csg The CSG to union against this CSG
  63543. * @returns The unioned CSG
  63544. */
  63545. union(csg: CSG): CSG;
  63546. /**
  63547. * Unions this CSG with another CSG in place
  63548. * @param csg The CSG to union against this CSG
  63549. */
  63550. unionInPlace(csg: CSG): void;
  63551. /**
  63552. * Subtracts this CSG with another CSG
  63553. * @param csg The CSG to subtract against this CSG
  63554. * @returns A new CSG
  63555. */
  63556. subtract(csg: CSG): CSG;
  63557. /**
  63558. * Subtracts this CSG with another CSG in place
  63559. * @param csg The CSG to subtact against this CSG
  63560. */
  63561. subtractInPlace(csg: CSG): void;
  63562. /**
  63563. * Intersect this CSG with another CSG
  63564. * @param csg The CSG to intersect against this CSG
  63565. * @returns A new CSG
  63566. */
  63567. intersect(csg: CSG): CSG;
  63568. /**
  63569. * Intersects this CSG with another CSG in place
  63570. * @param csg The CSG to intersect against this CSG
  63571. */
  63572. intersectInPlace(csg: CSG): void;
  63573. /**
  63574. * Return a new CSG solid with solid and empty space switched. This solid is
  63575. * not modified.
  63576. * @returns A new CSG solid with solid and empty space switched
  63577. */
  63578. inverse(): CSG;
  63579. /**
  63580. * Inverses the CSG in place
  63581. */
  63582. inverseInPlace(): void;
  63583. /**
  63584. * This is used to keep meshes transformations so they can be restored
  63585. * when we build back a Babylon Mesh
  63586. * NB : All CSG operations are performed in world coordinates
  63587. * @param csg The CSG to copy the transform attributes from
  63588. * @returns This CSG
  63589. */
  63590. copyTransformAttributes(csg: CSG): CSG;
  63591. /**
  63592. * Build Raw mesh from CSG
  63593. * Coordinates here are in world space
  63594. * @param name The name of the mesh geometry
  63595. * @param scene The Scene
  63596. * @param keepSubMeshes Specifies if the submeshes should be kept
  63597. * @returns A new Mesh
  63598. */
  63599. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63600. /**
  63601. * Build Mesh from CSG taking material and transforms into account
  63602. * @param name The name of the Mesh
  63603. * @param material The material of the Mesh
  63604. * @param scene The Scene
  63605. * @param keepSubMeshes Specifies if submeshes should be kept
  63606. * @returns The new Mesh
  63607. */
  63608. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63609. }
  63610. }
  63611. declare module "babylonjs/Meshes/trailMesh" {
  63612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63613. import { Mesh } from "babylonjs/Meshes/mesh";
  63614. import { Scene } from "babylonjs/scene";
  63615. /**
  63616. * Class used to create a trail following a mesh
  63617. */
  63618. export class TrailMesh extends Mesh {
  63619. private _generator;
  63620. private _autoStart;
  63621. private _running;
  63622. private _diameter;
  63623. private _length;
  63624. private _sectionPolygonPointsCount;
  63625. private _sectionVectors;
  63626. private _sectionNormalVectors;
  63627. private _beforeRenderObserver;
  63628. /**
  63629. * @constructor
  63630. * @param name The value used by scene.getMeshByName() to do a lookup.
  63631. * @param generator The mesh to generate a trail.
  63632. * @param scene The scene to add this mesh to.
  63633. * @param diameter Diameter of trailing mesh. Default is 1.
  63634. * @param length Length of trailing mesh. Default is 60.
  63635. * @param autoStart Automatically start trailing mesh. Default true.
  63636. */
  63637. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63638. /**
  63639. * "TrailMesh"
  63640. * @returns "TrailMesh"
  63641. */
  63642. getClassName(): string;
  63643. private _createMesh;
  63644. /**
  63645. * Start trailing mesh.
  63646. */
  63647. start(): void;
  63648. /**
  63649. * Stop trailing mesh.
  63650. */
  63651. stop(): void;
  63652. /**
  63653. * Update trailing mesh geometry.
  63654. */
  63655. update(): void;
  63656. /**
  63657. * Returns a new TrailMesh object.
  63658. * @param name is a string, the name given to the new mesh
  63659. * @param newGenerator use new generator object for cloned trail mesh
  63660. * @returns a new mesh
  63661. */
  63662. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  63663. /**
  63664. * Serializes this trail mesh
  63665. * @param serializationObject object to write serialization to
  63666. */
  63667. serialize(serializationObject: any): void;
  63668. /**
  63669. * Parses a serialized trail mesh
  63670. * @param parsedMesh the serialized mesh
  63671. * @param scene the scene to create the trail mesh in
  63672. * @returns the created trail mesh
  63673. */
  63674. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63675. }
  63676. }
  63677. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63678. import { Nullable } from "babylonjs/types";
  63679. import { Scene } from "babylonjs/scene";
  63680. import { Vector4 } from "babylonjs/Maths/math.vector";
  63681. import { Color4 } from "babylonjs/Maths/math.color";
  63682. import { Mesh } from "babylonjs/Meshes/mesh";
  63683. /**
  63684. * Class containing static functions to help procedurally build meshes
  63685. */
  63686. export class TiledBoxBuilder {
  63687. /**
  63688. * Creates a box mesh
  63689. * 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)
  63690. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63694. * @param name defines the name of the mesh
  63695. * @param options defines the options used to create the mesh
  63696. * @param scene defines the hosting scene
  63697. * @returns the box mesh
  63698. */
  63699. static CreateTiledBox(name: string, options: {
  63700. pattern?: number;
  63701. width?: number;
  63702. height?: number;
  63703. depth?: number;
  63704. tileSize?: number;
  63705. tileWidth?: number;
  63706. tileHeight?: number;
  63707. alignHorizontal?: number;
  63708. alignVertical?: number;
  63709. faceUV?: Vector4[];
  63710. faceColors?: Color4[];
  63711. sideOrientation?: number;
  63712. updatable?: boolean;
  63713. }, scene?: Nullable<Scene>): Mesh;
  63714. }
  63715. }
  63716. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63717. import { Vector4 } from "babylonjs/Maths/math.vector";
  63718. import { Mesh } from "babylonjs/Meshes/mesh";
  63719. /**
  63720. * Class containing static functions to help procedurally build meshes
  63721. */
  63722. export class TorusKnotBuilder {
  63723. /**
  63724. * Creates a torus knot mesh
  63725. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63726. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63727. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63728. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63732. * @param name defines the name of the mesh
  63733. * @param options defines the options used to create the mesh
  63734. * @param scene defines the hosting scene
  63735. * @returns the torus knot mesh
  63736. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63737. */
  63738. static CreateTorusKnot(name: string, options: {
  63739. radius?: number;
  63740. tube?: number;
  63741. radialSegments?: number;
  63742. tubularSegments?: number;
  63743. p?: number;
  63744. q?: number;
  63745. updatable?: boolean;
  63746. sideOrientation?: number;
  63747. frontUVs?: Vector4;
  63748. backUVs?: Vector4;
  63749. }, scene: any): Mesh;
  63750. }
  63751. }
  63752. declare module "babylonjs/Meshes/polygonMesh" {
  63753. import { Scene } from "babylonjs/scene";
  63754. import { Vector2 } from "babylonjs/Maths/math.vector";
  63755. import { Mesh } from "babylonjs/Meshes/mesh";
  63756. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63757. import { Path2 } from "babylonjs/Maths/math.path";
  63758. /**
  63759. * Polygon
  63760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63761. */
  63762. export class Polygon {
  63763. /**
  63764. * Creates a rectangle
  63765. * @param xmin bottom X coord
  63766. * @param ymin bottom Y coord
  63767. * @param xmax top X coord
  63768. * @param ymax top Y coord
  63769. * @returns points that make the resulting rectation
  63770. */
  63771. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63772. /**
  63773. * Creates a circle
  63774. * @param radius radius of circle
  63775. * @param cx scale in x
  63776. * @param cy scale in y
  63777. * @param numberOfSides number of sides that make up the circle
  63778. * @returns points that make the resulting circle
  63779. */
  63780. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63781. /**
  63782. * Creates a polygon from input string
  63783. * @param input Input polygon data
  63784. * @returns the parsed points
  63785. */
  63786. static Parse(input: string): Vector2[];
  63787. /**
  63788. * Starts building a polygon from x and y coordinates
  63789. * @param x x coordinate
  63790. * @param y y coordinate
  63791. * @returns the started path2
  63792. */
  63793. static StartingAt(x: number, y: number): Path2;
  63794. }
  63795. /**
  63796. * Builds a polygon
  63797. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63798. */
  63799. export class PolygonMeshBuilder {
  63800. private _points;
  63801. private _outlinepoints;
  63802. private _holes;
  63803. private _name;
  63804. private _scene;
  63805. private _epoints;
  63806. private _eholes;
  63807. private _addToepoint;
  63808. /**
  63809. * Babylon reference to the earcut plugin.
  63810. */
  63811. bjsEarcut: any;
  63812. /**
  63813. * Creates a PolygonMeshBuilder
  63814. * @param name name of the builder
  63815. * @param contours Path of the polygon
  63816. * @param scene scene to add to when creating the mesh
  63817. * @param earcutInjection can be used to inject your own earcut reference
  63818. */
  63819. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63820. /**
  63821. * Adds a whole within the polygon
  63822. * @param hole Array of points defining the hole
  63823. * @returns this
  63824. */
  63825. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63826. /**
  63827. * Creates the polygon
  63828. * @param updatable If the mesh should be updatable
  63829. * @param depth The depth of the mesh created
  63830. * @returns the created mesh
  63831. */
  63832. build(updatable?: boolean, depth?: number): Mesh;
  63833. /**
  63834. * Creates the polygon
  63835. * @param depth The depth of the mesh created
  63836. * @returns the created VertexData
  63837. */
  63838. buildVertexData(depth?: number): VertexData;
  63839. /**
  63840. * Adds a side to the polygon
  63841. * @param positions points that make the polygon
  63842. * @param normals normals of the polygon
  63843. * @param uvs uvs of the polygon
  63844. * @param indices indices of the polygon
  63845. * @param bounds bounds of the polygon
  63846. * @param points points of the polygon
  63847. * @param depth depth of the polygon
  63848. * @param flip flip of the polygon
  63849. */
  63850. private addSide;
  63851. }
  63852. }
  63853. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63854. import { Scene } from "babylonjs/scene";
  63855. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63856. import { Color4 } from "babylonjs/Maths/math.color";
  63857. import { Mesh } from "babylonjs/Meshes/mesh";
  63858. import { Nullable } from "babylonjs/types";
  63859. /**
  63860. * Class containing static functions to help procedurally build meshes
  63861. */
  63862. export class PolygonBuilder {
  63863. /**
  63864. * Creates a polygon mesh
  63865. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63866. * * 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
  63867. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63870. * * Remember you can only change the shape positions, not their number when updating a polygon
  63871. * @param name defines the name of the mesh
  63872. * @param options defines the options used to create the mesh
  63873. * @param scene defines the hosting scene
  63874. * @param earcutInjection can be used to inject your own earcut reference
  63875. * @returns the polygon mesh
  63876. */
  63877. static CreatePolygon(name: string, options: {
  63878. shape: Vector3[];
  63879. holes?: Vector3[][];
  63880. depth?: number;
  63881. faceUV?: Vector4[];
  63882. faceColors?: Color4[];
  63883. updatable?: boolean;
  63884. sideOrientation?: number;
  63885. frontUVs?: Vector4;
  63886. backUVs?: Vector4;
  63887. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63888. /**
  63889. * Creates an extruded polygon mesh, with depth in the Y direction.
  63890. * * 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)
  63891. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63892. * @param name defines the name of the mesh
  63893. * @param options defines the options used to create the mesh
  63894. * @param scene defines the hosting scene
  63895. * @param earcutInjection can be used to inject your own earcut reference
  63896. * @returns the polygon mesh
  63897. */
  63898. static ExtrudePolygon(name: string, options: {
  63899. shape: Vector3[];
  63900. holes?: Vector3[][];
  63901. depth?: number;
  63902. faceUV?: Vector4[];
  63903. faceColors?: Color4[];
  63904. updatable?: boolean;
  63905. sideOrientation?: number;
  63906. frontUVs?: Vector4;
  63907. backUVs?: Vector4;
  63908. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63909. }
  63910. }
  63911. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63912. import { Scene } from "babylonjs/scene";
  63913. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63914. import { Mesh } from "babylonjs/Meshes/mesh";
  63915. import { Nullable } from "babylonjs/types";
  63916. /**
  63917. * Class containing static functions to help procedurally build meshes
  63918. */
  63919. export class LatheBuilder {
  63920. /**
  63921. * Creates lathe mesh.
  63922. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63923. * * 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
  63924. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63925. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63926. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63927. * * 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
  63928. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63929. * * 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
  63930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 lathe mesh
  63938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63939. */
  63940. static CreateLathe(name: string, options: {
  63941. shape: Vector3[];
  63942. radius?: number;
  63943. tessellation?: number;
  63944. clip?: number;
  63945. arc?: number;
  63946. closed?: boolean;
  63947. updatable?: boolean;
  63948. sideOrientation?: number;
  63949. frontUVs?: Vector4;
  63950. backUVs?: Vector4;
  63951. cap?: number;
  63952. invertUV?: boolean;
  63953. }, scene?: Nullable<Scene>): Mesh;
  63954. }
  63955. }
  63956. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63957. import { Nullable } from "babylonjs/types";
  63958. import { Scene } from "babylonjs/scene";
  63959. import { Vector4 } from "babylonjs/Maths/math.vector";
  63960. import { Mesh } from "babylonjs/Meshes/mesh";
  63961. /**
  63962. * Class containing static functions to help procedurally build meshes
  63963. */
  63964. export class TiledPlaneBuilder {
  63965. /**
  63966. * Creates a tiled plane mesh
  63967. * * The parameter `pattern` will, depending on value, do nothing or
  63968. * * * flip (reflect about central vertical) alternate tiles across and up
  63969. * * * flip every tile on alternate rows
  63970. * * * rotate (180 degs) alternate tiles across and up
  63971. * * * rotate every tile on alternate rows
  63972. * * * flip and rotate alternate tiles across and up
  63973. * * * flip and rotate every tile on alternate rows
  63974. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63975. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63978. * * 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)
  63979. * * 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)
  63980. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63981. * @param name defines the name of the mesh
  63982. * @param options defines the options used to create the mesh
  63983. * @param scene defines the hosting scene
  63984. * @returns the box mesh
  63985. */
  63986. static CreateTiledPlane(name: string, options: {
  63987. pattern?: number;
  63988. tileSize?: number;
  63989. tileWidth?: number;
  63990. tileHeight?: number;
  63991. size?: number;
  63992. width?: number;
  63993. height?: number;
  63994. alignHorizontal?: number;
  63995. alignVertical?: number;
  63996. sideOrientation?: number;
  63997. frontUVs?: Vector4;
  63998. backUVs?: Vector4;
  63999. updatable?: boolean;
  64000. }, scene?: Nullable<Scene>): Mesh;
  64001. }
  64002. }
  64003. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64004. import { Nullable } from "babylonjs/types";
  64005. import { Scene } from "babylonjs/scene";
  64006. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64007. import { Mesh } from "babylonjs/Meshes/mesh";
  64008. /**
  64009. * Class containing static functions to help procedurally build meshes
  64010. */
  64011. export class TubeBuilder {
  64012. /**
  64013. * Creates a tube mesh.
  64014. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64015. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64016. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64017. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64018. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64019. * * 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)
  64020. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64021. * * 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
  64022. * * 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
  64023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64027. * @param name defines the name of the mesh
  64028. * @param options defines the options used to create the mesh
  64029. * @param scene defines the hosting scene
  64030. * @returns the tube mesh
  64031. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64032. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64033. */
  64034. static CreateTube(name: string, options: {
  64035. path: Vector3[];
  64036. radius?: number;
  64037. tessellation?: number;
  64038. radiusFunction?: {
  64039. (i: number, distance: number): number;
  64040. };
  64041. cap?: number;
  64042. arc?: number;
  64043. updatable?: boolean;
  64044. sideOrientation?: number;
  64045. frontUVs?: Vector4;
  64046. backUVs?: Vector4;
  64047. instance?: Mesh;
  64048. invertUV?: boolean;
  64049. }, scene?: Nullable<Scene>): Mesh;
  64050. }
  64051. }
  64052. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64053. import { Scene } from "babylonjs/scene";
  64054. import { Vector4 } from "babylonjs/Maths/math.vector";
  64055. import { Mesh } from "babylonjs/Meshes/mesh";
  64056. import { Nullable } from "babylonjs/types";
  64057. /**
  64058. * Class containing static functions to help procedurally build meshes
  64059. */
  64060. export class IcoSphereBuilder {
  64061. /**
  64062. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64063. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64064. * * 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`)
  64065. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64066. * * 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
  64067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64070. * @param name defines the name of the mesh
  64071. * @param options defines the options used to create the mesh
  64072. * @param scene defines the hosting scene
  64073. * @returns the icosahedron mesh
  64074. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64075. */
  64076. static CreateIcoSphere(name: string, options: {
  64077. radius?: number;
  64078. radiusX?: number;
  64079. radiusY?: number;
  64080. radiusZ?: number;
  64081. flat?: boolean;
  64082. subdivisions?: number;
  64083. sideOrientation?: number;
  64084. frontUVs?: Vector4;
  64085. backUVs?: Vector4;
  64086. updatable?: boolean;
  64087. }, scene?: Nullable<Scene>): Mesh;
  64088. }
  64089. }
  64090. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64091. import { Vector3 } from "babylonjs/Maths/math.vector";
  64092. import { Mesh } from "babylonjs/Meshes/mesh";
  64093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64094. /**
  64095. * Class containing static functions to help procedurally build meshes
  64096. */
  64097. export class DecalBuilder {
  64098. /**
  64099. * Creates a decal mesh.
  64100. * 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
  64101. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64102. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64103. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64104. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64105. * @param name defines the name of the mesh
  64106. * @param sourceMesh defines the mesh where the decal must be applied
  64107. * @param options defines the options used to create the mesh
  64108. * @param scene defines the hosting scene
  64109. * @returns the decal mesh
  64110. * @see https://doc.babylonjs.com/how_to/decals
  64111. */
  64112. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64113. position?: Vector3;
  64114. normal?: Vector3;
  64115. size?: Vector3;
  64116. angle?: number;
  64117. }): Mesh;
  64118. }
  64119. }
  64120. declare module "babylonjs/Meshes/meshBuilder" {
  64121. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64122. import { Nullable } from "babylonjs/types";
  64123. import { Scene } from "babylonjs/scene";
  64124. import { Mesh } from "babylonjs/Meshes/mesh";
  64125. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64126. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64128. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64129. import { Plane } from "babylonjs/Maths/math.plane";
  64130. /**
  64131. * Class containing static functions to help procedurally build meshes
  64132. */
  64133. export class MeshBuilder {
  64134. /**
  64135. * Creates a box mesh
  64136. * * The parameter `size` sets the size (float) of each box side (default 1)
  64137. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64138. * * 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)
  64139. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64143. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64144. * @param name defines the name of the mesh
  64145. * @param options defines the options used to create the mesh
  64146. * @param scene defines the hosting scene
  64147. * @returns the box mesh
  64148. */
  64149. static CreateBox(name: string, options: {
  64150. size?: number;
  64151. width?: number;
  64152. height?: number;
  64153. depth?: number;
  64154. faceUV?: Vector4[];
  64155. faceColors?: Color4[];
  64156. sideOrientation?: number;
  64157. frontUVs?: Vector4;
  64158. backUVs?: Vector4;
  64159. updatable?: boolean;
  64160. }, scene?: Nullable<Scene>): Mesh;
  64161. /**
  64162. * Creates a tiled box mesh
  64163. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64165. * @param name defines the name of the mesh
  64166. * @param options defines the options used to create the mesh
  64167. * @param scene defines the hosting scene
  64168. * @returns the tiled box mesh
  64169. */
  64170. static CreateTiledBox(name: string, options: {
  64171. pattern?: number;
  64172. size?: number;
  64173. width?: number;
  64174. height?: number;
  64175. depth: number;
  64176. tileSize?: number;
  64177. tileWidth?: number;
  64178. tileHeight?: number;
  64179. faceUV?: Vector4[];
  64180. faceColors?: Color4[];
  64181. alignHorizontal?: number;
  64182. alignVertical?: number;
  64183. sideOrientation?: number;
  64184. updatable?: boolean;
  64185. }, scene?: Nullable<Scene>): Mesh;
  64186. /**
  64187. * Creates a sphere mesh
  64188. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64189. * * 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`)
  64190. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64191. * * 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
  64192. * * 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)
  64193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64196. * @param name defines the name of the mesh
  64197. * @param options defines the options used to create the mesh
  64198. * @param scene defines the hosting scene
  64199. * @returns the sphere mesh
  64200. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64201. */
  64202. static CreateSphere(name: string, options: {
  64203. segments?: number;
  64204. diameter?: number;
  64205. diameterX?: number;
  64206. diameterY?: number;
  64207. diameterZ?: number;
  64208. arc?: number;
  64209. slice?: number;
  64210. sideOrientation?: number;
  64211. frontUVs?: Vector4;
  64212. backUVs?: Vector4;
  64213. updatable?: boolean;
  64214. }, scene?: Nullable<Scene>): Mesh;
  64215. /**
  64216. * Creates a plane polygonal mesh. By default, this is a disc
  64217. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64218. * * 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
  64219. * * 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
  64220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64223. * @param name defines the name of the mesh
  64224. * @param options defines the options used to create the mesh
  64225. * @param scene defines the hosting scene
  64226. * @returns the plane polygonal mesh
  64227. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64228. */
  64229. static CreateDisc(name: string, options: {
  64230. radius?: number;
  64231. tessellation?: number;
  64232. arc?: number;
  64233. updatable?: boolean;
  64234. sideOrientation?: number;
  64235. frontUVs?: Vector4;
  64236. backUVs?: Vector4;
  64237. }, scene?: Nullable<Scene>): Mesh;
  64238. /**
  64239. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64240. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64241. * * 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`)
  64242. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64243. * * 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
  64244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64247. * @param name defines the name of the mesh
  64248. * @param options defines the options used to create the mesh
  64249. * @param scene defines the hosting scene
  64250. * @returns the icosahedron mesh
  64251. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64252. */
  64253. static CreateIcoSphere(name: string, options: {
  64254. radius?: number;
  64255. radiusX?: number;
  64256. radiusY?: number;
  64257. radiusZ?: number;
  64258. flat?: boolean;
  64259. subdivisions?: number;
  64260. sideOrientation?: number;
  64261. frontUVs?: Vector4;
  64262. backUVs?: Vector4;
  64263. updatable?: boolean;
  64264. }, scene?: Nullable<Scene>): Mesh;
  64265. /**
  64266. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64267. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64268. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64269. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64270. * * 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
  64271. * * 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
  64272. * * 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
  64273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64276. * * 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
  64277. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64278. * * 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
  64279. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64281. * @param name defines the name of the mesh
  64282. * @param options defines the options used to create the mesh
  64283. * @param scene defines the hosting scene
  64284. * @returns the ribbon mesh
  64285. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64286. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64287. */
  64288. static CreateRibbon(name: string, options: {
  64289. pathArray: Vector3[][];
  64290. closeArray?: boolean;
  64291. closePath?: boolean;
  64292. offset?: number;
  64293. updatable?: boolean;
  64294. sideOrientation?: number;
  64295. frontUVs?: Vector4;
  64296. backUVs?: Vector4;
  64297. instance?: Mesh;
  64298. invertUV?: boolean;
  64299. uvs?: Vector2[];
  64300. colors?: Color4[];
  64301. }, scene?: Nullable<Scene>): Mesh;
  64302. /**
  64303. * Creates a cylinder or a cone mesh
  64304. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64305. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64306. * * 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.
  64307. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64308. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64309. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64310. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64311. * * 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).
  64312. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64313. * * 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).
  64314. * * 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
  64315. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64316. * * 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
  64317. * * 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.
  64318. * * If `enclose` is false, a ring surface is one element.
  64319. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64320. * * 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
  64321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64324. * @param name defines the name of the mesh
  64325. * @param options defines the options used to create the mesh
  64326. * @param scene defines the hosting scene
  64327. * @returns the cylinder mesh
  64328. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64329. */
  64330. static CreateCylinder(name: string, options: {
  64331. height?: number;
  64332. diameterTop?: number;
  64333. diameterBottom?: number;
  64334. diameter?: number;
  64335. tessellation?: number;
  64336. subdivisions?: number;
  64337. arc?: number;
  64338. faceColors?: Color4[];
  64339. faceUV?: Vector4[];
  64340. updatable?: boolean;
  64341. hasRings?: boolean;
  64342. enclose?: boolean;
  64343. cap?: number;
  64344. sideOrientation?: number;
  64345. frontUVs?: Vector4;
  64346. backUVs?: Vector4;
  64347. }, scene?: Nullable<Scene>): Mesh;
  64348. /**
  64349. * Creates a torus mesh
  64350. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64351. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64352. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64356. * @param name defines the name of the mesh
  64357. * @param options defines the options used to create the mesh
  64358. * @param scene defines the hosting scene
  64359. * @returns the torus mesh
  64360. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64361. */
  64362. static CreateTorus(name: string, options: {
  64363. diameter?: number;
  64364. thickness?: number;
  64365. tessellation?: number;
  64366. updatable?: boolean;
  64367. sideOrientation?: number;
  64368. frontUVs?: Vector4;
  64369. backUVs?: Vector4;
  64370. }, scene?: Nullable<Scene>): Mesh;
  64371. /**
  64372. * Creates a torus knot mesh
  64373. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64374. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64375. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64376. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64380. * @param name defines the name of the mesh
  64381. * @param options defines the options used to create the mesh
  64382. * @param scene defines the hosting scene
  64383. * @returns the torus knot mesh
  64384. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64385. */
  64386. static CreateTorusKnot(name: string, options: {
  64387. radius?: number;
  64388. tube?: number;
  64389. radialSegments?: number;
  64390. tubularSegments?: number;
  64391. p?: number;
  64392. q?: number;
  64393. updatable?: boolean;
  64394. sideOrientation?: number;
  64395. frontUVs?: Vector4;
  64396. backUVs?: Vector4;
  64397. }, scene?: Nullable<Scene>): Mesh;
  64398. /**
  64399. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64400. * * 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
  64401. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64402. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64403. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64404. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64405. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64406. * * 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
  64407. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64410. * @param name defines the name of the new line system
  64411. * @param options defines the options used to create the line system
  64412. * @param scene defines the hosting scene
  64413. * @returns a new line system mesh
  64414. */
  64415. static CreateLineSystem(name: string, options: {
  64416. lines: Vector3[][];
  64417. updatable?: boolean;
  64418. instance?: Nullable<LinesMesh>;
  64419. colors?: Nullable<Color4[][]>;
  64420. useVertexAlpha?: boolean;
  64421. }, scene: Nullable<Scene>): LinesMesh;
  64422. /**
  64423. * Creates a line mesh
  64424. * 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
  64425. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64426. * * The parameter `points` is an array successive Vector3
  64427. * * 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
  64428. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64429. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64430. * * When updating an instance, remember that only point positions can change, not the number of points
  64431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64433. * @param name defines the name of the new line system
  64434. * @param options defines the options used to create the line system
  64435. * @param scene defines the hosting scene
  64436. * @returns a new line mesh
  64437. */
  64438. static CreateLines(name: string, options: {
  64439. points: Vector3[];
  64440. updatable?: boolean;
  64441. instance?: Nullable<LinesMesh>;
  64442. colors?: Color4[];
  64443. useVertexAlpha?: boolean;
  64444. }, scene?: Nullable<Scene>): LinesMesh;
  64445. /**
  64446. * Creates a dashed line mesh
  64447. * * 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
  64448. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64449. * * The parameter `points` is an array successive Vector3
  64450. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64451. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64452. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64453. * * 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
  64454. * * When updating an instance, remember that only point positions can change, not the number of points
  64455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64456. * @param name defines the name of the mesh
  64457. * @param options defines the options used to create the mesh
  64458. * @param scene defines the hosting scene
  64459. * @returns the dashed line mesh
  64460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64461. */
  64462. static CreateDashedLines(name: string, options: {
  64463. points: Vector3[];
  64464. dashSize?: number;
  64465. gapSize?: number;
  64466. dashNb?: number;
  64467. updatable?: boolean;
  64468. instance?: LinesMesh;
  64469. }, scene?: Nullable<Scene>): LinesMesh;
  64470. /**
  64471. * 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.
  64472. * * 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.
  64473. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64474. * * 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.
  64475. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64476. * * 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
  64477. * * 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
  64478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64483. * @param name defines the name of the mesh
  64484. * @param options defines the options used to create the mesh
  64485. * @param scene defines the hosting scene
  64486. * @returns the extruded shape mesh
  64487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64489. */
  64490. static ExtrudeShape(name: string, options: {
  64491. shape: Vector3[];
  64492. path: Vector3[];
  64493. scale?: number;
  64494. rotation?: number;
  64495. cap?: number;
  64496. updatable?: boolean;
  64497. sideOrientation?: number;
  64498. frontUVs?: Vector4;
  64499. backUVs?: Vector4;
  64500. instance?: Mesh;
  64501. invertUV?: boolean;
  64502. }, scene?: Nullable<Scene>): Mesh;
  64503. /**
  64504. * Creates an custom extruded shape mesh.
  64505. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64506. * * 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.
  64507. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64508. * * 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
  64509. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64510. * * 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
  64511. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64512. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64513. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64514. * * 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
  64515. * * 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
  64516. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64521. * @param name defines the name of the mesh
  64522. * @param options defines the options used to create the mesh
  64523. * @param scene defines the hosting scene
  64524. * @returns the custom extruded shape mesh
  64525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64528. */
  64529. static ExtrudeShapeCustom(name: string, options: {
  64530. shape: Vector3[];
  64531. path: Vector3[];
  64532. scaleFunction?: any;
  64533. rotationFunction?: any;
  64534. ribbonCloseArray?: boolean;
  64535. ribbonClosePath?: boolean;
  64536. cap?: number;
  64537. updatable?: boolean;
  64538. sideOrientation?: number;
  64539. frontUVs?: Vector4;
  64540. backUVs?: Vector4;
  64541. instance?: Mesh;
  64542. invertUV?: boolean;
  64543. }, scene?: Nullable<Scene>): Mesh;
  64544. /**
  64545. * Creates lathe mesh.
  64546. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64547. * * 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
  64548. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64549. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64550. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64551. * * 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
  64552. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64553. * * 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
  64554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64558. * @param name defines the name of the mesh
  64559. * @param options defines the options used to create the mesh
  64560. * @param scene defines the hosting scene
  64561. * @returns the lathe mesh
  64562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64563. */
  64564. static CreateLathe(name: string, options: {
  64565. shape: Vector3[];
  64566. radius?: number;
  64567. tessellation?: number;
  64568. clip?: number;
  64569. arc?: number;
  64570. closed?: boolean;
  64571. updatable?: boolean;
  64572. sideOrientation?: number;
  64573. frontUVs?: Vector4;
  64574. backUVs?: Vector4;
  64575. cap?: number;
  64576. invertUV?: boolean;
  64577. }, scene?: Nullable<Scene>): Mesh;
  64578. /**
  64579. * Creates a tiled plane mesh
  64580. * * You can set a limited pattern arrangement with the tiles
  64581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64584. * @param name defines the name of the mesh
  64585. * @param options defines the options used to create the mesh
  64586. * @param scene defines the hosting scene
  64587. * @returns the plane mesh
  64588. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64589. */
  64590. static CreateTiledPlane(name: string, options: {
  64591. pattern?: number;
  64592. tileSize?: number;
  64593. tileWidth?: number;
  64594. tileHeight?: number;
  64595. size?: number;
  64596. width?: number;
  64597. height?: number;
  64598. alignHorizontal?: number;
  64599. alignVertical?: number;
  64600. sideOrientation?: number;
  64601. frontUVs?: Vector4;
  64602. backUVs?: Vector4;
  64603. updatable?: boolean;
  64604. }, scene?: Nullable<Scene>): Mesh;
  64605. /**
  64606. * Creates a plane mesh
  64607. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64608. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64609. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64613. * @param name defines the name of the mesh
  64614. * @param options defines the options used to create the mesh
  64615. * @param scene defines the hosting scene
  64616. * @returns the plane mesh
  64617. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64618. */
  64619. static CreatePlane(name: string, options: {
  64620. size?: number;
  64621. width?: number;
  64622. height?: number;
  64623. sideOrientation?: number;
  64624. frontUVs?: Vector4;
  64625. backUVs?: Vector4;
  64626. updatable?: boolean;
  64627. sourcePlane?: Plane;
  64628. }, scene?: Nullable<Scene>): Mesh;
  64629. /**
  64630. * Creates a ground mesh
  64631. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64632. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64634. * @param name defines the name of the mesh
  64635. * @param options defines the options used to create the mesh
  64636. * @param scene defines the hosting scene
  64637. * @returns the ground mesh
  64638. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64639. */
  64640. static CreateGround(name: string, options: {
  64641. width?: number;
  64642. height?: number;
  64643. subdivisions?: number;
  64644. subdivisionsX?: number;
  64645. subdivisionsY?: number;
  64646. updatable?: boolean;
  64647. }, scene?: Nullable<Scene>): Mesh;
  64648. /**
  64649. * Creates a tiled ground mesh
  64650. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64651. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64652. * * 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
  64653. * * 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
  64654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64655. * @param name defines the name of the mesh
  64656. * @param options defines the options used to create the mesh
  64657. * @param scene defines the hosting scene
  64658. * @returns the tiled ground mesh
  64659. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64660. */
  64661. static CreateTiledGround(name: string, options: {
  64662. xmin: number;
  64663. zmin: number;
  64664. xmax: number;
  64665. zmax: number;
  64666. subdivisions?: {
  64667. w: number;
  64668. h: number;
  64669. };
  64670. precision?: {
  64671. w: number;
  64672. h: number;
  64673. };
  64674. updatable?: boolean;
  64675. }, scene?: Nullable<Scene>): Mesh;
  64676. /**
  64677. * Creates a ground mesh from a height map
  64678. * * The parameter `url` sets the URL of the height map image resource.
  64679. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64680. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64681. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64682. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64683. * * 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.
  64684. * * 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).
  64685. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64687. * @param name defines the name of the mesh
  64688. * @param url defines the url to the height map
  64689. * @param options defines the options used to create the mesh
  64690. * @param scene defines the hosting scene
  64691. * @returns the ground mesh
  64692. * @see https://doc.babylonjs.com/babylon101/height_map
  64693. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64694. */
  64695. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64696. width?: number;
  64697. height?: number;
  64698. subdivisions?: number;
  64699. minHeight?: number;
  64700. maxHeight?: number;
  64701. colorFilter?: Color3;
  64702. alphaFilter?: number;
  64703. updatable?: boolean;
  64704. onReady?: (mesh: GroundMesh) => void;
  64705. }, scene?: Nullable<Scene>): GroundMesh;
  64706. /**
  64707. * Creates a polygon mesh
  64708. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64709. * * 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
  64710. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64713. * * Remember you can only change the shape positions, not their number when updating a polygon
  64714. * @param name defines the name of the mesh
  64715. * @param options defines the options used to create the mesh
  64716. * @param scene defines the hosting scene
  64717. * @param earcutInjection can be used to inject your own earcut reference
  64718. * @returns the polygon mesh
  64719. */
  64720. static CreatePolygon(name: string, options: {
  64721. shape: Vector3[];
  64722. holes?: Vector3[][];
  64723. depth?: number;
  64724. faceUV?: Vector4[];
  64725. faceColors?: Color4[];
  64726. updatable?: boolean;
  64727. sideOrientation?: number;
  64728. frontUVs?: Vector4;
  64729. backUVs?: Vector4;
  64730. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64731. /**
  64732. * Creates an extruded polygon mesh, with depth in the Y direction.
  64733. * * 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)
  64734. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64735. * @param name defines the name of the mesh
  64736. * @param options defines the options used to create the mesh
  64737. * @param scene defines the hosting scene
  64738. * @param earcutInjection can be used to inject your own earcut reference
  64739. * @returns the polygon mesh
  64740. */
  64741. static ExtrudePolygon(name: string, options: {
  64742. shape: Vector3[];
  64743. holes?: Vector3[][];
  64744. depth?: number;
  64745. faceUV?: Vector4[];
  64746. faceColors?: Color4[];
  64747. updatable?: boolean;
  64748. sideOrientation?: number;
  64749. frontUVs?: Vector4;
  64750. backUVs?: Vector4;
  64751. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64752. /**
  64753. * Creates a tube mesh.
  64754. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64755. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64756. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64757. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64758. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64759. * * 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)
  64760. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64761. * * 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
  64762. * * 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
  64763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64767. * @param name defines the name of the mesh
  64768. * @param options defines the options used to create the mesh
  64769. * @param scene defines the hosting scene
  64770. * @returns the tube mesh
  64771. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64772. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64773. */
  64774. static CreateTube(name: string, options: {
  64775. path: Vector3[];
  64776. radius?: number;
  64777. tessellation?: number;
  64778. radiusFunction?: {
  64779. (i: number, distance: number): number;
  64780. };
  64781. cap?: number;
  64782. arc?: number;
  64783. updatable?: boolean;
  64784. sideOrientation?: number;
  64785. frontUVs?: Vector4;
  64786. backUVs?: Vector4;
  64787. instance?: Mesh;
  64788. invertUV?: boolean;
  64789. }, scene?: Nullable<Scene>): Mesh;
  64790. /**
  64791. * Creates a polyhedron mesh
  64792. * * 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
  64793. * * The parameter `size` (positive float, default 1) sets the polygon size
  64794. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64795. * * 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`
  64796. * * 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
  64797. * * 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)`)
  64798. * * 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
  64799. * * 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
  64800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64803. * @param name defines the name of the mesh
  64804. * @param options defines the options used to create the mesh
  64805. * @param scene defines the hosting scene
  64806. * @returns the polyhedron mesh
  64807. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64808. */
  64809. static CreatePolyhedron(name: string, options: {
  64810. type?: number;
  64811. size?: number;
  64812. sizeX?: number;
  64813. sizeY?: number;
  64814. sizeZ?: number;
  64815. custom?: any;
  64816. faceUV?: Vector4[];
  64817. faceColors?: Color4[];
  64818. flat?: boolean;
  64819. updatable?: boolean;
  64820. sideOrientation?: number;
  64821. frontUVs?: Vector4;
  64822. backUVs?: Vector4;
  64823. }, scene?: Nullable<Scene>): Mesh;
  64824. /**
  64825. * Creates a decal mesh.
  64826. * 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
  64827. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64828. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64829. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64830. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64831. * @param name defines the name of the mesh
  64832. * @param sourceMesh defines the mesh where the decal must be applied
  64833. * @param options defines the options used to create the mesh
  64834. * @param scene defines the hosting scene
  64835. * @returns the decal mesh
  64836. * @see https://doc.babylonjs.com/how_to/decals
  64837. */
  64838. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64839. position?: Vector3;
  64840. normal?: Vector3;
  64841. size?: Vector3;
  64842. angle?: number;
  64843. }): Mesh;
  64844. }
  64845. }
  64846. declare module "babylonjs/Meshes/meshSimplification" {
  64847. import { Mesh } from "babylonjs/Meshes/mesh";
  64848. /**
  64849. * A simplifier interface for future simplification implementations
  64850. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64851. */
  64852. export interface ISimplifier {
  64853. /**
  64854. * Simplification of a given mesh according to the given settings.
  64855. * Since this requires computation, it is assumed that the function runs async.
  64856. * @param settings The settings of the simplification, including quality and distance
  64857. * @param successCallback A callback that will be called after the mesh was simplified.
  64858. * @param errorCallback in case of an error, this callback will be called. optional.
  64859. */
  64860. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64861. }
  64862. /**
  64863. * Expected simplification settings.
  64864. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64865. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64866. */
  64867. export interface ISimplificationSettings {
  64868. /**
  64869. * Gets or sets the expected quality
  64870. */
  64871. quality: number;
  64872. /**
  64873. * Gets or sets the distance when this optimized version should be used
  64874. */
  64875. distance: number;
  64876. /**
  64877. * Gets an already optimized mesh
  64878. */
  64879. optimizeMesh?: boolean;
  64880. }
  64881. /**
  64882. * Class used to specify simplification options
  64883. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64884. */
  64885. export class SimplificationSettings implements ISimplificationSettings {
  64886. /** expected quality */
  64887. quality: number;
  64888. /** distance when this optimized version should be used */
  64889. distance: number;
  64890. /** already optimized mesh */
  64891. optimizeMesh?: boolean | undefined;
  64892. /**
  64893. * Creates a SimplificationSettings
  64894. * @param quality expected quality
  64895. * @param distance distance when this optimized version should be used
  64896. * @param optimizeMesh already optimized mesh
  64897. */
  64898. constructor(
  64899. /** expected quality */
  64900. quality: number,
  64901. /** distance when this optimized version should be used */
  64902. distance: number,
  64903. /** already optimized mesh */
  64904. optimizeMesh?: boolean | undefined);
  64905. }
  64906. /**
  64907. * Interface used to define a simplification task
  64908. */
  64909. export interface ISimplificationTask {
  64910. /**
  64911. * Array of settings
  64912. */
  64913. settings: Array<ISimplificationSettings>;
  64914. /**
  64915. * Simplification type
  64916. */
  64917. simplificationType: SimplificationType;
  64918. /**
  64919. * Mesh to simplify
  64920. */
  64921. mesh: Mesh;
  64922. /**
  64923. * Callback called on success
  64924. */
  64925. successCallback?: () => void;
  64926. /**
  64927. * Defines if parallel processing can be used
  64928. */
  64929. parallelProcessing: boolean;
  64930. }
  64931. /**
  64932. * Queue used to order the simplification tasks
  64933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64934. */
  64935. export class SimplificationQueue {
  64936. private _simplificationArray;
  64937. /**
  64938. * Gets a boolean indicating that the process is still running
  64939. */
  64940. running: boolean;
  64941. /**
  64942. * Creates a new queue
  64943. */
  64944. constructor();
  64945. /**
  64946. * Adds a new simplification task
  64947. * @param task defines a task to add
  64948. */
  64949. addTask(task: ISimplificationTask): void;
  64950. /**
  64951. * Execute next task
  64952. */
  64953. executeNext(): void;
  64954. /**
  64955. * Execute a simplification task
  64956. * @param task defines the task to run
  64957. */
  64958. runSimplification(task: ISimplificationTask): void;
  64959. private getSimplifier;
  64960. }
  64961. /**
  64962. * The implemented types of simplification
  64963. * At the moment only Quadratic Error Decimation is implemented
  64964. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64965. */
  64966. export enum SimplificationType {
  64967. /** Quadratic error decimation */
  64968. QUADRATIC = 0
  64969. }
  64970. }
  64971. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64972. import { Scene } from "babylonjs/scene";
  64973. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64974. import { ISceneComponent } from "babylonjs/sceneComponent";
  64975. module "babylonjs/scene" {
  64976. interface Scene {
  64977. /** @hidden (Backing field) */
  64978. _simplificationQueue: SimplificationQueue;
  64979. /**
  64980. * Gets or sets the simplification queue attached to the scene
  64981. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64982. */
  64983. simplificationQueue: SimplificationQueue;
  64984. }
  64985. }
  64986. module "babylonjs/Meshes/mesh" {
  64987. interface Mesh {
  64988. /**
  64989. * Simplify the mesh according to the given array of settings.
  64990. * Function will return immediately and will simplify async
  64991. * @param settings a collection of simplification settings
  64992. * @param parallelProcessing should all levels calculate parallel or one after the other
  64993. * @param simplificationType the type of simplification to run
  64994. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64995. * @returns the current mesh
  64996. */
  64997. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64998. }
  64999. }
  65000. /**
  65001. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65002. * created in a scene
  65003. */
  65004. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65005. /**
  65006. * The component name helpfull to identify the component in the list of scene components.
  65007. */
  65008. readonly name: string;
  65009. /**
  65010. * The scene the component belongs to.
  65011. */
  65012. scene: Scene;
  65013. /**
  65014. * Creates a new instance of the component for the given scene
  65015. * @param scene Defines the scene to register the component in
  65016. */
  65017. constructor(scene: Scene);
  65018. /**
  65019. * Registers the component in a given scene
  65020. */
  65021. register(): void;
  65022. /**
  65023. * Rebuilds the elements related to this component in case of
  65024. * context lost for instance.
  65025. */
  65026. rebuild(): void;
  65027. /**
  65028. * Disposes the component and the associated ressources
  65029. */
  65030. dispose(): void;
  65031. private _beforeCameraUpdate;
  65032. }
  65033. }
  65034. declare module "babylonjs/Meshes/Builders/index" {
  65035. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65036. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65037. export * from "babylonjs/Meshes/Builders/discBuilder";
  65038. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65039. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65040. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65041. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65042. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65043. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65044. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65045. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65046. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65047. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65048. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65049. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65050. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65051. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65052. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65053. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65054. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65055. }
  65056. declare module "babylonjs/Meshes/index" {
  65057. export * from "babylonjs/Meshes/abstractMesh";
  65058. export * from "babylonjs/Meshes/buffer";
  65059. export * from "babylonjs/Meshes/Compression/index";
  65060. export * from "babylonjs/Meshes/csg";
  65061. export * from "babylonjs/Meshes/geometry";
  65062. export * from "babylonjs/Meshes/groundMesh";
  65063. export * from "babylonjs/Meshes/trailMesh";
  65064. export * from "babylonjs/Meshes/instancedMesh";
  65065. export * from "babylonjs/Meshes/linesMesh";
  65066. export * from "babylonjs/Meshes/mesh";
  65067. export * from "babylonjs/Meshes/mesh.vertexData";
  65068. export * from "babylonjs/Meshes/meshBuilder";
  65069. export * from "babylonjs/Meshes/meshSimplification";
  65070. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65071. export * from "babylonjs/Meshes/polygonMesh";
  65072. export * from "babylonjs/Meshes/subMesh";
  65073. export * from "babylonjs/Meshes/meshLODLevel";
  65074. export * from "babylonjs/Meshes/transformNode";
  65075. export * from "babylonjs/Meshes/Builders/index";
  65076. export * from "babylonjs/Meshes/dataBuffer";
  65077. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65078. }
  65079. declare module "babylonjs/Morph/index" {
  65080. export * from "babylonjs/Morph/morphTarget";
  65081. export * from "babylonjs/Morph/morphTargetManager";
  65082. }
  65083. declare module "babylonjs/Navigation/INavigationEngine" {
  65084. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65085. import { Vector3 } from "babylonjs/Maths/math";
  65086. import { Mesh } from "babylonjs/Meshes/mesh";
  65087. import { Scene } from "babylonjs/scene";
  65088. /**
  65089. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65090. */
  65091. export interface INavigationEnginePlugin {
  65092. /**
  65093. * plugin name
  65094. */
  65095. name: string;
  65096. /**
  65097. * Creates a navigation mesh
  65098. * @param meshes array of all the geometry used to compute the navigatio mesh
  65099. * @param parameters bunch of parameters used to filter geometry
  65100. */
  65101. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65102. /**
  65103. * Create a navigation mesh debug mesh
  65104. * @param scene is where the mesh will be added
  65105. * @returns debug display mesh
  65106. */
  65107. createDebugNavMesh(scene: Scene): Mesh;
  65108. /**
  65109. * Get a navigation mesh constrained position, closest to the parameter position
  65110. * @param position world position
  65111. * @returns the closest point to position constrained by the navigation mesh
  65112. */
  65113. getClosestPoint(position: Vector3): Vector3;
  65114. /**
  65115. * Get a navigation mesh constrained position, within a particular radius
  65116. * @param position world position
  65117. * @param maxRadius the maximum distance to the constrained world position
  65118. * @returns the closest point to position constrained by the navigation mesh
  65119. */
  65120. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65121. /**
  65122. * Compute the final position from a segment made of destination-position
  65123. * @param position world position
  65124. * @param destination world position
  65125. * @returns the resulting point along the navmesh
  65126. */
  65127. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65128. /**
  65129. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65130. * @param start world position
  65131. * @param end world position
  65132. * @returns array containing world position composing the path
  65133. */
  65134. computePath(start: Vector3, end: Vector3): Vector3[];
  65135. /**
  65136. * If this plugin is supported
  65137. * @returns true if plugin is supported
  65138. */
  65139. isSupported(): boolean;
  65140. /**
  65141. * Create a new Crowd so you can add agents
  65142. * @param maxAgents the maximum agent count in the crowd
  65143. * @param maxAgentRadius the maximum radius an agent can have
  65144. * @param scene to attach the crowd to
  65145. * @returns the crowd you can add agents to
  65146. */
  65147. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65148. /**
  65149. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65150. * The queries will try to find a solution within those bounds
  65151. * default is (1,1,1)
  65152. * @param extent x,y,z value that define the extent around the queries point of reference
  65153. */
  65154. setDefaultQueryExtent(extent: Vector3): void;
  65155. /**
  65156. * Get the Bounding box extent specified by setDefaultQueryExtent
  65157. * @returns the box extent values
  65158. */
  65159. getDefaultQueryExtent(): Vector3;
  65160. /**
  65161. * Release all resources
  65162. */
  65163. dispose(): void;
  65164. }
  65165. /**
  65166. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65167. */
  65168. export interface ICrowd {
  65169. /**
  65170. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65171. * You can attach anything to that node. The node position is updated in the scene update tick.
  65172. * @param pos world position that will be constrained by the navigation mesh
  65173. * @param parameters agent parameters
  65174. * @param transform hooked to the agent that will be update by the scene
  65175. * @returns agent index
  65176. */
  65177. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65178. /**
  65179. * Returns the agent position in world space
  65180. * @param index agent index returned by addAgent
  65181. * @returns world space position
  65182. */
  65183. getAgentPosition(index: number): Vector3;
  65184. /**
  65185. * Gets the agent velocity in world space
  65186. * @param index agent index returned by addAgent
  65187. * @returns world space velocity
  65188. */
  65189. getAgentVelocity(index: number): Vector3;
  65190. /**
  65191. * remove a particular agent previously created
  65192. * @param index agent index returned by addAgent
  65193. */
  65194. removeAgent(index: number): void;
  65195. /**
  65196. * get the list of all agents attached to this crowd
  65197. * @returns list of agent indices
  65198. */
  65199. getAgents(): number[];
  65200. /**
  65201. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65202. * @param deltaTime in seconds
  65203. */
  65204. update(deltaTime: number): void;
  65205. /**
  65206. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65207. * @param index agent index returned by addAgent
  65208. * @param destination targeted world position
  65209. */
  65210. agentGoto(index: number, destination: Vector3): void;
  65211. /**
  65212. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65213. * The queries will try to find a solution within those bounds
  65214. * default is (1,1,1)
  65215. * @param extent x,y,z value that define the extent around the queries point of reference
  65216. */
  65217. setDefaultQueryExtent(extent: Vector3): void;
  65218. /**
  65219. * Get the Bounding box extent specified by setDefaultQueryExtent
  65220. * @returns the box extent values
  65221. */
  65222. getDefaultQueryExtent(): Vector3;
  65223. /**
  65224. * Release all resources
  65225. */
  65226. dispose(): void;
  65227. }
  65228. /**
  65229. * Configures an agent
  65230. */
  65231. export interface IAgentParameters {
  65232. /**
  65233. * Agent radius. [Limit: >= 0]
  65234. */
  65235. radius: number;
  65236. /**
  65237. * Agent height. [Limit: > 0]
  65238. */
  65239. height: number;
  65240. /**
  65241. * Maximum allowed acceleration. [Limit: >= 0]
  65242. */
  65243. maxAcceleration: number;
  65244. /**
  65245. * Maximum allowed speed. [Limit: >= 0]
  65246. */
  65247. maxSpeed: number;
  65248. /**
  65249. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65250. */
  65251. collisionQueryRange: number;
  65252. /**
  65253. * The path visibility optimization range. [Limit: > 0]
  65254. */
  65255. pathOptimizationRange: number;
  65256. /**
  65257. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65258. */
  65259. separationWeight: number;
  65260. }
  65261. /**
  65262. * Configures the navigation mesh creation
  65263. */
  65264. export interface INavMeshParameters {
  65265. /**
  65266. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65267. */
  65268. cs: number;
  65269. /**
  65270. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65271. */
  65272. ch: number;
  65273. /**
  65274. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65275. */
  65276. walkableSlopeAngle: number;
  65277. /**
  65278. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65279. * be considered walkable. [Limit: >= 3] [Units: vx]
  65280. */
  65281. walkableHeight: number;
  65282. /**
  65283. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65284. */
  65285. walkableClimb: number;
  65286. /**
  65287. * The distance to erode/shrink the walkable area of the heightfield away from
  65288. * obstructions. [Limit: >=0] [Units: vx]
  65289. */
  65290. walkableRadius: number;
  65291. /**
  65292. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65293. */
  65294. maxEdgeLen: number;
  65295. /**
  65296. * The maximum distance a simplfied contour's border edges should deviate
  65297. * the original raw contour. [Limit: >=0] [Units: vx]
  65298. */
  65299. maxSimplificationError: number;
  65300. /**
  65301. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65302. */
  65303. minRegionArea: number;
  65304. /**
  65305. * Any regions with a span count smaller than this value will, if possible,
  65306. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65307. */
  65308. mergeRegionArea: number;
  65309. /**
  65310. * The maximum number of vertices allowed for polygons generated during the
  65311. * contour to polygon conversion process. [Limit: >= 3]
  65312. */
  65313. maxVertsPerPoly: number;
  65314. /**
  65315. * Sets the sampling distance to use when generating the detail mesh.
  65316. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65317. */
  65318. detailSampleDist: number;
  65319. /**
  65320. * The maximum distance the detail mesh surface should deviate from heightfield
  65321. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65322. */
  65323. detailSampleMaxError: number;
  65324. }
  65325. }
  65326. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65327. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65328. import { Mesh } from "babylonjs/Meshes/mesh";
  65329. import { Scene } from "babylonjs/scene";
  65330. import { Vector3 } from "babylonjs/Maths/math";
  65331. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65332. /**
  65333. * RecastJS navigation plugin
  65334. */
  65335. export class RecastJSPlugin implements INavigationEnginePlugin {
  65336. /**
  65337. * Reference to the Recast library
  65338. */
  65339. bjsRECAST: any;
  65340. /**
  65341. * plugin name
  65342. */
  65343. name: string;
  65344. /**
  65345. * the first navmesh created. We might extend this to support multiple navmeshes
  65346. */
  65347. navMesh: any;
  65348. /**
  65349. * Initializes the recastJS plugin
  65350. * @param recastInjection can be used to inject your own recast reference
  65351. */
  65352. constructor(recastInjection?: any);
  65353. /**
  65354. * Creates a navigation mesh
  65355. * @param meshes array of all the geometry used to compute the navigatio mesh
  65356. * @param parameters bunch of parameters used to filter geometry
  65357. */
  65358. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65359. /**
  65360. * Create a navigation mesh debug mesh
  65361. * @param scene is where the mesh will be added
  65362. * @returns debug display mesh
  65363. */
  65364. createDebugNavMesh(scene: Scene): Mesh;
  65365. /**
  65366. * Get a navigation mesh constrained position, closest to the parameter position
  65367. * @param position world position
  65368. * @returns the closest point to position constrained by the navigation mesh
  65369. */
  65370. getClosestPoint(position: Vector3): Vector3;
  65371. /**
  65372. * Get a navigation mesh constrained position, within a particular radius
  65373. * @param position world position
  65374. * @param maxRadius the maximum distance to the constrained world position
  65375. * @returns the closest point to position constrained by the navigation mesh
  65376. */
  65377. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65378. /**
  65379. * Compute the final position from a segment made of destination-position
  65380. * @param position world position
  65381. * @param destination world position
  65382. * @returns the resulting point along the navmesh
  65383. */
  65384. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65385. /**
  65386. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65387. * @param start world position
  65388. * @param end world position
  65389. * @returns array containing world position composing the path
  65390. */
  65391. computePath(start: Vector3, end: Vector3): Vector3[];
  65392. /**
  65393. * Create a new Crowd so you can add agents
  65394. * @param maxAgents the maximum agent count in the crowd
  65395. * @param maxAgentRadius the maximum radius an agent can have
  65396. * @param scene to attach the crowd to
  65397. * @returns the crowd you can add agents to
  65398. */
  65399. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65400. /**
  65401. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65402. * The queries will try to find a solution within those bounds
  65403. * default is (1,1,1)
  65404. * @param extent x,y,z value that define the extent around the queries point of reference
  65405. */
  65406. setDefaultQueryExtent(extent: Vector3): void;
  65407. /**
  65408. * Get the Bounding box extent specified by setDefaultQueryExtent
  65409. * @returns the box extent values
  65410. */
  65411. getDefaultQueryExtent(): Vector3;
  65412. /**
  65413. * Disposes
  65414. */
  65415. dispose(): void;
  65416. /**
  65417. * If this plugin is supported
  65418. * @returns true if plugin is supported
  65419. */
  65420. isSupported(): boolean;
  65421. }
  65422. /**
  65423. * Recast detour crowd implementation
  65424. */
  65425. export class RecastJSCrowd implements ICrowd {
  65426. /**
  65427. * Recast/detour plugin
  65428. */
  65429. bjsRECASTPlugin: RecastJSPlugin;
  65430. /**
  65431. * Link to the detour crowd
  65432. */
  65433. recastCrowd: any;
  65434. /**
  65435. * One transform per agent
  65436. */
  65437. transforms: TransformNode[];
  65438. /**
  65439. * All agents created
  65440. */
  65441. agents: number[];
  65442. /**
  65443. * Link to the scene is kept to unregister the crowd from the scene
  65444. */
  65445. private _scene;
  65446. /**
  65447. * Observer for crowd updates
  65448. */
  65449. private _onBeforeAnimationsObserver;
  65450. /**
  65451. * Constructor
  65452. * @param plugin recastJS plugin
  65453. * @param maxAgents the maximum agent count in the crowd
  65454. * @param maxAgentRadius the maximum radius an agent can have
  65455. * @param scene to attach the crowd to
  65456. * @returns the crowd you can add agents to
  65457. */
  65458. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65459. /**
  65460. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65461. * You can attach anything to that node. The node position is updated in the scene update tick.
  65462. * @param pos world position that will be constrained by the navigation mesh
  65463. * @param parameters agent parameters
  65464. * @param transform hooked to the agent that will be update by the scene
  65465. * @returns agent index
  65466. */
  65467. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65468. /**
  65469. * Returns the agent position in world space
  65470. * @param index agent index returned by addAgent
  65471. * @returns world space position
  65472. */
  65473. getAgentPosition(index: number): Vector3;
  65474. /**
  65475. * Returns the agent velocity in world space
  65476. * @param index agent index returned by addAgent
  65477. * @returns world space velocity
  65478. */
  65479. getAgentVelocity(index: number): Vector3;
  65480. /**
  65481. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65482. * @param index agent index returned by addAgent
  65483. * @param destination targeted world position
  65484. */
  65485. agentGoto(index: number, destination: Vector3): void;
  65486. /**
  65487. * remove a particular agent previously created
  65488. * @param index agent index returned by addAgent
  65489. */
  65490. removeAgent(index: number): void;
  65491. /**
  65492. * get the list of all agents attached to this crowd
  65493. * @returns list of agent indices
  65494. */
  65495. getAgents(): number[];
  65496. /**
  65497. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65498. * @param deltaTime in seconds
  65499. */
  65500. update(deltaTime: number): void;
  65501. /**
  65502. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65503. * The queries will try to find a solution within those bounds
  65504. * default is (1,1,1)
  65505. * @param extent x,y,z value that define the extent around the queries point of reference
  65506. */
  65507. setDefaultQueryExtent(extent: Vector3): void;
  65508. /**
  65509. * Get the Bounding box extent specified by setDefaultQueryExtent
  65510. * @returns the box extent values
  65511. */
  65512. getDefaultQueryExtent(): Vector3;
  65513. /**
  65514. * Release all resources
  65515. */
  65516. dispose(): void;
  65517. }
  65518. }
  65519. declare module "babylonjs/Navigation/Plugins/index" {
  65520. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65521. }
  65522. declare module "babylonjs/Navigation/index" {
  65523. export * from "babylonjs/Navigation/INavigationEngine";
  65524. export * from "babylonjs/Navigation/Plugins/index";
  65525. }
  65526. declare module "babylonjs/Offline/database" {
  65527. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65528. /**
  65529. * Class used to enable access to IndexedDB
  65530. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65531. */
  65532. export class Database implements IOfflineProvider {
  65533. private _callbackManifestChecked;
  65534. private _currentSceneUrl;
  65535. private _db;
  65536. private _enableSceneOffline;
  65537. private _enableTexturesOffline;
  65538. private _manifestVersionFound;
  65539. private _mustUpdateRessources;
  65540. private _hasReachedQuota;
  65541. private _isSupported;
  65542. private _idbFactory;
  65543. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65544. private static IsUASupportingBlobStorage;
  65545. /**
  65546. * Gets a boolean indicating if Database storate is enabled (off by default)
  65547. */
  65548. static IDBStorageEnabled: boolean;
  65549. /**
  65550. * Gets a boolean indicating if scene must be saved in the database
  65551. */
  65552. get enableSceneOffline(): boolean;
  65553. /**
  65554. * Gets a boolean indicating if textures must be saved in the database
  65555. */
  65556. get enableTexturesOffline(): boolean;
  65557. /**
  65558. * Creates a new Database
  65559. * @param urlToScene defines the url to load the scene
  65560. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65561. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65562. */
  65563. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65564. private static _ParseURL;
  65565. private static _ReturnFullUrlLocation;
  65566. private _checkManifestFile;
  65567. /**
  65568. * Open the database and make it available
  65569. * @param successCallback defines the callback to call on success
  65570. * @param errorCallback defines the callback to call on error
  65571. */
  65572. open(successCallback: () => void, errorCallback: () => void): void;
  65573. /**
  65574. * Loads an image from the database
  65575. * @param url defines the url to load from
  65576. * @param image defines the target DOM image
  65577. */
  65578. loadImage(url: string, image: HTMLImageElement): void;
  65579. private _loadImageFromDBAsync;
  65580. private _saveImageIntoDBAsync;
  65581. private _checkVersionFromDB;
  65582. private _loadVersionFromDBAsync;
  65583. private _saveVersionIntoDBAsync;
  65584. /**
  65585. * Loads a file from database
  65586. * @param url defines the URL to load from
  65587. * @param sceneLoaded defines a callback to call on success
  65588. * @param progressCallBack defines a callback to call when progress changed
  65589. * @param errorCallback defines a callback to call on error
  65590. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65591. */
  65592. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65593. private _loadFileAsync;
  65594. private _saveFileAsync;
  65595. /**
  65596. * Validates if xhr data is correct
  65597. * @param xhr defines the request to validate
  65598. * @param dataType defines the expected data type
  65599. * @returns true if data is correct
  65600. */
  65601. private static _ValidateXHRData;
  65602. }
  65603. }
  65604. declare module "babylonjs/Offline/index" {
  65605. export * from "babylonjs/Offline/database";
  65606. export * from "babylonjs/Offline/IOfflineProvider";
  65607. }
  65608. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65609. /** @hidden */
  65610. export var gpuUpdateParticlesPixelShader: {
  65611. name: string;
  65612. shader: string;
  65613. };
  65614. }
  65615. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65616. /** @hidden */
  65617. export var gpuUpdateParticlesVertexShader: {
  65618. name: string;
  65619. shader: string;
  65620. };
  65621. }
  65622. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65623. /** @hidden */
  65624. export var clipPlaneFragmentDeclaration2: {
  65625. name: string;
  65626. shader: string;
  65627. };
  65628. }
  65629. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65630. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65631. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65632. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65633. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65634. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65635. /** @hidden */
  65636. export var gpuRenderParticlesPixelShader: {
  65637. name: string;
  65638. shader: string;
  65639. };
  65640. }
  65641. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65642. /** @hidden */
  65643. export var clipPlaneVertexDeclaration2: {
  65644. name: string;
  65645. shader: string;
  65646. };
  65647. }
  65648. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65649. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65650. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65651. /** @hidden */
  65652. export var gpuRenderParticlesVertexShader: {
  65653. name: string;
  65654. shader: string;
  65655. };
  65656. }
  65657. declare module "babylonjs/Particles/gpuParticleSystem" {
  65658. import { Nullable } from "babylonjs/types";
  65659. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65660. import { Observable } from "babylonjs/Misc/observable";
  65661. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65662. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65663. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65664. import { Scene, IDisposable } from "babylonjs/scene";
  65665. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65666. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65667. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65668. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65669. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65670. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65671. /**
  65672. * This represents a GPU particle system in Babylon
  65673. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65674. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65675. */
  65676. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65677. /**
  65678. * The layer mask we are rendering the particles through.
  65679. */
  65680. layerMask: number;
  65681. private _capacity;
  65682. private _activeCount;
  65683. private _currentActiveCount;
  65684. private _accumulatedCount;
  65685. private _renderEffect;
  65686. private _updateEffect;
  65687. private _buffer0;
  65688. private _buffer1;
  65689. private _spriteBuffer;
  65690. private _updateVAO;
  65691. private _renderVAO;
  65692. private _targetIndex;
  65693. private _sourceBuffer;
  65694. private _targetBuffer;
  65695. private _engine;
  65696. private _currentRenderId;
  65697. private _started;
  65698. private _stopped;
  65699. private _timeDelta;
  65700. private _randomTexture;
  65701. private _randomTexture2;
  65702. private _attributesStrideSize;
  65703. private _updateEffectOptions;
  65704. private _randomTextureSize;
  65705. private _actualFrame;
  65706. private readonly _rawTextureWidth;
  65707. /**
  65708. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65709. */
  65710. static get IsSupported(): boolean;
  65711. /**
  65712. * An event triggered when the system is disposed.
  65713. */
  65714. onDisposeObservable: Observable<GPUParticleSystem>;
  65715. /**
  65716. * Gets the maximum number of particles active at the same time.
  65717. * @returns The max number of active particles.
  65718. */
  65719. getCapacity(): number;
  65720. /**
  65721. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65722. * to override the particles.
  65723. */
  65724. forceDepthWrite: boolean;
  65725. /**
  65726. * Gets or set the number of active particles
  65727. */
  65728. get activeParticleCount(): number;
  65729. set activeParticleCount(value: number);
  65730. private _preWarmDone;
  65731. /**
  65732. * Is this system ready to be used/rendered
  65733. * @return true if the system is ready
  65734. */
  65735. isReady(): boolean;
  65736. /**
  65737. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65738. * @returns True if it has been started, otherwise false.
  65739. */
  65740. isStarted(): boolean;
  65741. /**
  65742. * Starts the particle system and begins to emit
  65743. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65744. */
  65745. start(delay?: number): void;
  65746. /**
  65747. * Stops the particle system.
  65748. */
  65749. stop(): void;
  65750. /**
  65751. * Remove all active particles
  65752. */
  65753. reset(): void;
  65754. /**
  65755. * Returns the string "GPUParticleSystem"
  65756. * @returns a string containing the class name
  65757. */
  65758. getClassName(): string;
  65759. private _colorGradientsTexture;
  65760. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65761. /**
  65762. * Adds a new color gradient
  65763. * @param gradient defines the gradient to use (between 0 and 1)
  65764. * @param color1 defines the color to affect to the specified gradient
  65765. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65766. * @returns the current particle system
  65767. */
  65768. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65769. /**
  65770. * Remove a specific color gradient
  65771. * @param gradient defines the gradient to remove
  65772. * @returns the current particle system
  65773. */
  65774. removeColorGradient(gradient: number): GPUParticleSystem;
  65775. private _angularSpeedGradientsTexture;
  65776. private _sizeGradientsTexture;
  65777. private _velocityGradientsTexture;
  65778. private _limitVelocityGradientsTexture;
  65779. private _dragGradientsTexture;
  65780. private _addFactorGradient;
  65781. /**
  65782. * Adds a new size gradient
  65783. * @param gradient defines the gradient to use (between 0 and 1)
  65784. * @param factor defines the size factor to affect to the specified gradient
  65785. * @returns the current particle system
  65786. */
  65787. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65788. /**
  65789. * Remove a specific size gradient
  65790. * @param gradient defines the gradient to remove
  65791. * @returns the current particle system
  65792. */
  65793. removeSizeGradient(gradient: number): GPUParticleSystem;
  65794. /**
  65795. * Adds a new angular speed gradient
  65796. * @param gradient defines the gradient to use (between 0 and 1)
  65797. * @param factor defines the angular speed to affect to the specified gradient
  65798. * @returns the current particle system
  65799. */
  65800. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65801. /**
  65802. * Remove a specific angular speed gradient
  65803. * @param gradient defines the gradient to remove
  65804. * @returns the current particle system
  65805. */
  65806. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65807. /**
  65808. * Adds a new velocity gradient
  65809. * @param gradient defines the gradient to use (between 0 and 1)
  65810. * @param factor defines the velocity to affect to the specified gradient
  65811. * @returns the current particle system
  65812. */
  65813. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65814. /**
  65815. * Remove a specific velocity gradient
  65816. * @param gradient defines the gradient to remove
  65817. * @returns the current particle system
  65818. */
  65819. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65820. /**
  65821. * Adds a new limit velocity gradient
  65822. * @param gradient defines the gradient to use (between 0 and 1)
  65823. * @param factor defines the limit velocity value to affect to the specified gradient
  65824. * @returns the current particle system
  65825. */
  65826. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65827. /**
  65828. * Remove a specific limit velocity gradient
  65829. * @param gradient defines the gradient to remove
  65830. * @returns the current particle system
  65831. */
  65832. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65833. /**
  65834. * Adds a new drag gradient
  65835. * @param gradient defines the gradient to use (between 0 and 1)
  65836. * @param factor defines the drag value to affect to the specified gradient
  65837. * @returns the current particle system
  65838. */
  65839. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65840. /**
  65841. * Remove a specific drag gradient
  65842. * @param gradient defines the gradient to remove
  65843. * @returns the current particle system
  65844. */
  65845. removeDragGradient(gradient: number): GPUParticleSystem;
  65846. /**
  65847. * Not supported by GPUParticleSystem
  65848. * @param gradient defines the gradient to use (between 0 and 1)
  65849. * @param factor defines the emit rate value to affect to the specified gradient
  65850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65851. * @returns the current particle system
  65852. */
  65853. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65854. /**
  65855. * Not supported by GPUParticleSystem
  65856. * @param gradient defines the gradient to remove
  65857. * @returns the current particle system
  65858. */
  65859. removeEmitRateGradient(gradient: number): IParticleSystem;
  65860. /**
  65861. * Not supported by GPUParticleSystem
  65862. * @param gradient defines the gradient to use (between 0 and 1)
  65863. * @param factor defines the start size value to affect to the specified gradient
  65864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65865. * @returns the current particle system
  65866. */
  65867. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65868. /**
  65869. * Not supported by GPUParticleSystem
  65870. * @param gradient defines the gradient to remove
  65871. * @returns the current particle system
  65872. */
  65873. removeStartSizeGradient(gradient: number): IParticleSystem;
  65874. /**
  65875. * Not supported by GPUParticleSystem
  65876. * @param gradient defines the gradient to use (between 0 and 1)
  65877. * @param min defines the color remap minimal range
  65878. * @param max defines the color remap maximal range
  65879. * @returns the current particle system
  65880. */
  65881. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65882. /**
  65883. * Not supported by GPUParticleSystem
  65884. * @param gradient defines the gradient to remove
  65885. * @returns the current particle system
  65886. */
  65887. removeColorRemapGradient(): IParticleSystem;
  65888. /**
  65889. * Not supported by GPUParticleSystem
  65890. * @param gradient defines the gradient to use (between 0 and 1)
  65891. * @param min defines the alpha remap minimal range
  65892. * @param max defines the alpha remap maximal range
  65893. * @returns the current particle system
  65894. */
  65895. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65896. /**
  65897. * Not supported by GPUParticleSystem
  65898. * @param gradient defines the gradient to remove
  65899. * @returns the current particle system
  65900. */
  65901. removeAlphaRemapGradient(): IParticleSystem;
  65902. /**
  65903. * Not supported by GPUParticleSystem
  65904. * @param gradient defines the gradient to use (between 0 and 1)
  65905. * @param color defines the color to affect to the specified gradient
  65906. * @returns the current particle system
  65907. */
  65908. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65909. /**
  65910. * Not supported by GPUParticleSystem
  65911. * @param gradient defines the gradient to remove
  65912. * @returns the current particle system
  65913. */
  65914. removeRampGradient(): IParticleSystem;
  65915. /**
  65916. * Not supported by GPUParticleSystem
  65917. * @returns the list of ramp gradients
  65918. */
  65919. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65920. /**
  65921. * Not supported by GPUParticleSystem
  65922. * Gets or sets a boolean indicating that ramp gradients must be used
  65923. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65924. */
  65925. get useRampGradients(): boolean;
  65926. set useRampGradients(value: boolean);
  65927. /**
  65928. * Not supported by GPUParticleSystem
  65929. * @param gradient defines the gradient to use (between 0 and 1)
  65930. * @param factor defines the life time factor to affect to the specified gradient
  65931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65932. * @returns the current particle system
  65933. */
  65934. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65935. /**
  65936. * Not supported by GPUParticleSystem
  65937. * @param gradient defines the gradient to remove
  65938. * @returns the current particle system
  65939. */
  65940. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65941. /**
  65942. * Instantiates a GPU particle system.
  65943. * 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.
  65944. * @param name The name of the particle system
  65945. * @param options The options used to create the system
  65946. * @param scene The scene the particle system belongs to
  65947. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65948. */
  65949. constructor(name: string, options: Partial<{
  65950. capacity: number;
  65951. randomTextureSize: number;
  65952. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65953. protected _reset(): void;
  65954. private _createUpdateVAO;
  65955. private _createRenderVAO;
  65956. private _initialize;
  65957. /** @hidden */
  65958. _recreateUpdateEffect(): void;
  65959. /** @hidden */
  65960. _recreateRenderEffect(): void;
  65961. /**
  65962. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65963. * @param preWarm defines if we are in the pre-warmimg phase
  65964. */
  65965. animate(preWarm?: boolean): void;
  65966. private _createFactorGradientTexture;
  65967. private _createSizeGradientTexture;
  65968. private _createAngularSpeedGradientTexture;
  65969. private _createVelocityGradientTexture;
  65970. private _createLimitVelocityGradientTexture;
  65971. private _createDragGradientTexture;
  65972. private _createColorGradientTexture;
  65973. /**
  65974. * Renders the particle system in its current state
  65975. * @param preWarm defines if the system should only update the particles but not render them
  65976. * @returns the current number of particles
  65977. */
  65978. render(preWarm?: boolean): number;
  65979. /**
  65980. * Rebuilds the particle system
  65981. */
  65982. rebuild(): void;
  65983. private _releaseBuffers;
  65984. private _releaseVAOs;
  65985. /**
  65986. * Disposes the particle system and free the associated resources
  65987. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65988. */
  65989. dispose(disposeTexture?: boolean): void;
  65990. /**
  65991. * Clones the particle system.
  65992. * @param name The name of the cloned object
  65993. * @param newEmitter The new emitter to use
  65994. * @returns the cloned particle system
  65995. */
  65996. clone(name: string, newEmitter: any): GPUParticleSystem;
  65997. /**
  65998. * Serializes the particle system to a JSON object.
  65999. * @returns the JSON object
  66000. */
  66001. serialize(): any;
  66002. /**
  66003. * Parses a JSON object to create a GPU particle system.
  66004. * @param parsedParticleSystem The JSON object to parse
  66005. * @param scene The scene to create the particle system in
  66006. * @param rootUrl The root url to use to load external dependencies like texture
  66007. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66008. * @returns the parsed GPU particle system
  66009. */
  66010. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66011. }
  66012. }
  66013. declare module "babylonjs/Particles/particleSystemSet" {
  66014. import { Nullable } from "babylonjs/types";
  66015. import { Color3 } from "babylonjs/Maths/math.color";
  66016. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66018. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66019. import { Scene, IDisposable } from "babylonjs/scene";
  66020. /**
  66021. * Represents a set of particle systems working together to create a specific effect
  66022. */
  66023. export class ParticleSystemSet implements IDisposable {
  66024. /**
  66025. * Gets or sets base Assets URL
  66026. */
  66027. static BaseAssetsUrl: string;
  66028. private _emitterCreationOptions;
  66029. private _emitterNode;
  66030. /**
  66031. * Gets the particle system list
  66032. */
  66033. systems: IParticleSystem[];
  66034. /**
  66035. * Gets the emitter node used with this set
  66036. */
  66037. get emitterNode(): Nullable<TransformNode>;
  66038. /**
  66039. * Creates a new emitter mesh as a sphere
  66040. * @param options defines the options used to create the sphere
  66041. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66042. * @param scene defines the hosting scene
  66043. */
  66044. setEmitterAsSphere(options: {
  66045. diameter: number;
  66046. segments: number;
  66047. color: Color3;
  66048. }, renderingGroupId: number, scene: Scene): void;
  66049. /**
  66050. * Starts all particle systems of the set
  66051. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66052. */
  66053. start(emitter?: AbstractMesh): void;
  66054. /**
  66055. * Release all associated resources
  66056. */
  66057. dispose(): void;
  66058. /**
  66059. * Serialize the set into a JSON compatible object
  66060. * @returns a JSON compatible representation of the set
  66061. */
  66062. serialize(): any;
  66063. /**
  66064. * Parse a new ParticleSystemSet from a serialized source
  66065. * @param data defines a JSON compatible representation of the set
  66066. * @param scene defines the hosting scene
  66067. * @param gpu defines if we want GPU particles or CPU particles
  66068. * @returns a new ParticleSystemSet
  66069. */
  66070. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66071. }
  66072. }
  66073. declare module "babylonjs/Particles/particleHelper" {
  66074. import { Nullable } from "babylonjs/types";
  66075. import { Scene } from "babylonjs/scene";
  66076. import { Vector3 } from "babylonjs/Maths/math.vector";
  66077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66079. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66080. /**
  66081. * This class is made for on one-liner static method to help creating particle system set.
  66082. */
  66083. export class ParticleHelper {
  66084. /**
  66085. * Gets or sets base Assets URL
  66086. */
  66087. static BaseAssetsUrl: string;
  66088. /**
  66089. * Create a default particle system that you can tweak
  66090. * @param emitter defines the emitter to use
  66091. * @param capacity defines the system capacity (default is 500 particles)
  66092. * @param scene defines the hosting scene
  66093. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66094. * @returns the new Particle system
  66095. */
  66096. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66097. /**
  66098. * This is the main static method (one-liner) of this helper to create different particle systems
  66099. * @param type This string represents the type to the particle system to create
  66100. * @param scene The scene where the particle system should live
  66101. * @param gpu If the system will use gpu
  66102. * @returns the ParticleSystemSet created
  66103. */
  66104. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66105. /**
  66106. * Static function used to export a particle system to a ParticleSystemSet variable.
  66107. * Please note that the emitter shape is not exported
  66108. * @param systems defines the particle systems to export
  66109. * @returns the created particle system set
  66110. */
  66111. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66112. }
  66113. }
  66114. declare module "babylonjs/Particles/particleSystemComponent" {
  66115. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66116. import { Effect } from "babylonjs/Materials/effect";
  66117. import "babylonjs/Shaders/particles.vertex";
  66118. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66119. module "babylonjs/Engines/engine" {
  66120. interface Engine {
  66121. /**
  66122. * Create an effect to use with particle systems.
  66123. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66124. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66125. * @param uniformsNames defines a list of attribute names
  66126. * @param samplers defines an array of string used to represent textures
  66127. * @param defines defines the string containing the defines to use to compile the shaders
  66128. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66129. * @param onCompiled defines a function to call when the effect creation is successful
  66130. * @param onError defines a function to call when the effect creation has failed
  66131. * @returns the new Effect
  66132. */
  66133. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66134. }
  66135. }
  66136. module "babylonjs/Meshes/mesh" {
  66137. interface Mesh {
  66138. /**
  66139. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66140. * @returns an array of IParticleSystem
  66141. */
  66142. getEmittedParticleSystems(): IParticleSystem[];
  66143. /**
  66144. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66145. * @returns an array of IParticleSystem
  66146. */
  66147. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66148. }
  66149. }
  66150. /**
  66151. * @hidden
  66152. */
  66153. export var _IDoNeedToBeInTheBuild: number;
  66154. }
  66155. declare module "babylonjs/Particles/pointsCloudSystem" {
  66156. import { Color4 } from "babylonjs/Maths/math";
  66157. import { Mesh } from "babylonjs/Meshes/mesh";
  66158. import { Scene, IDisposable } from "babylonjs/scene";
  66159. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66160. /** Defines the 4 color options */
  66161. export enum PointColor {
  66162. /** color value */
  66163. Color = 2,
  66164. /** uv value */
  66165. UV = 1,
  66166. /** random value */
  66167. Random = 0,
  66168. /** stated value */
  66169. Stated = 3
  66170. }
  66171. /**
  66172. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66173. * 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.
  66174. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66175. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66176. *
  66177. * Full documentation here : TO BE ENTERED
  66178. */
  66179. export class PointsCloudSystem implements IDisposable {
  66180. /**
  66181. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66182. * Example : var p = SPS.particles[i];
  66183. */
  66184. particles: CloudPoint[];
  66185. /**
  66186. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66187. */
  66188. nbParticles: number;
  66189. /**
  66190. * This a counter for your own usage. It's not set by any SPS functions.
  66191. */
  66192. counter: number;
  66193. /**
  66194. * The PCS name. This name is also given to the underlying mesh.
  66195. */
  66196. name: string;
  66197. /**
  66198. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66199. */
  66200. mesh: Mesh;
  66201. /**
  66202. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66203. * Please read :
  66204. */
  66205. vars: any;
  66206. /**
  66207. * @hidden
  66208. */
  66209. _size: number;
  66210. private _scene;
  66211. private _promises;
  66212. private _positions;
  66213. private _indices;
  66214. private _normals;
  66215. private _colors;
  66216. private _uvs;
  66217. private _indices32;
  66218. private _positions32;
  66219. private _colors32;
  66220. private _uvs32;
  66221. private _updatable;
  66222. private _isVisibilityBoxLocked;
  66223. private _alwaysVisible;
  66224. private _groups;
  66225. private _groupCounter;
  66226. private _computeParticleColor;
  66227. private _computeParticleTexture;
  66228. private _computeParticleRotation;
  66229. private _computeBoundingBox;
  66230. private _isReady;
  66231. /**
  66232. * Creates a PCS (Points Cloud System) object
  66233. * @param name (String) is the PCS name, this will be the underlying mesh name
  66234. * @param pointSize (number) is the size for each point
  66235. * @param scene (Scene) is the scene in which the PCS is added
  66236. * @param options defines the options of the PCS e.g.
  66237. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66238. */
  66239. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66240. updatable?: boolean;
  66241. });
  66242. /**
  66243. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66244. * If no points were added to the PCS, the returned mesh is just a single point.
  66245. * @returns a promise for the created mesh
  66246. */
  66247. buildMeshAsync(): Promise<Mesh>;
  66248. /**
  66249. * @hidden
  66250. */
  66251. private _buildMesh;
  66252. private _addParticle;
  66253. private _randomUnitVector;
  66254. private _getColorIndicesForCoord;
  66255. private _setPointsColorOrUV;
  66256. private _colorFromTexture;
  66257. private _calculateDensity;
  66258. /**
  66259. * Adds points to the PCS in random positions within a unit sphere
  66260. * @param nb (positive integer) the number of particles to be created from this model
  66261. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66262. * @returns the number of groups in the system
  66263. */
  66264. addPoints(nb: number, pointFunction?: any): number;
  66265. /**
  66266. * Adds points to the PCS from the surface of the model shape
  66267. * @param mesh is any Mesh object that will be used as a surface model for the points
  66268. * @param nb (positive integer) the number of particles to be created from this model
  66269. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66270. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66271. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66272. * @returns the number of groups in the system
  66273. */
  66274. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66275. /**
  66276. * Adds points to the PCS inside the model shape
  66277. * @param mesh is any Mesh object that will be used as a surface model for the points
  66278. * @param nb (positive integer) the number of particles to be created from this model
  66279. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66280. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66281. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66282. * @returns the number of groups in the system
  66283. */
  66284. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66285. /**
  66286. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66287. * This method calls `updateParticle()` for each particle of the SPS.
  66288. * For an animated SPS, it is usually called within the render loop.
  66289. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66290. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66291. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66292. * @returns the PCS.
  66293. */
  66294. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66295. /**
  66296. * Disposes the PCS.
  66297. */
  66298. dispose(): void;
  66299. /**
  66300. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66301. * doc :
  66302. * @returns the PCS.
  66303. */
  66304. refreshVisibleSize(): PointsCloudSystem;
  66305. /**
  66306. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66307. * @param size the size (float) of the visibility box
  66308. * note : this doesn't lock the PCS mesh bounding box.
  66309. * doc :
  66310. */
  66311. setVisibilityBox(size: number): void;
  66312. /**
  66313. * Gets whether the PCS is always visible or not
  66314. * doc :
  66315. */
  66316. get isAlwaysVisible(): boolean;
  66317. /**
  66318. * Sets the PCS as always visible or not
  66319. * doc :
  66320. */
  66321. set isAlwaysVisible(val: boolean);
  66322. /**
  66323. * Tells to `setParticles()` to compute the particle rotations or not
  66324. * Default value : false. The PCS is faster when it's set to false
  66325. * Note : particle rotations are only applied to parent particles
  66326. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66327. */
  66328. set computeParticleRotation(val: boolean);
  66329. /**
  66330. * Tells to `setParticles()` to compute the particle colors or not.
  66331. * Default value : true. The PCS is faster when it's set to false.
  66332. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66333. */
  66334. set computeParticleColor(val: boolean);
  66335. set computeParticleTexture(val: boolean);
  66336. /**
  66337. * Gets if `setParticles()` computes the particle colors or not.
  66338. * Default value : false. The PCS is faster when it's set to false.
  66339. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66340. */
  66341. get computeParticleColor(): boolean;
  66342. /**
  66343. * Gets if `setParticles()` computes the particle textures or not.
  66344. * Default value : false. The PCS is faster when it's set to false.
  66345. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66346. */
  66347. get computeParticleTexture(): boolean;
  66348. /**
  66349. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66350. */
  66351. set computeBoundingBox(val: boolean);
  66352. /**
  66353. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66354. */
  66355. get computeBoundingBox(): boolean;
  66356. /**
  66357. * This function does nothing. It may be overwritten to set all the particle first values.
  66358. * The PCS doesn't call this function, you may have to call it by your own.
  66359. * doc :
  66360. */
  66361. initParticles(): void;
  66362. /**
  66363. * This function does nothing. It may be overwritten to recycle a particle
  66364. * The PCS doesn't call this function, you can to call it
  66365. * doc :
  66366. * @param particle The particle to recycle
  66367. * @returns the recycled particle
  66368. */
  66369. recycleParticle(particle: CloudPoint): CloudPoint;
  66370. /**
  66371. * Updates a particle : this function should be overwritten by the user.
  66372. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66373. * doc :
  66374. * @example : just set a particle position or velocity and recycle conditions
  66375. * @param particle The particle to update
  66376. * @returns the updated particle
  66377. */
  66378. updateParticle(particle: CloudPoint): CloudPoint;
  66379. /**
  66380. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66381. * This does nothing and may be overwritten by the user.
  66382. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66383. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66384. * @param update the boolean update value actually passed to setParticles()
  66385. */
  66386. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66387. /**
  66388. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66389. * This will be passed three parameters.
  66390. * This does nothing and may be overwritten by the user.
  66391. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66392. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66393. * @param update the boolean update value actually passed to setParticles()
  66394. */
  66395. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66396. }
  66397. }
  66398. declare module "babylonjs/Particles/cloudPoint" {
  66399. import { Nullable } from "babylonjs/types";
  66400. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66401. import { Mesh } from "babylonjs/Meshes/mesh";
  66402. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66403. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66404. /**
  66405. * Represents one particle of a points cloud system.
  66406. */
  66407. export class CloudPoint {
  66408. /**
  66409. * particle global index
  66410. */
  66411. idx: number;
  66412. /**
  66413. * The color of the particle
  66414. */
  66415. color: Nullable<Color4>;
  66416. /**
  66417. * The world space position of the particle.
  66418. */
  66419. position: Vector3;
  66420. /**
  66421. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66422. */
  66423. rotation: Vector3;
  66424. /**
  66425. * The world space rotation quaternion of the particle.
  66426. */
  66427. rotationQuaternion: Nullable<Quaternion>;
  66428. /**
  66429. * The uv of the particle.
  66430. */
  66431. uv: Nullable<Vector2>;
  66432. /**
  66433. * The current speed of the particle.
  66434. */
  66435. velocity: Vector3;
  66436. /**
  66437. * The pivot point in the particle local space.
  66438. */
  66439. pivot: Vector3;
  66440. /**
  66441. * Must the particle be translated from its pivot point in its local space ?
  66442. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66443. * Default : false
  66444. */
  66445. translateFromPivot: boolean;
  66446. /**
  66447. * Index of this particle in the global "positions" array (Internal use)
  66448. * @hidden
  66449. */
  66450. _pos: number;
  66451. /**
  66452. * @hidden Index of this particle in the global "indices" array (Internal use)
  66453. */
  66454. _ind: number;
  66455. /**
  66456. * Group this particle belongs to
  66457. */
  66458. _group: PointsGroup;
  66459. /**
  66460. * Group id of this particle
  66461. */
  66462. groupId: number;
  66463. /**
  66464. * Index of the particle in its group id (Internal use)
  66465. */
  66466. idxInGroup: number;
  66467. /**
  66468. * @hidden Particle BoundingInfo object (Internal use)
  66469. */
  66470. _boundingInfo: BoundingInfo;
  66471. /**
  66472. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66473. */
  66474. _pcs: PointsCloudSystem;
  66475. /**
  66476. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66477. */
  66478. _stillInvisible: boolean;
  66479. /**
  66480. * @hidden Last computed particle rotation matrix
  66481. */
  66482. _rotationMatrix: number[];
  66483. /**
  66484. * Parent particle Id, if any.
  66485. * Default null.
  66486. */
  66487. parentId: Nullable<number>;
  66488. /**
  66489. * @hidden Internal global position in the PCS.
  66490. */
  66491. _globalPosition: Vector3;
  66492. /**
  66493. * Creates a Point Cloud object.
  66494. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66495. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66496. * @param group (PointsGroup) is the group the particle belongs to
  66497. * @param groupId (integer) is the group identifier in the PCS.
  66498. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66499. * @param pcs defines the PCS it is associated to
  66500. */
  66501. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66502. /**
  66503. * get point size
  66504. */
  66505. get size(): Vector3;
  66506. /**
  66507. * Set point size
  66508. */
  66509. set size(scale: Vector3);
  66510. /**
  66511. * Legacy support, changed quaternion to rotationQuaternion
  66512. */
  66513. get quaternion(): Nullable<Quaternion>;
  66514. /**
  66515. * Legacy support, changed quaternion to rotationQuaternion
  66516. */
  66517. set quaternion(q: Nullable<Quaternion>);
  66518. /**
  66519. * Returns a boolean. True if the particle intersects a mesh, else false
  66520. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66521. * @param target is the object (point or mesh) what the intersection is computed against
  66522. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66523. * @returns true if it intersects
  66524. */
  66525. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66526. /**
  66527. * get the rotation matrix of the particle
  66528. * @hidden
  66529. */
  66530. getRotationMatrix(m: Matrix): void;
  66531. }
  66532. /**
  66533. * Represents a group of points in a points cloud system
  66534. * * PCS internal tool, don't use it manually.
  66535. */
  66536. export class PointsGroup {
  66537. /**
  66538. * The group id
  66539. * @hidden
  66540. */
  66541. groupID: number;
  66542. /**
  66543. * image data for group (internal use)
  66544. * @hidden
  66545. */
  66546. _groupImageData: Nullable<ArrayBufferView>;
  66547. /**
  66548. * Image Width (internal use)
  66549. * @hidden
  66550. */
  66551. _groupImgWidth: number;
  66552. /**
  66553. * Image Height (internal use)
  66554. * @hidden
  66555. */
  66556. _groupImgHeight: number;
  66557. /**
  66558. * Custom position function (internal use)
  66559. * @hidden
  66560. */
  66561. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66562. /**
  66563. * density per facet for surface points
  66564. * @hidden
  66565. */
  66566. _groupDensity: number[];
  66567. /**
  66568. * Only when points are colored by texture carries pointer to texture list array
  66569. * @hidden
  66570. */
  66571. _textureNb: number;
  66572. /**
  66573. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66574. * PCS internal tool, don't use it manually.
  66575. * @hidden
  66576. */
  66577. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66578. }
  66579. }
  66580. declare module "babylonjs/Particles/index" {
  66581. export * from "babylonjs/Particles/baseParticleSystem";
  66582. export * from "babylonjs/Particles/EmitterTypes/index";
  66583. export * from "babylonjs/Particles/gpuParticleSystem";
  66584. export * from "babylonjs/Particles/IParticleSystem";
  66585. export * from "babylonjs/Particles/particle";
  66586. export * from "babylonjs/Particles/particleHelper";
  66587. export * from "babylonjs/Particles/particleSystem";
  66588. export * from "babylonjs/Particles/particleSystemComponent";
  66589. export * from "babylonjs/Particles/particleSystemSet";
  66590. export * from "babylonjs/Particles/solidParticle";
  66591. export * from "babylonjs/Particles/solidParticleSystem";
  66592. export * from "babylonjs/Particles/cloudPoint";
  66593. export * from "babylonjs/Particles/pointsCloudSystem";
  66594. export * from "babylonjs/Particles/subEmitter";
  66595. }
  66596. declare module "babylonjs/Physics/physicsEngineComponent" {
  66597. import { Nullable } from "babylonjs/types";
  66598. import { Observable, Observer } from "babylonjs/Misc/observable";
  66599. import { Vector3 } from "babylonjs/Maths/math.vector";
  66600. import { Mesh } from "babylonjs/Meshes/mesh";
  66601. import { ISceneComponent } from "babylonjs/sceneComponent";
  66602. import { Scene } from "babylonjs/scene";
  66603. import { Node } from "babylonjs/node";
  66604. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66605. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66606. module "babylonjs/scene" {
  66607. interface Scene {
  66608. /** @hidden (Backing field) */
  66609. _physicsEngine: Nullable<IPhysicsEngine>;
  66610. /** @hidden */
  66611. _physicsTimeAccumulator: number;
  66612. /**
  66613. * Gets the current physics engine
  66614. * @returns a IPhysicsEngine or null if none attached
  66615. */
  66616. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66617. /**
  66618. * Enables physics to the current scene
  66619. * @param gravity defines the scene's gravity for the physics engine
  66620. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66621. * @return a boolean indicating if the physics engine was initialized
  66622. */
  66623. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66624. /**
  66625. * Disables and disposes the physics engine associated with the scene
  66626. */
  66627. disablePhysicsEngine(): void;
  66628. /**
  66629. * Gets a boolean indicating if there is an active physics engine
  66630. * @returns a boolean indicating if there is an active physics engine
  66631. */
  66632. isPhysicsEnabled(): boolean;
  66633. /**
  66634. * Deletes a physics compound impostor
  66635. * @param compound defines the compound to delete
  66636. */
  66637. deleteCompoundImpostor(compound: any): void;
  66638. /**
  66639. * An event triggered when physic simulation is about to be run
  66640. */
  66641. onBeforePhysicsObservable: Observable<Scene>;
  66642. /**
  66643. * An event triggered when physic simulation has been done
  66644. */
  66645. onAfterPhysicsObservable: Observable<Scene>;
  66646. }
  66647. }
  66648. module "babylonjs/Meshes/abstractMesh" {
  66649. interface AbstractMesh {
  66650. /** @hidden */
  66651. _physicsImpostor: Nullable<PhysicsImpostor>;
  66652. /**
  66653. * Gets or sets impostor used for physic simulation
  66654. * @see http://doc.babylonjs.com/features/physics_engine
  66655. */
  66656. physicsImpostor: Nullable<PhysicsImpostor>;
  66657. /**
  66658. * Gets the current physics impostor
  66659. * @see http://doc.babylonjs.com/features/physics_engine
  66660. * @returns a physics impostor or null
  66661. */
  66662. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66663. /** Apply a physic impulse to the mesh
  66664. * @param force defines the force to apply
  66665. * @param contactPoint defines where to apply the force
  66666. * @returns the current mesh
  66667. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66668. */
  66669. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66670. /**
  66671. * Creates a physic joint between two meshes
  66672. * @param otherMesh defines the other mesh to use
  66673. * @param pivot1 defines the pivot to use on this mesh
  66674. * @param pivot2 defines the pivot to use on the other mesh
  66675. * @param options defines additional options (can be plugin dependent)
  66676. * @returns the current mesh
  66677. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66678. */
  66679. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66680. /** @hidden */
  66681. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66682. }
  66683. }
  66684. /**
  66685. * Defines the physics engine scene component responsible to manage a physics engine
  66686. */
  66687. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66688. /**
  66689. * The component name helpful to identify the component in the list of scene components.
  66690. */
  66691. readonly name: string;
  66692. /**
  66693. * The scene the component belongs to.
  66694. */
  66695. scene: Scene;
  66696. /**
  66697. * Creates a new instance of the component for the given scene
  66698. * @param scene Defines the scene to register the component in
  66699. */
  66700. constructor(scene: Scene);
  66701. /**
  66702. * Registers the component in a given scene
  66703. */
  66704. register(): void;
  66705. /**
  66706. * Rebuilds the elements related to this component in case of
  66707. * context lost for instance.
  66708. */
  66709. rebuild(): void;
  66710. /**
  66711. * Disposes the component and the associated ressources
  66712. */
  66713. dispose(): void;
  66714. }
  66715. }
  66716. declare module "babylonjs/Physics/physicsHelper" {
  66717. import { Nullable } from "babylonjs/types";
  66718. import { Vector3 } from "babylonjs/Maths/math.vector";
  66719. import { Mesh } from "babylonjs/Meshes/mesh";
  66720. import { Scene } from "babylonjs/scene";
  66721. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66722. /**
  66723. * A helper for physics simulations
  66724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66725. */
  66726. export class PhysicsHelper {
  66727. private _scene;
  66728. private _physicsEngine;
  66729. /**
  66730. * Initializes the Physics helper
  66731. * @param scene Babylon.js scene
  66732. */
  66733. constructor(scene: Scene);
  66734. /**
  66735. * Applies a radial explosion impulse
  66736. * @param origin the origin of the explosion
  66737. * @param radiusOrEventOptions the radius or the options of radial explosion
  66738. * @param strength the explosion strength
  66739. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66740. * @returns A physics radial explosion event, or null
  66741. */
  66742. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66743. /**
  66744. * Applies a radial explosion force
  66745. * @param origin the origin of the explosion
  66746. * @param radiusOrEventOptions the radius or the options of radial explosion
  66747. * @param strength the explosion strength
  66748. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66749. * @returns A physics radial explosion event, or null
  66750. */
  66751. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66752. /**
  66753. * Creates a gravitational field
  66754. * @param origin the origin of the explosion
  66755. * @param radiusOrEventOptions the radius or the options of radial explosion
  66756. * @param strength the explosion strength
  66757. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66758. * @returns A physics gravitational field event, or null
  66759. */
  66760. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66761. /**
  66762. * Creates a physics updraft event
  66763. * @param origin the origin of the updraft
  66764. * @param radiusOrEventOptions the radius or the options of the updraft
  66765. * @param strength the strength of the updraft
  66766. * @param height the height of the updraft
  66767. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66768. * @returns A physics updraft event, or null
  66769. */
  66770. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66771. /**
  66772. * Creates a physics vortex event
  66773. * @param origin the of the vortex
  66774. * @param radiusOrEventOptions the radius or the options of the vortex
  66775. * @param strength the strength of the vortex
  66776. * @param height the height of the vortex
  66777. * @returns a Physics vortex event, or null
  66778. * A physics vortex event or null
  66779. */
  66780. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66781. }
  66782. /**
  66783. * Represents a physics radial explosion event
  66784. */
  66785. class PhysicsRadialExplosionEvent {
  66786. private _scene;
  66787. private _options;
  66788. private _sphere;
  66789. private _dataFetched;
  66790. /**
  66791. * Initializes a radial explosioin event
  66792. * @param _scene BabylonJS scene
  66793. * @param _options The options for the vortex event
  66794. */
  66795. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66796. /**
  66797. * Returns the data related to the radial explosion event (sphere).
  66798. * @returns The radial explosion event data
  66799. */
  66800. getData(): PhysicsRadialExplosionEventData;
  66801. /**
  66802. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66803. * @param impostor A physics imposter
  66804. * @param origin the origin of the explosion
  66805. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66806. */
  66807. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66808. /**
  66809. * Triggers affecterd impostors callbacks
  66810. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66811. */
  66812. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66813. /**
  66814. * Disposes the sphere.
  66815. * @param force Specifies if the sphere should be disposed by force
  66816. */
  66817. dispose(force?: boolean): void;
  66818. /*** Helpers ***/
  66819. private _prepareSphere;
  66820. private _intersectsWithSphere;
  66821. }
  66822. /**
  66823. * Represents a gravitational field event
  66824. */
  66825. class PhysicsGravitationalFieldEvent {
  66826. private _physicsHelper;
  66827. private _scene;
  66828. private _origin;
  66829. private _options;
  66830. private _tickCallback;
  66831. private _sphere;
  66832. private _dataFetched;
  66833. /**
  66834. * Initializes the physics gravitational field event
  66835. * @param _physicsHelper A physics helper
  66836. * @param _scene BabylonJS scene
  66837. * @param _origin The origin position of the gravitational field event
  66838. * @param _options The options for the vortex event
  66839. */
  66840. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66841. /**
  66842. * Returns the data related to the gravitational field event (sphere).
  66843. * @returns A gravitational field event
  66844. */
  66845. getData(): PhysicsGravitationalFieldEventData;
  66846. /**
  66847. * Enables the gravitational field.
  66848. */
  66849. enable(): void;
  66850. /**
  66851. * Disables the gravitational field.
  66852. */
  66853. disable(): void;
  66854. /**
  66855. * Disposes the sphere.
  66856. * @param force The force to dispose from the gravitational field event
  66857. */
  66858. dispose(force?: boolean): void;
  66859. private _tick;
  66860. }
  66861. /**
  66862. * Represents a physics updraft event
  66863. */
  66864. class PhysicsUpdraftEvent {
  66865. private _scene;
  66866. private _origin;
  66867. private _options;
  66868. private _physicsEngine;
  66869. private _originTop;
  66870. private _originDirection;
  66871. private _tickCallback;
  66872. private _cylinder;
  66873. private _cylinderPosition;
  66874. private _dataFetched;
  66875. /**
  66876. * Initializes the physics updraft event
  66877. * @param _scene BabylonJS scene
  66878. * @param _origin The origin position of the updraft
  66879. * @param _options The options for the updraft event
  66880. */
  66881. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66882. /**
  66883. * Returns the data related to the updraft event (cylinder).
  66884. * @returns A physics updraft event
  66885. */
  66886. getData(): PhysicsUpdraftEventData;
  66887. /**
  66888. * Enables the updraft.
  66889. */
  66890. enable(): void;
  66891. /**
  66892. * Disables the updraft.
  66893. */
  66894. disable(): void;
  66895. /**
  66896. * Disposes the cylinder.
  66897. * @param force Specifies if the updraft should be disposed by force
  66898. */
  66899. dispose(force?: boolean): void;
  66900. private getImpostorHitData;
  66901. private _tick;
  66902. /*** Helpers ***/
  66903. private _prepareCylinder;
  66904. private _intersectsWithCylinder;
  66905. }
  66906. /**
  66907. * Represents a physics vortex event
  66908. */
  66909. class PhysicsVortexEvent {
  66910. private _scene;
  66911. private _origin;
  66912. private _options;
  66913. private _physicsEngine;
  66914. private _originTop;
  66915. private _tickCallback;
  66916. private _cylinder;
  66917. private _cylinderPosition;
  66918. private _dataFetched;
  66919. /**
  66920. * Initializes the physics vortex event
  66921. * @param _scene The BabylonJS scene
  66922. * @param _origin The origin position of the vortex
  66923. * @param _options The options for the vortex event
  66924. */
  66925. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66926. /**
  66927. * Returns the data related to the vortex event (cylinder).
  66928. * @returns The physics vortex event data
  66929. */
  66930. getData(): PhysicsVortexEventData;
  66931. /**
  66932. * Enables the vortex.
  66933. */
  66934. enable(): void;
  66935. /**
  66936. * Disables the cortex.
  66937. */
  66938. disable(): void;
  66939. /**
  66940. * Disposes the sphere.
  66941. * @param force
  66942. */
  66943. dispose(force?: boolean): void;
  66944. private getImpostorHitData;
  66945. private _tick;
  66946. /*** Helpers ***/
  66947. private _prepareCylinder;
  66948. private _intersectsWithCylinder;
  66949. }
  66950. /**
  66951. * Options fot the radial explosion event
  66952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66953. */
  66954. export class PhysicsRadialExplosionEventOptions {
  66955. /**
  66956. * The radius of the sphere for the radial explosion.
  66957. */
  66958. radius: number;
  66959. /**
  66960. * The strenth of the explosion.
  66961. */
  66962. strength: number;
  66963. /**
  66964. * The strenght of the force in correspondence to the distance of the affected object
  66965. */
  66966. falloff: PhysicsRadialImpulseFalloff;
  66967. /**
  66968. * Sphere options for the radial explosion.
  66969. */
  66970. sphere: {
  66971. segments: number;
  66972. diameter: number;
  66973. };
  66974. /**
  66975. * Sphere options for the radial explosion.
  66976. */
  66977. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66978. }
  66979. /**
  66980. * Options fot the updraft event
  66981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66982. */
  66983. export class PhysicsUpdraftEventOptions {
  66984. /**
  66985. * The radius of the cylinder for the vortex
  66986. */
  66987. radius: number;
  66988. /**
  66989. * The strenth of the updraft.
  66990. */
  66991. strength: number;
  66992. /**
  66993. * The height of the cylinder for the updraft.
  66994. */
  66995. height: number;
  66996. /**
  66997. * The mode for the the updraft.
  66998. */
  66999. updraftMode: PhysicsUpdraftMode;
  67000. }
  67001. /**
  67002. * Options fot the vortex event
  67003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67004. */
  67005. export class PhysicsVortexEventOptions {
  67006. /**
  67007. * The radius of the cylinder for the vortex
  67008. */
  67009. radius: number;
  67010. /**
  67011. * The strenth of the vortex.
  67012. */
  67013. strength: number;
  67014. /**
  67015. * The height of the cylinder for the vortex.
  67016. */
  67017. height: number;
  67018. /**
  67019. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67020. */
  67021. centripetalForceThreshold: number;
  67022. /**
  67023. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67024. */
  67025. centripetalForceMultiplier: number;
  67026. /**
  67027. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67028. */
  67029. centrifugalForceMultiplier: number;
  67030. /**
  67031. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67032. */
  67033. updraftForceMultiplier: number;
  67034. }
  67035. /**
  67036. * The strenght of the force in correspondence to the distance of the affected object
  67037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67038. */
  67039. export enum PhysicsRadialImpulseFalloff {
  67040. /** Defines that impulse is constant in strength across it's whole radius */
  67041. Constant = 0,
  67042. /** Defines that impulse gets weaker if it's further from the origin */
  67043. Linear = 1
  67044. }
  67045. /**
  67046. * The strength of the force in correspondence to the distance of the affected object
  67047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67048. */
  67049. export enum PhysicsUpdraftMode {
  67050. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67051. Center = 0,
  67052. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67053. Perpendicular = 1
  67054. }
  67055. /**
  67056. * Interface for a physics hit data
  67057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67058. */
  67059. export interface PhysicsHitData {
  67060. /**
  67061. * The force applied at the contact point
  67062. */
  67063. force: Vector3;
  67064. /**
  67065. * The contact point
  67066. */
  67067. contactPoint: Vector3;
  67068. /**
  67069. * The distance from the origin to the contact point
  67070. */
  67071. distanceFromOrigin: number;
  67072. }
  67073. /**
  67074. * Interface for radial explosion event data
  67075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67076. */
  67077. export interface PhysicsRadialExplosionEventData {
  67078. /**
  67079. * A sphere used for the radial explosion event
  67080. */
  67081. sphere: Mesh;
  67082. }
  67083. /**
  67084. * Interface for gravitational field event data
  67085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67086. */
  67087. export interface PhysicsGravitationalFieldEventData {
  67088. /**
  67089. * A sphere mesh used for the gravitational field event
  67090. */
  67091. sphere: Mesh;
  67092. }
  67093. /**
  67094. * Interface for updraft event data
  67095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67096. */
  67097. export interface PhysicsUpdraftEventData {
  67098. /**
  67099. * A cylinder used for the updraft event
  67100. */
  67101. cylinder: Mesh;
  67102. }
  67103. /**
  67104. * Interface for vortex event data
  67105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67106. */
  67107. export interface PhysicsVortexEventData {
  67108. /**
  67109. * A cylinder used for the vortex event
  67110. */
  67111. cylinder: Mesh;
  67112. }
  67113. /**
  67114. * Interface for an affected physics impostor
  67115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67116. */
  67117. export interface PhysicsAffectedImpostorWithData {
  67118. /**
  67119. * The impostor affected by the effect
  67120. */
  67121. impostor: PhysicsImpostor;
  67122. /**
  67123. * The data about the hit/horce from the explosion
  67124. */
  67125. hitData: PhysicsHitData;
  67126. }
  67127. }
  67128. declare module "babylonjs/Physics/Plugins/index" {
  67129. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67130. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67131. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67132. }
  67133. declare module "babylonjs/Physics/index" {
  67134. export * from "babylonjs/Physics/IPhysicsEngine";
  67135. export * from "babylonjs/Physics/physicsEngine";
  67136. export * from "babylonjs/Physics/physicsEngineComponent";
  67137. export * from "babylonjs/Physics/physicsHelper";
  67138. export * from "babylonjs/Physics/physicsImpostor";
  67139. export * from "babylonjs/Physics/physicsJoint";
  67140. export * from "babylonjs/Physics/Plugins/index";
  67141. }
  67142. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67143. /** @hidden */
  67144. export var blackAndWhitePixelShader: {
  67145. name: string;
  67146. shader: string;
  67147. };
  67148. }
  67149. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67151. import { Camera } from "babylonjs/Cameras/camera";
  67152. import { Engine } from "babylonjs/Engines/engine";
  67153. import "babylonjs/Shaders/blackAndWhite.fragment";
  67154. /**
  67155. * Post process used to render in black and white
  67156. */
  67157. export class BlackAndWhitePostProcess extends PostProcess {
  67158. /**
  67159. * Linear about to convert he result to black and white (default: 1)
  67160. */
  67161. degree: number;
  67162. /**
  67163. * Creates a black and white post process
  67164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67165. * @param name The name of the effect.
  67166. * @param options The required width/height ratio to downsize to before computing the render pass.
  67167. * @param camera The camera to apply the render pass to.
  67168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67169. * @param engine The engine which the post process will be applied. (default: current engine)
  67170. * @param reusable If the post process can be reused on the same frame. (default: false)
  67171. */
  67172. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67173. }
  67174. }
  67175. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67176. import { Nullable } from "babylonjs/types";
  67177. import { Camera } from "babylonjs/Cameras/camera";
  67178. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67179. import { Engine } from "babylonjs/Engines/engine";
  67180. /**
  67181. * This represents a set of one or more post processes in Babylon.
  67182. * A post process can be used to apply a shader to a texture after it is rendered.
  67183. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67184. */
  67185. export class PostProcessRenderEffect {
  67186. private _postProcesses;
  67187. private _getPostProcesses;
  67188. private _singleInstance;
  67189. private _cameras;
  67190. private _indicesForCamera;
  67191. /**
  67192. * Name of the effect
  67193. * @hidden
  67194. */
  67195. _name: string;
  67196. /**
  67197. * Instantiates a post process render effect.
  67198. * A post process can be used to apply a shader to a texture after it is rendered.
  67199. * @param engine The engine the effect is tied to
  67200. * @param name The name of the effect
  67201. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67202. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67203. */
  67204. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67205. /**
  67206. * Checks if all the post processes in the effect are supported.
  67207. */
  67208. get isSupported(): boolean;
  67209. /**
  67210. * Updates the current state of the effect
  67211. * @hidden
  67212. */
  67213. _update(): void;
  67214. /**
  67215. * Attaches the effect on cameras
  67216. * @param cameras The camera to attach to.
  67217. * @hidden
  67218. */
  67219. _attachCameras(cameras: Camera): void;
  67220. /**
  67221. * Attaches the effect on cameras
  67222. * @param cameras The camera to attach to.
  67223. * @hidden
  67224. */
  67225. _attachCameras(cameras: Camera[]): void;
  67226. /**
  67227. * Detaches the effect on cameras
  67228. * @param cameras The camera to detatch from.
  67229. * @hidden
  67230. */
  67231. _detachCameras(cameras: Camera): void;
  67232. /**
  67233. * Detatches the effect on cameras
  67234. * @param cameras The camera to detatch from.
  67235. * @hidden
  67236. */
  67237. _detachCameras(cameras: Camera[]): void;
  67238. /**
  67239. * Enables the effect on given cameras
  67240. * @param cameras The camera to enable.
  67241. * @hidden
  67242. */
  67243. _enable(cameras: Camera): void;
  67244. /**
  67245. * Enables the effect on given cameras
  67246. * @param cameras The camera to enable.
  67247. * @hidden
  67248. */
  67249. _enable(cameras: Nullable<Camera[]>): void;
  67250. /**
  67251. * Disables the effect on the given cameras
  67252. * @param cameras The camera to disable.
  67253. * @hidden
  67254. */
  67255. _disable(cameras: Camera): void;
  67256. /**
  67257. * Disables the effect on the given cameras
  67258. * @param cameras The camera to disable.
  67259. * @hidden
  67260. */
  67261. _disable(cameras: Nullable<Camera[]>): void;
  67262. /**
  67263. * Gets a list of the post processes contained in the effect.
  67264. * @param camera The camera to get the post processes on.
  67265. * @returns The list of the post processes in the effect.
  67266. */
  67267. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67268. }
  67269. }
  67270. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67271. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67272. /** @hidden */
  67273. export var extractHighlightsPixelShader: {
  67274. name: string;
  67275. shader: string;
  67276. };
  67277. }
  67278. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67279. import { Nullable } from "babylonjs/types";
  67280. import { Camera } from "babylonjs/Cameras/camera";
  67281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67282. import { Engine } from "babylonjs/Engines/engine";
  67283. import "babylonjs/Shaders/extractHighlights.fragment";
  67284. /**
  67285. * 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.
  67286. */
  67287. export class ExtractHighlightsPostProcess extends PostProcess {
  67288. /**
  67289. * The luminance threshold, pixels below this value will be set to black.
  67290. */
  67291. threshold: number;
  67292. /** @hidden */
  67293. _exposure: number;
  67294. /**
  67295. * Post process which has the input texture to be used when performing highlight extraction
  67296. * @hidden
  67297. */
  67298. _inputPostProcess: Nullable<PostProcess>;
  67299. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67300. }
  67301. }
  67302. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67303. /** @hidden */
  67304. export var bloomMergePixelShader: {
  67305. name: string;
  67306. shader: string;
  67307. };
  67308. }
  67309. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67310. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67311. import { Nullable } from "babylonjs/types";
  67312. import { Engine } from "babylonjs/Engines/engine";
  67313. import { Camera } from "babylonjs/Cameras/camera";
  67314. import "babylonjs/Shaders/bloomMerge.fragment";
  67315. /**
  67316. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67317. */
  67318. export class BloomMergePostProcess extends PostProcess {
  67319. /** Weight of the bloom to be added to the original input. */
  67320. weight: number;
  67321. /**
  67322. * Creates a new instance of @see BloomMergePostProcess
  67323. * @param name The name of the effect.
  67324. * @param originalFromInput Post process which's input will be used for the merge.
  67325. * @param blurred Blurred highlights post process which's output will be used.
  67326. * @param weight Weight of the bloom to be added to the original input.
  67327. * @param options The required width/height ratio to downsize to before computing the render pass.
  67328. * @param camera The camera to apply the render pass to.
  67329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67330. * @param engine The engine which the post process will be applied. (default: current engine)
  67331. * @param reusable If the post process can be reused on the same frame. (default: false)
  67332. * @param textureType Type of textures used when performing the post process. (default: 0)
  67333. * @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)
  67334. */
  67335. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67336. /** Weight of the bloom to be added to the original input. */
  67337. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67338. }
  67339. }
  67340. declare module "babylonjs/PostProcesses/bloomEffect" {
  67341. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67342. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67343. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67344. import { Camera } from "babylonjs/Cameras/camera";
  67345. import { Scene } from "babylonjs/scene";
  67346. /**
  67347. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67348. */
  67349. export class BloomEffect extends PostProcessRenderEffect {
  67350. private bloomScale;
  67351. /**
  67352. * @hidden Internal
  67353. */
  67354. _effects: Array<PostProcess>;
  67355. /**
  67356. * @hidden Internal
  67357. */
  67358. _downscale: ExtractHighlightsPostProcess;
  67359. private _blurX;
  67360. private _blurY;
  67361. private _merge;
  67362. /**
  67363. * The luminance threshold to find bright areas of the image to bloom.
  67364. */
  67365. get threshold(): number;
  67366. set threshold(value: number);
  67367. /**
  67368. * The strength of the bloom.
  67369. */
  67370. get weight(): number;
  67371. set weight(value: number);
  67372. /**
  67373. * Specifies the size of the bloom blur kernel, relative to the final output size
  67374. */
  67375. get kernel(): number;
  67376. set kernel(value: number);
  67377. /**
  67378. * Creates a new instance of @see BloomEffect
  67379. * @param scene The scene the effect belongs to.
  67380. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67381. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67382. * @param bloomWeight The the strength of bloom.
  67383. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67384. * @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)
  67385. */
  67386. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67387. /**
  67388. * Disposes each of the internal effects for a given camera.
  67389. * @param camera The camera to dispose the effect on.
  67390. */
  67391. disposeEffects(camera: Camera): void;
  67392. /**
  67393. * @hidden Internal
  67394. */
  67395. _updateEffects(): void;
  67396. /**
  67397. * Internal
  67398. * @returns if all the contained post processes are ready.
  67399. * @hidden
  67400. */
  67401. _isReady(): boolean;
  67402. }
  67403. }
  67404. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67405. /** @hidden */
  67406. export var chromaticAberrationPixelShader: {
  67407. name: string;
  67408. shader: string;
  67409. };
  67410. }
  67411. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67412. import { Vector2 } from "babylonjs/Maths/math.vector";
  67413. import { Nullable } from "babylonjs/types";
  67414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67415. import { Camera } from "babylonjs/Cameras/camera";
  67416. import { Engine } from "babylonjs/Engines/engine";
  67417. import "babylonjs/Shaders/chromaticAberration.fragment";
  67418. /**
  67419. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67420. */
  67421. export class ChromaticAberrationPostProcess extends PostProcess {
  67422. /**
  67423. * The amount of seperation of rgb channels (default: 30)
  67424. */
  67425. aberrationAmount: number;
  67426. /**
  67427. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67428. */
  67429. radialIntensity: number;
  67430. /**
  67431. * 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))
  67432. */
  67433. direction: Vector2;
  67434. /**
  67435. * 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))
  67436. */
  67437. centerPosition: Vector2;
  67438. /**
  67439. * Creates a new instance ChromaticAberrationPostProcess
  67440. * @param name The name of the effect.
  67441. * @param screenWidth The width of the screen to apply the effect on.
  67442. * @param screenHeight The height of the screen to apply the effect on.
  67443. * @param options The required width/height ratio to downsize to before computing the render pass.
  67444. * @param camera The camera to apply the render pass to.
  67445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67446. * @param engine The engine which the post process will be applied. (default: current engine)
  67447. * @param reusable If the post process can be reused on the same frame. (default: false)
  67448. * @param textureType Type of textures used when performing the post process. (default: 0)
  67449. * @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)
  67450. */
  67451. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67452. }
  67453. }
  67454. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67455. /** @hidden */
  67456. export var circleOfConfusionPixelShader: {
  67457. name: string;
  67458. shader: string;
  67459. };
  67460. }
  67461. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67462. import { Nullable } from "babylonjs/types";
  67463. import { Engine } from "babylonjs/Engines/engine";
  67464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67465. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67466. import { Camera } from "babylonjs/Cameras/camera";
  67467. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67468. /**
  67469. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67470. */
  67471. export class CircleOfConfusionPostProcess extends PostProcess {
  67472. /**
  67473. * 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.
  67474. */
  67475. lensSize: number;
  67476. /**
  67477. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67478. */
  67479. fStop: number;
  67480. /**
  67481. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67482. */
  67483. focusDistance: number;
  67484. /**
  67485. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67486. */
  67487. focalLength: number;
  67488. private _depthTexture;
  67489. /**
  67490. * Creates a new instance CircleOfConfusionPostProcess
  67491. * @param name The name of the effect.
  67492. * @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.
  67493. * @param options The required width/height ratio to downsize to before computing the render pass.
  67494. * @param camera The camera to apply the render pass to.
  67495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67496. * @param engine The engine which the post process will be applied. (default: current engine)
  67497. * @param reusable If the post process can be reused on the same frame. (default: false)
  67498. * @param textureType Type of textures used when performing the post process. (default: 0)
  67499. * @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)
  67500. */
  67501. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67502. /**
  67503. * 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.
  67504. */
  67505. set depthTexture(value: RenderTargetTexture);
  67506. }
  67507. }
  67508. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67509. /** @hidden */
  67510. export var colorCorrectionPixelShader: {
  67511. name: string;
  67512. shader: string;
  67513. };
  67514. }
  67515. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67516. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67517. import { Engine } from "babylonjs/Engines/engine";
  67518. import { Camera } from "babylonjs/Cameras/camera";
  67519. import "babylonjs/Shaders/colorCorrection.fragment";
  67520. /**
  67521. *
  67522. * This post-process allows the modification of rendered colors by using
  67523. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67524. *
  67525. * The object needs to be provided an url to a texture containing the color
  67526. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67527. * Use an image editing software to tweak the LUT to match your needs.
  67528. *
  67529. * For an example of a color LUT, see here:
  67530. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67531. * For explanations on color grading, see here:
  67532. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67533. *
  67534. */
  67535. export class ColorCorrectionPostProcess extends PostProcess {
  67536. private _colorTableTexture;
  67537. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67538. }
  67539. }
  67540. declare module "babylonjs/Shaders/convolution.fragment" {
  67541. /** @hidden */
  67542. export var convolutionPixelShader: {
  67543. name: string;
  67544. shader: string;
  67545. };
  67546. }
  67547. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67548. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67549. import { Nullable } from "babylonjs/types";
  67550. import { Camera } from "babylonjs/Cameras/camera";
  67551. import { Engine } from "babylonjs/Engines/engine";
  67552. import "babylonjs/Shaders/convolution.fragment";
  67553. /**
  67554. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67555. * input texture to perform effects such as edge detection or sharpening
  67556. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67557. */
  67558. export class ConvolutionPostProcess extends PostProcess {
  67559. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67560. kernel: number[];
  67561. /**
  67562. * Creates a new instance ConvolutionPostProcess
  67563. * @param name The name of the effect.
  67564. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67565. * @param options The required width/height ratio to downsize to before computing the render pass.
  67566. * @param camera The camera to apply the render pass to.
  67567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67568. * @param engine The engine which the post process will be applied. (default: current engine)
  67569. * @param reusable If the post process can be reused on the same frame. (default: false)
  67570. * @param textureType Type of textures used when performing the post process. (default: 0)
  67571. */
  67572. constructor(name: string,
  67573. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67574. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67575. /**
  67576. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67577. */
  67578. static EdgeDetect0Kernel: number[];
  67579. /**
  67580. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67581. */
  67582. static EdgeDetect1Kernel: number[];
  67583. /**
  67584. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67585. */
  67586. static EdgeDetect2Kernel: number[];
  67587. /**
  67588. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67589. */
  67590. static SharpenKernel: number[];
  67591. /**
  67592. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67593. */
  67594. static EmbossKernel: number[];
  67595. /**
  67596. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67597. */
  67598. static GaussianKernel: number[];
  67599. }
  67600. }
  67601. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67602. import { Nullable } from "babylonjs/types";
  67603. import { Vector2 } from "babylonjs/Maths/math.vector";
  67604. import { Camera } from "babylonjs/Cameras/camera";
  67605. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67606. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67607. import { Engine } from "babylonjs/Engines/engine";
  67608. import { Scene } from "babylonjs/scene";
  67609. /**
  67610. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67611. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67612. * based on samples that have a large difference in distance than the center pixel.
  67613. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67614. */
  67615. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67616. direction: Vector2;
  67617. /**
  67618. * Creates a new instance CircleOfConfusionPostProcess
  67619. * @param name The name of the effect.
  67620. * @param scene The scene the effect belongs to.
  67621. * @param direction The direction the blur should be applied.
  67622. * @param kernel The size of the kernel used to blur.
  67623. * @param options The required width/height ratio to downsize to before computing the render pass.
  67624. * @param camera The camera to apply the render pass to.
  67625. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67626. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67628. * @param engine The engine which the post process will be applied. (default: current engine)
  67629. * @param reusable If the post process can be reused on the same frame. (default: false)
  67630. * @param textureType Type of textures used when performing the post process. (default: 0)
  67631. * @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)
  67632. */
  67633. 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);
  67634. }
  67635. }
  67636. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67637. /** @hidden */
  67638. export var depthOfFieldMergePixelShader: {
  67639. name: string;
  67640. shader: string;
  67641. };
  67642. }
  67643. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67644. import { Nullable } from "babylonjs/types";
  67645. import { Camera } from "babylonjs/Cameras/camera";
  67646. import { Effect } from "babylonjs/Materials/effect";
  67647. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67648. import { Engine } from "babylonjs/Engines/engine";
  67649. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67650. /**
  67651. * Options to be set when merging outputs from the default pipeline.
  67652. */
  67653. export class DepthOfFieldMergePostProcessOptions {
  67654. /**
  67655. * The original image to merge on top of
  67656. */
  67657. originalFromInput: PostProcess;
  67658. /**
  67659. * Parameters to perform the merge of the depth of field effect
  67660. */
  67661. depthOfField?: {
  67662. circleOfConfusion: PostProcess;
  67663. blurSteps: Array<PostProcess>;
  67664. };
  67665. /**
  67666. * Parameters to perform the merge of bloom effect
  67667. */
  67668. bloom?: {
  67669. blurred: PostProcess;
  67670. weight: number;
  67671. };
  67672. }
  67673. /**
  67674. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67675. */
  67676. export class DepthOfFieldMergePostProcess extends PostProcess {
  67677. private blurSteps;
  67678. /**
  67679. * Creates a new instance of DepthOfFieldMergePostProcess
  67680. * @param name The name of the effect.
  67681. * @param originalFromInput Post process which's input will be used for the merge.
  67682. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67683. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67684. * @param options The required width/height ratio to downsize to before computing the render pass.
  67685. * @param camera The camera to apply the render pass to.
  67686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67687. * @param engine The engine which the post process will be applied. (default: current engine)
  67688. * @param reusable If the post process can be reused on the same frame. (default: false)
  67689. * @param textureType Type of textures used when performing the post process. (default: 0)
  67690. * @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)
  67691. */
  67692. 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);
  67693. /**
  67694. * Updates the effect with the current post process compile time values and recompiles the shader.
  67695. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67696. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67697. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67698. * @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
  67699. * @param onCompiled Called when the shader has been compiled.
  67700. * @param onError Called if there is an error when compiling a shader.
  67701. */
  67702. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67703. }
  67704. }
  67705. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67706. import { Nullable } from "babylonjs/types";
  67707. import { Camera } from "babylonjs/Cameras/camera";
  67708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67710. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67711. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67712. import { Scene } from "babylonjs/scene";
  67713. /**
  67714. * Specifies the level of max blur that should be applied when using the depth of field effect
  67715. */
  67716. export enum DepthOfFieldEffectBlurLevel {
  67717. /**
  67718. * Subtle blur
  67719. */
  67720. Low = 0,
  67721. /**
  67722. * Medium blur
  67723. */
  67724. Medium = 1,
  67725. /**
  67726. * Large blur
  67727. */
  67728. High = 2
  67729. }
  67730. /**
  67731. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67732. */
  67733. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67734. private _circleOfConfusion;
  67735. /**
  67736. * @hidden Internal, blurs from high to low
  67737. */
  67738. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67739. private _depthOfFieldBlurY;
  67740. private _dofMerge;
  67741. /**
  67742. * @hidden Internal post processes in depth of field effect
  67743. */
  67744. _effects: Array<PostProcess>;
  67745. /**
  67746. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67747. */
  67748. set focalLength(value: number);
  67749. get focalLength(): number;
  67750. /**
  67751. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67752. */
  67753. set fStop(value: number);
  67754. get fStop(): number;
  67755. /**
  67756. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67757. */
  67758. set focusDistance(value: number);
  67759. get focusDistance(): number;
  67760. /**
  67761. * 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.
  67762. */
  67763. set lensSize(value: number);
  67764. get lensSize(): number;
  67765. /**
  67766. * Creates a new instance DepthOfFieldEffect
  67767. * @param scene The scene the effect belongs to.
  67768. * @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.
  67769. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67770. * @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)
  67771. */
  67772. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67773. /**
  67774. * Get the current class name of the current effet
  67775. * @returns "DepthOfFieldEffect"
  67776. */
  67777. getClassName(): string;
  67778. /**
  67779. * 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.
  67780. */
  67781. set depthTexture(value: RenderTargetTexture);
  67782. /**
  67783. * Disposes each of the internal effects for a given camera.
  67784. * @param camera The camera to dispose the effect on.
  67785. */
  67786. disposeEffects(camera: Camera): void;
  67787. /**
  67788. * @hidden Internal
  67789. */
  67790. _updateEffects(): void;
  67791. /**
  67792. * Internal
  67793. * @returns if all the contained post processes are ready.
  67794. * @hidden
  67795. */
  67796. _isReady(): boolean;
  67797. }
  67798. }
  67799. declare module "babylonjs/Shaders/displayPass.fragment" {
  67800. /** @hidden */
  67801. export var displayPassPixelShader: {
  67802. name: string;
  67803. shader: string;
  67804. };
  67805. }
  67806. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67807. import { Nullable } from "babylonjs/types";
  67808. import { Camera } from "babylonjs/Cameras/camera";
  67809. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67810. import { Engine } from "babylonjs/Engines/engine";
  67811. import "babylonjs/Shaders/displayPass.fragment";
  67812. /**
  67813. * DisplayPassPostProcess which produces an output the same as it's input
  67814. */
  67815. export class DisplayPassPostProcess extends PostProcess {
  67816. /**
  67817. * Creates the DisplayPassPostProcess
  67818. * @param name The name of the effect.
  67819. * @param options The required width/height ratio to downsize to before computing the render pass.
  67820. * @param camera The camera to apply the render pass to.
  67821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67822. * @param engine The engine which the post process will be applied. (default: current engine)
  67823. * @param reusable If the post process can be reused on the same frame. (default: false)
  67824. */
  67825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67826. }
  67827. }
  67828. declare module "babylonjs/Shaders/filter.fragment" {
  67829. /** @hidden */
  67830. export var filterPixelShader: {
  67831. name: string;
  67832. shader: string;
  67833. };
  67834. }
  67835. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67836. import { Nullable } from "babylonjs/types";
  67837. import { Matrix } from "babylonjs/Maths/math.vector";
  67838. import { Camera } from "babylonjs/Cameras/camera";
  67839. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67840. import { Engine } from "babylonjs/Engines/engine";
  67841. import "babylonjs/Shaders/filter.fragment";
  67842. /**
  67843. * Applies a kernel filter to the image
  67844. */
  67845. export class FilterPostProcess extends PostProcess {
  67846. /** The matrix to be applied to the image */
  67847. kernelMatrix: Matrix;
  67848. /**
  67849. *
  67850. * @param name The name of the effect.
  67851. * @param kernelMatrix The matrix to be applied to the image
  67852. * @param options The required width/height ratio to downsize to before computing the render pass.
  67853. * @param camera The camera to apply the render pass to.
  67854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67855. * @param engine The engine which the post process will be applied. (default: current engine)
  67856. * @param reusable If the post process can be reused on the same frame. (default: false)
  67857. */
  67858. constructor(name: string,
  67859. /** The matrix to be applied to the image */
  67860. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67861. }
  67862. }
  67863. declare module "babylonjs/Shaders/fxaa.fragment" {
  67864. /** @hidden */
  67865. export var fxaaPixelShader: {
  67866. name: string;
  67867. shader: string;
  67868. };
  67869. }
  67870. declare module "babylonjs/Shaders/fxaa.vertex" {
  67871. /** @hidden */
  67872. export var fxaaVertexShader: {
  67873. name: string;
  67874. shader: string;
  67875. };
  67876. }
  67877. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67878. import { Nullable } from "babylonjs/types";
  67879. import { Camera } from "babylonjs/Cameras/camera";
  67880. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67881. import { Engine } from "babylonjs/Engines/engine";
  67882. import "babylonjs/Shaders/fxaa.fragment";
  67883. import "babylonjs/Shaders/fxaa.vertex";
  67884. /**
  67885. * Fxaa post process
  67886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67887. */
  67888. export class FxaaPostProcess extends PostProcess {
  67889. /** @hidden */
  67890. texelWidth: number;
  67891. /** @hidden */
  67892. texelHeight: number;
  67893. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67894. private _getDefines;
  67895. }
  67896. }
  67897. declare module "babylonjs/Shaders/grain.fragment" {
  67898. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67899. /** @hidden */
  67900. export var grainPixelShader: {
  67901. name: string;
  67902. shader: string;
  67903. };
  67904. }
  67905. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67906. import { Nullable } from "babylonjs/types";
  67907. import { Camera } from "babylonjs/Cameras/camera";
  67908. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67909. import { Engine } from "babylonjs/Engines/engine";
  67910. import "babylonjs/Shaders/grain.fragment";
  67911. /**
  67912. * The GrainPostProcess adds noise to the image at mid luminance levels
  67913. */
  67914. export class GrainPostProcess extends PostProcess {
  67915. /**
  67916. * The intensity of the grain added (default: 30)
  67917. */
  67918. intensity: number;
  67919. /**
  67920. * If the grain should be randomized on every frame
  67921. */
  67922. animated: boolean;
  67923. /**
  67924. * Creates a new instance of @see GrainPostProcess
  67925. * @param name The name of the effect.
  67926. * @param options The required width/height ratio to downsize to before computing the render pass.
  67927. * @param camera The camera to apply the render pass to.
  67928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67929. * @param engine The engine which the post process will be applied. (default: current engine)
  67930. * @param reusable If the post process can be reused on the same frame. (default: false)
  67931. * @param textureType Type of textures used when performing the post process. (default: 0)
  67932. * @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)
  67933. */
  67934. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67935. }
  67936. }
  67937. declare module "babylonjs/Shaders/highlights.fragment" {
  67938. /** @hidden */
  67939. export var highlightsPixelShader: {
  67940. name: string;
  67941. shader: string;
  67942. };
  67943. }
  67944. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67945. import { Nullable } from "babylonjs/types";
  67946. import { Camera } from "babylonjs/Cameras/camera";
  67947. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67948. import { Engine } from "babylonjs/Engines/engine";
  67949. import "babylonjs/Shaders/highlights.fragment";
  67950. /**
  67951. * Extracts highlights from the image
  67952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67953. */
  67954. export class HighlightsPostProcess extends PostProcess {
  67955. /**
  67956. * Extracts highlights from the image
  67957. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67958. * @param name The name of the effect.
  67959. * @param options The required width/height ratio to downsize to before computing the render pass.
  67960. * @param camera The camera to apply the render pass to.
  67961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67962. * @param engine The engine which the post process will be applied. (default: current engine)
  67963. * @param reusable If the post process can be reused on the same frame. (default: false)
  67964. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67965. */
  67966. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67967. }
  67968. }
  67969. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67970. /** @hidden */
  67971. export var mrtFragmentDeclaration: {
  67972. name: string;
  67973. shader: string;
  67974. };
  67975. }
  67976. declare module "babylonjs/Shaders/geometry.fragment" {
  67977. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67978. /** @hidden */
  67979. export var geometryPixelShader: {
  67980. name: string;
  67981. shader: string;
  67982. };
  67983. }
  67984. declare module "babylonjs/Shaders/geometry.vertex" {
  67985. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67987. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67988. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67989. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67990. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67991. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67992. /** @hidden */
  67993. export var geometryVertexShader: {
  67994. name: string;
  67995. shader: string;
  67996. };
  67997. }
  67998. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67999. import { Matrix } from "babylonjs/Maths/math.vector";
  68000. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68001. import { Mesh } from "babylonjs/Meshes/mesh";
  68002. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68003. import { Effect } from "babylonjs/Materials/effect";
  68004. import { Scene } from "babylonjs/scene";
  68005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68006. import "babylonjs/Shaders/geometry.fragment";
  68007. import "babylonjs/Shaders/geometry.vertex";
  68008. /** @hidden */
  68009. interface ISavedTransformationMatrix {
  68010. world: Matrix;
  68011. viewProjection: Matrix;
  68012. }
  68013. /**
  68014. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68015. */
  68016. export class GeometryBufferRenderer {
  68017. /**
  68018. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68019. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68020. */
  68021. static readonly POSITION_TEXTURE_TYPE: number;
  68022. /**
  68023. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68024. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68025. */
  68026. static readonly VELOCITY_TEXTURE_TYPE: number;
  68027. /**
  68028. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68029. * in order to compute objects velocities when enableVelocity is set to "true"
  68030. * @hidden
  68031. */
  68032. _previousTransformationMatrices: {
  68033. [index: number]: ISavedTransformationMatrix;
  68034. };
  68035. /**
  68036. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68037. * in order to compute objects velocities when enableVelocity is set to "true"
  68038. * @hidden
  68039. */
  68040. _previousBonesTransformationMatrices: {
  68041. [index: number]: Float32Array;
  68042. };
  68043. /**
  68044. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68045. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68046. */
  68047. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68048. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68049. renderTransparentMeshes: boolean;
  68050. private _scene;
  68051. private _multiRenderTarget;
  68052. private _ratio;
  68053. private _enablePosition;
  68054. private _enableVelocity;
  68055. private _positionIndex;
  68056. private _velocityIndex;
  68057. protected _effect: Effect;
  68058. protected _cachedDefines: string;
  68059. /**
  68060. * Set the render list (meshes to be rendered) used in the G buffer.
  68061. */
  68062. set renderList(meshes: Mesh[]);
  68063. /**
  68064. * Gets wether or not G buffer are supported by the running hardware.
  68065. * This requires draw buffer supports
  68066. */
  68067. get isSupported(): boolean;
  68068. /**
  68069. * Returns the index of the given texture type in the G-Buffer textures array
  68070. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68071. * @returns the index of the given texture type in the G-Buffer textures array
  68072. */
  68073. getTextureIndex(textureType: number): number;
  68074. /**
  68075. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68076. */
  68077. get enablePosition(): boolean;
  68078. /**
  68079. * Sets whether or not objects positions are enabled for the G buffer.
  68080. */
  68081. set enablePosition(enable: boolean);
  68082. /**
  68083. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68084. */
  68085. get enableVelocity(): boolean;
  68086. /**
  68087. * Sets wether or not objects velocities are enabled for the G buffer.
  68088. */
  68089. set enableVelocity(enable: boolean);
  68090. /**
  68091. * Gets the scene associated with the buffer.
  68092. */
  68093. get scene(): Scene;
  68094. /**
  68095. * Gets the ratio used by the buffer during its creation.
  68096. * How big is the buffer related to the main canvas.
  68097. */
  68098. get ratio(): number;
  68099. /** @hidden */
  68100. static _SceneComponentInitialization: (scene: Scene) => void;
  68101. /**
  68102. * Creates a new G Buffer for the scene
  68103. * @param scene The scene the buffer belongs to
  68104. * @param ratio How big is the buffer related to the main canvas.
  68105. */
  68106. constructor(scene: Scene, ratio?: number);
  68107. /**
  68108. * Checks wether everything is ready to render a submesh to the G buffer.
  68109. * @param subMesh the submesh to check readiness for
  68110. * @param useInstances is the mesh drawn using instance or not
  68111. * @returns true if ready otherwise false
  68112. */
  68113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68114. /**
  68115. * Gets the current underlying G Buffer.
  68116. * @returns the buffer
  68117. */
  68118. getGBuffer(): MultiRenderTarget;
  68119. /**
  68120. * Gets the number of samples used to render the buffer (anti aliasing).
  68121. */
  68122. get samples(): number;
  68123. /**
  68124. * Sets the number of samples used to render the buffer (anti aliasing).
  68125. */
  68126. set samples(value: number);
  68127. /**
  68128. * Disposes the renderer and frees up associated resources.
  68129. */
  68130. dispose(): void;
  68131. protected _createRenderTargets(): void;
  68132. private _copyBonesTransformationMatrices;
  68133. }
  68134. }
  68135. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68136. import { Nullable } from "babylonjs/types";
  68137. import { Scene } from "babylonjs/scene";
  68138. import { ISceneComponent } from "babylonjs/sceneComponent";
  68139. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68140. module "babylonjs/scene" {
  68141. interface Scene {
  68142. /** @hidden (Backing field) */
  68143. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68144. /**
  68145. * Gets or Sets the current geometry buffer associated to the scene.
  68146. */
  68147. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68148. /**
  68149. * Enables a GeometryBufferRender and associates it with the scene
  68150. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68151. * @returns the GeometryBufferRenderer
  68152. */
  68153. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68154. /**
  68155. * Disables the GeometryBufferRender associated with the scene
  68156. */
  68157. disableGeometryBufferRenderer(): void;
  68158. }
  68159. }
  68160. /**
  68161. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68162. * in several rendering techniques.
  68163. */
  68164. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68165. /**
  68166. * The component name helpful to identify the component in the list of scene components.
  68167. */
  68168. readonly name: string;
  68169. /**
  68170. * The scene the component belongs to.
  68171. */
  68172. scene: Scene;
  68173. /**
  68174. * Creates a new instance of the component for the given scene
  68175. * @param scene Defines the scene to register the component in
  68176. */
  68177. constructor(scene: Scene);
  68178. /**
  68179. * Registers the component in a given scene
  68180. */
  68181. register(): void;
  68182. /**
  68183. * Rebuilds the elements related to this component in case of
  68184. * context lost for instance.
  68185. */
  68186. rebuild(): void;
  68187. /**
  68188. * Disposes the component and the associated ressources
  68189. */
  68190. dispose(): void;
  68191. private _gatherRenderTargets;
  68192. }
  68193. }
  68194. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68195. /** @hidden */
  68196. export var motionBlurPixelShader: {
  68197. name: string;
  68198. shader: string;
  68199. };
  68200. }
  68201. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68202. import { Nullable } from "babylonjs/types";
  68203. import { Camera } from "babylonjs/Cameras/camera";
  68204. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68205. import { Scene } from "babylonjs/scene";
  68206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68207. import "babylonjs/Animations/animatable";
  68208. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68209. import "babylonjs/Shaders/motionBlur.fragment";
  68210. import { Engine } from "babylonjs/Engines/engine";
  68211. /**
  68212. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68213. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68214. * As an example, all you have to do is to create the post-process:
  68215. * var mb = new BABYLON.MotionBlurPostProcess(
  68216. * 'mb', // The name of the effect.
  68217. * scene, // The scene containing the objects to blur according to their velocity.
  68218. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68219. * camera // The camera to apply the render pass to.
  68220. * );
  68221. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68222. */
  68223. export class MotionBlurPostProcess extends PostProcess {
  68224. /**
  68225. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68226. */
  68227. motionStrength: number;
  68228. /**
  68229. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68230. */
  68231. get motionBlurSamples(): number;
  68232. /**
  68233. * Sets the number of iterations to be used for motion blur quality
  68234. */
  68235. set motionBlurSamples(samples: number);
  68236. private _motionBlurSamples;
  68237. private _geometryBufferRenderer;
  68238. /**
  68239. * Creates a new instance MotionBlurPostProcess
  68240. * @param name The name of the effect.
  68241. * @param scene The scene containing the objects to blur according to their velocity.
  68242. * @param options The required width/height ratio to downsize to before computing the render pass.
  68243. * @param camera The camera to apply the render pass to.
  68244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68245. * @param engine The engine which the post process will be applied. (default: current engine)
  68246. * @param reusable If the post process can be reused on the same frame. (default: false)
  68247. * @param textureType Type of textures used when performing the post process. (default: 0)
  68248. * @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)
  68249. */
  68250. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68251. /**
  68252. * Excludes the given skinned mesh from computing bones velocities.
  68253. * 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.
  68254. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68255. */
  68256. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68257. /**
  68258. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68259. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68260. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68261. */
  68262. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68263. /**
  68264. * Disposes the post process.
  68265. * @param camera The camera to dispose the post process on.
  68266. */
  68267. dispose(camera?: Camera): void;
  68268. }
  68269. }
  68270. declare module "babylonjs/Shaders/refraction.fragment" {
  68271. /** @hidden */
  68272. export var refractionPixelShader: {
  68273. name: string;
  68274. shader: string;
  68275. };
  68276. }
  68277. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68278. import { Color3 } from "babylonjs/Maths/math.color";
  68279. import { Camera } from "babylonjs/Cameras/camera";
  68280. import { Texture } from "babylonjs/Materials/Textures/texture";
  68281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68282. import { Engine } from "babylonjs/Engines/engine";
  68283. import "babylonjs/Shaders/refraction.fragment";
  68284. /**
  68285. * Post process which applies a refractin texture
  68286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68287. */
  68288. export class RefractionPostProcess extends PostProcess {
  68289. /** the base color of the refraction (used to taint the rendering) */
  68290. color: Color3;
  68291. /** simulated refraction depth */
  68292. depth: number;
  68293. /** the coefficient of the base color (0 to remove base color tainting) */
  68294. colorLevel: number;
  68295. private _refTexture;
  68296. private _ownRefractionTexture;
  68297. /**
  68298. * Gets or sets the refraction texture
  68299. * Please note that you are responsible for disposing the texture if you set it manually
  68300. */
  68301. get refractionTexture(): Texture;
  68302. set refractionTexture(value: Texture);
  68303. /**
  68304. * Initializes the RefractionPostProcess
  68305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68306. * @param name The name of the effect.
  68307. * @param refractionTextureUrl Url of the refraction texture to use
  68308. * @param color the base color of the refraction (used to taint the rendering)
  68309. * @param depth simulated refraction depth
  68310. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68311. * @param camera The camera to apply the render pass to.
  68312. * @param options The required width/height ratio to downsize to before computing the render pass.
  68313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68314. * @param engine The engine which the post process will be applied. (default: current engine)
  68315. * @param reusable If the post process can be reused on the same frame. (default: false)
  68316. */
  68317. constructor(name: string, refractionTextureUrl: string,
  68318. /** the base color of the refraction (used to taint the rendering) */
  68319. color: Color3,
  68320. /** simulated refraction depth */
  68321. depth: number,
  68322. /** the coefficient of the base color (0 to remove base color tainting) */
  68323. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68324. /**
  68325. * Disposes of the post process
  68326. * @param camera Camera to dispose post process on
  68327. */
  68328. dispose(camera: Camera): void;
  68329. }
  68330. }
  68331. declare module "babylonjs/Shaders/sharpen.fragment" {
  68332. /** @hidden */
  68333. export var sharpenPixelShader: {
  68334. name: string;
  68335. shader: string;
  68336. };
  68337. }
  68338. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68339. import { Nullable } from "babylonjs/types";
  68340. import { Camera } from "babylonjs/Cameras/camera";
  68341. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68342. import "babylonjs/Shaders/sharpen.fragment";
  68343. import { Engine } from "babylonjs/Engines/engine";
  68344. /**
  68345. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68346. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68347. */
  68348. export class SharpenPostProcess extends PostProcess {
  68349. /**
  68350. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68351. */
  68352. colorAmount: number;
  68353. /**
  68354. * How much sharpness should be applied (default: 0.3)
  68355. */
  68356. edgeAmount: number;
  68357. /**
  68358. * Creates a new instance ConvolutionPostProcess
  68359. * @param name The name of the effect.
  68360. * @param options The required width/height ratio to downsize to before computing the render pass.
  68361. * @param camera The camera to apply the render pass to.
  68362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68363. * @param engine The engine which the post process will be applied. (default: current engine)
  68364. * @param reusable If the post process can be reused on the same frame. (default: false)
  68365. * @param textureType Type of textures used when performing the post process. (default: 0)
  68366. * @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)
  68367. */
  68368. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68369. }
  68370. }
  68371. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68372. import { Nullable } from "babylonjs/types";
  68373. import { Camera } from "babylonjs/Cameras/camera";
  68374. import { Engine } from "babylonjs/Engines/engine";
  68375. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68376. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68377. /**
  68378. * PostProcessRenderPipeline
  68379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68380. */
  68381. export class PostProcessRenderPipeline {
  68382. private engine;
  68383. private _renderEffects;
  68384. private _renderEffectsForIsolatedPass;
  68385. /**
  68386. * List of inspectable custom properties (used by the Inspector)
  68387. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68388. */
  68389. inspectableCustomProperties: IInspectable[];
  68390. /**
  68391. * @hidden
  68392. */
  68393. protected _cameras: Camera[];
  68394. /** @hidden */
  68395. _name: string;
  68396. /**
  68397. * Gets pipeline name
  68398. */
  68399. get name(): string;
  68400. /** Gets the list of attached cameras */
  68401. get cameras(): Camera[];
  68402. /**
  68403. * Initializes a PostProcessRenderPipeline
  68404. * @param engine engine to add the pipeline to
  68405. * @param name name of the pipeline
  68406. */
  68407. constructor(engine: Engine, name: string);
  68408. /**
  68409. * Gets the class name
  68410. * @returns "PostProcessRenderPipeline"
  68411. */
  68412. getClassName(): string;
  68413. /**
  68414. * If all the render effects in the pipeline are supported
  68415. */
  68416. get isSupported(): boolean;
  68417. /**
  68418. * Adds an effect to the pipeline
  68419. * @param renderEffect the effect to add
  68420. */
  68421. addEffect(renderEffect: PostProcessRenderEffect): void;
  68422. /** @hidden */
  68423. _rebuild(): void;
  68424. /** @hidden */
  68425. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68426. /** @hidden */
  68427. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68428. /** @hidden */
  68429. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68430. /** @hidden */
  68431. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68432. /** @hidden */
  68433. _attachCameras(cameras: Camera, unique: boolean): void;
  68434. /** @hidden */
  68435. _attachCameras(cameras: Camera[], unique: boolean): void;
  68436. /** @hidden */
  68437. _detachCameras(cameras: Camera): void;
  68438. /** @hidden */
  68439. _detachCameras(cameras: Nullable<Camera[]>): void;
  68440. /** @hidden */
  68441. _update(): void;
  68442. /** @hidden */
  68443. _reset(): void;
  68444. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68445. /**
  68446. * Disposes of the pipeline
  68447. */
  68448. dispose(): void;
  68449. }
  68450. }
  68451. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68452. import { Camera } from "babylonjs/Cameras/camera";
  68453. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68454. /**
  68455. * PostProcessRenderPipelineManager class
  68456. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68457. */
  68458. export class PostProcessRenderPipelineManager {
  68459. private _renderPipelines;
  68460. /**
  68461. * Initializes a PostProcessRenderPipelineManager
  68462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68463. */
  68464. constructor();
  68465. /**
  68466. * Gets the list of supported render pipelines
  68467. */
  68468. get supportedPipelines(): PostProcessRenderPipeline[];
  68469. /**
  68470. * Adds a pipeline to the manager
  68471. * @param renderPipeline The pipeline to add
  68472. */
  68473. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68474. /**
  68475. * Attaches a camera to the pipeline
  68476. * @param renderPipelineName The name of the pipeline to attach to
  68477. * @param cameras the camera to attach
  68478. * @param unique if the camera can be attached multiple times to the pipeline
  68479. */
  68480. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68481. /**
  68482. * Detaches a camera from the pipeline
  68483. * @param renderPipelineName The name of the pipeline to detach from
  68484. * @param cameras the camera to detach
  68485. */
  68486. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68487. /**
  68488. * Enables an effect by name on a pipeline
  68489. * @param renderPipelineName the name of the pipeline to enable the effect in
  68490. * @param renderEffectName the name of the effect to enable
  68491. * @param cameras the cameras that the effect should be enabled on
  68492. */
  68493. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68494. /**
  68495. * Disables an effect by name on a pipeline
  68496. * @param renderPipelineName the name of the pipeline to disable the effect in
  68497. * @param renderEffectName the name of the effect to disable
  68498. * @param cameras the cameras that the effect should be disabled on
  68499. */
  68500. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68501. /**
  68502. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68503. */
  68504. update(): void;
  68505. /** @hidden */
  68506. _rebuild(): void;
  68507. /**
  68508. * Disposes of the manager and pipelines
  68509. */
  68510. dispose(): void;
  68511. }
  68512. }
  68513. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68514. import { ISceneComponent } from "babylonjs/sceneComponent";
  68515. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68516. import { Scene } from "babylonjs/scene";
  68517. module "babylonjs/scene" {
  68518. interface Scene {
  68519. /** @hidden (Backing field) */
  68520. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68521. /**
  68522. * Gets the postprocess render pipeline manager
  68523. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68524. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68525. */
  68526. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68527. }
  68528. }
  68529. /**
  68530. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68531. */
  68532. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68533. /**
  68534. * The component name helpfull to identify the component in the list of scene components.
  68535. */
  68536. readonly name: string;
  68537. /**
  68538. * The scene the component belongs to.
  68539. */
  68540. scene: Scene;
  68541. /**
  68542. * Creates a new instance of the component for the given scene
  68543. * @param scene Defines the scene to register the component in
  68544. */
  68545. constructor(scene: Scene);
  68546. /**
  68547. * Registers the component in a given scene
  68548. */
  68549. register(): void;
  68550. /**
  68551. * Rebuilds the elements related to this component in case of
  68552. * context lost for instance.
  68553. */
  68554. rebuild(): void;
  68555. /**
  68556. * Disposes the component and the associated ressources
  68557. */
  68558. dispose(): void;
  68559. private _gatherRenderTargets;
  68560. }
  68561. }
  68562. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68563. import { Nullable } from "babylonjs/types";
  68564. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68565. import { Camera } from "babylonjs/Cameras/camera";
  68566. import { IDisposable } from "babylonjs/scene";
  68567. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68568. import { Scene } from "babylonjs/scene";
  68569. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68570. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68571. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68572. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68573. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68574. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68575. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68576. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68577. import { Animation } from "babylonjs/Animations/animation";
  68578. /**
  68579. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68580. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68581. */
  68582. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68583. private _scene;
  68584. private _camerasToBeAttached;
  68585. /**
  68586. * ID of the sharpen post process,
  68587. */
  68588. private readonly SharpenPostProcessId;
  68589. /**
  68590. * @ignore
  68591. * ID of the image processing post process;
  68592. */
  68593. readonly ImageProcessingPostProcessId: string;
  68594. /**
  68595. * @ignore
  68596. * ID of the Fast Approximate Anti-Aliasing post process;
  68597. */
  68598. readonly FxaaPostProcessId: string;
  68599. /**
  68600. * ID of the chromatic aberration post process,
  68601. */
  68602. private readonly ChromaticAberrationPostProcessId;
  68603. /**
  68604. * ID of the grain post process
  68605. */
  68606. private readonly GrainPostProcessId;
  68607. /**
  68608. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68609. */
  68610. sharpen: SharpenPostProcess;
  68611. private _sharpenEffect;
  68612. private bloom;
  68613. /**
  68614. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68615. */
  68616. depthOfField: DepthOfFieldEffect;
  68617. /**
  68618. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68619. */
  68620. fxaa: FxaaPostProcess;
  68621. /**
  68622. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68623. */
  68624. imageProcessing: ImageProcessingPostProcess;
  68625. /**
  68626. * Chromatic aberration post process which will shift rgb colors in the image
  68627. */
  68628. chromaticAberration: ChromaticAberrationPostProcess;
  68629. private _chromaticAberrationEffect;
  68630. /**
  68631. * Grain post process which add noise to the image
  68632. */
  68633. grain: GrainPostProcess;
  68634. private _grainEffect;
  68635. /**
  68636. * Glow post process which adds a glow to emissive areas of the image
  68637. */
  68638. private _glowLayer;
  68639. /**
  68640. * Animations which can be used to tweak settings over a period of time
  68641. */
  68642. animations: Animation[];
  68643. private _imageProcessingConfigurationObserver;
  68644. private _sharpenEnabled;
  68645. private _bloomEnabled;
  68646. private _depthOfFieldEnabled;
  68647. private _depthOfFieldBlurLevel;
  68648. private _fxaaEnabled;
  68649. private _imageProcessingEnabled;
  68650. private _defaultPipelineTextureType;
  68651. private _bloomScale;
  68652. private _chromaticAberrationEnabled;
  68653. private _grainEnabled;
  68654. private _buildAllowed;
  68655. /**
  68656. * Gets active scene
  68657. */
  68658. get scene(): Scene;
  68659. /**
  68660. * Enable or disable the sharpen process from the pipeline
  68661. */
  68662. set sharpenEnabled(enabled: boolean);
  68663. get sharpenEnabled(): boolean;
  68664. private _resizeObserver;
  68665. private _hardwareScaleLevel;
  68666. private _bloomKernel;
  68667. /**
  68668. * Specifies the size of the bloom blur kernel, relative to the final output size
  68669. */
  68670. get bloomKernel(): number;
  68671. set bloomKernel(value: number);
  68672. /**
  68673. * Specifies the weight of the bloom in the final rendering
  68674. */
  68675. private _bloomWeight;
  68676. /**
  68677. * Specifies the luma threshold for the area that will be blurred by the bloom
  68678. */
  68679. private _bloomThreshold;
  68680. private _hdr;
  68681. /**
  68682. * The strength of the bloom.
  68683. */
  68684. set bloomWeight(value: number);
  68685. get bloomWeight(): number;
  68686. /**
  68687. * The strength of the bloom.
  68688. */
  68689. set bloomThreshold(value: number);
  68690. get bloomThreshold(): number;
  68691. /**
  68692. * The scale of the bloom, lower value will provide better performance.
  68693. */
  68694. set bloomScale(value: number);
  68695. get bloomScale(): number;
  68696. /**
  68697. * Enable or disable the bloom from the pipeline
  68698. */
  68699. set bloomEnabled(enabled: boolean);
  68700. get bloomEnabled(): boolean;
  68701. private _rebuildBloom;
  68702. /**
  68703. * If the depth of field is enabled.
  68704. */
  68705. get depthOfFieldEnabled(): boolean;
  68706. set depthOfFieldEnabled(enabled: boolean);
  68707. /**
  68708. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68709. */
  68710. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68711. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68712. /**
  68713. * If the anti aliasing is enabled.
  68714. */
  68715. set fxaaEnabled(enabled: boolean);
  68716. get fxaaEnabled(): boolean;
  68717. private _samples;
  68718. /**
  68719. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68720. */
  68721. set samples(sampleCount: number);
  68722. get samples(): number;
  68723. /**
  68724. * If image processing is enabled.
  68725. */
  68726. set imageProcessingEnabled(enabled: boolean);
  68727. get imageProcessingEnabled(): boolean;
  68728. /**
  68729. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68730. */
  68731. set glowLayerEnabled(enabled: boolean);
  68732. get glowLayerEnabled(): boolean;
  68733. /**
  68734. * Gets the glow layer (or null if not defined)
  68735. */
  68736. get glowLayer(): Nullable<GlowLayer>;
  68737. /**
  68738. * Enable or disable the chromaticAberration process from the pipeline
  68739. */
  68740. set chromaticAberrationEnabled(enabled: boolean);
  68741. get chromaticAberrationEnabled(): boolean;
  68742. /**
  68743. * Enable or disable the grain process from the pipeline
  68744. */
  68745. set grainEnabled(enabled: boolean);
  68746. get grainEnabled(): boolean;
  68747. /**
  68748. * @constructor
  68749. * @param name - The rendering pipeline name (default: "")
  68750. * @param hdr - If high dynamic range textures should be used (default: true)
  68751. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68752. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68753. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68754. */
  68755. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68756. /**
  68757. * Get the class name
  68758. * @returns "DefaultRenderingPipeline"
  68759. */
  68760. getClassName(): string;
  68761. /**
  68762. * Force the compilation of the entire pipeline.
  68763. */
  68764. prepare(): void;
  68765. private _hasCleared;
  68766. private _prevPostProcess;
  68767. private _prevPrevPostProcess;
  68768. private _setAutoClearAndTextureSharing;
  68769. private _depthOfFieldSceneObserver;
  68770. private _buildPipeline;
  68771. private _disposePostProcesses;
  68772. /**
  68773. * Adds a camera to the pipeline
  68774. * @param camera the camera to be added
  68775. */
  68776. addCamera(camera: Camera): void;
  68777. /**
  68778. * Removes a camera from the pipeline
  68779. * @param camera the camera to remove
  68780. */
  68781. removeCamera(camera: Camera): void;
  68782. /**
  68783. * Dispose of the pipeline and stop all post processes
  68784. */
  68785. dispose(): void;
  68786. /**
  68787. * Serialize the rendering pipeline (Used when exporting)
  68788. * @returns the serialized object
  68789. */
  68790. serialize(): any;
  68791. /**
  68792. * Parse the serialized pipeline
  68793. * @param source Source pipeline.
  68794. * @param scene The scene to load the pipeline to.
  68795. * @param rootUrl The URL of the serialized pipeline.
  68796. * @returns An instantiated pipeline from the serialized object.
  68797. */
  68798. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68799. }
  68800. }
  68801. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68802. /** @hidden */
  68803. export var lensHighlightsPixelShader: {
  68804. name: string;
  68805. shader: string;
  68806. };
  68807. }
  68808. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68809. /** @hidden */
  68810. export var depthOfFieldPixelShader: {
  68811. name: string;
  68812. shader: string;
  68813. };
  68814. }
  68815. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68816. import { Camera } from "babylonjs/Cameras/camera";
  68817. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68818. import { Scene } from "babylonjs/scene";
  68819. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68820. import "babylonjs/Shaders/chromaticAberration.fragment";
  68821. import "babylonjs/Shaders/lensHighlights.fragment";
  68822. import "babylonjs/Shaders/depthOfField.fragment";
  68823. /**
  68824. * BABYLON.JS Chromatic Aberration GLSL Shader
  68825. * Author: Olivier Guyot
  68826. * Separates very slightly R, G and B colors on the edges of the screen
  68827. * Inspired by Francois Tarlier & Martins Upitis
  68828. */
  68829. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68830. /**
  68831. * @ignore
  68832. * The chromatic aberration PostProcess id in the pipeline
  68833. */
  68834. LensChromaticAberrationEffect: string;
  68835. /**
  68836. * @ignore
  68837. * The highlights enhancing PostProcess id in the pipeline
  68838. */
  68839. HighlightsEnhancingEffect: string;
  68840. /**
  68841. * @ignore
  68842. * The depth-of-field PostProcess id in the pipeline
  68843. */
  68844. LensDepthOfFieldEffect: string;
  68845. private _scene;
  68846. private _depthTexture;
  68847. private _grainTexture;
  68848. private _chromaticAberrationPostProcess;
  68849. private _highlightsPostProcess;
  68850. private _depthOfFieldPostProcess;
  68851. private _edgeBlur;
  68852. private _grainAmount;
  68853. private _chromaticAberration;
  68854. private _distortion;
  68855. private _highlightsGain;
  68856. private _highlightsThreshold;
  68857. private _dofDistance;
  68858. private _dofAperture;
  68859. private _dofDarken;
  68860. private _dofPentagon;
  68861. private _blurNoise;
  68862. /**
  68863. * @constructor
  68864. *
  68865. * Effect parameters are as follow:
  68866. * {
  68867. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68868. * edge_blur: number; // from 0 to x (1 for realism)
  68869. * distortion: number; // from 0 to x (1 for realism)
  68870. * grain_amount: number; // from 0 to 1
  68871. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68872. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68873. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68874. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68875. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68876. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68877. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68878. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68879. * }
  68880. * Note: if an effect parameter is unset, effect is disabled
  68881. *
  68882. * @param name The rendering pipeline name
  68883. * @param parameters - An object containing all parameters (see above)
  68884. * @param scene The scene linked to this pipeline
  68885. * @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)
  68886. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68887. */
  68888. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68889. /**
  68890. * Get the class name
  68891. * @returns "LensRenderingPipeline"
  68892. */
  68893. getClassName(): string;
  68894. /**
  68895. * Gets associated scene
  68896. */
  68897. get scene(): Scene;
  68898. /**
  68899. * Gets or sets the edge blur
  68900. */
  68901. get edgeBlur(): number;
  68902. set edgeBlur(value: number);
  68903. /**
  68904. * Gets or sets the grain amount
  68905. */
  68906. get grainAmount(): number;
  68907. set grainAmount(value: number);
  68908. /**
  68909. * Gets or sets the chromatic aberration amount
  68910. */
  68911. get chromaticAberration(): number;
  68912. set chromaticAberration(value: number);
  68913. /**
  68914. * Gets or sets the depth of field aperture
  68915. */
  68916. get dofAperture(): number;
  68917. set dofAperture(value: number);
  68918. /**
  68919. * Gets or sets the edge distortion
  68920. */
  68921. get edgeDistortion(): number;
  68922. set edgeDistortion(value: number);
  68923. /**
  68924. * Gets or sets the depth of field distortion
  68925. */
  68926. get dofDistortion(): number;
  68927. set dofDistortion(value: number);
  68928. /**
  68929. * Gets or sets the darken out of focus amount
  68930. */
  68931. get darkenOutOfFocus(): number;
  68932. set darkenOutOfFocus(value: number);
  68933. /**
  68934. * Gets or sets a boolean indicating if blur noise is enabled
  68935. */
  68936. get blurNoise(): boolean;
  68937. set blurNoise(value: boolean);
  68938. /**
  68939. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68940. */
  68941. get pentagonBokeh(): boolean;
  68942. set pentagonBokeh(value: boolean);
  68943. /**
  68944. * Gets or sets the highlight grain amount
  68945. */
  68946. get highlightsGain(): number;
  68947. set highlightsGain(value: number);
  68948. /**
  68949. * Gets or sets the highlight threshold
  68950. */
  68951. get highlightsThreshold(): number;
  68952. set highlightsThreshold(value: number);
  68953. /**
  68954. * Sets the amount of blur at the edges
  68955. * @param amount blur amount
  68956. */
  68957. setEdgeBlur(amount: number): void;
  68958. /**
  68959. * Sets edge blur to 0
  68960. */
  68961. disableEdgeBlur(): void;
  68962. /**
  68963. * Sets the amout of grain
  68964. * @param amount Amount of grain
  68965. */
  68966. setGrainAmount(amount: number): void;
  68967. /**
  68968. * Set grain amount to 0
  68969. */
  68970. disableGrain(): void;
  68971. /**
  68972. * Sets the chromatic aberration amount
  68973. * @param amount amount of chromatic aberration
  68974. */
  68975. setChromaticAberration(amount: number): void;
  68976. /**
  68977. * Sets chromatic aberration amount to 0
  68978. */
  68979. disableChromaticAberration(): void;
  68980. /**
  68981. * Sets the EdgeDistortion amount
  68982. * @param amount amount of EdgeDistortion
  68983. */
  68984. setEdgeDistortion(amount: number): void;
  68985. /**
  68986. * Sets edge distortion to 0
  68987. */
  68988. disableEdgeDistortion(): void;
  68989. /**
  68990. * Sets the FocusDistance amount
  68991. * @param amount amount of FocusDistance
  68992. */
  68993. setFocusDistance(amount: number): void;
  68994. /**
  68995. * Disables depth of field
  68996. */
  68997. disableDepthOfField(): void;
  68998. /**
  68999. * Sets the Aperture amount
  69000. * @param amount amount of Aperture
  69001. */
  69002. setAperture(amount: number): void;
  69003. /**
  69004. * Sets the DarkenOutOfFocus amount
  69005. * @param amount amount of DarkenOutOfFocus
  69006. */
  69007. setDarkenOutOfFocus(amount: number): void;
  69008. private _pentagonBokehIsEnabled;
  69009. /**
  69010. * Creates a pentagon bokeh effect
  69011. */
  69012. enablePentagonBokeh(): void;
  69013. /**
  69014. * Disables the pentagon bokeh effect
  69015. */
  69016. disablePentagonBokeh(): void;
  69017. /**
  69018. * Enables noise blur
  69019. */
  69020. enableNoiseBlur(): void;
  69021. /**
  69022. * Disables noise blur
  69023. */
  69024. disableNoiseBlur(): void;
  69025. /**
  69026. * Sets the HighlightsGain amount
  69027. * @param amount amount of HighlightsGain
  69028. */
  69029. setHighlightsGain(amount: number): void;
  69030. /**
  69031. * Sets the HighlightsThreshold amount
  69032. * @param amount amount of HighlightsThreshold
  69033. */
  69034. setHighlightsThreshold(amount: number): void;
  69035. /**
  69036. * Disables highlights
  69037. */
  69038. disableHighlights(): void;
  69039. /**
  69040. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69041. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69042. */
  69043. dispose(disableDepthRender?: boolean): void;
  69044. private _createChromaticAberrationPostProcess;
  69045. private _createHighlightsPostProcess;
  69046. private _createDepthOfFieldPostProcess;
  69047. private _createGrainTexture;
  69048. }
  69049. }
  69050. declare module "babylonjs/Shaders/ssao2.fragment" {
  69051. /** @hidden */
  69052. export var ssao2PixelShader: {
  69053. name: string;
  69054. shader: string;
  69055. };
  69056. }
  69057. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69058. /** @hidden */
  69059. export var ssaoCombinePixelShader: {
  69060. name: string;
  69061. shader: string;
  69062. };
  69063. }
  69064. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69065. import { Camera } from "babylonjs/Cameras/camera";
  69066. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69067. import { Scene } from "babylonjs/scene";
  69068. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69069. import "babylonjs/Shaders/ssao2.fragment";
  69070. import "babylonjs/Shaders/ssaoCombine.fragment";
  69071. /**
  69072. * Render pipeline to produce ssao effect
  69073. */
  69074. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69075. /**
  69076. * @ignore
  69077. * The PassPostProcess id in the pipeline that contains the original scene color
  69078. */
  69079. SSAOOriginalSceneColorEffect: string;
  69080. /**
  69081. * @ignore
  69082. * The SSAO PostProcess id in the pipeline
  69083. */
  69084. SSAORenderEffect: string;
  69085. /**
  69086. * @ignore
  69087. * The horizontal blur PostProcess id in the pipeline
  69088. */
  69089. SSAOBlurHRenderEffect: string;
  69090. /**
  69091. * @ignore
  69092. * The vertical blur PostProcess id in the pipeline
  69093. */
  69094. SSAOBlurVRenderEffect: string;
  69095. /**
  69096. * @ignore
  69097. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69098. */
  69099. SSAOCombineRenderEffect: string;
  69100. /**
  69101. * The output strength of the SSAO post-process. Default value is 1.0.
  69102. */
  69103. totalStrength: number;
  69104. /**
  69105. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69106. */
  69107. maxZ: number;
  69108. /**
  69109. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69110. */
  69111. minZAspect: number;
  69112. private _samples;
  69113. /**
  69114. * Number of samples used for the SSAO calculations. Default value is 8
  69115. */
  69116. set samples(n: number);
  69117. get samples(): number;
  69118. private _textureSamples;
  69119. /**
  69120. * Number of samples to use for antialiasing
  69121. */
  69122. set textureSamples(n: number);
  69123. get textureSamples(): number;
  69124. /**
  69125. * Ratio object used for SSAO ratio and blur ratio
  69126. */
  69127. private _ratio;
  69128. /**
  69129. * Dynamically generated sphere sampler.
  69130. */
  69131. private _sampleSphere;
  69132. /**
  69133. * Blur filter offsets
  69134. */
  69135. private _samplerOffsets;
  69136. private _expensiveBlur;
  69137. /**
  69138. * If bilateral blur should be used
  69139. */
  69140. set expensiveBlur(b: boolean);
  69141. get expensiveBlur(): boolean;
  69142. /**
  69143. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69144. */
  69145. radius: number;
  69146. /**
  69147. * The base color of the SSAO post-process
  69148. * The final result is "base + ssao" between [0, 1]
  69149. */
  69150. base: number;
  69151. /**
  69152. * Support test.
  69153. */
  69154. static get IsSupported(): boolean;
  69155. private _scene;
  69156. private _depthTexture;
  69157. private _normalTexture;
  69158. private _randomTexture;
  69159. private _originalColorPostProcess;
  69160. private _ssaoPostProcess;
  69161. private _blurHPostProcess;
  69162. private _blurVPostProcess;
  69163. private _ssaoCombinePostProcess;
  69164. /**
  69165. * Gets active scene
  69166. */
  69167. get scene(): Scene;
  69168. /**
  69169. * @constructor
  69170. * @param name The rendering pipeline name
  69171. * @param scene The scene linked to this pipeline
  69172. * @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 }
  69173. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69174. */
  69175. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69176. /**
  69177. * Get the class name
  69178. * @returns "SSAO2RenderingPipeline"
  69179. */
  69180. getClassName(): string;
  69181. /**
  69182. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69183. */
  69184. dispose(disableGeometryBufferRenderer?: boolean): void;
  69185. private _createBlurPostProcess;
  69186. /** @hidden */
  69187. _rebuild(): void;
  69188. private _bits;
  69189. private _radicalInverse_VdC;
  69190. private _hammersley;
  69191. private _hemisphereSample_uniform;
  69192. private _generateHemisphere;
  69193. private _createSSAOPostProcess;
  69194. private _createSSAOCombinePostProcess;
  69195. private _createRandomTexture;
  69196. /**
  69197. * Serialize the rendering pipeline (Used when exporting)
  69198. * @returns the serialized object
  69199. */
  69200. serialize(): any;
  69201. /**
  69202. * Parse the serialized pipeline
  69203. * @param source Source pipeline.
  69204. * @param scene The scene to load the pipeline to.
  69205. * @param rootUrl The URL of the serialized pipeline.
  69206. * @returns An instantiated pipeline from the serialized object.
  69207. */
  69208. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69209. }
  69210. }
  69211. declare module "babylonjs/Shaders/ssao.fragment" {
  69212. /** @hidden */
  69213. export var ssaoPixelShader: {
  69214. name: string;
  69215. shader: string;
  69216. };
  69217. }
  69218. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69219. import { Camera } from "babylonjs/Cameras/camera";
  69220. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69221. import { Scene } from "babylonjs/scene";
  69222. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69223. import "babylonjs/Shaders/ssao.fragment";
  69224. import "babylonjs/Shaders/ssaoCombine.fragment";
  69225. /**
  69226. * Render pipeline to produce ssao effect
  69227. */
  69228. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69229. /**
  69230. * @ignore
  69231. * The PassPostProcess id in the pipeline that contains the original scene color
  69232. */
  69233. SSAOOriginalSceneColorEffect: string;
  69234. /**
  69235. * @ignore
  69236. * The SSAO PostProcess id in the pipeline
  69237. */
  69238. SSAORenderEffect: string;
  69239. /**
  69240. * @ignore
  69241. * The horizontal blur PostProcess id in the pipeline
  69242. */
  69243. SSAOBlurHRenderEffect: string;
  69244. /**
  69245. * @ignore
  69246. * The vertical blur PostProcess id in the pipeline
  69247. */
  69248. SSAOBlurVRenderEffect: string;
  69249. /**
  69250. * @ignore
  69251. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69252. */
  69253. SSAOCombineRenderEffect: string;
  69254. /**
  69255. * The output strength of the SSAO post-process. Default value is 1.0.
  69256. */
  69257. totalStrength: number;
  69258. /**
  69259. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69260. */
  69261. radius: number;
  69262. /**
  69263. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69264. * Must not be equal to fallOff and superior to fallOff.
  69265. * Default value is 0.0075
  69266. */
  69267. area: number;
  69268. /**
  69269. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69270. * Must not be equal to area and inferior to area.
  69271. * Default value is 0.000001
  69272. */
  69273. fallOff: number;
  69274. /**
  69275. * The base color of the SSAO post-process
  69276. * The final result is "base + ssao" between [0, 1]
  69277. */
  69278. base: number;
  69279. private _scene;
  69280. private _depthTexture;
  69281. private _randomTexture;
  69282. private _originalColorPostProcess;
  69283. private _ssaoPostProcess;
  69284. private _blurHPostProcess;
  69285. private _blurVPostProcess;
  69286. private _ssaoCombinePostProcess;
  69287. private _firstUpdate;
  69288. /**
  69289. * Gets active scene
  69290. */
  69291. get scene(): Scene;
  69292. /**
  69293. * @constructor
  69294. * @param name - The rendering pipeline name
  69295. * @param scene - The scene linked to this pipeline
  69296. * @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 }
  69297. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69298. */
  69299. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69300. /**
  69301. * Get the class name
  69302. * @returns "SSAORenderingPipeline"
  69303. */
  69304. getClassName(): string;
  69305. /**
  69306. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69307. */
  69308. dispose(disableDepthRender?: boolean): void;
  69309. private _createBlurPostProcess;
  69310. /** @hidden */
  69311. _rebuild(): void;
  69312. private _createSSAOPostProcess;
  69313. private _createSSAOCombinePostProcess;
  69314. private _createRandomTexture;
  69315. }
  69316. }
  69317. declare module "babylonjs/Shaders/standard.fragment" {
  69318. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69319. /** @hidden */
  69320. export var standardPixelShader: {
  69321. name: string;
  69322. shader: string;
  69323. };
  69324. }
  69325. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69326. import { Nullable } from "babylonjs/types";
  69327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69328. import { Camera } from "babylonjs/Cameras/camera";
  69329. import { Texture } from "babylonjs/Materials/Textures/texture";
  69330. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69331. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69332. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69333. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69334. import { IDisposable } from "babylonjs/scene";
  69335. import { SpotLight } from "babylonjs/Lights/spotLight";
  69336. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69337. import { Scene } from "babylonjs/scene";
  69338. import { Animation } from "babylonjs/Animations/animation";
  69339. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69340. import "babylonjs/Shaders/standard.fragment";
  69341. /**
  69342. * Standard rendering pipeline
  69343. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69344. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69345. */
  69346. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69347. /**
  69348. * Public members
  69349. */
  69350. /**
  69351. * Post-process which contains the original scene color before the pipeline applies all the effects
  69352. */
  69353. originalPostProcess: Nullable<PostProcess>;
  69354. /**
  69355. * Post-process used to down scale an image x4
  69356. */
  69357. downSampleX4PostProcess: Nullable<PostProcess>;
  69358. /**
  69359. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69360. */
  69361. brightPassPostProcess: Nullable<PostProcess>;
  69362. /**
  69363. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69364. */
  69365. blurHPostProcesses: PostProcess[];
  69366. /**
  69367. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69368. */
  69369. blurVPostProcesses: PostProcess[];
  69370. /**
  69371. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69372. */
  69373. textureAdderPostProcess: Nullable<PostProcess>;
  69374. /**
  69375. * Post-process used to create volumetric lighting effect
  69376. */
  69377. volumetricLightPostProcess: Nullable<PostProcess>;
  69378. /**
  69379. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69380. */
  69381. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69382. /**
  69383. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69384. */
  69385. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69386. /**
  69387. * Post-process used to merge the volumetric light effect and the real scene color
  69388. */
  69389. volumetricLightMergePostProces: Nullable<PostProcess>;
  69390. /**
  69391. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69392. */
  69393. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69394. /**
  69395. * Base post-process used to calculate the average luminance of the final image for HDR
  69396. */
  69397. luminancePostProcess: Nullable<PostProcess>;
  69398. /**
  69399. * Post-processes used to create down sample post-processes in order to get
  69400. * the average luminance of the final image for HDR
  69401. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69402. */
  69403. luminanceDownSamplePostProcesses: PostProcess[];
  69404. /**
  69405. * Post-process used to create a HDR effect (light adaptation)
  69406. */
  69407. hdrPostProcess: Nullable<PostProcess>;
  69408. /**
  69409. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69410. */
  69411. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69412. /**
  69413. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69414. */
  69415. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69416. /**
  69417. * Post-process used to merge the final HDR post-process and the real scene color
  69418. */
  69419. hdrFinalPostProcess: Nullable<PostProcess>;
  69420. /**
  69421. * Post-process used to create a lens flare effect
  69422. */
  69423. lensFlarePostProcess: Nullable<PostProcess>;
  69424. /**
  69425. * Post-process that merges the result of the lens flare post-process and the real scene color
  69426. */
  69427. lensFlareComposePostProcess: Nullable<PostProcess>;
  69428. /**
  69429. * Post-process used to create a motion blur effect
  69430. */
  69431. motionBlurPostProcess: Nullable<PostProcess>;
  69432. /**
  69433. * Post-process used to create a depth of field effect
  69434. */
  69435. depthOfFieldPostProcess: Nullable<PostProcess>;
  69436. /**
  69437. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69438. */
  69439. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69440. /**
  69441. * Represents the brightness threshold in order to configure the illuminated surfaces
  69442. */
  69443. brightThreshold: number;
  69444. /**
  69445. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69446. */
  69447. blurWidth: number;
  69448. /**
  69449. * Sets if the blur for highlighted surfaces must be only horizontal
  69450. */
  69451. horizontalBlur: boolean;
  69452. /**
  69453. * Gets the overall exposure used by the pipeline
  69454. */
  69455. get exposure(): number;
  69456. /**
  69457. * Sets the overall exposure used by the pipeline
  69458. */
  69459. set exposure(value: number);
  69460. /**
  69461. * Texture used typically to simulate "dirty" on camera lens
  69462. */
  69463. lensTexture: Nullable<Texture>;
  69464. /**
  69465. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69466. */
  69467. volumetricLightCoefficient: number;
  69468. /**
  69469. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69470. */
  69471. volumetricLightPower: number;
  69472. /**
  69473. * Used the set the blur intensity to smooth the volumetric lights
  69474. */
  69475. volumetricLightBlurScale: number;
  69476. /**
  69477. * Light (spot or directional) used to generate the volumetric lights rays
  69478. * The source light must have a shadow generate so the pipeline can get its
  69479. * depth map
  69480. */
  69481. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69482. /**
  69483. * For eye adaptation, represents the minimum luminance the eye can see
  69484. */
  69485. hdrMinimumLuminance: number;
  69486. /**
  69487. * For eye adaptation, represents the decrease luminance speed
  69488. */
  69489. hdrDecreaseRate: number;
  69490. /**
  69491. * For eye adaptation, represents the increase luminance speed
  69492. */
  69493. hdrIncreaseRate: number;
  69494. /**
  69495. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69496. */
  69497. get hdrAutoExposure(): boolean;
  69498. /**
  69499. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69500. */
  69501. set hdrAutoExposure(value: boolean);
  69502. /**
  69503. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69504. */
  69505. lensColorTexture: Nullable<Texture>;
  69506. /**
  69507. * The overall strengh for the lens flare effect
  69508. */
  69509. lensFlareStrength: number;
  69510. /**
  69511. * Dispersion coefficient for lens flare ghosts
  69512. */
  69513. lensFlareGhostDispersal: number;
  69514. /**
  69515. * Main lens flare halo width
  69516. */
  69517. lensFlareHaloWidth: number;
  69518. /**
  69519. * Based on the lens distortion effect, defines how much the lens flare result
  69520. * is distorted
  69521. */
  69522. lensFlareDistortionStrength: number;
  69523. /**
  69524. * Configures the blur intensity used for for lens flare (halo)
  69525. */
  69526. lensFlareBlurWidth: number;
  69527. /**
  69528. * Lens star texture must be used to simulate rays on the flares and is available
  69529. * in the documentation
  69530. */
  69531. lensStarTexture: Nullable<Texture>;
  69532. /**
  69533. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69534. * flare effect by taking account of the dirt texture
  69535. */
  69536. lensFlareDirtTexture: Nullable<Texture>;
  69537. /**
  69538. * Represents the focal length for the depth of field effect
  69539. */
  69540. depthOfFieldDistance: number;
  69541. /**
  69542. * Represents the blur intensity for the blurred part of the depth of field effect
  69543. */
  69544. depthOfFieldBlurWidth: number;
  69545. /**
  69546. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69547. */
  69548. get motionStrength(): number;
  69549. /**
  69550. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69551. */
  69552. set motionStrength(strength: number);
  69553. /**
  69554. * Gets wether or not the motion blur post-process is object based or screen based.
  69555. */
  69556. get objectBasedMotionBlur(): boolean;
  69557. /**
  69558. * Sets wether or not the motion blur post-process should be object based or screen based
  69559. */
  69560. set objectBasedMotionBlur(value: boolean);
  69561. /**
  69562. * List of animations for the pipeline (IAnimatable implementation)
  69563. */
  69564. animations: Animation[];
  69565. /**
  69566. * Private members
  69567. */
  69568. private _scene;
  69569. private _currentDepthOfFieldSource;
  69570. private _basePostProcess;
  69571. private _fixedExposure;
  69572. private _currentExposure;
  69573. private _hdrAutoExposure;
  69574. private _hdrCurrentLuminance;
  69575. private _motionStrength;
  69576. private _isObjectBasedMotionBlur;
  69577. private _floatTextureType;
  69578. private _camerasToBeAttached;
  69579. private _ratio;
  69580. private _bloomEnabled;
  69581. private _depthOfFieldEnabled;
  69582. private _vlsEnabled;
  69583. private _lensFlareEnabled;
  69584. private _hdrEnabled;
  69585. private _motionBlurEnabled;
  69586. private _fxaaEnabled;
  69587. private _motionBlurSamples;
  69588. private _volumetricLightStepsCount;
  69589. private _samples;
  69590. /**
  69591. * @ignore
  69592. * Specifies if the bloom pipeline is enabled
  69593. */
  69594. get BloomEnabled(): boolean;
  69595. set BloomEnabled(enabled: boolean);
  69596. /**
  69597. * @ignore
  69598. * Specifies if the depth of field pipeline is enabed
  69599. */
  69600. get DepthOfFieldEnabled(): boolean;
  69601. set DepthOfFieldEnabled(enabled: boolean);
  69602. /**
  69603. * @ignore
  69604. * Specifies if the lens flare pipeline is enabed
  69605. */
  69606. get LensFlareEnabled(): boolean;
  69607. set LensFlareEnabled(enabled: boolean);
  69608. /**
  69609. * @ignore
  69610. * Specifies if the HDR pipeline is enabled
  69611. */
  69612. get HDREnabled(): boolean;
  69613. set HDREnabled(enabled: boolean);
  69614. /**
  69615. * @ignore
  69616. * Specifies if the volumetric lights scattering effect is enabled
  69617. */
  69618. get VLSEnabled(): boolean;
  69619. set VLSEnabled(enabled: boolean);
  69620. /**
  69621. * @ignore
  69622. * Specifies if the motion blur effect is enabled
  69623. */
  69624. get MotionBlurEnabled(): boolean;
  69625. set MotionBlurEnabled(enabled: boolean);
  69626. /**
  69627. * Specifies if anti-aliasing is enabled
  69628. */
  69629. get fxaaEnabled(): boolean;
  69630. set fxaaEnabled(enabled: boolean);
  69631. /**
  69632. * Specifies the number of steps used to calculate the volumetric lights
  69633. * Typically in interval [50, 200]
  69634. */
  69635. get volumetricLightStepsCount(): number;
  69636. set volumetricLightStepsCount(count: number);
  69637. /**
  69638. * Specifies the number of samples used for the motion blur effect
  69639. * Typically in interval [16, 64]
  69640. */
  69641. get motionBlurSamples(): number;
  69642. set motionBlurSamples(samples: number);
  69643. /**
  69644. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69645. */
  69646. get samples(): number;
  69647. set samples(sampleCount: number);
  69648. /**
  69649. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69650. * @constructor
  69651. * @param name The rendering pipeline name
  69652. * @param scene The scene linked to this pipeline
  69653. * @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)
  69654. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69655. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69656. */
  69657. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69658. private _buildPipeline;
  69659. private _createDownSampleX4PostProcess;
  69660. private _createBrightPassPostProcess;
  69661. private _createBlurPostProcesses;
  69662. private _createTextureAdderPostProcess;
  69663. private _createVolumetricLightPostProcess;
  69664. private _createLuminancePostProcesses;
  69665. private _createHdrPostProcess;
  69666. private _createLensFlarePostProcess;
  69667. private _createDepthOfFieldPostProcess;
  69668. private _createMotionBlurPostProcess;
  69669. private _getDepthTexture;
  69670. private _disposePostProcesses;
  69671. /**
  69672. * Dispose of the pipeline and stop all post processes
  69673. */
  69674. dispose(): void;
  69675. /**
  69676. * Serialize the rendering pipeline (Used when exporting)
  69677. * @returns the serialized object
  69678. */
  69679. serialize(): any;
  69680. /**
  69681. * Parse the serialized pipeline
  69682. * @param source Source pipeline.
  69683. * @param scene The scene to load the pipeline to.
  69684. * @param rootUrl The URL of the serialized pipeline.
  69685. * @returns An instantiated pipeline from the serialized object.
  69686. */
  69687. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69688. /**
  69689. * Luminance steps
  69690. */
  69691. static LuminanceSteps: number;
  69692. }
  69693. }
  69694. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69695. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69696. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69697. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69698. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69699. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69700. }
  69701. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69702. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69703. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69704. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69705. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69706. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69707. }
  69708. declare module "babylonjs/Shaders/tonemap.fragment" {
  69709. /** @hidden */
  69710. export var tonemapPixelShader: {
  69711. name: string;
  69712. shader: string;
  69713. };
  69714. }
  69715. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69716. import { Camera } from "babylonjs/Cameras/camera";
  69717. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69718. import "babylonjs/Shaders/tonemap.fragment";
  69719. import { Engine } from "babylonjs/Engines/engine";
  69720. /** Defines operator used for tonemapping */
  69721. export enum TonemappingOperator {
  69722. /** Hable */
  69723. Hable = 0,
  69724. /** Reinhard */
  69725. Reinhard = 1,
  69726. /** HejiDawson */
  69727. HejiDawson = 2,
  69728. /** Photographic */
  69729. Photographic = 3
  69730. }
  69731. /**
  69732. * Defines a post process to apply tone mapping
  69733. */
  69734. export class TonemapPostProcess extends PostProcess {
  69735. private _operator;
  69736. /** Defines the required exposure adjustement */
  69737. exposureAdjustment: number;
  69738. /**
  69739. * Creates a new TonemapPostProcess
  69740. * @param name defines the name of the postprocess
  69741. * @param _operator defines the operator to use
  69742. * @param exposureAdjustment defines the required exposure adjustement
  69743. * @param camera defines the camera to use (can be null)
  69744. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69745. * @param engine defines the hosting engine (can be ignore if camera is set)
  69746. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69747. */
  69748. constructor(name: string, _operator: TonemappingOperator,
  69749. /** Defines the required exposure adjustement */
  69750. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69751. }
  69752. }
  69753. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69754. /** @hidden */
  69755. export var volumetricLightScatteringPixelShader: {
  69756. name: string;
  69757. shader: string;
  69758. };
  69759. }
  69760. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69761. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69763. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69764. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69766. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69767. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69768. /** @hidden */
  69769. export var volumetricLightScatteringPassVertexShader: {
  69770. name: string;
  69771. shader: string;
  69772. };
  69773. }
  69774. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69775. /** @hidden */
  69776. export var volumetricLightScatteringPassPixelShader: {
  69777. name: string;
  69778. shader: string;
  69779. };
  69780. }
  69781. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69782. import { Vector3 } from "babylonjs/Maths/math.vector";
  69783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69784. import { Mesh } from "babylonjs/Meshes/mesh";
  69785. import { Camera } from "babylonjs/Cameras/camera";
  69786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69787. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69788. import { Scene } from "babylonjs/scene";
  69789. import "babylonjs/Meshes/Builders/planeBuilder";
  69790. import "babylonjs/Shaders/depth.vertex";
  69791. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69792. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69793. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69794. import { Engine } from "babylonjs/Engines/engine";
  69795. /**
  69796. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69797. */
  69798. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69799. private _volumetricLightScatteringPass;
  69800. private _volumetricLightScatteringRTT;
  69801. private _viewPort;
  69802. private _screenCoordinates;
  69803. private _cachedDefines;
  69804. /**
  69805. * If not undefined, the mesh position is computed from the attached node position
  69806. */
  69807. attachedNode: {
  69808. position: Vector3;
  69809. };
  69810. /**
  69811. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69812. */
  69813. customMeshPosition: Vector3;
  69814. /**
  69815. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69816. */
  69817. useCustomMeshPosition: boolean;
  69818. /**
  69819. * If the post-process should inverse the light scattering direction
  69820. */
  69821. invert: boolean;
  69822. /**
  69823. * The internal mesh used by the post-process
  69824. */
  69825. mesh: Mesh;
  69826. /**
  69827. * @hidden
  69828. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69829. */
  69830. get useDiffuseColor(): boolean;
  69831. set useDiffuseColor(useDiffuseColor: boolean);
  69832. /**
  69833. * Array containing the excluded meshes not rendered in the internal pass
  69834. */
  69835. excludedMeshes: AbstractMesh[];
  69836. /**
  69837. * Controls the overall intensity of the post-process
  69838. */
  69839. exposure: number;
  69840. /**
  69841. * Dissipates each sample's contribution in range [0, 1]
  69842. */
  69843. decay: number;
  69844. /**
  69845. * Controls the overall intensity of each sample
  69846. */
  69847. weight: number;
  69848. /**
  69849. * Controls the density of each sample
  69850. */
  69851. density: number;
  69852. /**
  69853. * @constructor
  69854. * @param name The post-process name
  69855. * @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)
  69856. * @param camera The camera that the post-process will be attached to
  69857. * @param mesh The mesh used to create the light scattering
  69858. * @param samples The post-process quality, default 100
  69859. * @param samplingModeThe post-process filtering mode
  69860. * @param engine The babylon engine
  69861. * @param reusable If the post-process is reusable
  69862. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69863. */
  69864. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69865. /**
  69866. * Returns the string "VolumetricLightScatteringPostProcess"
  69867. * @returns "VolumetricLightScatteringPostProcess"
  69868. */
  69869. getClassName(): string;
  69870. private _isReady;
  69871. /**
  69872. * Sets the new light position for light scattering effect
  69873. * @param position The new custom light position
  69874. */
  69875. setCustomMeshPosition(position: Vector3): void;
  69876. /**
  69877. * Returns the light position for light scattering effect
  69878. * @return Vector3 The custom light position
  69879. */
  69880. getCustomMeshPosition(): Vector3;
  69881. /**
  69882. * Disposes the internal assets and detaches the post-process from the camera
  69883. */
  69884. dispose(camera: Camera): void;
  69885. /**
  69886. * Returns the render target texture used by the post-process
  69887. * @return the render target texture used by the post-process
  69888. */
  69889. getPass(): RenderTargetTexture;
  69890. private _meshExcluded;
  69891. private _createPass;
  69892. private _updateMeshScreenCoordinates;
  69893. /**
  69894. * Creates a default mesh for the Volumeric Light Scattering post-process
  69895. * @param name The mesh name
  69896. * @param scene The scene where to create the mesh
  69897. * @return the default mesh
  69898. */
  69899. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69900. }
  69901. }
  69902. declare module "babylonjs/PostProcesses/index" {
  69903. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69904. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69905. export * from "babylonjs/PostProcesses/bloomEffect";
  69906. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69907. export * from "babylonjs/PostProcesses/blurPostProcess";
  69908. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69909. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69910. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69911. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69912. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69913. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69914. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69915. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69916. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69917. export * from "babylonjs/PostProcesses/filterPostProcess";
  69918. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69919. export * from "babylonjs/PostProcesses/grainPostProcess";
  69920. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69921. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69922. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69923. export * from "babylonjs/PostProcesses/passPostProcess";
  69924. export * from "babylonjs/PostProcesses/postProcess";
  69925. export * from "babylonjs/PostProcesses/postProcessManager";
  69926. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69927. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69928. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69929. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69930. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69931. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69932. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69933. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69934. }
  69935. declare module "babylonjs/Probes/index" {
  69936. export * from "babylonjs/Probes/reflectionProbe";
  69937. }
  69938. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69939. import { Scene } from "babylonjs/scene";
  69940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69941. import { SmartArray } from "babylonjs/Misc/smartArray";
  69942. import { ISceneComponent } from "babylonjs/sceneComponent";
  69943. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69944. import "babylonjs/Meshes/Builders/boxBuilder";
  69945. import "babylonjs/Shaders/color.fragment";
  69946. import "babylonjs/Shaders/color.vertex";
  69947. import { Color3 } from "babylonjs/Maths/math.color";
  69948. module "babylonjs/scene" {
  69949. interface Scene {
  69950. /** @hidden (Backing field) */
  69951. _boundingBoxRenderer: BoundingBoxRenderer;
  69952. /** @hidden (Backing field) */
  69953. _forceShowBoundingBoxes: boolean;
  69954. /**
  69955. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69956. */
  69957. forceShowBoundingBoxes: boolean;
  69958. /**
  69959. * Gets the bounding box renderer associated with the scene
  69960. * @returns a BoundingBoxRenderer
  69961. */
  69962. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69963. }
  69964. }
  69965. module "babylonjs/Meshes/abstractMesh" {
  69966. interface AbstractMesh {
  69967. /** @hidden (Backing field) */
  69968. _showBoundingBox: boolean;
  69969. /**
  69970. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69971. */
  69972. showBoundingBox: boolean;
  69973. }
  69974. }
  69975. /**
  69976. * Component responsible of rendering the bounding box of the meshes in a scene.
  69977. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69978. */
  69979. export class BoundingBoxRenderer implements ISceneComponent {
  69980. /**
  69981. * The component name helpfull to identify the component in the list of scene components.
  69982. */
  69983. readonly name: string;
  69984. /**
  69985. * The scene the component belongs to.
  69986. */
  69987. scene: Scene;
  69988. /**
  69989. * Color of the bounding box lines placed in front of an object
  69990. */
  69991. frontColor: Color3;
  69992. /**
  69993. * Color of the bounding box lines placed behind an object
  69994. */
  69995. backColor: Color3;
  69996. /**
  69997. * Defines if the renderer should show the back lines or not
  69998. */
  69999. showBackLines: boolean;
  70000. /**
  70001. * @hidden
  70002. */
  70003. renderList: SmartArray<BoundingBox>;
  70004. private _colorShader;
  70005. private _vertexBuffers;
  70006. private _indexBuffer;
  70007. private _fillIndexBuffer;
  70008. private _fillIndexData;
  70009. /**
  70010. * Instantiates a new bounding box renderer in a scene.
  70011. * @param scene the scene the renderer renders in
  70012. */
  70013. constructor(scene: Scene);
  70014. /**
  70015. * Registers the component in a given scene
  70016. */
  70017. register(): void;
  70018. private _evaluateSubMesh;
  70019. private _activeMesh;
  70020. private _prepareRessources;
  70021. private _createIndexBuffer;
  70022. /**
  70023. * Rebuilds the elements related to this component in case of
  70024. * context lost for instance.
  70025. */
  70026. rebuild(): void;
  70027. /**
  70028. * @hidden
  70029. */
  70030. reset(): void;
  70031. /**
  70032. * Render the bounding boxes of a specific rendering group
  70033. * @param renderingGroupId defines the rendering group to render
  70034. */
  70035. render(renderingGroupId: number): void;
  70036. /**
  70037. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70038. * @param mesh Define the mesh to render the occlusion bounding box for
  70039. */
  70040. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70041. /**
  70042. * Dispose and release the resources attached to this renderer.
  70043. */
  70044. dispose(): void;
  70045. }
  70046. }
  70047. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70048. import { Nullable } from "babylonjs/types";
  70049. import { Scene } from "babylonjs/scene";
  70050. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70051. import { Camera } from "babylonjs/Cameras/camera";
  70052. import { ISceneComponent } from "babylonjs/sceneComponent";
  70053. module "babylonjs/scene" {
  70054. interface Scene {
  70055. /** @hidden (Backing field) */
  70056. _depthRenderer: {
  70057. [id: string]: DepthRenderer;
  70058. };
  70059. /**
  70060. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70061. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70062. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70063. * @returns the created depth renderer
  70064. */
  70065. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70066. /**
  70067. * Disables a depth renderer for a given camera
  70068. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70069. */
  70070. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70071. }
  70072. }
  70073. /**
  70074. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70075. * in several rendering techniques.
  70076. */
  70077. export class DepthRendererSceneComponent implements ISceneComponent {
  70078. /**
  70079. * The component name helpfull to identify the component in the list of scene components.
  70080. */
  70081. readonly name: string;
  70082. /**
  70083. * The scene the component belongs to.
  70084. */
  70085. scene: Scene;
  70086. /**
  70087. * Creates a new instance of the component for the given scene
  70088. * @param scene Defines the scene to register the component in
  70089. */
  70090. constructor(scene: Scene);
  70091. /**
  70092. * Registers the component in a given scene
  70093. */
  70094. register(): void;
  70095. /**
  70096. * Rebuilds the elements related to this component in case of
  70097. * context lost for instance.
  70098. */
  70099. rebuild(): void;
  70100. /**
  70101. * Disposes the component and the associated ressources
  70102. */
  70103. dispose(): void;
  70104. private _gatherRenderTargets;
  70105. private _gatherActiveCameraRenderTargets;
  70106. }
  70107. }
  70108. declare module "babylonjs/Shaders/outline.fragment" {
  70109. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70110. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70111. /** @hidden */
  70112. export var outlinePixelShader: {
  70113. name: string;
  70114. shader: string;
  70115. };
  70116. }
  70117. declare module "babylonjs/Shaders/outline.vertex" {
  70118. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70119. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70121. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70122. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70123. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70124. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70125. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70126. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70127. /** @hidden */
  70128. export var outlineVertexShader: {
  70129. name: string;
  70130. shader: string;
  70131. };
  70132. }
  70133. declare module "babylonjs/Rendering/outlineRenderer" {
  70134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70135. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70136. import { Scene } from "babylonjs/scene";
  70137. import { ISceneComponent } from "babylonjs/sceneComponent";
  70138. import "babylonjs/Shaders/outline.fragment";
  70139. import "babylonjs/Shaders/outline.vertex";
  70140. module "babylonjs/scene" {
  70141. interface Scene {
  70142. /** @hidden */
  70143. _outlineRenderer: OutlineRenderer;
  70144. /**
  70145. * Gets the outline renderer associated with the scene
  70146. * @returns a OutlineRenderer
  70147. */
  70148. getOutlineRenderer(): OutlineRenderer;
  70149. }
  70150. }
  70151. module "babylonjs/Meshes/abstractMesh" {
  70152. interface AbstractMesh {
  70153. /** @hidden (Backing field) */
  70154. _renderOutline: boolean;
  70155. /**
  70156. * Gets or sets a boolean indicating if the outline must be rendered as well
  70157. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70158. */
  70159. renderOutline: boolean;
  70160. /** @hidden (Backing field) */
  70161. _renderOverlay: boolean;
  70162. /**
  70163. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70164. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70165. */
  70166. renderOverlay: boolean;
  70167. }
  70168. }
  70169. /**
  70170. * This class is responsible to draw bothe outline/overlay of meshes.
  70171. * It should not be used directly but through the available method on mesh.
  70172. */
  70173. export class OutlineRenderer implements ISceneComponent {
  70174. /**
  70175. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70176. */
  70177. private static _StencilReference;
  70178. /**
  70179. * The name of the component. Each component must have a unique name.
  70180. */
  70181. name: string;
  70182. /**
  70183. * The scene the component belongs to.
  70184. */
  70185. scene: Scene;
  70186. /**
  70187. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70188. */
  70189. zOffset: number;
  70190. private _engine;
  70191. private _effect;
  70192. private _cachedDefines;
  70193. private _savedDepthWrite;
  70194. /**
  70195. * Instantiates a new outline renderer. (There could be only one per scene).
  70196. * @param scene Defines the scene it belongs to
  70197. */
  70198. constructor(scene: Scene);
  70199. /**
  70200. * Register the component to one instance of a scene.
  70201. */
  70202. register(): void;
  70203. /**
  70204. * Rebuilds the elements related to this component in case of
  70205. * context lost for instance.
  70206. */
  70207. rebuild(): void;
  70208. /**
  70209. * Disposes the component and the associated ressources.
  70210. */
  70211. dispose(): void;
  70212. /**
  70213. * Renders the outline in the canvas.
  70214. * @param subMesh Defines the sumesh to render
  70215. * @param batch Defines the batch of meshes in case of instances
  70216. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70217. */
  70218. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70219. /**
  70220. * Returns whether or not the outline renderer is ready for a given submesh.
  70221. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70222. * @param subMesh Defines the submesh to check readyness for
  70223. * @param useInstances Defines wheter wee are trying to render instances or not
  70224. * @returns true if ready otherwise false
  70225. */
  70226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70227. private _beforeRenderingMesh;
  70228. private _afterRenderingMesh;
  70229. }
  70230. }
  70231. declare module "babylonjs/Rendering/index" {
  70232. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70233. export * from "babylonjs/Rendering/depthRenderer";
  70234. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70235. export * from "babylonjs/Rendering/edgesRenderer";
  70236. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70237. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70238. export * from "babylonjs/Rendering/outlineRenderer";
  70239. export * from "babylonjs/Rendering/renderingGroup";
  70240. export * from "babylonjs/Rendering/renderingManager";
  70241. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70242. }
  70243. declare module "babylonjs/Sprites/ISprites" {
  70244. /**
  70245. * Defines the basic options interface of a Sprite Frame Source Size.
  70246. */
  70247. export interface ISpriteJSONSpriteSourceSize {
  70248. /**
  70249. * number of the original width of the Frame
  70250. */
  70251. w: number;
  70252. /**
  70253. * number of the original height of the Frame
  70254. */
  70255. h: number;
  70256. }
  70257. /**
  70258. * Defines the basic options interface of a Sprite Frame Data.
  70259. */
  70260. export interface ISpriteJSONSpriteFrameData {
  70261. /**
  70262. * number of the x offset of the Frame
  70263. */
  70264. x: number;
  70265. /**
  70266. * number of the y offset of the Frame
  70267. */
  70268. y: number;
  70269. /**
  70270. * number of the width of the Frame
  70271. */
  70272. w: number;
  70273. /**
  70274. * number of the height of the Frame
  70275. */
  70276. h: number;
  70277. }
  70278. /**
  70279. * Defines the basic options interface of a JSON Sprite.
  70280. */
  70281. export interface ISpriteJSONSprite {
  70282. /**
  70283. * string name of the Frame
  70284. */
  70285. filename: string;
  70286. /**
  70287. * ISpriteJSONSpriteFrame basic object of the frame data
  70288. */
  70289. frame: ISpriteJSONSpriteFrameData;
  70290. /**
  70291. * boolean to flag is the frame was rotated.
  70292. */
  70293. rotated: boolean;
  70294. /**
  70295. * boolean to flag is the frame was trimmed.
  70296. */
  70297. trimmed: boolean;
  70298. /**
  70299. * ISpriteJSONSpriteFrame basic object of the source data
  70300. */
  70301. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70302. /**
  70303. * ISpriteJSONSpriteFrame basic object of the source data
  70304. */
  70305. sourceSize: ISpriteJSONSpriteSourceSize;
  70306. }
  70307. /**
  70308. * Defines the basic options interface of a JSON atlas.
  70309. */
  70310. export interface ISpriteJSONAtlas {
  70311. /**
  70312. * Array of objects that contain the frame data.
  70313. */
  70314. frames: Array<ISpriteJSONSprite>;
  70315. /**
  70316. * object basic object containing the sprite meta data.
  70317. */
  70318. meta?: object;
  70319. }
  70320. }
  70321. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70322. /** @hidden */
  70323. export var spriteMapPixelShader: {
  70324. name: string;
  70325. shader: string;
  70326. };
  70327. }
  70328. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70329. /** @hidden */
  70330. export var spriteMapVertexShader: {
  70331. name: string;
  70332. shader: string;
  70333. };
  70334. }
  70335. declare module "babylonjs/Sprites/spriteMap" {
  70336. import { IDisposable, Scene } from "babylonjs/scene";
  70337. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70338. import { Texture } from "babylonjs/Materials/Textures/texture";
  70339. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70340. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70341. import "babylonjs/Meshes/Builders/planeBuilder";
  70342. import "babylonjs/Shaders/spriteMap.fragment";
  70343. import "babylonjs/Shaders/spriteMap.vertex";
  70344. /**
  70345. * Defines the basic options interface of a SpriteMap
  70346. */
  70347. export interface ISpriteMapOptions {
  70348. /**
  70349. * Vector2 of the number of cells in the grid.
  70350. */
  70351. stageSize?: Vector2;
  70352. /**
  70353. * Vector2 of the size of the output plane in World Units.
  70354. */
  70355. outputSize?: Vector2;
  70356. /**
  70357. * Vector3 of the position of the output plane in World Units.
  70358. */
  70359. outputPosition?: Vector3;
  70360. /**
  70361. * Vector3 of the rotation of the output plane.
  70362. */
  70363. outputRotation?: Vector3;
  70364. /**
  70365. * number of layers that the system will reserve in resources.
  70366. */
  70367. layerCount?: number;
  70368. /**
  70369. * number of max animation frames a single cell will reserve in resources.
  70370. */
  70371. maxAnimationFrames?: number;
  70372. /**
  70373. * number cell index of the base tile when the system compiles.
  70374. */
  70375. baseTile?: number;
  70376. /**
  70377. * boolean flip the sprite after its been repositioned by the framing data.
  70378. */
  70379. flipU?: boolean;
  70380. /**
  70381. * Vector3 scalar of the global RGB values of the SpriteMap.
  70382. */
  70383. colorMultiply?: Vector3;
  70384. }
  70385. /**
  70386. * Defines the IDisposable interface in order to be cleanable from resources.
  70387. */
  70388. export interface ISpriteMap extends IDisposable {
  70389. /**
  70390. * String name of the SpriteMap.
  70391. */
  70392. name: string;
  70393. /**
  70394. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70395. */
  70396. atlasJSON: ISpriteJSONAtlas;
  70397. /**
  70398. * Texture of the SpriteMap.
  70399. */
  70400. spriteSheet: Texture;
  70401. /**
  70402. * The parameters to initialize the SpriteMap with.
  70403. */
  70404. options: ISpriteMapOptions;
  70405. }
  70406. /**
  70407. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70408. */
  70409. export class SpriteMap implements ISpriteMap {
  70410. /** The Name of the spriteMap */
  70411. name: string;
  70412. /** The JSON file with the frame and meta data */
  70413. atlasJSON: ISpriteJSONAtlas;
  70414. /** The systems Sprite Sheet Texture */
  70415. spriteSheet: Texture;
  70416. /** Arguments passed with the Constructor */
  70417. options: ISpriteMapOptions;
  70418. /** Public Sprite Storage array, parsed from atlasJSON */
  70419. sprites: Array<ISpriteJSONSprite>;
  70420. /** Returns the Number of Sprites in the System */
  70421. get spriteCount(): number;
  70422. /** Returns the Position of Output Plane*/
  70423. get position(): Vector3;
  70424. /** Returns the Position of Output Plane*/
  70425. set position(v: Vector3);
  70426. /** Returns the Rotation of Output Plane*/
  70427. get rotation(): Vector3;
  70428. /** Returns the Rotation of Output Plane*/
  70429. set rotation(v: Vector3);
  70430. /** Sets the AnimationMap*/
  70431. get animationMap(): RawTexture;
  70432. /** Sets the AnimationMap*/
  70433. set animationMap(v: RawTexture);
  70434. /** Scene that the SpriteMap was created in */
  70435. private _scene;
  70436. /** Texture Buffer of Float32 that holds tile frame data*/
  70437. private _frameMap;
  70438. /** Texture Buffers of Float32 that holds tileMap data*/
  70439. private _tileMaps;
  70440. /** Texture Buffer of Float32 that holds Animation Data*/
  70441. private _animationMap;
  70442. /** Custom ShaderMaterial Central to the System*/
  70443. private _material;
  70444. /** Custom ShaderMaterial Central to the System*/
  70445. private _output;
  70446. /** Systems Time Ticker*/
  70447. private _time;
  70448. /**
  70449. * Creates a new SpriteMap
  70450. * @param name defines the SpriteMaps Name
  70451. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70452. * @param spriteSheet is the Texture that the Sprites are on.
  70453. * @param options a basic deployment configuration
  70454. * @param scene The Scene that the map is deployed on
  70455. */
  70456. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70457. /**
  70458. * Returns tileID location
  70459. * @returns Vector2 the cell position ID
  70460. */
  70461. getTileID(): Vector2;
  70462. /**
  70463. * Gets the UV location of the mouse over the SpriteMap.
  70464. * @returns Vector2 the UV position of the mouse interaction
  70465. */
  70466. getMousePosition(): Vector2;
  70467. /**
  70468. * Creates the "frame" texture Buffer
  70469. * -------------------------------------
  70470. * Structure of frames
  70471. * "filename": "Falling-Water-2.png",
  70472. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70473. * "rotated": true,
  70474. * "trimmed": true,
  70475. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70476. * "sourceSize": {"w":32,"h":32}
  70477. * @returns RawTexture of the frameMap
  70478. */
  70479. private _createFrameBuffer;
  70480. /**
  70481. * Creates the tileMap texture Buffer
  70482. * @param buffer normally and array of numbers, or a false to generate from scratch
  70483. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70484. * @returns RawTexture of the tileMap
  70485. */
  70486. private _createTileBuffer;
  70487. /**
  70488. * Modifies the data of the tileMaps
  70489. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70490. * @param pos is the iVector2 Coordinates of the Tile
  70491. * @param tile The SpriteIndex of the new Tile
  70492. */
  70493. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70494. /**
  70495. * Creates the animationMap texture Buffer
  70496. * @param buffer normally and array of numbers, or a false to generate from scratch
  70497. * @returns RawTexture of the animationMap
  70498. */
  70499. private _createTileAnimationBuffer;
  70500. /**
  70501. * Modifies the data of the animationMap
  70502. * @param cellID is the Index of the Sprite
  70503. * @param _frame is the target Animation frame
  70504. * @param toCell is the Target Index of the next frame of the animation
  70505. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70506. * @param speed is a global scalar of the time variable on the map.
  70507. */
  70508. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70509. /**
  70510. * Exports the .tilemaps file
  70511. */
  70512. saveTileMaps(): void;
  70513. /**
  70514. * Imports the .tilemaps file
  70515. * @param url of the .tilemaps file
  70516. */
  70517. loadTileMaps(url: string): void;
  70518. /**
  70519. * Release associated resources
  70520. */
  70521. dispose(): void;
  70522. }
  70523. }
  70524. declare module "babylonjs/Sprites/spritePackedManager" {
  70525. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70526. import { Scene } from "babylonjs/scene";
  70527. /**
  70528. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70529. * @see http://doc.babylonjs.com/babylon101/sprites
  70530. */
  70531. export class SpritePackedManager extends SpriteManager {
  70532. /** defines the packed manager's name */
  70533. name: string;
  70534. /**
  70535. * Creates a new sprite manager from a packed sprite sheet
  70536. * @param name defines the manager's name
  70537. * @param imgUrl defines the sprite sheet url
  70538. * @param capacity defines the maximum allowed number of sprites
  70539. * @param scene defines the hosting scene
  70540. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70541. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70542. * @param samplingMode defines the smapling mode to use with spritesheet
  70543. * @param fromPacked set to true; do not alter
  70544. */
  70545. constructor(
  70546. /** defines the packed manager's name */
  70547. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70548. }
  70549. }
  70550. declare module "babylonjs/Sprites/index" {
  70551. export * from "babylonjs/Sprites/sprite";
  70552. export * from "babylonjs/Sprites/ISprites";
  70553. export * from "babylonjs/Sprites/spriteManager";
  70554. export * from "babylonjs/Sprites/spriteMap";
  70555. export * from "babylonjs/Sprites/spritePackedManager";
  70556. export * from "babylonjs/Sprites/spriteSceneComponent";
  70557. }
  70558. declare module "babylonjs/States/index" {
  70559. export * from "babylonjs/States/alphaCullingState";
  70560. export * from "babylonjs/States/depthCullingState";
  70561. export * from "babylonjs/States/stencilState";
  70562. }
  70563. declare module "babylonjs/Misc/assetsManager" {
  70564. import { Scene } from "babylonjs/scene";
  70565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70566. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70567. import { Skeleton } from "babylonjs/Bones/skeleton";
  70568. import { Observable } from "babylonjs/Misc/observable";
  70569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70570. import { Texture } from "babylonjs/Materials/Textures/texture";
  70571. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70572. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70573. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70574. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70575. /**
  70576. * Defines the list of states available for a task inside a AssetsManager
  70577. */
  70578. export enum AssetTaskState {
  70579. /**
  70580. * Initialization
  70581. */
  70582. INIT = 0,
  70583. /**
  70584. * Running
  70585. */
  70586. RUNNING = 1,
  70587. /**
  70588. * Done
  70589. */
  70590. DONE = 2,
  70591. /**
  70592. * Error
  70593. */
  70594. ERROR = 3
  70595. }
  70596. /**
  70597. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70598. */
  70599. export abstract class AbstractAssetTask {
  70600. /**
  70601. * Task name
  70602. */ name: string;
  70603. /**
  70604. * Callback called when the task is successful
  70605. */
  70606. onSuccess: (task: any) => void;
  70607. /**
  70608. * Callback called when the task is not successful
  70609. */
  70610. onError: (task: any, message?: string, exception?: any) => void;
  70611. /**
  70612. * Creates a new AssetsManager
  70613. * @param name defines the name of the task
  70614. */
  70615. constructor(
  70616. /**
  70617. * Task name
  70618. */ name: string);
  70619. private _isCompleted;
  70620. private _taskState;
  70621. private _errorObject;
  70622. /**
  70623. * Get if the task is completed
  70624. */
  70625. get isCompleted(): boolean;
  70626. /**
  70627. * Gets the current state of the task
  70628. */
  70629. get taskState(): AssetTaskState;
  70630. /**
  70631. * Gets the current error object (if task is in error)
  70632. */
  70633. get errorObject(): {
  70634. message?: string;
  70635. exception?: any;
  70636. };
  70637. /**
  70638. * Internal only
  70639. * @hidden
  70640. */
  70641. _setErrorObject(message?: string, exception?: any): void;
  70642. /**
  70643. * Execute the current task
  70644. * @param scene defines the scene where you want your assets to be loaded
  70645. * @param onSuccess is a callback called when the task is successfully executed
  70646. * @param onError is a callback called if an error occurs
  70647. */
  70648. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70649. /**
  70650. * Execute the current task
  70651. * @param scene defines the scene where you want your assets to be loaded
  70652. * @param onSuccess is a callback called when the task is successfully executed
  70653. * @param onError is a callback called if an error occurs
  70654. */
  70655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70656. /**
  70657. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70658. * This can be used with failed tasks that have the reason for failure fixed.
  70659. */
  70660. reset(): void;
  70661. private onErrorCallback;
  70662. private onDoneCallback;
  70663. }
  70664. /**
  70665. * Define the interface used by progress events raised during assets loading
  70666. */
  70667. export interface IAssetsProgressEvent {
  70668. /**
  70669. * Defines the number of remaining tasks to process
  70670. */
  70671. remainingCount: number;
  70672. /**
  70673. * Defines the total number of tasks
  70674. */
  70675. totalCount: number;
  70676. /**
  70677. * Defines the task that was just processed
  70678. */
  70679. task: AbstractAssetTask;
  70680. }
  70681. /**
  70682. * Class used to share progress information about assets loading
  70683. */
  70684. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70685. /**
  70686. * Defines the number of remaining tasks to process
  70687. */
  70688. remainingCount: number;
  70689. /**
  70690. * Defines the total number of tasks
  70691. */
  70692. totalCount: number;
  70693. /**
  70694. * Defines the task that was just processed
  70695. */
  70696. task: AbstractAssetTask;
  70697. /**
  70698. * Creates a AssetsProgressEvent
  70699. * @param remainingCount defines the number of remaining tasks to process
  70700. * @param totalCount defines the total number of tasks
  70701. * @param task defines the task that was just processed
  70702. */
  70703. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70704. }
  70705. /**
  70706. * Define a task used by AssetsManager to load meshes
  70707. */
  70708. export class MeshAssetTask extends AbstractAssetTask {
  70709. /**
  70710. * Defines the name of the task
  70711. */
  70712. name: string;
  70713. /**
  70714. * Defines the list of mesh's names you want to load
  70715. */
  70716. meshesNames: any;
  70717. /**
  70718. * Defines the root url to use as a base to load your meshes and associated resources
  70719. */
  70720. rootUrl: string;
  70721. /**
  70722. * Defines the filename of the scene to load from
  70723. */
  70724. sceneFilename: string;
  70725. /**
  70726. * Gets the list of loaded meshes
  70727. */
  70728. loadedMeshes: Array<AbstractMesh>;
  70729. /**
  70730. * Gets the list of loaded particle systems
  70731. */
  70732. loadedParticleSystems: Array<IParticleSystem>;
  70733. /**
  70734. * Gets the list of loaded skeletons
  70735. */
  70736. loadedSkeletons: Array<Skeleton>;
  70737. /**
  70738. * Gets the list of loaded animation groups
  70739. */
  70740. loadedAnimationGroups: Array<AnimationGroup>;
  70741. /**
  70742. * Callback called when the task is successful
  70743. */
  70744. onSuccess: (task: MeshAssetTask) => void;
  70745. /**
  70746. * Callback called when the task is successful
  70747. */
  70748. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70749. /**
  70750. * Creates a new MeshAssetTask
  70751. * @param name defines the name of the task
  70752. * @param meshesNames defines the list of mesh's names you want to load
  70753. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70754. * @param sceneFilename defines the filename of the scene to load from
  70755. */
  70756. constructor(
  70757. /**
  70758. * Defines the name of the task
  70759. */
  70760. name: string,
  70761. /**
  70762. * Defines the list of mesh's names you want to load
  70763. */
  70764. meshesNames: any,
  70765. /**
  70766. * Defines the root url to use as a base to load your meshes and associated resources
  70767. */
  70768. rootUrl: string,
  70769. /**
  70770. * Defines the filename of the scene to load from
  70771. */
  70772. sceneFilename: string);
  70773. /**
  70774. * Execute the current task
  70775. * @param scene defines the scene where you want your assets to be loaded
  70776. * @param onSuccess is a callback called when the task is successfully executed
  70777. * @param onError is a callback called if an error occurs
  70778. */
  70779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70780. }
  70781. /**
  70782. * Define a task used by AssetsManager to load text content
  70783. */
  70784. export class TextFileAssetTask extends AbstractAssetTask {
  70785. /**
  70786. * Defines the name of the task
  70787. */
  70788. name: string;
  70789. /**
  70790. * Defines the location of the file to load
  70791. */
  70792. url: string;
  70793. /**
  70794. * Gets the loaded text string
  70795. */
  70796. text: string;
  70797. /**
  70798. * Callback called when the task is successful
  70799. */
  70800. onSuccess: (task: TextFileAssetTask) => void;
  70801. /**
  70802. * Callback called when the task is successful
  70803. */
  70804. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70805. /**
  70806. * Creates a new TextFileAssetTask object
  70807. * @param name defines the name of the task
  70808. * @param url defines the location of the file to load
  70809. */
  70810. constructor(
  70811. /**
  70812. * Defines the name of the task
  70813. */
  70814. name: string,
  70815. /**
  70816. * Defines the location of the file to load
  70817. */
  70818. url: string);
  70819. /**
  70820. * Execute the current task
  70821. * @param scene defines the scene where you want your assets to be loaded
  70822. * @param onSuccess is a callback called when the task is successfully executed
  70823. * @param onError is a callback called if an error occurs
  70824. */
  70825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70826. }
  70827. /**
  70828. * Define a task used by AssetsManager to load binary data
  70829. */
  70830. export class BinaryFileAssetTask extends AbstractAssetTask {
  70831. /**
  70832. * Defines the name of the task
  70833. */
  70834. name: string;
  70835. /**
  70836. * Defines the location of the file to load
  70837. */
  70838. url: string;
  70839. /**
  70840. * Gets the lodaded data (as an array buffer)
  70841. */
  70842. data: ArrayBuffer;
  70843. /**
  70844. * Callback called when the task is successful
  70845. */
  70846. onSuccess: (task: BinaryFileAssetTask) => void;
  70847. /**
  70848. * Callback called when the task is successful
  70849. */
  70850. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70851. /**
  70852. * Creates a new BinaryFileAssetTask object
  70853. * @param name defines the name of the new task
  70854. * @param url defines the location of the file to load
  70855. */
  70856. constructor(
  70857. /**
  70858. * Defines the name of the task
  70859. */
  70860. name: string,
  70861. /**
  70862. * Defines the location of the file to load
  70863. */
  70864. url: string);
  70865. /**
  70866. * Execute the current task
  70867. * @param scene defines the scene where you want your assets to be loaded
  70868. * @param onSuccess is a callback called when the task is successfully executed
  70869. * @param onError is a callback called if an error occurs
  70870. */
  70871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70872. }
  70873. /**
  70874. * Define a task used by AssetsManager to load images
  70875. */
  70876. export class ImageAssetTask extends AbstractAssetTask {
  70877. /**
  70878. * Defines the name of the task
  70879. */
  70880. name: string;
  70881. /**
  70882. * Defines the location of the image to load
  70883. */
  70884. url: string;
  70885. /**
  70886. * Gets the loaded images
  70887. */
  70888. image: HTMLImageElement;
  70889. /**
  70890. * Callback called when the task is successful
  70891. */
  70892. onSuccess: (task: ImageAssetTask) => void;
  70893. /**
  70894. * Callback called when the task is successful
  70895. */
  70896. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70897. /**
  70898. * Creates a new ImageAssetTask
  70899. * @param name defines the name of the task
  70900. * @param url defines the location of the image to load
  70901. */
  70902. constructor(
  70903. /**
  70904. * Defines the name of the task
  70905. */
  70906. name: string,
  70907. /**
  70908. * Defines the location of the image to load
  70909. */
  70910. url: string);
  70911. /**
  70912. * Execute the current task
  70913. * @param scene defines the scene where you want your assets to be loaded
  70914. * @param onSuccess is a callback called when the task is successfully executed
  70915. * @param onError is a callback called if an error occurs
  70916. */
  70917. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70918. }
  70919. /**
  70920. * Defines the interface used by texture loading tasks
  70921. */
  70922. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70923. /**
  70924. * Gets the loaded texture
  70925. */
  70926. texture: TEX;
  70927. }
  70928. /**
  70929. * Define a task used by AssetsManager to load 2D textures
  70930. */
  70931. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70932. /**
  70933. * Defines the name of the task
  70934. */
  70935. name: string;
  70936. /**
  70937. * Defines the location of the file to load
  70938. */
  70939. url: string;
  70940. /**
  70941. * Defines if mipmap should not be generated (default is false)
  70942. */
  70943. noMipmap?: boolean | undefined;
  70944. /**
  70945. * Defines if texture must be inverted on Y axis (default is false)
  70946. */
  70947. invertY?: boolean | undefined;
  70948. /**
  70949. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70950. */
  70951. samplingMode: number;
  70952. /**
  70953. * Gets the loaded texture
  70954. */
  70955. texture: Texture;
  70956. /**
  70957. * Callback called when the task is successful
  70958. */
  70959. onSuccess: (task: TextureAssetTask) => void;
  70960. /**
  70961. * Callback called when the task is successful
  70962. */
  70963. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70964. /**
  70965. * Creates a new TextureAssetTask object
  70966. * @param name defines the name of the task
  70967. * @param url defines the location of the file to load
  70968. * @param noMipmap defines if mipmap should not be generated (default is false)
  70969. * @param invertY defines if texture must be inverted on Y axis (default is false)
  70970. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70971. */
  70972. constructor(
  70973. /**
  70974. * Defines the name of the task
  70975. */
  70976. name: string,
  70977. /**
  70978. * Defines the location of the file to load
  70979. */
  70980. url: string,
  70981. /**
  70982. * Defines if mipmap should not be generated (default is false)
  70983. */
  70984. noMipmap?: boolean | undefined,
  70985. /**
  70986. * Defines if texture must be inverted on Y axis (default is false)
  70987. */
  70988. invertY?: boolean | undefined,
  70989. /**
  70990. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70991. */
  70992. samplingMode?: number);
  70993. /**
  70994. * Execute the current task
  70995. * @param scene defines the scene where you want your assets to be loaded
  70996. * @param onSuccess is a callback called when the task is successfully executed
  70997. * @param onError is a callback called if an error occurs
  70998. */
  70999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71000. }
  71001. /**
  71002. * Define a task used by AssetsManager to load cube textures
  71003. */
  71004. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71005. /**
  71006. * Defines the name of the task
  71007. */
  71008. name: string;
  71009. /**
  71010. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71011. */
  71012. url: string;
  71013. /**
  71014. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71015. */
  71016. extensions?: string[] | undefined;
  71017. /**
  71018. * Defines if mipmaps should not be generated (default is false)
  71019. */
  71020. noMipmap?: boolean | undefined;
  71021. /**
  71022. * Defines the explicit list of files (undefined by default)
  71023. */
  71024. files?: string[] | undefined;
  71025. /**
  71026. * Gets the loaded texture
  71027. */
  71028. texture: CubeTexture;
  71029. /**
  71030. * Callback called when the task is successful
  71031. */
  71032. onSuccess: (task: CubeTextureAssetTask) => void;
  71033. /**
  71034. * Callback called when the task is successful
  71035. */
  71036. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71037. /**
  71038. * Creates a new CubeTextureAssetTask
  71039. * @param name defines the name of the task
  71040. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71041. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71042. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71043. * @param files defines the explicit list of files (undefined by default)
  71044. */
  71045. constructor(
  71046. /**
  71047. * Defines the name of the task
  71048. */
  71049. name: string,
  71050. /**
  71051. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71052. */
  71053. url: string,
  71054. /**
  71055. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71056. */
  71057. extensions?: string[] | undefined,
  71058. /**
  71059. * Defines if mipmaps should not be generated (default is false)
  71060. */
  71061. noMipmap?: boolean | undefined,
  71062. /**
  71063. * Defines the explicit list of files (undefined by default)
  71064. */
  71065. files?: string[] | undefined);
  71066. /**
  71067. * Execute the current task
  71068. * @param scene defines the scene where you want your assets to be loaded
  71069. * @param onSuccess is a callback called when the task is successfully executed
  71070. * @param onError is a callback called if an error occurs
  71071. */
  71072. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71073. }
  71074. /**
  71075. * Define a task used by AssetsManager to load HDR cube textures
  71076. */
  71077. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71078. /**
  71079. * Defines the name of the task
  71080. */
  71081. name: string;
  71082. /**
  71083. * Defines the location of the file to load
  71084. */
  71085. url: string;
  71086. /**
  71087. * Defines the desired size (the more it increases the longer the generation will be)
  71088. */
  71089. size: number;
  71090. /**
  71091. * Defines if mipmaps should not be generated (default is false)
  71092. */
  71093. noMipmap: boolean;
  71094. /**
  71095. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71096. */
  71097. generateHarmonics: boolean;
  71098. /**
  71099. * 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)
  71100. */
  71101. gammaSpace: boolean;
  71102. /**
  71103. * Internal Use Only
  71104. */
  71105. reserved: boolean;
  71106. /**
  71107. * Gets the loaded texture
  71108. */
  71109. texture: HDRCubeTexture;
  71110. /**
  71111. * Callback called when the task is successful
  71112. */
  71113. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71114. /**
  71115. * Callback called when the task is successful
  71116. */
  71117. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71118. /**
  71119. * Creates a new HDRCubeTextureAssetTask object
  71120. * @param name defines the name of the task
  71121. * @param url defines the location of the file to load
  71122. * @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.
  71123. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71124. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71125. * @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)
  71126. * @param reserved Internal use only
  71127. */
  71128. constructor(
  71129. /**
  71130. * Defines the name of the task
  71131. */
  71132. name: string,
  71133. /**
  71134. * Defines the location of the file to load
  71135. */
  71136. url: string,
  71137. /**
  71138. * Defines the desired size (the more it increases the longer the generation will be)
  71139. */
  71140. size: number,
  71141. /**
  71142. * Defines if mipmaps should not be generated (default is false)
  71143. */
  71144. noMipmap?: boolean,
  71145. /**
  71146. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71147. */
  71148. generateHarmonics?: boolean,
  71149. /**
  71150. * 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)
  71151. */
  71152. gammaSpace?: boolean,
  71153. /**
  71154. * Internal Use Only
  71155. */
  71156. reserved?: boolean);
  71157. /**
  71158. * Execute the current task
  71159. * @param scene defines the scene where you want your assets to be loaded
  71160. * @param onSuccess is a callback called when the task is successfully executed
  71161. * @param onError is a callback called if an error occurs
  71162. */
  71163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71164. }
  71165. /**
  71166. * Define a task used by AssetsManager to load Equirectangular cube textures
  71167. */
  71168. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71169. /**
  71170. * Defines the name of the task
  71171. */
  71172. name: string;
  71173. /**
  71174. * Defines the location of the file to load
  71175. */
  71176. url: string;
  71177. /**
  71178. * Defines the desired size (the more it increases the longer the generation will be)
  71179. */
  71180. size: number;
  71181. /**
  71182. * Defines if mipmaps should not be generated (default is false)
  71183. */
  71184. noMipmap: boolean;
  71185. /**
  71186. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71187. * but the standard material would require them in Gamma space) (default is true)
  71188. */
  71189. gammaSpace: boolean;
  71190. /**
  71191. * Gets the loaded texture
  71192. */
  71193. texture: EquiRectangularCubeTexture;
  71194. /**
  71195. * Callback called when the task is successful
  71196. */
  71197. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71198. /**
  71199. * Callback called when the task is successful
  71200. */
  71201. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71202. /**
  71203. * Creates a new EquiRectangularCubeTextureAssetTask object
  71204. * @param name defines the name of the task
  71205. * @param url defines the location of the file to load
  71206. * @param size defines the desired size (the more it increases the longer the generation will be)
  71207. * If the size is omitted this implies you are using a preprocessed cubemap.
  71208. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71209. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71210. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71211. * (default is true)
  71212. */
  71213. constructor(
  71214. /**
  71215. * Defines the name of the task
  71216. */
  71217. name: string,
  71218. /**
  71219. * Defines the location of the file to load
  71220. */
  71221. url: string,
  71222. /**
  71223. * Defines the desired size (the more it increases the longer the generation will be)
  71224. */
  71225. size: number,
  71226. /**
  71227. * Defines if mipmaps should not be generated (default is false)
  71228. */
  71229. noMipmap?: boolean,
  71230. /**
  71231. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71232. * but the standard material would require them in Gamma space) (default is true)
  71233. */
  71234. gammaSpace?: boolean);
  71235. /**
  71236. * Execute the current task
  71237. * @param scene defines the scene where you want your assets to be loaded
  71238. * @param onSuccess is a callback called when the task is successfully executed
  71239. * @param onError is a callback called if an error occurs
  71240. */
  71241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71242. }
  71243. /**
  71244. * This class can be used to easily import assets into a scene
  71245. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71246. */
  71247. export class AssetsManager {
  71248. private _scene;
  71249. private _isLoading;
  71250. protected _tasks: AbstractAssetTask[];
  71251. protected _waitingTasksCount: number;
  71252. protected _totalTasksCount: number;
  71253. /**
  71254. * Callback called when all tasks are processed
  71255. */
  71256. onFinish: (tasks: AbstractAssetTask[]) => void;
  71257. /**
  71258. * Callback called when a task is successful
  71259. */
  71260. onTaskSuccess: (task: AbstractAssetTask) => void;
  71261. /**
  71262. * Callback called when a task had an error
  71263. */
  71264. onTaskError: (task: AbstractAssetTask) => void;
  71265. /**
  71266. * Callback called when a task is done (whatever the result is)
  71267. */
  71268. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71269. /**
  71270. * Observable called when all tasks are processed
  71271. */
  71272. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71273. /**
  71274. * Observable called when a task had an error
  71275. */
  71276. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71277. /**
  71278. * Observable called when all tasks were executed
  71279. */
  71280. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71281. /**
  71282. * Observable called when a task is done (whatever the result is)
  71283. */
  71284. onProgressObservable: Observable<IAssetsProgressEvent>;
  71285. /**
  71286. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71288. */
  71289. useDefaultLoadingScreen: boolean;
  71290. /**
  71291. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71292. * when all assets have been downloaded.
  71293. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71294. */
  71295. autoHideLoadingUI: boolean;
  71296. /**
  71297. * Creates a new AssetsManager
  71298. * @param scene defines the scene to work on
  71299. */
  71300. constructor(scene: Scene);
  71301. /**
  71302. * Add a MeshAssetTask to the list of active tasks
  71303. * @param taskName defines the name of the new task
  71304. * @param meshesNames defines the name of meshes to load
  71305. * @param rootUrl defines the root url to use to locate files
  71306. * @param sceneFilename defines the filename of the scene file
  71307. * @returns a new MeshAssetTask object
  71308. */
  71309. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71310. /**
  71311. * Add a TextFileAssetTask to the list of active tasks
  71312. * @param taskName defines the name of the new task
  71313. * @param url defines the url of the file to load
  71314. * @returns a new TextFileAssetTask object
  71315. */
  71316. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71317. /**
  71318. * Add a BinaryFileAssetTask to the list of active tasks
  71319. * @param taskName defines the name of the new task
  71320. * @param url defines the url of the file to load
  71321. * @returns a new BinaryFileAssetTask object
  71322. */
  71323. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71324. /**
  71325. * Add a ImageAssetTask to the list of active tasks
  71326. * @param taskName defines the name of the new task
  71327. * @param url defines the url of the file to load
  71328. * @returns a new ImageAssetTask object
  71329. */
  71330. addImageTask(taskName: string, url: string): ImageAssetTask;
  71331. /**
  71332. * Add a TextureAssetTask to the list of active tasks
  71333. * @param taskName defines the name of the new task
  71334. * @param url defines the url of the file to load
  71335. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71336. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71337. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71338. * @returns a new TextureAssetTask object
  71339. */
  71340. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71341. /**
  71342. * Add a CubeTextureAssetTask to the list of active tasks
  71343. * @param taskName defines the name of the new task
  71344. * @param url defines the url of the file to load
  71345. * @param extensions defines the extension to use to load the cube map (can be null)
  71346. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71347. * @param files defines the list of files to load (can be null)
  71348. * @returns a new CubeTextureAssetTask object
  71349. */
  71350. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71351. /**
  71352. *
  71353. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71354. * @param taskName defines the name of the new task
  71355. * @param url defines the url of the file to load
  71356. * @param size defines the size you want for the cubemap (can be null)
  71357. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71358. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71359. * @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)
  71360. * @param reserved Internal use only
  71361. * @returns a new HDRCubeTextureAssetTask object
  71362. */
  71363. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71364. /**
  71365. *
  71366. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71367. * @param taskName defines the name of the new task
  71368. * @param url defines the url of the file to load
  71369. * @param size defines the size you want for the cubemap (can be null)
  71370. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71371. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71372. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71373. * @returns a new EquiRectangularCubeTextureAssetTask object
  71374. */
  71375. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71376. /**
  71377. * Remove a task from the assets manager.
  71378. * @param task the task to remove
  71379. */
  71380. removeTask(task: AbstractAssetTask): void;
  71381. private _decreaseWaitingTasksCount;
  71382. private _runTask;
  71383. /**
  71384. * Reset the AssetsManager and remove all tasks
  71385. * @return the current instance of the AssetsManager
  71386. */
  71387. reset(): AssetsManager;
  71388. /**
  71389. * Start the loading process
  71390. * @return the current instance of the AssetsManager
  71391. */
  71392. load(): AssetsManager;
  71393. /**
  71394. * Start the loading process as an async operation
  71395. * @return a promise returning the list of failed tasks
  71396. */
  71397. loadAsync(): Promise<void>;
  71398. }
  71399. }
  71400. declare module "babylonjs/Misc/deferred" {
  71401. /**
  71402. * Wrapper class for promise with external resolve and reject.
  71403. */
  71404. export class Deferred<T> {
  71405. /**
  71406. * The promise associated with this deferred object.
  71407. */
  71408. readonly promise: Promise<T>;
  71409. private _resolve;
  71410. private _reject;
  71411. /**
  71412. * The resolve method of the promise associated with this deferred object.
  71413. */
  71414. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71415. /**
  71416. * The reject method of the promise associated with this deferred object.
  71417. */
  71418. get reject(): (reason?: any) => void;
  71419. /**
  71420. * Constructor for this deferred object.
  71421. */
  71422. constructor();
  71423. }
  71424. }
  71425. declare module "babylonjs/Misc/meshExploder" {
  71426. import { Mesh } from "babylonjs/Meshes/mesh";
  71427. /**
  71428. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71429. */
  71430. export class MeshExploder {
  71431. private _centerMesh;
  71432. private _meshes;
  71433. private _meshesOrigins;
  71434. private _toCenterVectors;
  71435. private _scaledDirection;
  71436. private _newPosition;
  71437. private _centerPosition;
  71438. /**
  71439. * Explodes meshes from a center mesh.
  71440. * @param meshes The meshes to explode.
  71441. * @param centerMesh The mesh to be center of explosion.
  71442. */
  71443. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71444. private _setCenterMesh;
  71445. /**
  71446. * Get class name
  71447. * @returns "MeshExploder"
  71448. */
  71449. getClassName(): string;
  71450. /**
  71451. * "Exploded meshes"
  71452. * @returns Array of meshes with the centerMesh at index 0.
  71453. */
  71454. getMeshes(): Array<Mesh>;
  71455. /**
  71456. * Explodes meshes giving a specific direction
  71457. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71458. */
  71459. explode(direction?: number): void;
  71460. }
  71461. }
  71462. declare module "babylonjs/Misc/filesInput" {
  71463. import { Engine } from "babylonjs/Engines/engine";
  71464. import { Scene } from "babylonjs/scene";
  71465. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71466. /**
  71467. * Class used to help managing file picking and drag'n'drop
  71468. */
  71469. export class FilesInput {
  71470. /**
  71471. * List of files ready to be loaded
  71472. */
  71473. static get FilesToLoad(): {
  71474. [key: string]: File;
  71475. };
  71476. /**
  71477. * Callback called when a file is processed
  71478. */
  71479. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71480. private _engine;
  71481. private _currentScene;
  71482. private _sceneLoadedCallback;
  71483. private _progressCallback;
  71484. private _additionalRenderLoopLogicCallback;
  71485. private _textureLoadingCallback;
  71486. private _startingProcessingFilesCallback;
  71487. private _onReloadCallback;
  71488. private _errorCallback;
  71489. private _elementToMonitor;
  71490. private _sceneFileToLoad;
  71491. private _filesToLoad;
  71492. /**
  71493. * Creates a new FilesInput
  71494. * @param engine defines the rendering engine
  71495. * @param scene defines the hosting scene
  71496. * @param sceneLoadedCallback callback called when scene is loaded
  71497. * @param progressCallback callback called to track progress
  71498. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71499. * @param textureLoadingCallback callback called when a texture is loading
  71500. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71501. * @param onReloadCallback callback called when a reload is requested
  71502. * @param errorCallback callback call if an error occurs
  71503. */
  71504. 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);
  71505. private _dragEnterHandler;
  71506. private _dragOverHandler;
  71507. private _dropHandler;
  71508. /**
  71509. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71510. * @param elementToMonitor defines the DOM element to track
  71511. */
  71512. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71513. /**
  71514. * Release all associated resources
  71515. */
  71516. dispose(): void;
  71517. private renderFunction;
  71518. private drag;
  71519. private drop;
  71520. private _traverseFolder;
  71521. private _processFiles;
  71522. /**
  71523. * Load files from a drop event
  71524. * @param event defines the drop event to use as source
  71525. */
  71526. loadFiles(event: any): void;
  71527. private _processReload;
  71528. /**
  71529. * Reload the current scene from the loaded files
  71530. */
  71531. reload(): void;
  71532. }
  71533. }
  71534. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71535. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71536. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71537. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71538. }
  71539. declare module "babylonjs/Misc/sceneOptimizer" {
  71540. import { Scene, IDisposable } from "babylonjs/scene";
  71541. import { Observable } from "babylonjs/Misc/observable";
  71542. /**
  71543. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71545. */
  71546. export class SceneOptimization {
  71547. /**
  71548. * Defines the priority of this optimization (0 by default which means first in the list)
  71549. */
  71550. priority: number;
  71551. /**
  71552. * Gets a string describing the action executed by the current optimization
  71553. * @returns description string
  71554. */
  71555. getDescription(): string;
  71556. /**
  71557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71558. * @param scene defines the current scene where to apply this optimization
  71559. * @param optimizer defines the current optimizer
  71560. * @returns true if everything that can be done was applied
  71561. */
  71562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71563. /**
  71564. * Creates the SceneOptimization object
  71565. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71566. * @param desc defines the description associated with the optimization
  71567. */
  71568. constructor(
  71569. /**
  71570. * Defines the priority of this optimization (0 by default which means first in the list)
  71571. */
  71572. priority?: number);
  71573. }
  71574. /**
  71575. * Defines an optimization used to reduce the size of render target textures
  71576. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71577. */
  71578. export class TextureOptimization extends SceneOptimization {
  71579. /**
  71580. * Defines the priority of this optimization (0 by default which means first in the list)
  71581. */
  71582. priority: number;
  71583. /**
  71584. * 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
  71585. */
  71586. maximumSize: number;
  71587. /**
  71588. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71589. */
  71590. step: number;
  71591. /**
  71592. * Gets a string describing the action executed by the current optimization
  71593. * @returns description string
  71594. */
  71595. getDescription(): string;
  71596. /**
  71597. * Creates the TextureOptimization object
  71598. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71599. * @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
  71600. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71601. */
  71602. constructor(
  71603. /**
  71604. * Defines the priority of this optimization (0 by default which means first in the list)
  71605. */
  71606. priority?: number,
  71607. /**
  71608. * 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
  71609. */
  71610. maximumSize?: number,
  71611. /**
  71612. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71613. */
  71614. step?: number);
  71615. /**
  71616. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71617. * @param scene defines the current scene where to apply this optimization
  71618. * @param optimizer defines the current optimizer
  71619. * @returns true if everything that can be done was applied
  71620. */
  71621. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71622. }
  71623. /**
  71624. * Defines an optimization used to increase or decrease the rendering resolution
  71625. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71626. */
  71627. export class HardwareScalingOptimization extends SceneOptimization {
  71628. /**
  71629. * Defines the priority of this optimization (0 by default which means first in the list)
  71630. */
  71631. priority: number;
  71632. /**
  71633. * Defines the maximum scale to use (2 by default)
  71634. */
  71635. maximumScale: number;
  71636. /**
  71637. * Defines the step to use between two passes (0.5 by default)
  71638. */
  71639. step: number;
  71640. private _currentScale;
  71641. private _directionOffset;
  71642. /**
  71643. * Gets a string describing the action executed by the current optimization
  71644. * @return description string
  71645. */
  71646. getDescription(): string;
  71647. /**
  71648. * Creates the HardwareScalingOptimization object
  71649. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71650. * @param maximumScale defines the maximum scale to use (2 by default)
  71651. * @param step defines the step to use between two passes (0.5 by default)
  71652. */
  71653. constructor(
  71654. /**
  71655. * Defines the priority of this optimization (0 by default which means first in the list)
  71656. */
  71657. priority?: number,
  71658. /**
  71659. * Defines the maximum scale to use (2 by default)
  71660. */
  71661. maximumScale?: number,
  71662. /**
  71663. * Defines the step to use between two passes (0.5 by default)
  71664. */
  71665. step?: number);
  71666. /**
  71667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71668. * @param scene defines the current scene where to apply this optimization
  71669. * @param optimizer defines the current optimizer
  71670. * @returns true if everything that can be done was applied
  71671. */
  71672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71673. }
  71674. /**
  71675. * Defines an optimization used to remove shadows
  71676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71677. */
  71678. export class ShadowsOptimization extends SceneOptimization {
  71679. /**
  71680. * Gets a string describing the action executed by the current optimization
  71681. * @return description string
  71682. */
  71683. getDescription(): string;
  71684. /**
  71685. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71686. * @param scene defines the current scene where to apply this optimization
  71687. * @param optimizer defines the current optimizer
  71688. * @returns true if everything that can be done was applied
  71689. */
  71690. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71691. }
  71692. /**
  71693. * Defines an optimization used to turn post-processes off
  71694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71695. */
  71696. export class PostProcessesOptimization extends SceneOptimization {
  71697. /**
  71698. * Gets a string describing the action executed by the current optimization
  71699. * @return description string
  71700. */
  71701. getDescription(): string;
  71702. /**
  71703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71704. * @param scene defines the current scene where to apply this optimization
  71705. * @param optimizer defines the current optimizer
  71706. * @returns true if everything that can be done was applied
  71707. */
  71708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71709. }
  71710. /**
  71711. * Defines an optimization used to turn lens flares off
  71712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71713. */
  71714. export class LensFlaresOptimization extends SceneOptimization {
  71715. /**
  71716. * Gets a string describing the action executed by the current optimization
  71717. * @return description string
  71718. */
  71719. getDescription(): string;
  71720. /**
  71721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71722. * @param scene defines the current scene where to apply this optimization
  71723. * @param optimizer defines the current optimizer
  71724. * @returns true if everything that can be done was applied
  71725. */
  71726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71727. }
  71728. /**
  71729. * Defines an optimization based on user defined callback.
  71730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71731. */
  71732. export class CustomOptimization extends SceneOptimization {
  71733. /**
  71734. * Callback called to apply the custom optimization.
  71735. */
  71736. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71737. /**
  71738. * Callback called to get custom description
  71739. */
  71740. onGetDescription: () => string;
  71741. /**
  71742. * Gets a string describing the action executed by the current optimization
  71743. * @returns description string
  71744. */
  71745. getDescription(): string;
  71746. /**
  71747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71748. * @param scene defines the current scene where to apply this optimization
  71749. * @param optimizer defines the current optimizer
  71750. * @returns true if everything that can be done was applied
  71751. */
  71752. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71753. }
  71754. /**
  71755. * Defines an optimization used to turn particles off
  71756. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71757. */
  71758. export class ParticlesOptimization extends SceneOptimization {
  71759. /**
  71760. * Gets a string describing the action executed by the current optimization
  71761. * @return description string
  71762. */
  71763. getDescription(): string;
  71764. /**
  71765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71766. * @param scene defines the current scene where to apply this optimization
  71767. * @param optimizer defines the current optimizer
  71768. * @returns true if everything that can be done was applied
  71769. */
  71770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71771. }
  71772. /**
  71773. * Defines an optimization used to turn render targets off
  71774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71775. */
  71776. export class RenderTargetsOptimization extends SceneOptimization {
  71777. /**
  71778. * Gets a string describing the action executed by the current optimization
  71779. * @return description string
  71780. */
  71781. getDescription(): string;
  71782. /**
  71783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71784. * @param scene defines the current scene where to apply this optimization
  71785. * @param optimizer defines the current optimizer
  71786. * @returns true if everything that can be done was applied
  71787. */
  71788. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71789. }
  71790. /**
  71791. * Defines an optimization used to merge meshes with compatible materials
  71792. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71793. */
  71794. export class MergeMeshesOptimization extends SceneOptimization {
  71795. private static _UpdateSelectionTree;
  71796. /**
  71797. * Gets or sets a boolean which defines if optimization octree has to be updated
  71798. */
  71799. static get UpdateSelectionTree(): boolean;
  71800. /**
  71801. * Gets or sets a boolean which defines if optimization octree has to be updated
  71802. */
  71803. static set UpdateSelectionTree(value: boolean);
  71804. /**
  71805. * Gets a string describing the action executed by the current optimization
  71806. * @return description string
  71807. */
  71808. getDescription(): string;
  71809. private _canBeMerged;
  71810. /**
  71811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71812. * @param scene defines the current scene where to apply this optimization
  71813. * @param optimizer defines the current optimizer
  71814. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71815. * @returns true if everything that can be done was applied
  71816. */
  71817. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71818. }
  71819. /**
  71820. * Defines a list of options used by SceneOptimizer
  71821. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71822. */
  71823. export class SceneOptimizerOptions {
  71824. /**
  71825. * Defines the target frame rate to reach (60 by default)
  71826. */
  71827. targetFrameRate: number;
  71828. /**
  71829. * Defines the interval between two checkes (2000ms by default)
  71830. */
  71831. trackerDuration: number;
  71832. /**
  71833. * Gets the list of optimizations to apply
  71834. */
  71835. optimizations: SceneOptimization[];
  71836. /**
  71837. * Creates a new list of options used by SceneOptimizer
  71838. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71839. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71840. */
  71841. constructor(
  71842. /**
  71843. * Defines the target frame rate to reach (60 by default)
  71844. */
  71845. targetFrameRate?: number,
  71846. /**
  71847. * Defines the interval between two checkes (2000ms by default)
  71848. */
  71849. trackerDuration?: number);
  71850. /**
  71851. * Add a new optimization
  71852. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71853. * @returns the current SceneOptimizerOptions
  71854. */
  71855. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71856. /**
  71857. * Add a new custom optimization
  71858. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71859. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71861. * @returns the current SceneOptimizerOptions
  71862. */
  71863. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71864. /**
  71865. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71866. * @param targetFrameRate defines the target frame rate (60 by default)
  71867. * @returns a SceneOptimizerOptions object
  71868. */
  71869. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71870. /**
  71871. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71872. * @param targetFrameRate defines the target frame rate (60 by default)
  71873. * @returns a SceneOptimizerOptions object
  71874. */
  71875. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71876. /**
  71877. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71878. * @param targetFrameRate defines the target frame rate (60 by default)
  71879. * @returns a SceneOptimizerOptions object
  71880. */
  71881. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71882. }
  71883. /**
  71884. * Class used to run optimizations in order to reach a target frame rate
  71885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71886. */
  71887. export class SceneOptimizer implements IDisposable {
  71888. private _isRunning;
  71889. private _options;
  71890. private _scene;
  71891. private _currentPriorityLevel;
  71892. private _targetFrameRate;
  71893. private _trackerDuration;
  71894. private _currentFrameRate;
  71895. private _sceneDisposeObserver;
  71896. private _improvementMode;
  71897. /**
  71898. * Defines an observable called when the optimizer reaches the target frame rate
  71899. */
  71900. onSuccessObservable: Observable<SceneOptimizer>;
  71901. /**
  71902. * Defines an observable called when the optimizer enables an optimization
  71903. */
  71904. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71905. /**
  71906. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71907. */
  71908. onFailureObservable: Observable<SceneOptimizer>;
  71909. /**
  71910. * Gets a boolean indicating if the optimizer is in improvement mode
  71911. */
  71912. get isInImprovementMode(): boolean;
  71913. /**
  71914. * Gets the current priority level (0 at start)
  71915. */
  71916. get currentPriorityLevel(): number;
  71917. /**
  71918. * Gets the current frame rate checked by the SceneOptimizer
  71919. */
  71920. get currentFrameRate(): number;
  71921. /**
  71922. * Gets or sets the current target frame rate (60 by default)
  71923. */
  71924. get targetFrameRate(): number;
  71925. /**
  71926. * Gets or sets the current target frame rate (60 by default)
  71927. */
  71928. set targetFrameRate(value: number);
  71929. /**
  71930. * Gets or sets the current interval between two checks (every 2000ms by default)
  71931. */
  71932. get trackerDuration(): number;
  71933. /**
  71934. * Gets or sets the current interval between two checks (every 2000ms by default)
  71935. */
  71936. set trackerDuration(value: number);
  71937. /**
  71938. * Gets the list of active optimizations
  71939. */
  71940. get optimizations(): SceneOptimization[];
  71941. /**
  71942. * Creates a new SceneOptimizer
  71943. * @param scene defines the scene to work on
  71944. * @param options defines the options to use with the SceneOptimizer
  71945. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71946. * @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)
  71947. */
  71948. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71949. /**
  71950. * Stops the current optimizer
  71951. */
  71952. stop(): void;
  71953. /**
  71954. * Reset the optimizer to initial step (current priority level = 0)
  71955. */
  71956. reset(): void;
  71957. /**
  71958. * Start the optimizer. By default it will try to reach a specific framerate
  71959. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71960. */
  71961. start(): void;
  71962. private _checkCurrentState;
  71963. /**
  71964. * Release all resources
  71965. */
  71966. dispose(): void;
  71967. /**
  71968. * Helper function to create a SceneOptimizer with one single line of code
  71969. * @param scene defines the scene to work on
  71970. * @param options defines the options to use with the SceneOptimizer
  71971. * @param onSuccess defines a callback to call on success
  71972. * @param onFailure defines a callback to call on failure
  71973. * @returns the new SceneOptimizer object
  71974. */
  71975. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71976. }
  71977. }
  71978. declare module "babylonjs/Misc/sceneSerializer" {
  71979. import { Scene } from "babylonjs/scene";
  71980. /**
  71981. * Class used to serialize a scene into a string
  71982. */
  71983. export class SceneSerializer {
  71984. /**
  71985. * Clear cache used by a previous serialization
  71986. */
  71987. static ClearCache(): void;
  71988. /**
  71989. * Serialize a scene into a JSON compatible object
  71990. * @param scene defines the scene to serialize
  71991. * @returns a JSON compatible object
  71992. */
  71993. static Serialize(scene: Scene): any;
  71994. /**
  71995. * Serialize a mesh into a JSON compatible object
  71996. * @param toSerialize defines the mesh to serialize
  71997. * @param withParents defines if parents must be serialized as well
  71998. * @param withChildren defines if children must be serialized as well
  71999. * @returns a JSON compatible object
  72000. */
  72001. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72002. }
  72003. }
  72004. declare module "babylonjs/Misc/textureTools" {
  72005. import { Texture } from "babylonjs/Materials/Textures/texture";
  72006. /**
  72007. * Class used to host texture specific utilities
  72008. */
  72009. export class TextureTools {
  72010. /**
  72011. * Uses the GPU to create a copy texture rescaled at a given size
  72012. * @param texture Texture to copy from
  72013. * @param width defines the desired width
  72014. * @param height defines the desired height
  72015. * @param useBilinearMode defines if bilinear mode has to be used
  72016. * @return the generated texture
  72017. */
  72018. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72019. }
  72020. }
  72021. declare module "babylonjs/Misc/videoRecorder" {
  72022. import { Nullable } from "babylonjs/types";
  72023. import { Engine } from "babylonjs/Engines/engine";
  72024. /**
  72025. * This represents the different options available for the video capture.
  72026. */
  72027. export interface VideoRecorderOptions {
  72028. /** Defines the mime type of the video. */
  72029. mimeType: string;
  72030. /** Defines the FPS the video should be recorded at. */
  72031. fps: number;
  72032. /** Defines the chunk size for the recording data. */
  72033. recordChunckSize: number;
  72034. /** The audio tracks to attach to the recording. */
  72035. audioTracks?: MediaStreamTrack[];
  72036. }
  72037. /**
  72038. * This can help with recording videos from BabylonJS.
  72039. * This is based on the available WebRTC functionalities of the browser.
  72040. *
  72041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72042. */
  72043. export class VideoRecorder {
  72044. private static readonly _defaultOptions;
  72045. /**
  72046. * Returns whether or not the VideoRecorder is available in your browser.
  72047. * @param engine Defines the Babylon Engine.
  72048. * @returns true if supported otherwise false.
  72049. */
  72050. static IsSupported(engine: Engine): boolean;
  72051. private readonly _options;
  72052. private _canvas;
  72053. private _mediaRecorder;
  72054. private _recordedChunks;
  72055. private _fileName;
  72056. private _resolve;
  72057. private _reject;
  72058. /**
  72059. * True when a recording is already in progress.
  72060. */
  72061. get isRecording(): boolean;
  72062. /**
  72063. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72064. * @param engine Defines the BabylonJS Engine you wish to record.
  72065. * @param options Defines options that can be used to customize the capture.
  72066. */
  72067. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72068. /**
  72069. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72070. */
  72071. stopRecording(): void;
  72072. /**
  72073. * Starts recording the canvas for a max duration specified in parameters.
  72074. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72075. * If null no automatic download will start and you can rely on the promise to get the data back.
  72076. * @param maxDuration Defines the maximum recording time in seconds.
  72077. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72078. * @return A promise callback at the end of the recording with the video data in Blob.
  72079. */
  72080. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72081. /**
  72082. * Releases internal resources used during the recording.
  72083. */
  72084. dispose(): void;
  72085. private _handleDataAvailable;
  72086. private _handleError;
  72087. private _handleStop;
  72088. }
  72089. }
  72090. declare module "babylonjs/Misc/screenshotTools" {
  72091. import { Camera } from "babylonjs/Cameras/camera";
  72092. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72093. import { Engine } from "babylonjs/Engines/engine";
  72094. /**
  72095. * Class containing a set of static utilities functions for screenshots
  72096. */
  72097. export class ScreenshotTools {
  72098. /**
  72099. * Captures a screenshot of the current rendering
  72100. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72101. * @param engine defines the rendering engine
  72102. * @param camera defines the source camera
  72103. * @param size This parameter can be set to a single number or to an object with the
  72104. * following (optional) properties: precision, width, height. If a single number is passed,
  72105. * it will be used for both width and height. If an object is passed, the screenshot size
  72106. * will be derived from the parameters. The precision property is a multiplier allowing
  72107. * rendering at a higher or lower resolution
  72108. * @param successCallback defines the callback receives a single parameter which contains the
  72109. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72110. * src parameter of an <img> to display it
  72111. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72112. * Check your browser for supported MIME types
  72113. */
  72114. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72115. /**
  72116. * Captures a screenshot of the current rendering
  72117. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72118. * @param engine defines the rendering engine
  72119. * @param camera defines the source camera
  72120. * @param size This parameter can be set to a single number or to an object with the
  72121. * following (optional) properties: precision, width, height. If a single number is passed,
  72122. * it will be used for both width and height. If an object is passed, the screenshot size
  72123. * will be derived from the parameters. The precision property is a multiplier allowing
  72124. * rendering at a higher or lower resolution
  72125. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72126. * Check your browser for supported MIME types
  72127. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72128. * to the src parameter of an <img> to display it
  72129. */
  72130. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72131. /**
  72132. * Generates an image screenshot from the specified camera.
  72133. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72134. * @param engine The engine to use for rendering
  72135. * @param camera The camera to use for rendering
  72136. * @param size This parameter can be set to a single number or to an object with the
  72137. * following (optional) properties: precision, width, height. If a single number is passed,
  72138. * it will be used for both width and height. If an object is passed, the screenshot size
  72139. * will be derived from the parameters. The precision property is a multiplier allowing
  72140. * rendering at a higher or lower resolution
  72141. * @param successCallback The callback receives a single parameter which contains the
  72142. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72143. * src parameter of an <img> to display it
  72144. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72145. * Check your browser for supported MIME types
  72146. * @param samples Texture samples (default: 1)
  72147. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72148. * @param fileName A name for for the downloaded file.
  72149. */
  72150. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  72151. /**
  72152. * Generates an image screenshot from the specified camera.
  72153. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72154. * @param engine The engine to use for rendering
  72155. * @param camera The camera to use for rendering
  72156. * @param size This parameter can be set to a single number or to an object with the
  72157. * following (optional) properties: precision, width, height. If a single number is passed,
  72158. * it will be used for both width and height. If an object is passed, the screenshot size
  72159. * will be derived from the parameters. The precision property is a multiplier allowing
  72160. * rendering at a higher or lower resolution
  72161. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72162. * Check your browser for supported MIME types
  72163. * @param samples Texture samples (default: 1)
  72164. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72165. * @param fileName A name for for the downloaded file.
  72166. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72167. * to the src parameter of an <img> to display it
  72168. */
  72169. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  72170. /**
  72171. * Gets height and width for screenshot size
  72172. * @private
  72173. */
  72174. private static _getScreenshotSize;
  72175. }
  72176. }
  72177. declare module "babylonjs/Misc/dataReader" {
  72178. /**
  72179. * Interface for a data buffer
  72180. */
  72181. export interface IDataBuffer {
  72182. /**
  72183. * Reads bytes from the data buffer.
  72184. * @param byteOffset The byte offset to read
  72185. * @param byteLength The byte length to read
  72186. * @returns A promise that resolves when the bytes are read
  72187. */
  72188. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72189. /**
  72190. * The byte length of the buffer.
  72191. */
  72192. readonly byteLength: number;
  72193. }
  72194. /**
  72195. * Utility class for reading from a data buffer
  72196. */
  72197. export class DataReader {
  72198. /**
  72199. * The data buffer associated with this data reader.
  72200. */
  72201. readonly buffer: IDataBuffer;
  72202. /**
  72203. * The current byte offset from the beginning of the data buffer.
  72204. */
  72205. byteOffset: number;
  72206. private _dataView;
  72207. private _dataByteOffset;
  72208. /**
  72209. * Constructor
  72210. * @param buffer The buffer to read
  72211. */
  72212. constructor(buffer: IDataBuffer);
  72213. /**
  72214. * Loads the given byte length.
  72215. * @param byteLength The byte length to load
  72216. * @returns A promise that resolves when the load is complete
  72217. */
  72218. loadAsync(byteLength: number): Promise<void>;
  72219. /**
  72220. * Read a unsigned 32-bit integer from the currently loaded data range.
  72221. * @returns The 32-bit integer read
  72222. */
  72223. readUint32(): number;
  72224. /**
  72225. * Read a byte array from the currently loaded data range.
  72226. * @param byteLength The byte length to read
  72227. * @returns The byte array read
  72228. */
  72229. readUint8Array(byteLength: number): Uint8Array;
  72230. /**
  72231. * Read a string from the currently loaded data range.
  72232. * @param byteLength The byte length to read
  72233. * @returns The string read
  72234. */
  72235. readString(byteLength: number): string;
  72236. /**
  72237. * Skips the given byte length the currently loaded data range.
  72238. * @param byteLength The byte length to skip
  72239. */
  72240. skipBytes(byteLength: number): void;
  72241. }
  72242. }
  72243. declare module "babylonjs/Misc/index" {
  72244. export * from "babylonjs/Misc/andOrNotEvaluator";
  72245. export * from "babylonjs/Misc/assetsManager";
  72246. export * from "babylonjs/Misc/basis";
  72247. export * from "babylonjs/Misc/dds";
  72248. export * from "babylonjs/Misc/decorators";
  72249. export * from "babylonjs/Misc/deferred";
  72250. export * from "babylonjs/Misc/environmentTextureTools";
  72251. export * from "babylonjs/Misc/meshExploder";
  72252. export * from "babylonjs/Misc/filesInput";
  72253. export * from "babylonjs/Misc/HighDynamicRange/index";
  72254. export * from "babylonjs/Misc/khronosTextureContainer";
  72255. export * from "babylonjs/Misc/observable";
  72256. export * from "babylonjs/Misc/performanceMonitor";
  72257. export * from "babylonjs/Misc/promise";
  72258. export * from "babylonjs/Misc/sceneOptimizer";
  72259. export * from "babylonjs/Misc/sceneSerializer";
  72260. export * from "babylonjs/Misc/smartArray";
  72261. export * from "babylonjs/Misc/stringDictionary";
  72262. export * from "babylonjs/Misc/tags";
  72263. export * from "babylonjs/Misc/textureTools";
  72264. export * from "babylonjs/Misc/tga";
  72265. export * from "babylonjs/Misc/tools";
  72266. export * from "babylonjs/Misc/videoRecorder";
  72267. export * from "babylonjs/Misc/virtualJoystick";
  72268. export * from "babylonjs/Misc/workerPool";
  72269. export * from "babylonjs/Misc/logger";
  72270. export * from "babylonjs/Misc/typeStore";
  72271. export * from "babylonjs/Misc/filesInputStore";
  72272. export * from "babylonjs/Misc/deepCopier";
  72273. export * from "babylonjs/Misc/pivotTools";
  72274. export * from "babylonjs/Misc/precisionDate";
  72275. export * from "babylonjs/Misc/screenshotTools";
  72276. export * from "babylonjs/Misc/typeStore";
  72277. export * from "babylonjs/Misc/webRequest";
  72278. export * from "babylonjs/Misc/iInspectable";
  72279. export * from "babylonjs/Misc/brdfTextureTools";
  72280. export * from "babylonjs/Misc/rgbdTextureTools";
  72281. export * from "babylonjs/Misc/gradients";
  72282. export * from "babylonjs/Misc/perfCounter";
  72283. export * from "babylonjs/Misc/fileRequest";
  72284. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72285. export * from "babylonjs/Misc/retryStrategy";
  72286. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72287. export * from "babylonjs/Misc/canvasGenerator";
  72288. export * from "babylonjs/Misc/fileTools";
  72289. export * from "babylonjs/Misc/stringTools";
  72290. export * from "babylonjs/Misc/dataReader";
  72291. export * from "babylonjs/Misc/minMaxReducer";
  72292. export * from "babylonjs/Misc/depthReducer";
  72293. }
  72294. declare module "babylonjs/index" {
  72295. export * from "babylonjs/abstractScene";
  72296. export * from "babylonjs/Actions/index";
  72297. export * from "babylonjs/Animations/index";
  72298. export * from "babylonjs/assetContainer";
  72299. export * from "babylonjs/Audio/index";
  72300. export * from "babylonjs/Behaviors/index";
  72301. export * from "babylonjs/Bones/index";
  72302. export * from "babylonjs/Cameras/index";
  72303. export * from "babylonjs/Collisions/index";
  72304. export * from "babylonjs/Culling/index";
  72305. export * from "babylonjs/Debug/index";
  72306. export * from "babylonjs/Engines/index";
  72307. export * from "babylonjs/Events/index";
  72308. export * from "babylonjs/Gamepads/index";
  72309. export * from "babylonjs/Gizmos/index";
  72310. export * from "babylonjs/Helpers/index";
  72311. export * from "babylonjs/Instrumentation/index";
  72312. export * from "babylonjs/Layers/index";
  72313. export * from "babylonjs/LensFlares/index";
  72314. export * from "babylonjs/Lights/index";
  72315. export * from "babylonjs/Loading/index";
  72316. export * from "babylonjs/Materials/index";
  72317. export * from "babylonjs/Maths/index";
  72318. export * from "babylonjs/Meshes/index";
  72319. export * from "babylonjs/Morph/index";
  72320. export * from "babylonjs/Navigation/index";
  72321. export * from "babylonjs/node";
  72322. export * from "babylonjs/Offline/index";
  72323. export * from "babylonjs/Particles/index";
  72324. export * from "babylonjs/Physics/index";
  72325. export * from "babylonjs/PostProcesses/index";
  72326. export * from "babylonjs/Probes/index";
  72327. export * from "babylonjs/Rendering/index";
  72328. export * from "babylonjs/scene";
  72329. export * from "babylonjs/sceneComponent";
  72330. export * from "babylonjs/Sprites/index";
  72331. export * from "babylonjs/States/index";
  72332. export * from "babylonjs/Misc/index";
  72333. export * from "babylonjs/types";
  72334. }
  72335. declare module "babylonjs/Animations/pathCursor" {
  72336. import { Vector3 } from "babylonjs/Maths/math.vector";
  72337. import { Path2 } from "babylonjs/Maths/math.path";
  72338. /**
  72339. * A cursor which tracks a point on a path
  72340. */
  72341. export class PathCursor {
  72342. private path;
  72343. /**
  72344. * Stores path cursor callbacks for when an onchange event is triggered
  72345. */
  72346. private _onchange;
  72347. /**
  72348. * The value of the path cursor
  72349. */
  72350. value: number;
  72351. /**
  72352. * The animation array of the path cursor
  72353. */
  72354. animations: Animation[];
  72355. /**
  72356. * Initializes the path cursor
  72357. * @param path The path to track
  72358. */
  72359. constructor(path: Path2);
  72360. /**
  72361. * Gets the cursor point on the path
  72362. * @returns A point on the path cursor at the cursor location
  72363. */
  72364. getPoint(): Vector3;
  72365. /**
  72366. * Moves the cursor ahead by the step amount
  72367. * @param step The amount to move the cursor forward
  72368. * @returns This path cursor
  72369. */
  72370. moveAhead(step?: number): PathCursor;
  72371. /**
  72372. * Moves the cursor behind by the step amount
  72373. * @param step The amount to move the cursor back
  72374. * @returns This path cursor
  72375. */
  72376. moveBack(step?: number): PathCursor;
  72377. /**
  72378. * Moves the cursor by the step amount
  72379. * If the step amount is greater than one, an exception is thrown
  72380. * @param step The amount to move the cursor
  72381. * @returns This path cursor
  72382. */
  72383. move(step: number): PathCursor;
  72384. /**
  72385. * Ensures that the value is limited between zero and one
  72386. * @returns This path cursor
  72387. */
  72388. private ensureLimits;
  72389. /**
  72390. * Runs onchange callbacks on change (used by the animation engine)
  72391. * @returns This path cursor
  72392. */
  72393. private raiseOnChange;
  72394. /**
  72395. * Executes a function on change
  72396. * @param f A path cursor onchange callback
  72397. * @returns This path cursor
  72398. */
  72399. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72400. }
  72401. }
  72402. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  72403. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  72404. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  72405. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  72406. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  72407. }
  72408. declare module "babylonjs/Engines/Processors/Expressions/index" {
  72409. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  72410. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  72411. }
  72412. declare module "babylonjs/Engines/Processors/index" {
  72413. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  72414. export * from "babylonjs/Engines/Processors/Expressions/index";
  72415. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  72416. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  72417. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  72418. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  72419. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  72420. export * from "babylonjs/Engines/Processors/shaderProcessor";
  72421. }
  72422. declare module "babylonjs/Legacy/legacy" {
  72423. import * as Babylon from "babylonjs/index";
  72424. export * from "babylonjs/index";
  72425. }
  72426. declare module "babylonjs/Shaders/blur.fragment" {
  72427. /** @hidden */
  72428. export var blurPixelShader: {
  72429. name: string;
  72430. shader: string;
  72431. };
  72432. }
  72433. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  72434. /** @hidden */
  72435. export var pointCloudVertexDeclaration: {
  72436. name: string;
  72437. shader: string;
  72438. };
  72439. }
  72440. declare module "babylonjs" {
  72441. export * from "babylonjs/Legacy/legacy";
  72442. }
  72443. declare module BABYLON {
  72444. /** Alias type for value that can be null */
  72445. export type Nullable<T> = T | null;
  72446. /**
  72447. * Alias type for number that are floats
  72448. * @ignorenaming
  72449. */
  72450. export type float = number;
  72451. /**
  72452. * Alias type for number that are doubles.
  72453. * @ignorenaming
  72454. */
  72455. export type double = number;
  72456. /**
  72457. * Alias type for number that are integer
  72458. * @ignorenaming
  72459. */
  72460. export type int = number;
  72461. /** Alias type for number array or Float32Array */
  72462. export type FloatArray = number[] | Float32Array;
  72463. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  72464. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  72465. /**
  72466. * Alias for types that can be used by a Buffer or VertexBuffer.
  72467. */
  72468. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  72469. /**
  72470. * Alias type for primitive types
  72471. * @ignorenaming
  72472. */
  72473. type Primitive = undefined | null | boolean | string | number | Function;
  72474. /**
  72475. * Type modifier to make all the properties of an object Readonly
  72476. */
  72477. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  72478. /**
  72479. * Type modifier to make all the properties of an object Readonly recursively
  72480. */
  72481. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  72482. /**
  72483. * Type modifier to make object properties readonly.
  72484. */
  72485. export type DeepImmutableObject<T> = {
  72486. readonly [K in keyof T]: DeepImmutable<T[K]>;
  72487. };
  72488. /** @hidden */
  72489. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  72490. }
  72491. }
  72492. declare module BABYLON {
  72493. /**
  72494. * A class serves as a medium between the observable and its observers
  72495. */
  72496. export class EventState {
  72497. /**
  72498. * Create a new EventState
  72499. * @param mask defines the mask associated with this state
  72500. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72501. * @param target defines the original target of the state
  72502. * @param currentTarget defines the current target of the state
  72503. */
  72504. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  72505. /**
  72506. * Initialize the current event state
  72507. * @param mask defines the mask associated with this state
  72508. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72509. * @param target defines the original target of the state
  72510. * @param currentTarget defines the current target of the state
  72511. * @returns the current event state
  72512. */
  72513. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72514. /**
  72515. * An Observer can set this property to true to prevent subsequent observers of being notified
  72516. */
  72517. skipNextObservers: boolean;
  72518. /**
  72519. * Get the mask value that were used to trigger the event corresponding to this EventState object
  72520. */
  72521. mask: number;
  72522. /**
  72523. * The object that originally notified the event
  72524. */
  72525. target?: any;
  72526. /**
  72527. * The current object in the bubbling phase
  72528. */
  72529. currentTarget?: any;
  72530. /**
  72531. * This will be populated with the return value of the last function that was executed.
  72532. * If it is the first function in the callback chain it will be the event data.
  72533. */
  72534. lastReturnValue?: any;
  72535. }
  72536. /**
  72537. * Represent an Observer registered to a given Observable object.
  72538. */
  72539. export class Observer<T> {
  72540. /**
  72541. * Defines the callback to call when the observer is notified
  72542. */
  72543. callback: (eventData: T, eventState: EventState) => void;
  72544. /**
  72545. * Defines the mask of the observer (used to filter notifications)
  72546. */
  72547. mask: number;
  72548. /**
  72549. * Defines the current scope used to restore the JS context
  72550. */
  72551. scope: any;
  72552. /** @hidden */
  72553. _willBeUnregistered: boolean;
  72554. /**
  72555. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  72556. */
  72557. unregisterOnNextCall: boolean;
  72558. /**
  72559. * Creates a new observer
  72560. * @param callback defines the callback to call when the observer is notified
  72561. * @param mask defines the mask of the observer (used to filter notifications)
  72562. * @param scope defines the current scope used to restore the JS context
  72563. */
  72564. constructor(
  72565. /**
  72566. * Defines the callback to call when the observer is notified
  72567. */
  72568. callback: (eventData: T, eventState: EventState) => void,
  72569. /**
  72570. * Defines the mask of the observer (used to filter notifications)
  72571. */
  72572. mask: number,
  72573. /**
  72574. * Defines the current scope used to restore the JS context
  72575. */
  72576. scope?: any);
  72577. }
  72578. /**
  72579. * Represent a list of observers registered to multiple Observables object.
  72580. */
  72581. export class MultiObserver<T> {
  72582. private _observers;
  72583. private _observables;
  72584. /**
  72585. * Release associated resources
  72586. */
  72587. dispose(): void;
  72588. /**
  72589. * Raise a callback when one of the observable will notify
  72590. * @param observables defines a list of observables to watch
  72591. * @param callback defines the callback to call on notification
  72592. * @param mask defines the mask used to filter notifications
  72593. * @param scope defines the current scope used to restore the JS context
  72594. * @returns the new MultiObserver
  72595. */
  72596. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  72597. }
  72598. /**
  72599. * The Observable class is a simple implementation of the Observable pattern.
  72600. *
  72601. * 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.
  72602. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  72603. * 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).
  72604. * 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.
  72605. */
  72606. export class Observable<T> {
  72607. private _observers;
  72608. private _eventState;
  72609. private _onObserverAdded;
  72610. /**
  72611. * Gets the list of observers
  72612. */
  72613. get observers(): Array<Observer<T>>;
  72614. /**
  72615. * Creates a new observable
  72616. * @param onObserverAdded defines a callback to call when a new observer is added
  72617. */
  72618. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  72619. /**
  72620. * Create a new Observer with the specified callback
  72621. * @param callback the callback that will be executed for that Observer
  72622. * @param mask the mask used to filter observers
  72623. * @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.
  72624. * @param scope optional scope for the callback to be called from
  72625. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  72626. * @returns the new observer created for the callback
  72627. */
  72628. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  72629. /**
  72630. * Create a new Observer with the specified callback and unregisters after the next notification
  72631. * @param callback the callback that will be executed for that Observer
  72632. * @returns the new observer created for the callback
  72633. */
  72634. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  72635. /**
  72636. * Remove an Observer from the Observable object
  72637. * @param observer the instance of the Observer to remove
  72638. * @returns false if it doesn't belong to this Observable
  72639. */
  72640. remove(observer: Nullable<Observer<T>>): boolean;
  72641. /**
  72642. * Remove a callback from the Observable object
  72643. * @param callback the callback to remove
  72644. * @param scope optional scope. If used only the callbacks with this scope will be removed
  72645. * @returns false if it doesn't belong to this Observable
  72646. */
  72647. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  72648. private _deferUnregister;
  72649. private _remove;
  72650. /**
  72651. * Moves the observable to the top of the observer list making it get called first when notified
  72652. * @param observer the observer to move
  72653. */
  72654. makeObserverTopPriority(observer: Observer<T>): void;
  72655. /**
  72656. * Moves the observable to the bottom of the observer list making it get called last when notified
  72657. * @param observer the observer to move
  72658. */
  72659. makeObserverBottomPriority(observer: Observer<T>): void;
  72660. /**
  72661. * Notify all Observers by calling their respective callback with the given data
  72662. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  72663. * @param eventData defines the data to send to all observers
  72664. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  72665. * @param target defines the original target of the state
  72666. * @param currentTarget defines the current target of the state
  72667. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  72668. */
  72669. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  72670. /**
  72671. * Calling this will execute each callback, expecting it to be a promise or return a value.
  72672. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  72673. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  72674. * and it is crucial that all callbacks will be executed.
  72675. * The order of the callbacks is kept, callbacks are not executed parallel.
  72676. *
  72677. * @param eventData The data to be sent to each callback
  72678. * @param mask is used to filter observers defaults to -1
  72679. * @param target defines the callback target (see EventState)
  72680. * @param currentTarget defines he current object in the bubbling phase
  72681. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  72682. */
  72683. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  72684. /**
  72685. * Notify a specific observer
  72686. * @param observer defines the observer to notify
  72687. * @param eventData defines the data to be sent to each callback
  72688. * @param mask is used to filter observers defaults to -1
  72689. */
  72690. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  72691. /**
  72692. * Gets a boolean indicating if the observable has at least one observer
  72693. * @returns true is the Observable has at least one Observer registered
  72694. */
  72695. hasObservers(): boolean;
  72696. /**
  72697. * Clear the list of observers
  72698. */
  72699. clear(): void;
  72700. /**
  72701. * Clone the current observable
  72702. * @returns a new observable
  72703. */
  72704. clone(): Observable<T>;
  72705. /**
  72706. * Does this observable handles observer registered with a given mask
  72707. * @param mask defines the mask to be tested
  72708. * @return whether or not one observer registered with the given mask is handeled
  72709. **/
  72710. hasSpecificMask(mask?: number): boolean;
  72711. }
  72712. }
  72713. declare module BABYLON {
  72714. /**
  72715. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  72716. * Babylon.js
  72717. */
  72718. export class DomManagement {
  72719. /**
  72720. * Checks if the window object exists
  72721. * @returns true if the window object exists
  72722. */
  72723. static IsWindowObjectExist(): boolean;
  72724. /**
  72725. * Checks if the navigator object exists
  72726. * @returns true if the navigator object exists
  72727. */
  72728. static IsNavigatorAvailable(): boolean;
  72729. /**
  72730. * Extracts text content from a DOM element hierarchy
  72731. * @param element defines the root element
  72732. * @returns a string
  72733. */
  72734. static GetDOMTextContent(element: HTMLElement): string;
  72735. }
  72736. }
  72737. declare module BABYLON {
  72738. /**
  72739. * Logger used througouht the application to allow configuration of
  72740. * the log level required for the messages.
  72741. */
  72742. export class Logger {
  72743. /**
  72744. * No log
  72745. */
  72746. static readonly NoneLogLevel: number;
  72747. /**
  72748. * Only message logs
  72749. */
  72750. static readonly MessageLogLevel: number;
  72751. /**
  72752. * Only warning logs
  72753. */
  72754. static readonly WarningLogLevel: number;
  72755. /**
  72756. * Only error logs
  72757. */
  72758. static readonly ErrorLogLevel: number;
  72759. /**
  72760. * All logs
  72761. */
  72762. static readonly AllLogLevel: number;
  72763. private static _LogCache;
  72764. /**
  72765. * Gets a value indicating the number of loading errors
  72766. * @ignorenaming
  72767. */
  72768. static errorsCount: number;
  72769. /**
  72770. * Callback called when a new log is added
  72771. */
  72772. static OnNewCacheEntry: (entry: string) => void;
  72773. private static _AddLogEntry;
  72774. private static _FormatMessage;
  72775. private static _LogDisabled;
  72776. private static _LogEnabled;
  72777. private static _WarnDisabled;
  72778. private static _WarnEnabled;
  72779. private static _ErrorDisabled;
  72780. private static _ErrorEnabled;
  72781. /**
  72782. * Log a message to the console
  72783. */
  72784. static Log: (message: string) => void;
  72785. /**
  72786. * Write a warning message to the console
  72787. */
  72788. static Warn: (message: string) => void;
  72789. /**
  72790. * Write an error message to the console
  72791. */
  72792. static Error: (message: string) => void;
  72793. /**
  72794. * Gets current log cache (list of logs)
  72795. */
  72796. static get LogCache(): string;
  72797. /**
  72798. * Clears the log cache
  72799. */
  72800. static ClearLogCache(): void;
  72801. /**
  72802. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  72803. */
  72804. static set LogLevels(level: number);
  72805. }
  72806. }
  72807. declare module BABYLON {
  72808. /** @hidden */
  72809. export class _TypeStore {
  72810. /** @hidden */
  72811. static RegisteredTypes: {
  72812. [key: string]: Object;
  72813. };
  72814. /** @hidden */
  72815. static GetClass(fqdn: string): any;
  72816. }
  72817. }
  72818. declare module BABYLON {
  72819. /**
  72820. * Helper to manipulate strings
  72821. */
  72822. export class StringTools {
  72823. /**
  72824. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  72825. * @param str Source string
  72826. * @param suffix Suffix to search for in the source string
  72827. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  72828. */
  72829. static EndsWith(str: string, suffix: string): boolean;
  72830. /**
  72831. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  72832. * @param str Source string
  72833. * @param suffix Suffix to search for in the source string
  72834. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  72835. */
  72836. static StartsWith(str: string, suffix: string): boolean;
  72837. /**
  72838. * Decodes a buffer into a string
  72839. * @param buffer The buffer to decode
  72840. * @returns The decoded string
  72841. */
  72842. static Decode(buffer: Uint8Array | Uint16Array): string;
  72843. /**
  72844. * Encode a buffer to a base64 string
  72845. * @param buffer defines the buffer to encode
  72846. * @returns the encoded string
  72847. */
  72848. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  72849. }
  72850. }
  72851. declare module BABYLON {
  72852. /**
  72853. * Class containing a set of static utilities functions for deep copy.
  72854. */
  72855. export class DeepCopier {
  72856. /**
  72857. * Tries to copy an object by duplicating every property
  72858. * @param source defines the source object
  72859. * @param destination defines the target object
  72860. * @param doNotCopyList defines a list of properties to avoid
  72861. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  72862. */
  72863. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  72864. }
  72865. }
  72866. declare module BABYLON {
  72867. /**
  72868. * Class containing a set of static utilities functions for precision date
  72869. */
  72870. export class PrecisionDate {
  72871. /**
  72872. * Gets either window.performance.now() if supported or Date.now() else
  72873. */
  72874. static get Now(): number;
  72875. }
  72876. }
  72877. declare module BABYLON {
  72878. /** @hidden */
  72879. export class _DevTools {
  72880. static WarnImport(name: string): string;
  72881. }
  72882. }
  72883. declare module BABYLON {
  72884. /**
  72885. * Interface used to define the mechanism to get data from the network
  72886. */
  72887. export interface IWebRequest {
  72888. /**
  72889. * Returns client's response url
  72890. */
  72891. responseURL: string;
  72892. /**
  72893. * Returns client's status
  72894. */
  72895. status: number;
  72896. /**
  72897. * Returns client's status as a text
  72898. */
  72899. statusText: string;
  72900. }
  72901. }
  72902. declare module BABYLON {
  72903. /**
  72904. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  72905. */
  72906. export class WebRequest implements IWebRequest {
  72907. private _xhr;
  72908. /**
  72909. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  72910. * i.e. when loading files, where the server/service expects an Authorization header
  72911. */
  72912. static CustomRequestHeaders: {
  72913. [key: string]: string;
  72914. };
  72915. /**
  72916. * Add callback functions in this array to update all the requests before they get sent to the network
  72917. */
  72918. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  72919. private _injectCustomRequestHeaders;
  72920. /**
  72921. * Gets or sets a function to be called when loading progress changes
  72922. */
  72923. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  72924. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  72925. /**
  72926. * Returns client's state
  72927. */
  72928. get readyState(): number;
  72929. /**
  72930. * Returns client's status
  72931. */
  72932. get status(): number;
  72933. /**
  72934. * Returns client's status as a text
  72935. */
  72936. get statusText(): string;
  72937. /**
  72938. * Returns client's response
  72939. */
  72940. get response(): any;
  72941. /**
  72942. * Returns client's response url
  72943. */
  72944. get responseURL(): string;
  72945. /**
  72946. * Returns client's response as text
  72947. */
  72948. get responseText(): string;
  72949. /**
  72950. * Gets or sets the expected response type
  72951. */
  72952. get responseType(): XMLHttpRequestResponseType;
  72953. set responseType(value: XMLHttpRequestResponseType);
  72954. /** @hidden */
  72955. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  72956. /** @hidden */
  72957. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  72958. /**
  72959. * Cancels any network activity
  72960. */
  72961. abort(): void;
  72962. /**
  72963. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  72964. * @param body defines an optional request body
  72965. */
  72966. send(body?: Document | BodyInit | null): void;
  72967. /**
  72968. * Sets the request method, request URL
  72969. * @param method defines the method to use (GET, POST, etc..)
  72970. * @param url defines the url to connect with
  72971. */
  72972. open(method: string, url: string): void;
  72973. /**
  72974. * Sets the value of a request header.
  72975. * @param name The name of the header whose value is to be set
  72976. * @param value The value to set as the body of the header
  72977. */
  72978. setRequestHeader(name: string, value: string): void;
  72979. /**
  72980. * Get the string containing the text of a particular header's value.
  72981. * @param name The name of the header
  72982. * @returns The string containing the text of the given header name
  72983. */
  72984. getResponseHeader(name: string): Nullable<string>;
  72985. }
  72986. }
  72987. declare module BABYLON {
  72988. /**
  72989. * File request interface
  72990. */
  72991. export interface IFileRequest {
  72992. /**
  72993. * Raised when the request is complete (success or error).
  72994. */
  72995. onCompleteObservable: Observable<IFileRequest>;
  72996. /**
  72997. * Aborts the request for a file.
  72998. */
  72999. abort: () => void;
  73000. }
  73001. }
  73002. declare module BABYLON {
  73003. /**
  73004. * Define options used to create a render target texture
  73005. */
  73006. export class RenderTargetCreationOptions {
  73007. /**
  73008. * Specifies is mipmaps must be generated
  73009. */
  73010. generateMipMaps?: boolean;
  73011. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73012. generateDepthBuffer?: boolean;
  73013. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73014. generateStencilBuffer?: boolean;
  73015. /** Defines texture type (int by default) */
  73016. type?: number;
  73017. /** Defines sampling mode (trilinear by default) */
  73018. samplingMode?: number;
  73019. /** Defines format (RGBA by default) */
  73020. format?: number;
  73021. }
  73022. }
  73023. declare module BABYLON {
  73024. /**
  73025. * @hidden
  73026. **/
  73027. export class _TimeToken {
  73028. _startTimeQuery: Nullable<WebGLQuery>;
  73029. _endTimeQuery: Nullable<WebGLQuery>;
  73030. _timeElapsedQuery: Nullable<WebGLQuery>;
  73031. _timeElapsedQueryEnded: boolean;
  73032. }
  73033. }
  73034. declare module BABYLON {
  73035. /** Defines the cross module used constants to avoid circular dependncies */
  73036. export class Constants {
  73037. /** Defines that alpha blending is disabled */
  73038. static readonly ALPHA_DISABLE: number;
  73039. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73040. static readonly ALPHA_ADD: number;
  73041. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73042. static readonly ALPHA_COMBINE: number;
  73043. /** Defines that alpha blending is DEST - SRC * DEST */
  73044. static readonly ALPHA_SUBTRACT: number;
  73045. /** Defines that alpha blending is SRC * DEST */
  73046. static readonly ALPHA_MULTIPLY: number;
  73047. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73048. static readonly ALPHA_MAXIMIZED: number;
  73049. /** Defines that alpha blending is SRC + DEST */
  73050. static readonly ALPHA_ONEONE: number;
  73051. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73052. static readonly ALPHA_PREMULTIPLIED: number;
  73053. /**
  73054. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73055. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73056. */
  73057. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73058. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73059. static readonly ALPHA_INTERPOLATE: number;
  73060. /**
  73061. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73062. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73063. */
  73064. static readonly ALPHA_SCREENMODE: number;
  73065. /**
  73066. * Defines that alpha blending is SRC + DST
  73067. * Alpha will be set to SRC ALPHA + DST ALPHA
  73068. */
  73069. static readonly ALPHA_ONEONE_ONEONE: number;
  73070. /**
  73071. * Defines that alpha blending is SRC * DST ALPHA + DST
  73072. * Alpha will be set to 0
  73073. */
  73074. static readonly ALPHA_ALPHATOCOLOR: number;
  73075. /**
  73076. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73077. */
  73078. static readonly ALPHA_REVERSEONEMINUS: number;
  73079. /**
  73080. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73081. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73082. */
  73083. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73084. /**
  73085. * Defines that alpha blending is SRC + DST
  73086. * Alpha will be set to SRC ALPHA
  73087. */
  73088. static readonly ALPHA_ONEONE_ONEZERO: number;
  73089. /**
  73090. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73091. * Alpha will be set to DST ALPHA
  73092. */
  73093. static readonly ALPHA_EXCLUSION: number;
  73094. /** Defines that alpha blending equation a SUM */
  73095. static readonly ALPHA_EQUATION_ADD: number;
  73096. /** Defines that alpha blending equation a SUBSTRACTION */
  73097. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73098. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73099. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73100. /** Defines that alpha blending equation a MAX operation */
  73101. static readonly ALPHA_EQUATION_MAX: number;
  73102. /** Defines that alpha blending equation a MIN operation */
  73103. static readonly ALPHA_EQUATION_MIN: number;
  73104. /**
  73105. * Defines that alpha blending equation a DARKEN operation:
  73106. * It takes the min of the src and sums the alpha channels.
  73107. */
  73108. static readonly ALPHA_EQUATION_DARKEN: number;
  73109. /** Defines that the ressource is not delayed*/
  73110. static readonly DELAYLOADSTATE_NONE: number;
  73111. /** Defines that the ressource was successfully delay loaded */
  73112. static readonly DELAYLOADSTATE_LOADED: number;
  73113. /** Defines that the ressource is currently delay loading */
  73114. static readonly DELAYLOADSTATE_LOADING: number;
  73115. /** Defines that the ressource is delayed and has not started loading */
  73116. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73117. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73118. static readonly NEVER: number;
  73119. /** 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 */
  73120. static readonly ALWAYS: number;
  73121. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73122. static readonly LESS: number;
  73123. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73124. static readonly EQUAL: number;
  73125. /** 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 */
  73126. static readonly LEQUAL: number;
  73127. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73128. static readonly GREATER: number;
  73129. /** 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 */
  73130. static readonly GEQUAL: number;
  73131. /** 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 */
  73132. static readonly NOTEQUAL: number;
  73133. /** Passed to stencilOperation to specify that stencil value must be kept */
  73134. static readonly KEEP: number;
  73135. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73136. static readonly REPLACE: number;
  73137. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73138. static readonly INCR: number;
  73139. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73140. static readonly DECR: number;
  73141. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73142. static readonly INVERT: number;
  73143. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73144. static readonly INCR_WRAP: number;
  73145. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73146. static readonly DECR_WRAP: number;
  73147. /** Texture is not repeating outside of 0..1 UVs */
  73148. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73149. /** Texture is repeating outside of 0..1 UVs */
  73150. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73151. /** Texture is repeating and mirrored */
  73152. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73153. /** ALPHA */
  73154. static readonly TEXTUREFORMAT_ALPHA: number;
  73155. /** LUMINANCE */
  73156. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73157. /** LUMINANCE_ALPHA */
  73158. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73159. /** RGB */
  73160. static readonly TEXTUREFORMAT_RGB: number;
  73161. /** RGBA */
  73162. static readonly TEXTUREFORMAT_RGBA: number;
  73163. /** RED */
  73164. static readonly TEXTUREFORMAT_RED: number;
  73165. /** RED (2nd reference) */
  73166. static readonly TEXTUREFORMAT_R: number;
  73167. /** RG */
  73168. static readonly TEXTUREFORMAT_RG: number;
  73169. /** RED_INTEGER */
  73170. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73171. /** RED_INTEGER (2nd reference) */
  73172. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73173. /** RG_INTEGER */
  73174. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73175. /** RGB_INTEGER */
  73176. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73177. /** RGBA_INTEGER */
  73178. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73179. /** UNSIGNED_BYTE */
  73180. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73181. /** UNSIGNED_BYTE (2nd reference) */
  73182. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73183. /** FLOAT */
  73184. static readonly TEXTURETYPE_FLOAT: number;
  73185. /** HALF_FLOAT */
  73186. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73187. /** BYTE */
  73188. static readonly TEXTURETYPE_BYTE: number;
  73189. /** SHORT */
  73190. static readonly TEXTURETYPE_SHORT: number;
  73191. /** UNSIGNED_SHORT */
  73192. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73193. /** INT */
  73194. static readonly TEXTURETYPE_INT: number;
  73195. /** UNSIGNED_INT */
  73196. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73197. /** UNSIGNED_SHORT_4_4_4_4 */
  73198. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73199. /** UNSIGNED_SHORT_5_5_5_1 */
  73200. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73201. /** UNSIGNED_SHORT_5_6_5 */
  73202. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73203. /** UNSIGNED_INT_2_10_10_10_REV */
  73204. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73205. /** UNSIGNED_INT_24_8 */
  73206. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73207. /** UNSIGNED_INT_10F_11F_11F_REV */
  73208. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73209. /** UNSIGNED_INT_5_9_9_9_REV */
  73210. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73211. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73212. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73213. /** nearest is mag = nearest and min = nearest and no mip */
  73214. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73215. /** mag = nearest and min = nearest and mip = none */
  73216. static readonly TEXTURE_NEAREST_NEAREST: number;
  73217. /** Bilinear is mag = linear and min = linear and no mip */
  73218. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73219. /** mag = linear and min = linear and mip = none */
  73220. static readonly TEXTURE_LINEAR_LINEAR: number;
  73221. /** Trilinear is mag = linear and min = linear and mip = linear */
  73222. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73223. /** Trilinear is mag = linear and min = linear and mip = linear */
  73224. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73225. /** mag = nearest and min = nearest and mip = nearest */
  73226. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  73227. /** mag = nearest and min = linear and mip = nearest */
  73228. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  73229. /** mag = nearest and min = linear and mip = linear */
  73230. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  73231. /** mag = nearest and min = linear and mip = none */
  73232. static readonly TEXTURE_NEAREST_LINEAR: number;
  73233. /** nearest is mag = nearest and min = nearest and mip = linear */
  73234. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  73235. /** mag = linear and min = nearest and mip = nearest */
  73236. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  73237. /** mag = linear and min = nearest and mip = linear */
  73238. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  73239. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73240. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  73241. /** mag = linear and min = nearest and mip = none */
  73242. static readonly TEXTURE_LINEAR_NEAREST: number;
  73243. /** Explicit coordinates mode */
  73244. static readonly TEXTURE_EXPLICIT_MODE: number;
  73245. /** Spherical coordinates mode */
  73246. static readonly TEXTURE_SPHERICAL_MODE: number;
  73247. /** Planar coordinates mode */
  73248. static readonly TEXTURE_PLANAR_MODE: number;
  73249. /** Cubic coordinates mode */
  73250. static readonly TEXTURE_CUBIC_MODE: number;
  73251. /** Projection coordinates mode */
  73252. static readonly TEXTURE_PROJECTION_MODE: number;
  73253. /** Skybox coordinates mode */
  73254. static readonly TEXTURE_SKYBOX_MODE: number;
  73255. /** Inverse Cubic coordinates mode */
  73256. static readonly TEXTURE_INVCUBIC_MODE: number;
  73257. /** Equirectangular coordinates mode */
  73258. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  73259. /** Equirectangular Fixed coordinates mode */
  73260. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  73261. /** Equirectangular Fixed Mirrored coordinates mode */
  73262. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73263. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  73264. static readonly SCALEMODE_FLOOR: number;
  73265. /** Defines that texture rescaling will look for the nearest power of 2 size */
  73266. static readonly SCALEMODE_NEAREST: number;
  73267. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  73268. static readonly SCALEMODE_CEILING: number;
  73269. /**
  73270. * The dirty texture flag value
  73271. */
  73272. static readonly MATERIAL_TextureDirtyFlag: number;
  73273. /**
  73274. * The dirty light flag value
  73275. */
  73276. static readonly MATERIAL_LightDirtyFlag: number;
  73277. /**
  73278. * The dirty fresnel flag value
  73279. */
  73280. static readonly MATERIAL_FresnelDirtyFlag: number;
  73281. /**
  73282. * The dirty attribute flag value
  73283. */
  73284. static readonly MATERIAL_AttributesDirtyFlag: number;
  73285. /**
  73286. * The dirty misc flag value
  73287. */
  73288. static readonly MATERIAL_MiscDirtyFlag: number;
  73289. /**
  73290. * The all dirty flag value
  73291. */
  73292. static readonly MATERIAL_AllDirtyFlag: number;
  73293. /**
  73294. * Returns the triangle fill mode
  73295. */
  73296. static readonly MATERIAL_TriangleFillMode: number;
  73297. /**
  73298. * Returns the wireframe mode
  73299. */
  73300. static readonly MATERIAL_WireFrameFillMode: number;
  73301. /**
  73302. * Returns the point fill mode
  73303. */
  73304. static readonly MATERIAL_PointFillMode: number;
  73305. /**
  73306. * Returns the point list draw mode
  73307. */
  73308. static readonly MATERIAL_PointListDrawMode: number;
  73309. /**
  73310. * Returns the line list draw mode
  73311. */
  73312. static readonly MATERIAL_LineListDrawMode: number;
  73313. /**
  73314. * Returns the line loop draw mode
  73315. */
  73316. static readonly MATERIAL_LineLoopDrawMode: number;
  73317. /**
  73318. * Returns the line strip draw mode
  73319. */
  73320. static readonly MATERIAL_LineStripDrawMode: number;
  73321. /**
  73322. * Returns the triangle strip draw mode
  73323. */
  73324. static readonly MATERIAL_TriangleStripDrawMode: number;
  73325. /**
  73326. * Returns the triangle fan draw mode
  73327. */
  73328. static readonly MATERIAL_TriangleFanDrawMode: number;
  73329. /**
  73330. * Stores the clock-wise side orientation
  73331. */
  73332. static readonly MATERIAL_ClockWiseSideOrientation: number;
  73333. /**
  73334. * Stores the counter clock-wise side orientation
  73335. */
  73336. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  73337. /**
  73338. * Nothing
  73339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73340. */
  73341. static readonly ACTION_NothingTrigger: number;
  73342. /**
  73343. * On pick
  73344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73345. */
  73346. static readonly ACTION_OnPickTrigger: number;
  73347. /**
  73348. * On left pick
  73349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73350. */
  73351. static readonly ACTION_OnLeftPickTrigger: number;
  73352. /**
  73353. * On right pick
  73354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73355. */
  73356. static readonly ACTION_OnRightPickTrigger: number;
  73357. /**
  73358. * On center pick
  73359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73360. */
  73361. static readonly ACTION_OnCenterPickTrigger: number;
  73362. /**
  73363. * On pick down
  73364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73365. */
  73366. static readonly ACTION_OnPickDownTrigger: number;
  73367. /**
  73368. * On double pick
  73369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73370. */
  73371. static readonly ACTION_OnDoublePickTrigger: number;
  73372. /**
  73373. * On pick up
  73374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73375. */
  73376. static readonly ACTION_OnPickUpTrigger: number;
  73377. /**
  73378. * On pick out.
  73379. * This trigger will only be raised if you also declared a OnPickDown
  73380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73381. */
  73382. static readonly ACTION_OnPickOutTrigger: number;
  73383. /**
  73384. * On long press
  73385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73386. */
  73387. static readonly ACTION_OnLongPressTrigger: number;
  73388. /**
  73389. * On pointer over
  73390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73391. */
  73392. static readonly ACTION_OnPointerOverTrigger: number;
  73393. /**
  73394. * On pointer out
  73395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73396. */
  73397. static readonly ACTION_OnPointerOutTrigger: number;
  73398. /**
  73399. * On every frame
  73400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73401. */
  73402. static readonly ACTION_OnEveryFrameTrigger: number;
  73403. /**
  73404. * On intersection enter
  73405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73406. */
  73407. static readonly ACTION_OnIntersectionEnterTrigger: number;
  73408. /**
  73409. * On intersection exit
  73410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73411. */
  73412. static readonly ACTION_OnIntersectionExitTrigger: number;
  73413. /**
  73414. * On key down
  73415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73416. */
  73417. static readonly ACTION_OnKeyDownTrigger: number;
  73418. /**
  73419. * On key up
  73420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73421. */
  73422. static readonly ACTION_OnKeyUpTrigger: number;
  73423. /**
  73424. * Billboard mode will only apply to Y axis
  73425. */
  73426. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  73427. /**
  73428. * Billboard mode will apply to all axes
  73429. */
  73430. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  73431. /**
  73432. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73433. */
  73434. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  73435. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  73436. * Test order :
  73437. * Is the bounding sphere outside the frustum ?
  73438. * If not, are the bounding box vertices outside the frustum ?
  73439. * It not, then the cullable object is in the frustum.
  73440. */
  73441. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  73442. /** Culling strategy : Bounding Sphere Only.
  73443. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  73444. * It's also less accurate than the standard because some not visible objects can still be selected.
  73445. * Test : is the bounding sphere outside the frustum ?
  73446. * If not, then the cullable object is in the frustum.
  73447. */
  73448. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  73449. /** Culling strategy : Optimistic Inclusion.
  73450. * This in an inclusion test first, then the standard exclusion test.
  73451. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  73452. * 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.
  73453. * Anyway, it's as accurate as the standard strategy.
  73454. * Test :
  73455. * Is the cullable object bounding sphere center in the frustum ?
  73456. * If not, apply the default culling strategy.
  73457. */
  73458. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  73459. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  73460. * This in an inclusion test first, then the bounding sphere only exclusion test.
  73461. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  73462. * 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.
  73463. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  73464. * Test :
  73465. * Is the cullable object bounding sphere center in the frustum ?
  73466. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  73467. */
  73468. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  73469. /**
  73470. * No logging while loading
  73471. */
  73472. static readonly SCENELOADER_NO_LOGGING: number;
  73473. /**
  73474. * Minimal logging while loading
  73475. */
  73476. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  73477. /**
  73478. * Summary logging while loading
  73479. */
  73480. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  73481. /**
  73482. * Detailled logging while loading
  73483. */
  73484. static readonly SCENELOADER_DETAILED_LOGGING: number;
  73485. }
  73486. }
  73487. declare module BABYLON {
  73488. /**
  73489. * This represents the required contract to create a new type of texture loader.
  73490. */
  73491. export interface IInternalTextureLoader {
  73492. /**
  73493. * Defines wether the loader supports cascade loading the different faces.
  73494. */
  73495. supportCascades: boolean;
  73496. /**
  73497. * This returns if the loader support the current file information.
  73498. * @param extension defines the file extension of the file being loaded
  73499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73500. * @param fallback defines the fallback internal texture if any
  73501. * @param isBase64 defines whether the texture is encoded as a base64
  73502. * @param isBuffer defines whether the texture data are stored as a buffer
  73503. * @returns true if the loader can load the specified file
  73504. */
  73505. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73506. /**
  73507. * Transform the url before loading if required.
  73508. * @param rootUrl the url of the texture
  73509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73510. * @returns the transformed texture
  73511. */
  73512. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73513. /**
  73514. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73515. * @param rootUrl the url of the texture
  73516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73517. * @returns the fallback texture
  73518. */
  73519. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73520. /**
  73521. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73522. * @param data contains the texture data
  73523. * @param texture defines the BabylonJS internal texture
  73524. * @param createPolynomials will be true if polynomials have been requested
  73525. * @param onLoad defines the callback to trigger once the texture is ready
  73526. * @param onError defines the callback to trigger in case of error
  73527. */
  73528. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73529. /**
  73530. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73531. * @param data contains the texture data
  73532. * @param texture defines the BabylonJS internal texture
  73533. * @param callback defines the method to call once ready to upload
  73534. */
  73535. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73536. }
  73537. }
  73538. declare module BABYLON {
  73539. /**
  73540. * Class used to store and describe the pipeline context associated with an effect
  73541. */
  73542. export interface IPipelineContext {
  73543. /**
  73544. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  73545. */
  73546. isAsync: boolean;
  73547. /**
  73548. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  73549. */
  73550. isReady: boolean;
  73551. /** @hidden */
  73552. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  73553. }
  73554. }
  73555. declare module BABYLON {
  73556. /**
  73557. * Class used to store gfx data (like WebGLBuffer)
  73558. */
  73559. export class DataBuffer {
  73560. /**
  73561. * Gets or sets the number of objects referencing this buffer
  73562. */
  73563. references: number;
  73564. /** Gets or sets the size of the underlying buffer */
  73565. capacity: number;
  73566. /**
  73567. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  73568. */
  73569. is32Bits: boolean;
  73570. /**
  73571. * Gets the underlying buffer
  73572. */
  73573. get underlyingResource(): any;
  73574. }
  73575. }
  73576. declare module BABYLON {
  73577. /** @hidden */
  73578. export interface IShaderProcessor {
  73579. attributeProcessor?: (attribute: string) => string;
  73580. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  73581. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  73582. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  73583. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  73584. lineProcessor?: (line: string, isFragment: boolean) => string;
  73585. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73586. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73587. }
  73588. }
  73589. declare module BABYLON {
  73590. /** @hidden */
  73591. export interface ProcessingOptions {
  73592. defines: string[];
  73593. indexParameters: any;
  73594. isFragment: boolean;
  73595. shouldUseHighPrecisionShader: boolean;
  73596. supportsUniformBuffers: boolean;
  73597. shadersRepository: string;
  73598. includesShadersStore: {
  73599. [key: string]: string;
  73600. };
  73601. processor?: IShaderProcessor;
  73602. version: string;
  73603. platformName: string;
  73604. lookForClosingBracketForUniformBuffer?: boolean;
  73605. }
  73606. }
  73607. declare module BABYLON {
  73608. /** @hidden */
  73609. export class ShaderCodeNode {
  73610. line: string;
  73611. children: ShaderCodeNode[];
  73612. additionalDefineKey?: string;
  73613. additionalDefineValue?: string;
  73614. isValid(preprocessors: {
  73615. [key: string]: string;
  73616. }): boolean;
  73617. process(preprocessors: {
  73618. [key: string]: string;
  73619. }, options: ProcessingOptions): string;
  73620. }
  73621. }
  73622. declare module BABYLON {
  73623. /** @hidden */
  73624. export class ShaderCodeCursor {
  73625. private _lines;
  73626. lineIndex: number;
  73627. get currentLine(): string;
  73628. get canRead(): boolean;
  73629. set lines(value: string[]);
  73630. }
  73631. }
  73632. declare module BABYLON {
  73633. /** @hidden */
  73634. export class ShaderCodeConditionNode extends ShaderCodeNode {
  73635. process(preprocessors: {
  73636. [key: string]: string;
  73637. }, options: ProcessingOptions): string;
  73638. }
  73639. }
  73640. declare module BABYLON {
  73641. /** @hidden */
  73642. export class ShaderDefineExpression {
  73643. isTrue(preprocessors: {
  73644. [key: string]: string;
  73645. }): boolean;
  73646. }
  73647. }
  73648. declare module BABYLON {
  73649. /** @hidden */
  73650. export class ShaderCodeTestNode extends ShaderCodeNode {
  73651. testExpression: ShaderDefineExpression;
  73652. isValid(preprocessors: {
  73653. [key: string]: string;
  73654. }): boolean;
  73655. }
  73656. }
  73657. declare module BABYLON {
  73658. /** @hidden */
  73659. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  73660. define: string;
  73661. not: boolean;
  73662. constructor(define: string, not?: boolean);
  73663. isTrue(preprocessors: {
  73664. [key: string]: string;
  73665. }): boolean;
  73666. }
  73667. }
  73668. declare module BABYLON {
  73669. /** @hidden */
  73670. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  73671. leftOperand: ShaderDefineExpression;
  73672. rightOperand: ShaderDefineExpression;
  73673. isTrue(preprocessors: {
  73674. [key: string]: string;
  73675. }): boolean;
  73676. }
  73677. }
  73678. declare module BABYLON {
  73679. /** @hidden */
  73680. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  73681. leftOperand: ShaderDefineExpression;
  73682. rightOperand: ShaderDefineExpression;
  73683. isTrue(preprocessors: {
  73684. [key: string]: string;
  73685. }): boolean;
  73686. }
  73687. }
  73688. declare module BABYLON {
  73689. /** @hidden */
  73690. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  73691. define: string;
  73692. operand: string;
  73693. testValue: string;
  73694. constructor(define: string, operand: string, testValue: string);
  73695. isTrue(preprocessors: {
  73696. [key: string]: string;
  73697. }): boolean;
  73698. }
  73699. }
  73700. declare module BABYLON {
  73701. /**
  73702. * Class used to enable access to offline support
  73703. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  73704. */
  73705. export interface IOfflineProvider {
  73706. /**
  73707. * Gets a boolean indicating if scene must be saved in the database
  73708. */
  73709. enableSceneOffline: boolean;
  73710. /**
  73711. * Gets a boolean indicating if textures must be saved in the database
  73712. */
  73713. enableTexturesOffline: boolean;
  73714. /**
  73715. * Open the offline support and make it available
  73716. * @param successCallback defines the callback to call on success
  73717. * @param errorCallback defines the callback to call on error
  73718. */
  73719. open(successCallback: () => void, errorCallback: () => void): void;
  73720. /**
  73721. * Loads an image from the offline support
  73722. * @param url defines the url to load from
  73723. * @param image defines the target DOM image
  73724. */
  73725. loadImage(url: string, image: HTMLImageElement): void;
  73726. /**
  73727. * Loads a file from offline support
  73728. * @param url defines the URL to load from
  73729. * @param sceneLoaded defines a callback to call on success
  73730. * @param progressCallBack defines a callback to call when progress changed
  73731. * @param errorCallback defines a callback to call on error
  73732. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  73733. */
  73734. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  73735. }
  73736. }
  73737. declare module BABYLON {
  73738. /**
  73739. * Class used to help managing file picking and drag'n'drop
  73740. * File Storage
  73741. */
  73742. export class FilesInputStore {
  73743. /**
  73744. * List of files ready to be loaded
  73745. */
  73746. static FilesToLoad: {
  73747. [key: string]: File;
  73748. };
  73749. }
  73750. }
  73751. declare module BABYLON {
  73752. /**
  73753. * Class used to define a retry strategy when error happens while loading assets
  73754. */
  73755. export class RetryStrategy {
  73756. /**
  73757. * Function used to defines an exponential back off strategy
  73758. * @param maxRetries defines the maximum number of retries (3 by default)
  73759. * @param baseInterval defines the interval between retries
  73760. * @returns the strategy function to use
  73761. */
  73762. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  73763. }
  73764. }
  73765. declare module BABYLON {
  73766. /**
  73767. * @ignore
  73768. * Application error to support additional information when loading a file
  73769. */
  73770. export abstract class BaseError extends Error {
  73771. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  73772. }
  73773. }
  73774. declare module BABYLON {
  73775. /** @ignore */
  73776. export class LoadFileError extends BaseError {
  73777. request?: WebRequest;
  73778. file?: File;
  73779. /**
  73780. * Creates a new LoadFileError
  73781. * @param message defines the message of the error
  73782. * @param request defines the optional web request
  73783. * @param file defines the optional file
  73784. */
  73785. constructor(message: string, object?: WebRequest | File);
  73786. }
  73787. /** @ignore */
  73788. export class RequestFileError extends BaseError {
  73789. request: WebRequest;
  73790. /**
  73791. * Creates a new LoadFileError
  73792. * @param message defines the message of the error
  73793. * @param request defines the optional web request
  73794. */
  73795. constructor(message: string, request: WebRequest);
  73796. }
  73797. /** @ignore */
  73798. export class ReadFileError extends BaseError {
  73799. file: File;
  73800. /**
  73801. * Creates a new ReadFileError
  73802. * @param message defines the message of the error
  73803. * @param file defines the optional file
  73804. */
  73805. constructor(message: string, file: File);
  73806. }
  73807. /**
  73808. * @hidden
  73809. */
  73810. export class FileTools {
  73811. /**
  73812. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  73813. */
  73814. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  73815. /**
  73816. * Gets or sets the base URL to use to load assets
  73817. */
  73818. static BaseUrl: string;
  73819. /**
  73820. * Default behaviour for cors in the application.
  73821. * It can be a string if the expected behavior is identical in the entire app.
  73822. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  73823. */
  73824. static CorsBehavior: string | ((url: string | string[]) => string);
  73825. /**
  73826. * Gets or sets a function used to pre-process url before using them to load assets
  73827. */
  73828. static PreprocessUrl: (url: string) => string;
  73829. /**
  73830. * Removes unwanted characters from an url
  73831. * @param url defines the url to clean
  73832. * @returns the cleaned url
  73833. */
  73834. private static _CleanUrl;
  73835. /**
  73836. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  73837. * @param url define the url we are trying
  73838. * @param element define the dom element where to configure the cors policy
  73839. */
  73840. static SetCorsBehavior(url: string | string[], element: {
  73841. crossOrigin: string | null;
  73842. }): void;
  73843. /**
  73844. * Loads an image as an HTMLImageElement.
  73845. * @param input url string, ArrayBuffer, or Blob to load
  73846. * @param onLoad callback called when the image successfully loads
  73847. * @param onError callback called when the image fails to load
  73848. * @param offlineProvider offline provider for caching
  73849. * @param mimeType optional mime type
  73850. * @returns the HTMLImageElement of the loaded image
  73851. */
  73852. 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>;
  73853. /**
  73854. * Reads a file from a File object
  73855. * @param file defines the file to load
  73856. * @param onSuccess defines the callback to call when data is loaded
  73857. * @param onProgress defines the callback to call during loading process
  73858. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  73859. * @param onError defines the callback to call when an error occurs
  73860. * @returns a file request object
  73861. */
  73862. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  73863. /**
  73864. * Loads a file from a url
  73865. * @param url url to load
  73866. * @param onSuccess callback called when the file successfully loads
  73867. * @param onProgress callback called while file is loading (if the server supports this mode)
  73868. * @param offlineProvider defines the offline provider for caching
  73869. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73870. * @param onError callback called when the file fails to load
  73871. * @returns a file request object
  73872. */
  73873. 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;
  73874. /**
  73875. * Loads a file
  73876. * @param url url to load
  73877. * @param onSuccess callback called when the file successfully loads
  73878. * @param onProgress callback called while file is loading (if the server supports this mode)
  73879. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73880. * @param onError callback called when the file fails to load
  73881. * @param onOpened callback called when the web request is opened
  73882. * @returns a file request object
  73883. */
  73884. 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;
  73885. /**
  73886. * Checks if the loaded document was accessed via `file:`-Protocol.
  73887. * @returns boolean
  73888. */
  73889. static IsFileURL(): boolean;
  73890. }
  73891. }
  73892. declare module BABYLON {
  73893. /** @hidden */
  73894. export class ShaderProcessor {
  73895. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  73896. private static _ProcessPrecision;
  73897. private static _ExtractOperation;
  73898. private static _BuildSubExpression;
  73899. private static _BuildExpression;
  73900. private static _MoveCursorWithinIf;
  73901. private static _MoveCursor;
  73902. private static _EvaluatePreProcessors;
  73903. private static _PreparePreProcessors;
  73904. private static _ProcessShaderConversion;
  73905. private static _ProcessIncludes;
  73906. /**
  73907. * Loads a file from a url
  73908. * @param url url to load
  73909. * @param onSuccess callback called when the file successfully loads
  73910. * @param onProgress callback called while file is loading (if the server supports this mode)
  73911. * @param offlineProvider defines the offline provider for caching
  73912. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73913. * @param onError callback called when the file fails to load
  73914. * @returns a file request object
  73915. * @hidden
  73916. */
  73917. 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;
  73918. }
  73919. }
  73920. declare module BABYLON {
  73921. /**
  73922. * @hidden
  73923. */
  73924. export interface IColor4Like {
  73925. r: float;
  73926. g: float;
  73927. b: float;
  73928. a: float;
  73929. }
  73930. /**
  73931. * @hidden
  73932. */
  73933. export interface IColor3Like {
  73934. r: float;
  73935. g: float;
  73936. b: float;
  73937. }
  73938. /**
  73939. * @hidden
  73940. */
  73941. export interface IVector4Like {
  73942. x: float;
  73943. y: float;
  73944. z: float;
  73945. w: float;
  73946. }
  73947. /**
  73948. * @hidden
  73949. */
  73950. export interface IVector3Like {
  73951. x: float;
  73952. y: float;
  73953. z: float;
  73954. }
  73955. /**
  73956. * @hidden
  73957. */
  73958. export interface IVector2Like {
  73959. x: float;
  73960. y: float;
  73961. }
  73962. /**
  73963. * @hidden
  73964. */
  73965. export interface IMatrixLike {
  73966. toArray(): DeepImmutable<Float32Array>;
  73967. updateFlag: int;
  73968. }
  73969. /**
  73970. * @hidden
  73971. */
  73972. export interface IViewportLike {
  73973. x: float;
  73974. y: float;
  73975. width: float;
  73976. height: float;
  73977. }
  73978. /**
  73979. * @hidden
  73980. */
  73981. export interface IPlaneLike {
  73982. normal: IVector3Like;
  73983. d: float;
  73984. normalize(): void;
  73985. }
  73986. }
  73987. declare module BABYLON {
  73988. /**
  73989. * Interface used to define common properties for effect fallbacks
  73990. */
  73991. export interface IEffectFallbacks {
  73992. /**
  73993. * Removes the defines that should be removed when falling back.
  73994. * @param currentDefines defines the current define statements for the shader.
  73995. * @param effect defines the current effect we try to compile
  73996. * @returns The resulting defines with defines of the current rank removed.
  73997. */
  73998. reduce(currentDefines: string, effect: Effect): string;
  73999. /**
  74000. * Removes the fallback from the bound mesh.
  74001. */
  74002. unBindMesh(): void;
  74003. /**
  74004. * Checks to see if more fallbacks are still availible.
  74005. */
  74006. hasMoreFallbacks: boolean;
  74007. }
  74008. }
  74009. declare module BABYLON {
  74010. /**
  74011. * Class used to evalaute queries containing `and` and `or` operators
  74012. */
  74013. export class AndOrNotEvaluator {
  74014. /**
  74015. * Evaluate a query
  74016. * @param query defines the query to evaluate
  74017. * @param evaluateCallback defines the callback used to filter result
  74018. * @returns true if the query matches
  74019. */
  74020. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74021. private static _HandleParenthesisContent;
  74022. private static _SimplifyNegation;
  74023. }
  74024. }
  74025. declare module BABYLON {
  74026. /**
  74027. * Class used to store custom tags
  74028. */
  74029. export class Tags {
  74030. /**
  74031. * Adds support for tags on the given object
  74032. * @param obj defines the object to use
  74033. */
  74034. static EnableFor(obj: any): void;
  74035. /**
  74036. * Removes tags support
  74037. * @param obj defines the object to use
  74038. */
  74039. static DisableFor(obj: any): void;
  74040. /**
  74041. * Gets a boolean indicating if the given object has tags
  74042. * @param obj defines the object to use
  74043. * @returns a boolean
  74044. */
  74045. static HasTags(obj: any): boolean;
  74046. /**
  74047. * Gets the tags available on a given object
  74048. * @param obj defines the object to use
  74049. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74050. * @returns the tags
  74051. */
  74052. static GetTags(obj: any, asString?: boolean): any;
  74053. /**
  74054. * Adds tags to an object
  74055. * @param obj defines the object to use
  74056. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74057. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74058. */
  74059. static AddTagsTo(obj: any, tagsString: string): void;
  74060. /**
  74061. * @hidden
  74062. */
  74063. static _AddTagTo(obj: any, tag: string): void;
  74064. /**
  74065. * Removes specific tags from a specific object
  74066. * @param obj defines the object to use
  74067. * @param tagsString defines the tags to remove
  74068. */
  74069. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74070. /**
  74071. * @hidden
  74072. */
  74073. static _RemoveTagFrom(obj: any, tag: string): void;
  74074. /**
  74075. * Defines if tags hosted on an object match a given query
  74076. * @param obj defines the object to use
  74077. * @param tagsQuery defines the tag query
  74078. * @returns a boolean
  74079. */
  74080. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74081. }
  74082. }
  74083. declare module BABYLON {
  74084. /**
  74085. * Scalar computation library
  74086. */
  74087. export class Scalar {
  74088. /**
  74089. * Two pi constants convenient for computation.
  74090. */
  74091. static TwoPi: number;
  74092. /**
  74093. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74094. * @param a number
  74095. * @param b number
  74096. * @param epsilon (default = 1.401298E-45)
  74097. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74098. */
  74099. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74100. /**
  74101. * Returns a string : the upper case translation of the number i to hexadecimal.
  74102. * @param i number
  74103. * @returns the upper case translation of the number i to hexadecimal.
  74104. */
  74105. static ToHex(i: number): string;
  74106. /**
  74107. * Returns -1 if value is negative and +1 is value is positive.
  74108. * @param value the value
  74109. * @returns the value itself if it's equal to zero.
  74110. */
  74111. static Sign(value: number): number;
  74112. /**
  74113. * Returns the value itself if it's between min and max.
  74114. * Returns min if the value is lower than min.
  74115. * Returns max if the value is greater than max.
  74116. * @param value the value to clmap
  74117. * @param min the min value to clamp to (default: 0)
  74118. * @param max the max value to clamp to (default: 1)
  74119. * @returns the clamped value
  74120. */
  74121. static Clamp(value: number, min?: number, max?: number): number;
  74122. /**
  74123. * the log2 of value.
  74124. * @param value the value to compute log2 of
  74125. * @returns the log2 of value.
  74126. */
  74127. static Log2(value: number): number;
  74128. /**
  74129. * Loops the value, so that it is never larger than length and never smaller than 0.
  74130. *
  74131. * This is similar to the modulo operator but it works with floating point numbers.
  74132. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74133. * With t = 5 and length = 2.5, the result would be 0.0.
  74134. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74135. * @param value the value
  74136. * @param length the length
  74137. * @returns the looped value
  74138. */
  74139. static Repeat(value: number, length: number): number;
  74140. /**
  74141. * Normalize the value between 0.0 and 1.0 using min and max values
  74142. * @param value value to normalize
  74143. * @param min max to normalize between
  74144. * @param max min to normalize between
  74145. * @returns the normalized value
  74146. */
  74147. static Normalize(value: number, min: number, max: number): number;
  74148. /**
  74149. * Denormalize the value from 0.0 and 1.0 using min and max values
  74150. * @param normalized value to denormalize
  74151. * @param min max to denormalize between
  74152. * @param max min to denormalize between
  74153. * @returns the denormalized value
  74154. */
  74155. static Denormalize(normalized: number, min: number, max: number): number;
  74156. /**
  74157. * Calculates the shortest difference between two given angles given in degrees.
  74158. * @param current current angle in degrees
  74159. * @param target target angle in degrees
  74160. * @returns the delta
  74161. */
  74162. static DeltaAngle(current: number, target: number): number;
  74163. /**
  74164. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74165. * @param tx value
  74166. * @param length length
  74167. * @returns The returned value will move back and forth between 0 and length
  74168. */
  74169. static PingPong(tx: number, length: number): number;
  74170. /**
  74171. * Interpolates between min and max with smoothing at the limits.
  74172. *
  74173. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74174. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74175. * @param from from
  74176. * @param to to
  74177. * @param tx value
  74178. * @returns the smooth stepped value
  74179. */
  74180. static SmoothStep(from: number, to: number, tx: number): number;
  74181. /**
  74182. * Moves a value current towards target.
  74183. *
  74184. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74185. * Negative values of maxDelta pushes the value away from target.
  74186. * @param current current value
  74187. * @param target target value
  74188. * @param maxDelta max distance to move
  74189. * @returns resulting value
  74190. */
  74191. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74192. /**
  74193. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74194. *
  74195. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74196. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74197. * @param current current value
  74198. * @param target target value
  74199. * @param maxDelta max distance to move
  74200. * @returns resulting angle
  74201. */
  74202. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74203. /**
  74204. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74205. * @param start start value
  74206. * @param end target value
  74207. * @param amount amount to lerp between
  74208. * @returns the lerped value
  74209. */
  74210. static Lerp(start: number, end: number, amount: number): number;
  74211. /**
  74212. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74213. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74214. * @param start start value
  74215. * @param end target value
  74216. * @param amount amount to lerp between
  74217. * @returns the lerped value
  74218. */
  74219. static LerpAngle(start: number, end: number, amount: number): number;
  74220. /**
  74221. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74222. * @param a start value
  74223. * @param b target value
  74224. * @param value value between a and b
  74225. * @returns the inverseLerp value
  74226. */
  74227. static InverseLerp(a: number, b: number, value: number): number;
  74228. /**
  74229. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74230. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74231. * @param value1 spline value
  74232. * @param tangent1 spline value
  74233. * @param value2 spline value
  74234. * @param tangent2 spline value
  74235. * @param amount input value
  74236. * @returns hermite result
  74237. */
  74238. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74239. /**
  74240. * Returns a random float number between and min and max values
  74241. * @param min min value of random
  74242. * @param max max value of random
  74243. * @returns random value
  74244. */
  74245. static RandomRange(min: number, max: number): number;
  74246. /**
  74247. * This function returns percentage of a number in a given range.
  74248. *
  74249. * RangeToPercent(40,20,60) will return 0.5 (50%)
  74250. * RangeToPercent(34,0,100) will return 0.34 (34%)
  74251. * @param number to convert to percentage
  74252. * @param min min range
  74253. * @param max max range
  74254. * @returns the percentage
  74255. */
  74256. static RangeToPercent(number: number, min: number, max: number): number;
  74257. /**
  74258. * This function returns number that corresponds to the percentage in a given range.
  74259. *
  74260. * PercentToRange(0.34,0,100) will return 34.
  74261. * @param percent to convert to number
  74262. * @param min min range
  74263. * @param max max range
  74264. * @returns the number
  74265. */
  74266. static PercentToRange(percent: number, min: number, max: number): number;
  74267. /**
  74268. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  74269. * @param angle The angle to normalize in radian.
  74270. * @return The converted angle.
  74271. */
  74272. static NormalizeRadians(angle: number): number;
  74273. }
  74274. }
  74275. declare module BABYLON {
  74276. /**
  74277. * Constant used to convert a value to gamma space
  74278. * @ignorenaming
  74279. */
  74280. export const ToGammaSpace: number;
  74281. /**
  74282. * Constant used to convert a value to linear space
  74283. * @ignorenaming
  74284. */
  74285. export const ToLinearSpace = 2.2;
  74286. /**
  74287. * Constant used to define the minimal number value in Babylon.js
  74288. * @ignorenaming
  74289. */
  74290. let Epsilon: number;
  74291. }
  74292. declare module BABYLON {
  74293. /**
  74294. * Class used to represent a viewport on screen
  74295. */
  74296. export class Viewport {
  74297. /** viewport left coordinate */
  74298. x: number;
  74299. /** viewport top coordinate */
  74300. y: number;
  74301. /**viewport width */
  74302. width: number;
  74303. /** viewport height */
  74304. height: number;
  74305. /**
  74306. * Creates a Viewport object located at (x, y) and sized (width, height)
  74307. * @param x defines viewport left coordinate
  74308. * @param y defines viewport top coordinate
  74309. * @param width defines the viewport width
  74310. * @param height defines the viewport height
  74311. */
  74312. constructor(
  74313. /** viewport left coordinate */
  74314. x: number,
  74315. /** viewport top coordinate */
  74316. y: number,
  74317. /**viewport width */
  74318. width: number,
  74319. /** viewport height */
  74320. height: number);
  74321. /**
  74322. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  74323. * @param renderWidth defines the rendering width
  74324. * @param renderHeight defines the rendering height
  74325. * @returns a new Viewport
  74326. */
  74327. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  74328. /**
  74329. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  74330. * @param renderWidth defines the rendering width
  74331. * @param renderHeight defines the rendering height
  74332. * @param ref defines the target viewport
  74333. * @returns the current viewport
  74334. */
  74335. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  74336. /**
  74337. * Returns a new Viewport copied from the current one
  74338. * @returns a new Viewport
  74339. */
  74340. clone(): Viewport;
  74341. }
  74342. }
  74343. declare module BABYLON {
  74344. /**
  74345. * Class containing a set of static utilities functions for arrays.
  74346. */
  74347. export class ArrayTools {
  74348. /**
  74349. * Returns an array of the given size filled with element built from the given constructor and the paramters
  74350. * @param size the number of element to construct and put in the array
  74351. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  74352. * @returns a new array filled with new objects
  74353. */
  74354. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  74355. }
  74356. }
  74357. declare module BABYLON {
  74358. /**
  74359. * Class representing a vector containing 2 coordinates
  74360. */
  74361. export class Vector2 {
  74362. /** defines the first coordinate */
  74363. x: number;
  74364. /** defines the second coordinate */
  74365. y: number;
  74366. /**
  74367. * Creates a new Vector2 from the given x and y coordinates
  74368. * @param x defines the first coordinate
  74369. * @param y defines the second coordinate
  74370. */
  74371. constructor(
  74372. /** defines the first coordinate */
  74373. x?: number,
  74374. /** defines the second coordinate */
  74375. y?: number);
  74376. /**
  74377. * Gets a string with the Vector2 coordinates
  74378. * @returns a string with the Vector2 coordinates
  74379. */
  74380. toString(): string;
  74381. /**
  74382. * Gets class name
  74383. * @returns the string "Vector2"
  74384. */
  74385. getClassName(): string;
  74386. /**
  74387. * Gets current vector hash code
  74388. * @returns the Vector2 hash code as a number
  74389. */
  74390. getHashCode(): number;
  74391. /**
  74392. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  74393. * @param array defines the source array
  74394. * @param index defines the offset in source array
  74395. * @returns the current Vector2
  74396. */
  74397. toArray(array: FloatArray, index?: number): Vector2;
  74398. /**
  74399. * Copy the current vector to an array
  74400. * @returns a new array with 2 elements: the Vector2 coordinates.
  74401. */
  74402. asArray(): number[];
  74403. /**
  74404. * Sets the Vector2 coordinates with the given Vector2 coordinates
  74405. * @param source defines the source Vector2
  74406. * @returns the current updated Vector2
  74407. */
  74408. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  74409. /**
  74410. * Sets the Vector2 coordinates with the given floats
  74411. * @param x defines the first coordinate
  74412. * @param y defines the second coordinate
  74413. * @returns the current updated Vector2
  74414. */
  74415. copyFromFloats(x: number, y: number): Vector2;
  74416. /**
  74417. * Sets the Vector2 coordinates with the given floats
  74418. * @param x defines the first coordinate
  74419. * @param y defines the second coordinate
  74420. * @returns the current updated Vector2
  74421. */
  74422. set(x: number, y: number): Vector2;
  74423. /**
  74424. * Add another vector with the current one
  74425. * @param otherVector defines the other vector
  74426. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  74427. */
  74428. add(otherVector: DeepImmutable<Vector2>): Vector2;
  74429. /**
  74430. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  74431. * @param otherVector defines the other vector
  74432. * @param result defines the target vector
  74433. * @returns the unmodified current Vector2
  74434. */
  74435. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74436. /**
  74437. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  74438. * @param otherVector defines the other vector
  74439. * @returns the current updated Vector2
  74440. */
  74441. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74442. /**
  74443. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  74444. * @param otherVector defines the other vector
  74445. * @returns a new Vector2
  74446. */
  74447. addVector3(otherVector: Vector3): Vector2;
  74448. /**
  74449. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  74450. * @param otherVector defines the other vector
  74451. * @returns a new Vector2
  74452. */
  74453. subtract(otherVector: Vector2): Vector2;
  74454. /**
  74455. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  74456. * @param otherVector defines the other vector
  74457. * @param result defines the target vector
  74458. * @returns the unmodified current Vector2
  74459. */
  74460. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74461. /**
  74462. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  74463. * @param otherVector defines the other vector
  74464. * @returns the current updated Vector2
  74465. */
  74466. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74467. /**
  74468. * Multiplies in place the current Vector2 coordinates by the given ones
  74469. * @param otherVector defines the other vector
  74470. * @returns the current updated Vector2
  74471. */
  74472. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74473. /**
  74474. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  74475. * @param otherVector defines the other vector
  74476. * @returns a new Vector2
  74477. */
  74478. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  74479. /**
  74480. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  74481. * @param otherVector defines the other vector
  74482. * @param result defines the target vector
  74483. * @returns the unmodified current Vector2
  74484. */
  74485. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74486. /**
  74487. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  74488. * @param x defines the first coordinate
  74489. * @param y defines the second coordinate
  74490. * @returns a new Vector2
  74491. */
  74492. multiplyByFloats(x: number, y: number): Vector2;
  74493. /**
  74494. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  74495. * @param otherVector defines the other vector
  74496. * @returns a new Vector2
  74497. */
  74498. divide(otherVector: Vector2): Vector2;
  74499. /**
  74500. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  74501. * @param otherVector defines the other vector
  74502. * @param result defines the target vector
  74503. * @returns the unmodified current Vector2
  74504. */
  74505. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74506. /**
  74507. * Divides the current Vector2 coordinates by the given ones
  74508. * @param otherVector defines the other vector
  74509. * @returns the current updated Vector2
  74510. */
  74511. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74512. /**
  74513. * Gets a new Vector2 with current Vector2 negated coordinates
  74514. * @returns a new Vector2
  74515. */
  74516. negate(): Vector2;
  74517. /**
  74518. * Multiply the Vector2 coordinates by scale
  74519. * @param scale defines the scaling factor
  74520. * @returns the current updated Vector2
  74521. */
  74522. scaleInPlace(scale: number): Vector2;
  74523. /**
  74524. * Returns a new Vector2 scaled by "scale" from the current Vector2
  74525. * @param scale defines the scaling factor
  74526. * @returns a new Vector2
  74527. */
  74528. scale(scale: number): Vector2;
  74529. /**
  74530. * Scale the current Vector2 values by a factor to a given Vector2
  74531. * @param scale defines the scale factor
  74532. * @param result defines the Vector2 object where to store the result
  74533. * @returns the unmodified current Vector2
  74534. */
  74535. scaleToRef(scale: number, result: Vector2): Vector2;
  74536. /**
  74537. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  74538. * @param scale defines the scale factor
  74539. * @param result defines the Vector2 object where to store the result
  74540. * @returns the unmodified current Vector2
  74541. */
  74542. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  74543. /**
  74544. * Gets a boolean if two vectors are equals
  74545. * @param otherVector defines the other vector
  74546. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  74547. */
  74548. equals(otherVector: DeepImmutable<Vector2>): boolean;
  74549. /**
  74550. * Gets a boolean if two vectors are equals (using an epsilon value)
  74551. * @param otherVector defines the other vector
  74552. * @param epsilon defines the minimal distance to consider equality
  74553. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  74554. */
  74555. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  74556. /**
  74557. * Gets a new Vector2 from current Vector2 floored values
  74558. * @returns a new Vector2
  74559. */
  74560. floor(): Vector2;
  74561. /**
  74562. * Gets a new Vector2 from current Vector2 floored values
  74563. * @returns a new Vector2
  74564. */
  74565. fract(): Vector2;
  74566. /**
  74567. * Gets the length of the vector
  74568. * @returns the vector length (float)
  74569. */
  74570. length(): number;
  74571. /**
  74572. * Gets the vector squared length
  74573. * @returns the vector squared length (float)
  74574. */
  74575. lengthSquared(): number;
  74576. /**
  74577. * Normalize the vector
  74578. * @returns the current updated Vector2
  74579. */
  74580. normalize(): Vector2;
  74581. /**
  74582. * Gets a new Vector2 copied from the Vector2
  74583. * @returns a new Vector2
  74584. */
  74585. clone(): Vector2;
  74586. /**
  74587. * Gets a new Vector2(0, 0)
  74588. * @returns a new Vector2
  74589. */
  74590. static Zero(): Vector2;
  74591. /**
  74592. * Gets a new Vector2(1, 1)
  74593. * @returns a new Vector2
  74594. */
  74595. static One(): Vector2;
  74596. /**
  74597. * Gets a new Vector2 set from the given index element of the given array
  74598. * @param array defines the data source
  74599. * @param offset defines the offset in the data source
  74600. * @returns a new Vector2
  74601. */
  74602. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  74603. /**
  74604. * Sets "result" from the given index element of the given array
  74605. * @param array defines the data source
  74606. * @param offset defines the offset in the data source
  74607. * @param result defines the target vector
  74608. */
  74609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  74610. /**
  74611. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  74612. * @param value1 defines 1st point of control
  74613. * @param value2 defines 2nd point of control
  74614. * @param value3 defines 3rd point of control
  74615. * @param value4 defines 4th point of control
  74616. * @param amount defines the interpolation factor
  74617. * @returns a new Vector2
  74618. */
  74619. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  74620. /**
  74621. * 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".
  74622. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  74623. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  74624. * @param value defines the value to clamp
  74625. * @param min defines the lower limit
  74626. * @param max defines the upper limit
  74627. * @returns a new Vector2
  74628. */
  74629. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  74630. /**
  74631. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  74632. * @param value1 defines the 1st control point
  74633. * @param tangent1 defines the outgoing tangent
  74634. * @param value2 defines the 2nd control point
  74635. * @param tangent2 defines the incoming tangent
  74636. * @param amount defines the interpolation factor
  74637. * @returns a new Vector2
  74638. */
  74639. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  74640. /**
  74641. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  74642. * @param start defines the start vector
  74643. * @param end defines the end vector
  74644. * @param amount defines the interpolation factor
  74645. * @returns a new Vector2
  74646. */
  74647. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  74648. /**
  74649. * Gets the dot product of the vector "left" and the vector "right"
  74650. * @param left defines first vector
  74651. * @param right defines second vector
  74652. * @returns the dot product (float)
  74653. */
  74654. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  74655. /**
  74656. * Returns a new Vector2 equal to the normalized given vector
  74657. * @param vector defines the vector to normalize
  74658. * @returns a new Vector2
  74659. */
  74660. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  74661. /**
  74662. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  74663. * @param left defines 1st vector
  74664. * @param right defines 2nd vector
  74665. * @returns a new Vector2
  74666. */
  74667. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  74668. /**
  74669. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  74670. * @param left defines 1st vector
  74671. * @param right defines 2nd vector
  74672. * @returns a new Vector2
  74673. */
  74674. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  74675. /**
  74676. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  74677. * @param vector defines the vector to transform
  74678. * @param transformation defines the matrix to apply
  74679. * @returns a new Vector2
  74680. */
  74681. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  74682. /**
  74683. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  74684. * @param vector defines the vector to transform
  74685. * @param transformation defines the matrix to apply
  74686. * @param result defines the target vector
  74687. */
  74688. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  74689. /**
  74690. * Determines if a given vector is included in a triangle
  74691. * @param p defines the vector to test
  74692. * @param p0 defines 1st triangle point
  74693. * @param p1 defines 2nd triangle point
  74694. * @param p2 defines 3rd triangle point
  74695. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  74696. */
  74697. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  74698. /**
  74699. * Gets the distance between the vectors "value1" and "value2"
  74700. * @param value1 defines first vector
  74701. * @param value2 defines second vector
  74702. * @returns the distance between vectors
  74703. */
  74704. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  74705. /**
  74706. * Returns the squared distance between the vectors "value1" and "value2"
  74707. * @param value1 defines first vector
  74708. * @param value2 defines second vector
  74709. * @returns the squared distance between vectors
  74710. */
  74711. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  74712. /**
  74713. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  74714. * @param value1 defines first vector
  74715. * @param value2 defines second vector
  74716. * @returns a new Vector2
  74717. */
  74718. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  74719. /**
  74720. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  74721. * @param p defines the middle point
  74722. * @param segA defines one point of the segment
  74723. * @param segB defines the other point of the segment
  74724. * @returns the shortest distance
  74725. */
  74726. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  74727. }
  74728. /**
  74729. * Class used to store (x,y,z) vector representation
  74730. * A Vector3 is the main object used in 3D geometry
  74731. * It can represent etiher the coordinates of a point the space, either a direction
  74732. * Reminder: js uses a left handed forward facing system
  74733. */
  74734. export class Vector3 {
  74735. /**
  74736. * Defines the first coordinates (on X axis)
  74737. */
  74738. x: number;
  74739. /**
  74740. * Defines the second coordinates (on Y axis)
  74741. */
  74742. y: number;
  74743. /**
  74744. * Defines the third coordinates (on Z axis)
  74745. */
  74746. z: number;
  74747. private static _UpReadOnly;
  74748. private static _ZeroReadOnly;
  74749. /**
  74750. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  74751. * @param x defines the first coordinates (on X axis)
  74752. * @param y defines the second coordinates (on Y axis)
  74753. * @param z defines the third coordinates (on Z axis)
  74754. */
  74755. constructor(
  74756. /**
  74757. * Defines the first coordinates (on X axis)
  74758. */
  74759. x?: number,
  74760. /**
  74761. * Defines the second coordinates (on Y axis)
  74762. */
  74763. y?: number,
  74764. /**
  74765. * Defines the third coordinates (on Z axis)
  74766. */
  74767. z?: number);
  74768. /**
  74769. * Creates a string representation of the Vector3
  74770. * @returns a string with the Vector3 coordinates.
  74771. */
  74772. toString(): string;
  74773. /**
  74774. * Gets the class name
  74775. * @returns the string "Vector3"
  74776. */
  74777. getClassName(): string;
  74778. /**
  74779. * Creates the Vector3 hash code
  74780. * @returns a number which tends to be unique between Vector3 instances
  74781. */
  74782. getHashCode(): number;
  74783. /**
  74784. * Creates an array containing three elements : the coordinates of the Vector3
  74785. * @returns a new array of numbers
  74786. */
  74787. asArray(): number[];
  74788. /**
  74789. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  74790. * @param array defines the destination array
  74791. * @param index defines the offset in the destination array
  74792. * @returns the current Vector3
  74793. */
  74794. toArray(array: FloatArray, index?: number): Vector3;
  74795. /**
  74796. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  74797. * @returns a new Quaternion object, computed from the Vector3 coordinates
  74798. */
  74799. toQuaternion(): Quaternion;
  74800. /**
  74801. * Adds the given vector to the current Vector3
  74802. * @param otherVector defines the second operand
  74803. * @returns the current updated Vector3
  74804. */
  74805. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74806. /**
  74807. * Adds the given coordinates to the current Vector3
  74808. * @param x defines the x coordinate of the operand
  74809. * @param y defines the y coordinate of the operand
  74810. * @param z defines the z coordinate of the operand
  74811. * @returns the current updated Vector3
  74812. */
  74813. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  74814. /**
  74815. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  74816. * @param otherVector defines the second operand
  74817. * @returns the resulting Vector3
  74818. */
  74819. add(otherVector: DeepImmutable<Vector3>): Vector3;
  74820. /**
  74821. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  74822. * @param otherVector defines the second operand
  74823. * @param result defines the Vector3 object where to store the result
  74824. * @returns the current Vector3
  74825. */
  74826. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74827. /**
  74828. * Subtract the given vector from the current Vector3
  74829. * @param otherVector defines the second operand
  74830. * @returns the current updated Vector3
  74831. */
  74832. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74833. /**
  74834. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  74835. * @param otherVector defines the second operand
  74836. * @returns the resulting Vector3
  74837. */
  74838. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  74839. /**
  74840. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  74841. * @param otherVector defines the second operand
  74842. * @param result defines the Vector3 object where to store the result
  74843. * @returns the current Vector3
  74844. */
  74845. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74846. /**
  74847. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  74848. * @param x defines the x coordinate of the operand
  74849. * @param y defines the y coordinate of the operand
  74850. * @param z defines the z coordinate of the operand
  74851. * @returns the resulting Vector3
  74852. */
  74853. subtractFromFloats(x: number, y: number, z: number): Vector3;
  74854. /**
  74855. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  74856. * @param x defines the x coordinate of the operand
  74857. * @param y defines the y coordinate of the operand
  74858. * @param z defines the z coordinate of the operand
  74859. * @param result defines the Vector3 object where to store the result
  74860. * @returns the current Vector3
  74861. */
  74862. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  74863. /**
  74864. * Gets a new Vector3 set with the current Vector3 negated coordinates
  74865. * @returns a new Vector3
  74866. */
  74867. negate(): Vector3;
  74868. /**
  74869. * Negate this vector in place
  74870. * @returns this
  74871. */
  74872. negateInPlace(): Vector3;
  74873. /**
  74874. * Multiplies the Vector3 coordinates by the float "scale"
  74875. * @param scale defines the multiplier factor
  74876. * @returns the current updated Vector3
  74877. */
  74878. scaleInPlace(scale: number): Vector3;
  74879. /**
  74880. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  74881. * @param scale defines the multiplier factor
  74882. * @returns a new Vector3
  74883. */
  74884. scale(scale: number): Vector3;
  74885. /**
  74886. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  74887. * @param scale defines the multiplier factor
  74888. * @param result defines the Vector3 object where to store the result
  74889. * @returns the current Vector3
  74890. */
  74891. scaleToRef(scale: number, result: Vector3): Vector3;
  74892. /**
  74893. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  74894. * @param scale defines the scale factor
  74895. * @param result defines the Vector3 object where to store the result
  74896. * @returns the unmodified current Vector3
  74897. */
  74898. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  74899. /**
  74900. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  74901. * @param otherVector defines the second operand
  74902. * @returns true if both vectors are equals
  74903. */
  74904. equals(otherVector: DeepImmutable<Vector3>): boolean;
  74905. /**
  74906. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  74907. * @param otherVector defines the second operand
  74908. * @param epsilon defines the minimal distance to define values as equals
  74909. * @returns true if both vectors are distant less than epsilon
  74910. */
  74911. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  74912. /**
  74913. * Returns true if the current Vector3 coordinates equals the given floats
  74914. * @param x defines the x coordinate of the operand
  74915. * @param y defines the y coordinate of the operand
  74916. * @param z defines the z coordinate of the operand
  74917. * @returns true if both vectors are equals
  74918. */
  74919. equalsToFloats(x: number, y: number, z: number): boolean;
  74920. /**
  74921. * Multiplies the current Vector3 coordinates by the given ones
  74922. * @param otherVector defines the second operand
  74923. * @returns the current updated Vector3
  74924. */
  74925. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74926. /**
  74927. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  74928. * @param otherVector defines the second operand
  74929. * @returns the new Vector3
  74930. */
  74931. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  74932. /**
  74933. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  74934. * @param otherVector defines the second operand
  74935. * @param result defines the Vector3 object where to store the result
  74936. * @returns the current Vector3
  74937. */
  74938. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74939. /**
  74940. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  74941. * @param x defines the x coordinate of the operand
  74942. * @param y defines the y coordinate of the operand
  74943. * @param z defines the z coordinate of the operand
  74944. * @returns the new Vector3
  74945. */
  74946. multiplyByFloats(x: number, y: number, z: number): Vector3;
  74947. /**
  74948. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  74949. * @param otherVector defines the second operand
  74950. * @returns the new Vector3
  74951. */
  74952. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  74953. /**
  74954. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  74955. * @param otherVector defines the second operand
  74956. * @param result defines the Vector3 object where to store the result
  74957. * @returns the current Vector3
  74958. */
  74959. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74960. /**
  74961. * Divides the current Vector3 coordinates by the given ones.
  74962. * @param otherVector defines the second operand
  74963. * @returns the current updated Vector3
  74964. */
  74965. divideInPlace(otherVector: Vector3): Vector3;
  74966. /**
  74967. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  74968. * @param other defines the second operand
  74969. * @returns the current updated Vector3
  74970. */
  74971. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  74972. /**
  74973. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  74974. * @param other defines the second operand
  74975. * @returns the current updated Vector3
  74976. */
  74977. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  74978. /**
  74979. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  74980. * @param x defines the x coordinate of the operand
  74981. * @param y defines the y coordinate of the operand
  74982. * @param z defines the z coordinate of the operand
  74983. * @returns the current updated Vector3
  74984. */
  74985. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  74986. /**
  74987. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  74988. * @param x defines the x coordinate of the operand
  74989. * @param y defines the y coordinate of the operand
  74990. * @param z defines the z coordinate of the operand
  74991. * @returns the current updated Vector3
  74992. */
  74993. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  74994. /**
  74995. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  74996. * Check if is non uniform within a certain amount of decimal places to account for this
  74997. * @param epsilon the amount the values can differ
  74998. * @returns if the the vector is non uniform to a certain number of decimal places
  74999. */
  75000. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75001. /**
  75002. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75003. */
  75004. get isNonUniform(): boolean;
  75005. /**
  75006. * Gets a new Vector3 from current Vector3 floored values
  75007. * @returns a new Vector3
  75008. */
  75009. floor(): Vector3;
  75010. /**
  75011. * Gets a new Vector3 from current Vector3 floored values
  75012. * @returns a new Vector3
  75013. */
  75014. fract(): Vector3;
  75015. /**
  75016. * Gets the length of the Vector3
  75017. * @returns the length of the Vector3
  75018. */
  75019. length(): number;
  75020. /**
  75021. * Gets the squared length of the Vector3
  75022. * @returns squared length of the Vector3
  75023. */
  75024. lengthSquared(): number;
  75025. /**
  75026. * Normalize the current Vector3.
  75027. * Please note that this is an in place operation.
  75028. * @returns the current updated Vector3
  75029. */
  75030. normalize(): Vector3;
  75031. /**
  75032. * Reorders the x y z properties of the vector in place
  75033. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75034. * @returns the current updated vector
  75035. */
  75036. reorderInPlace(order: string): this;
  75037. /**
  75038. * Rotates the vector around 0,0,0 by a quaternion
  75039. * @param quaternion the rotation quaternion
  75040. * @param result vector to store the result
  75041. * @returns the resulting vector
  75042. */
  75043. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75044. /**
  75045. * Rotates a vector around a given point
  75046. * @param quaternion the rotation quaternion
  75047. * @param point the point to rotate around
  75048. * @param result vector to store the result
  75049. * @returns the resulting vector
  75050. */
  75051. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75052. /**
  75053. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75054. * The cross product is then orthogonal to both current and "other"
  75055. * @param other defines the right operand
  75056. * @returns the cross product
  75057. */
  75058. cross(other: Vector3): Vector3;
  75059. /**
  75060. * Normalize the current Vector3 with the given input length.
  75061. * Please note that this is an in place operation.
  75062. * @param len the length of the vector
  75063. * @returns the current updated Vector3
  75064. */
  75065. normalizeFromLength(len: number): Vector3;
  75066. /**
  75067. * Normalize the current Vector3 to a new vector
  75068. * @returns the new Vector3
  75069. */
  75070. normalizeToNew(): Vector3;
  75071. /**
  75072. * Normalize the current Vector3 to the reference
  75073. * @param reference define the Vector3 to update
  75074. * @returns the updated Vector3
  75075. */
  75076. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75077. /**
  75078. * Creates a new Vector3 copied from the current Vector3
  75079. * @returns the new Vector3
  75080. */
  75081. clone(): Vector3;
  75082. /**
  75083. * Copies the given vector coordinates to the current Vector3 ones
  75084. * @param source defines the source Vector3
  75085. * @returns the current updated Vector3
  75086. */
  75087. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75088. /**
  75089. * Copies the given floats to the current Vector3 coordinates
  75090. * @param x defines the x coordinate of the operand
  75091. * @param y defines the y coordinate of the operand
  75092. * @param z defines the z coordinate of the operand
  75093. * @returns the current updated Vector3
  75094. */
  75095. copyFromFloats(x: number, y: number, z: number): Vector3;
  75096. /**
  75097. * Copies the given floats to the current Vector3 coordinates
  75098. * @param x defines the x coordinate of the operand
  75099. * @param y defines the y coordinate of the operand
  75100. * @param z defines the z coordinate of the operand
  75101. * @returns the current updated Vector3
  75102. */
  75103. set(x: number, y: number, z: number): Vector3;
  75104. /**
  75105. * Copies the given float to the current Vector3 coordinates
  75106. * @param v defines the x, y and z coordinates of the operand
  75107. * @returns the current updated Vector3
  75108. */
  75109. setAll(v: number): Vector3;
  75110. /**
  75111. * Get the clip factor between two vectors
  75112. * @param vector0 defines the first operand
  75113. * @param vector1 defines the second operand
  75114. * @param axis defines the axis to use
  75115. * @param size defines the size along the axis
  75116. * @returns the clip factor
  75117. */
  75118. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75119. /**
  75120. * Get angle between two vectors
  75121. * @param vector0 angle between vector0 and vector1
  75122. * @param vector1 angle between vector0 and vector1
  75123. * @param normal direction of the normal
  75124. * @return the angle between vector0 and vector1
  75125. */
  75126. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75127. /**
  75128. * Returns a new Vector3 set from the index "offset" of the given array
  75129. * @param array defines the source array
  75130. * @param offset defines the offset in the source array
  75131. * @returns the new Vector3
  75132. */
  75133. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75134. /**
  75135. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75136. * @param array defines the source array
  75137. * @param offset defines the offset in the source array
  75138. * @returns the new Vector3
  75139. * @deprecated Please use FromArray instead.
  75140. */
  75141. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75142. /**
  75143. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75144. * @param array defines the source array
  75145. * @param offset defines the offset in the source array
  75146. * @param result defines the Vector3 where to store the result
  75147. */
  75148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75149. /**
  75150. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75151. * @param array defines the source array
  75152. * @param offset defines the offset in the source array
  75153. * @param result defines the Vector3 where to store the result
  75154. * @deprecated Please use FromArrayToRef instead.
  75155. */
  75156. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75157. /**
  75158. * Sets the given vector "result" with the given floats.
  75159. * @param x defines the x coordinate of the source
  75160. * @param y defines the y coordinate of the source
  75161. * @param z defines the z coordinate of the source
  75162. * @param result defines the Vector3 where to store the result
  75163. */
  75164. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75165. /**
  75166. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75167. * @returns a new empty Vector3
  75168. */
  75169. static Zero(): Vector3;
  75170. /**
  75171. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75172. * @returns a new unit Vector3
  75173. */
  75174. static One(): Vector3;
  75175. /**
  75176. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75177. * @returns a new up Vector3
  75178. */
  75179. static Up(): Vector3;
  75180. /**
  75181. * Gets a up Vector3 that must not be updated
  75182. */
  75183. static get UpReadOnly(): DeepImmutable<Vector3>;
  75184. /**
  75185. * Gets a zero Vector3 that must not be updated
  75186. */
  75187. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75188. /**
  75189. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75190. * @returns a new down Vector3
  75191. */
  75192. static Down(): Vector3;
  75193. /**
  75194. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75195. * @returns a new forward Vector3
  75196. */
  75197. static Forward(): Vector3;
  75198. /**
  75199. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75200. * @returns a new forward Vector3
  75201. */
  75202. static Backward(): Vector3;
  75203. /**
  75204. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75205. * @returns a new right Vector3
  75206. */
  75207. static Right(): Vector3;
  75208. /**
  75209. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75210. * @returns a new left Vector3
  75211. */
  75212. static Left(): Vector3;
  75213. /**
  75214. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75215. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75216. * @param vector defines the Vector3 to transform
  75217. * @param transformation defines the transformation matrix
  75218. * @returns the transformed Vector3
  75219. */
  75220. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75221. /**
  75222. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75223. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75224. * @param vector defines the Vector3 to transform
  75225. * @param transformation defines the transformation matrix
  75226. * @param result defines the Vector3 where to store the result
  75227. */
  75228. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75229. /**
  75230. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  75231. * This method computes tranformed coordinates only, not transformed direction vectors
  75232. * @param x define the x coordinate of the source vector
  75233. * @param y define the y coordinate of the source vector
  75234. * @param z define the z coordinate of the source vector
  75235. * @param transformation defines the transformation matrix
  75236. * @param result defines the Vector3 where to store the result
  75237. */
  75238. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75239. /**
  75240. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  75241. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75242. * @param vector defines the Vector3 to transform
  75243. * @param transformation defines the transformation matrix
  75244. * @returns the new Vector3
  75245. */
  75246. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75247. /**
  75248. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  75249. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75250. * @param vector defines the Vector3 to transform
  75251. * @param transformation defines the transformation matrix
  75252. * @param result defines the Vector3 where to store the result
  75253. */
  75254. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75255. /**
  75256. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  75257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75258. * @param x define the x coordinate of the source vector
  75259. * @param y define the y coordinate of the source vector
  75260. * @param z define the z coordinate of the source vector
  75261. * @param transformation defines the transformation matrix
  75262. * @param result defines the Vector3 where to store the result
  75263. */
  75264. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75265. /**
  75266. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  75267. * @param value1 defines the first control point
  75268. * @param value2 defines the second control point
  75269. * @param value3 defines the third control point
  75270. * @param value4 defines the fourth control point
  75271. * @param amount defines the amount on the spline to use
  75272. * @returns the new Vector3
  75273. */
  75274. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  75275. /**
  75276. * 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"
  75277. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75278. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75279. * @param value defines the current value
  75280. * @param min defines the lower range value
  75281. * @param max defines the upper range value
  75282. * @returns the new Vector3
  75283. */
  75284. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  75285. /**
  75286. * 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"
  75287. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75288. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75289. * @param value defines the current value
  75290. * @param min defines the lower range value
  75291. * @param max defines the upper range value
  75292. * @param result defines the Vector3 where to store the result
  75293. */
  75294. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  75295. /**
  75296. * Checks if a given vector is inside a specific range
  75297. * @param v defines the vector to test
  75298. * @param min defines the minimum range
  75299. * @param max defines the maximum range
  75300. */
  75301. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  75302. /**
  75303. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  75304. * @param value1 defines the first control point
  75305. * @param tangent1 defines the first tangent vector
  75306. * @param value2 defines the second control point
  75307. * @param tangent2 defines the second tangent vector
  75308. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  75309. * @returns the new Vector3
  75310. */
  75311. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  75312. /**
  75313. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  75314. * @param start defines the start value
  75315. * @param end defines the end value
  75316. * @param amount max defines amount between both (between 0 and 1)
  75317. * @returns the new Vector3
  75318. */
  75319. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  75320. /**
  75321. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  75322. * @param start defines the start value
  75323. * @param end defines the end value
  75324. * @param amount max defines amount between both (between 0 and 1)
  75325. * @param result defines the Vector3 where to store the result
  75326. */
  75327. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  75328. /**
  75329. * Returns the dot product (float) between the vectors "left" and "right"
  75330. * @param left defines the left operand
  75331. * @param right defines the right operand
  75332. * @returns the dot product
  75333. */
  75334. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  75335. /**
  75336. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  75337. * The cross product is then orthogonal to both "left" and "right"
  75338. * @param left defines the left operand
  75339. * @param right defines the right operand
  75340. * @returns the cross product
  75341. */
  75342. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75343. /**
  75344. * Sets the given vector "result" with the cross product of "left" and "right"
  75345. * The cross product is then orthogonal to both "left" and "right"
  75346. * @param left defines the left operand
  75347. * @param right defines the right operand
  75348. * @param result defines the Vector3 where to store the result
  75349. */
  75350. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  75351. /**
  75352. * Returns a new Vector3 as the normalization of the given vector
  75353. * @param vector defines the Vector3 to normalize
  75354. * @returns the new Vector3
  75355. */
  75356. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  75357. /**
  75358. * Sets the given vector "result" with the normalization of the given first vector
  75359. * @param vector defines the Vector3 to normalize
  75360. * @param result defines the Vector3 where to store the result
  75361. */
  75362. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  75363. /**
  75364. * Project a Vector3 onto screen space
  75365. * @param vector defines the Vector3 to project
  75366. * @param world defines the world matrix to use
  75367. * @param transform defines the transform (view x projection) matrix to use
  75368. * @param viewport defines the screen viewport to use
  75369. * @returns the new Vector3
  75370. */
  75371. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  75372. /** @hidden */
  75373. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  75374. /**
  75375. * Unproject from screen space to object space
  75376. * @param source defines the screen space Vector3 to use
  75377. * @param viewportWidth defines the current width of the viewport
  75378. * @param viewportHeight defines the current height of the viewport
  75379. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75380. * @param transform defines the transform (view x projection) matrix to use
  75381. * @returns the new Vector3
  75382. */
  75383. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  75384. /**
  75385. * Unproject from screen space to object space
  75386. * @param source defines the screen space Vector3 to use
  75387. * @param viewportWidth defines the current width of the viewport
  75388. * @param viewportHeight defines the current height of the viewport
  75389. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75390. * @param view defines the view matrix to use
  75391. * @param projection defines the projection matrix to use
  75392. * @returns the new Vector3
  75393. */
  75394. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  75395. /**
  75396. * Unproject from screen space to object space
  75397. * @param source defines the screen space Vector3 to use
  75398. * @param viewportWidth defines the current width of the viewport
  75399. * @param viewportHeight defines the current height of the viewport
  75400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75401. * @param view defines the view matrix to use
  75402. * @param projection defines the projection matrix to use
  75403. * @param result defines the Vector3 where to store the result
  75404. */
  75405. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75406. /**
  75407. * Unproject from screen space to object space
  75408. * @param sourceX defines the screen space x coordinate to use
  75409. * @param sourceY defines the screen space y coordinate to use
  75410. * @param sourceZ defines the screen space z coordinate to use
  75411. * @param viewportWidth defines the current width of the viewport
  75412. * @param viewportHeight defines the current height of the viewport
  75413. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75414. * @param view defines the view matrix to use
  75415. * @param projection defines the projection matrix to use
  75416. * @param result defines the Vector3 where to store the result
  75417. */
  75418. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75419. /**
  75420. * Gets the minimal coordinate values between two Vector3
  75421. * @param left defines the first operand
  75422. * @param right defines the second operand
  75423. * @returns the new Vector3
  75424. */
  75425. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75426. /**
  75427. * Gets the maximal coordinate values between two Vector3
  75428. * @param left defines the first operand
  75429. * @param right defines the second operand
  75430. * @returns the new Vector3
  75431. */
  75432. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75433. /**
  75434. * Returns the distance between the vectors "value1" and "value2"
  75435. * @param value1 defines the first operand
  75436. * @param value2 defines the second operand
  75437. * @returns the distance
  75438. */
  75439. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75440. /**
  75441. * Returns the squared distance between the vectors "value1" and "value2"
  75442. * @param value1 defines the first operand
  75443. * @param value2 defines the second operand
  75444. * @returns the squared distance
  75445. */
  75446. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75447. /**
  75448. * Returns a new Vector3 located at the center between "value1" and "value2"
  75449. * @param value1 defines the first operand
  75450. * @param value2 defines the second operand
  75451. * @returns the new Vector3
  75452. */
  75453. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  75454. /**
  75455. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  75456. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  75457. * to something in order to rotate it from its local system to the given target system
  75458. * Note: axis1, axis2 and axis3 are normalized during this operation
  75459. * @param axis1 defines the first axis
  75460. * @param axis2 defines the second axis
  75461. * @param axis3 defines the third axis
  75462. * @returns a new Vector3
  75463. */
  75464. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  75465. /**
  75466. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  75467. * @param axis1 defines the first axis
  75468. * @param axis2 defines the second axis
  75469. * @param axis3 defines the third axis
  75470. * @param ref defines the Vector3 where to store the result
  75471. */
  75472. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  75473. }
  75474. /**
  75475. * Vector4 class created for EulerAngle class conversion to Quaternion
  75476. */
  75477. export class Vector4 {
  75478. /** x value of the vector */
  75479. x: number;
  75480. /** y value of the vector */
  75481. y: number;
  75482. /** z value of the vector */
  75483. z: number;
  75484. /** w value of the vector */
  75485. w: number;
  75486. /**
  75487. * Creates a Vector4 object from the given floats.
  75488. * @param x x value of the vector
  75489. * @param y y value of the vector
  75490. * @param z z value of the vector
  75491. * @param w w value of the vector
  75492. */
  75493. constructor(
  75494. /** x value of the vector */
  75495. x: number,
  75496. /** y value of the vector */
  75497. y: number,
  75498. /** z value of the vector */
  75499. z: number,
  75500. /** w value of the vector */
  75501. w: number);
  75502. /**
  75503. * Returns the string with the Vector4 coordinates.
  75504. * @returns a string containing all the vector values
  75505. */
  75506. toString(): string;
  75507. /**
  75508. * Returns the string "Vector4".
  75509. * @returns "Vector4"
  75510. */
  75511. getClassName(): string;
  75512. /**
  75513. * Returns the Vector4 hash code.
  75514. * @returns a unique hash code
  75515. */
  75516. getHashCode(): number;
  75517. /**
  75518. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  75519. * @returns the resulting array
  75520. */
  75521. asArray(): number[];
  75522. /**
  75523. * Populates the given array from the given index with the Vector4 coordinates.
  75524. * @param array array to populate
  75525. * @param index index of the array to start at (default: 0)
  75526. * @returns the Vector4.
  75527. */
  75528. toArray(array: FloatArray, index?: number): Vector4;
  75529. /**
  75530. * Adds the given vector to the current Vector4.
  75531. * @param otherVector the vector to add
  75532. * @returns the updated Vector4.
  75533. */
  75534. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75535. /**
  75536. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  75537. * @param otherVector the vector to add
  75538. * @returns the resulting vector
  75539. */
  75540. add(otherVector: DeepImmutable<Vector4>): Vector4;
  75541. /**
  75542. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  75543. * @param otherVector the vector to add
  75544. * @param result the vector to store the result
  75545. * @returns the current Vector4.
  75546. */
  75547. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75548. /**
  75549. * Subtract in place the given vector from the current Vector4.
  75550. * @param otherVector the vector to subtract
  75551. * @returns the updated Vector4.
  75552. */
  75553. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75554. /**
  75555. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  75556. * @param otherVector the vector to add
  75557. * @returns the new vector with the result
  75558. */
  75559. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  75560. /**
  75561. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  75562. * @param otherVector the vector to subtract
  75563. * @param result the vector to store the result
  75564. * @returns the current Vector4.
  75565. */
  75566. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75567. /**
  75568. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75569. */
  75570. /**
  75571. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75572. * @param x value to subtract
  75573. * @param y value to subtract
  75574. * @param z value to subtract
  75575. * @param w value to subtract
  75576. * @returns new vector containing the result
  75577. */
  75578. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  75579. /**
  75580. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75581. * @param x value to subtract
  75582. * @param y value to subtract
  75583. * @param z value to subtract
  75584. * @param w value to subtract
  75585. * @param result the vector to store the result in
  75586. * @returns the current Vector4.
  75587. */
  75588. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  75589. /**
  75590. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  75591. * @returns a new vector with the negated values
  75592. */
  75593. negate(): Vector4;
  75594. /**
  75595. * Multiplies the current Vector4 coordinates by scale (float).
  75596. * @param scale the number to scale with
  75597. * @returns the updated Vector4.
  75598. */
  75599. scaleInPlace(scale: number): Vector4;
  75600. /**
  75601. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  75602. * @param scale the number to scale with
  75603. * @returns a new vector with the result
  75604. */
  75605. scale(scale: number): Vector4;
  75606. /**
  75607. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  75608. * @param scale the number to scale with
  75609. * @param result a vector to store the result in
  75610. * @returns the current Vector4.
  75611. */
  75612. scaleToRef(scale: number, result: Vector4): Vector4;
  75613. /**
  75614. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  75615. * @param scale defines the scale factor
  75616. * @param result defines the Vector4 object where to store the result
  75617. * @returns the unmodified current Vector4
  75618. */
  75619. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  75620. /**
  75621. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  75622. * @param otherVector the vector to compare against
  75623. * @returns true if they are equal
  75624. */
  75625. equals(otherVector: DeepImmutable<Vector4>): boolean;
  75626. /**
  75627. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  75628. * @param otherVector vector to compare against
  75629. * @param epsilon (Default: very small number)
  75630. * @returns true if they are equal
  75631. */
  75632. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  75633. /**
  75634. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  75635. * @param x x value to compare against
  75636. * @param y y value to compare against
  75637. * @param z z value to compare against
  75638. * @param w w value to compare against
  75639. * @returns true if equal
  75640. */
  75641. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  75642. /**
  75643. * Multiplies in place the current Vector4 by the given one.
  75644. * @param otherVector vector to multiple with
  75645. * @returns the updated Vector4.
  75646. */
  75647. multiplyInPlace(otherVector: Vector4): Vector4;
  75648. /**
  75649. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  75650. * @param otherVector vector to multiple with
  75651. * @returns resulting new vector
  75652. */
  75653. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  75654. /**
  75655. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  75656. * @param otherVector vector to multiple with
  75657. * @param result vector to store the result
  75658. * @returns the current Vector4.
  75659. */
  75660. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75661. /**
  75662. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  75663. * @param x x value multiply with
  75664. * @param y y value multiply with
  75665. * @param z z value multiply with
  75666. * @param w w value multiply with
  75667. * @returns resulting new vector
  75668. */
  75669. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  75670. /**
  75671. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  75672. * @param otherVector vector to devide with
  75673. * @returns resulting new vector
  75674. */
  75675. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  75676. /**
  75677. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  75678. * @param otherVector vector to devide with
  75679. * @param result vector to store the result
  75680. * @returns the current Vector4.
  75681. */
  75682. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75683. /**
  75684. * Divides the current Vector3 coordinates by the given ones.
  75685. * @param otherVector vector to devide with
  75686. * @returns the updated Vector3.
  75687. */
  75688. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75689. /**
  75690. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  75691. * @param other defines the second operand
  75692. * @returns the current updated Vector4
  75693. */
  75694. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  75695. /**
  75696. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  75697. * @param other defines the second operand
  75698. * @returns the current updated Vector4
  75699. */
  75700. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  75701. /**
  75702. * Gets a new Vector4 from current Vector4 floored values
  75703. * @returns a new Vector4
  75704. */
  75705. floor(): Vector4;
  75706. /**
  75707. * Gets a new Vector4 from current Vector3 floored values
  75708. * @returns a new Vector4
  75709. */
  75710. fract(): Vector4;
  75711. /**
  75712. * Returns the Vector4 length (float).
  75713. * @returns the length
  75714. */
  75715. length(): number;
  75716. /**
  75717. * Returns the Vector4 squared length (float).
  75718. * @returns the length squared
  75719. */
  75720. lengthSquared(): number;
  75721. /**
  75722. * Normalizes in place the Vector4.
  75723. * @returns the updated Vector4.
  75724. */
  75725. normalize(): Vector4;
  75726. /**
  75727. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  75728. * @returns this converted to a new vector3
  75729. */
  75730. toVector3(): Vector3;
  75731. /**
  75732. * Returns a new Vector4 copied from the current one.
  75733. * @returns the new cloned vector
  75734. */
  75735. clone(): Vector4;
  75736. /**
  75737. * Updates the current Vector4 with the given one coordinates.
  75738. * @param source the source vector to copy from
  75739. * @returns the updated Vector4.
  75740. */
  75741. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  75742. /**
  75743. * Updates the current Vector4 coordinates with the given floats.
  75744. * @param x float to copy from
  75745. * @param y float to copy from
  75746. * @param z float to copy from
  75747. * @param w float to copy from
  75748. * @returns the updated Vector4.
  75749. */
  75750. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  75751. /**
  75752. * Updates the current Vector4 coordinates with the given floats.
  75753. * @param x float to set from
  75754. * @param y float to set from
  75755. * @param z float to set from
  75756. * @param w float to set from
  75757. * @returns the updated Vector4.
  75758. */
  75759. set(x: number, y: number, z: number, w: number): Vector4;
  75760. /**
  75761. * Copies the given float to the current Vector3 coordinates
  75762. * @param v defines the x, y, z and w coordinates of the operand
  75763. * @returns the current updated Vector3
  75764. */
  75765. setAll(v: number): Vector4;
  75766. /**
  75767. * Returns a new Vector4 set from the starting index of the given array.
  75768. * @param array the array to pull values from
  75769. * @param offset the offset into the array to start at
  75770. * @returns the new vector
  75771. */
  75772. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  75773. /**
  75774. * Updates the given vector "result" from the starting index of the given array.
  75775. * @param array the array to pull values from
  75776. * @param offset the offset into the array to start at
  75777. * @param result the vector to store the result in
  75778. */
  75779. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  75780. /**
  75781. * Updates the given vector "result" from the starting index of the given Float32Array.
  75782. * @param array the array to pull values from
  75783. * @param offset the offset into the array to start at
  75784. * @param result the vector to store the result in
  75785. */
  75786. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  75787. /**
  75788. * Updates the given vector "result" coordinates from the given floats.
  75789. * @param x float to set from
  75790. * @param y float to set from
  75791. * @param z float to set from
  75792. * @param w float to set from
  75793. * @param result the vector to the floats in
  75794. */
  75795. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  75796. /**
  75797. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  75798. * @returns the new vector
  75799. */
  75800. static Zero(): Vector4;
  75801. /**
  75802. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  75803. * @returns the new vector
  75804. */
  75805. static One(): Vector4;
  75806. /**
  75807. * Returns a new normalized Vector4 from the given one.
  75808. * @param vector the vector to normalize
  75809. * @returns the vector
  75810. */
  75811. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  75812. /**
  75813. * Updates the given vector "result" from the normalization of the given one.
  75814. * @param vector the vector to normalize
  75815. * @param result the vector to store the result in
  75816. */
  75817. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  75818. /**
  75819. * Returns a vector with the minimum values from the left and right vectors
  75820. * @param left left vector to minimize
  75821. * @param right right vector to minimize
  75822. * @returns a new vector with the minimum of the left and right vector values
  75823. */
  75824. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  75825. /**
  75826. * Returns a vector with the maximum values from the left and right vectors
  75827. * @param left left vector to maximize
  75828. * @param right right vector to maximize
  75829. * @returns a new vector with the maximum of the left and right vector values
  75830. */
  75831. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  75832. /**
  75833. * Returns the distance (float) between the vectors "value1" and "value2".
  75834. * @param value1 value to calulate the distance between
  75835. * @param value2 value to calulate the distance between
  75836. * @return the distance between the two vectors
  75837. */
  75838. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  75839. /**
  75840. * Returns the squared distance (float) between the vectors "value1" and "value2".
  75841. * @param value1 value to calulate the distance between
  75842. * @param value2 value to calulate the distance between
  75843. * @return the distance between the two vectors squared
  75844. */
  75845. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  75846. /**
  75847. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  75848. * @param value1 value to calulate the center between
  75849. * @param value2 value to calulate the center between
  75850. * @return the center between the two vectors
  75851. */
  75852. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  75853. /**
  75854. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  75855. * This methods computes transformed normalized direction vectors only.
  75856. * @param vector the vector to transform
  75857. * @param transformation the transformation matrix to apply
  75858. * @returns the new vector
  75859. */
  75860. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  75861. /**
  75862. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  75863. * This methods computes transformed normalized direction vectors only.
  75864. * @param vector the vector to transform
  75865. * @param transformation the transformation matrix to apply
  75866. * @param result the vector to store the result in
  75867. */
  75868. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  75869. /**
  75870. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  75871. * This methods computes transformed normalized direction vectors only.
  75872. * @param x value to transform
  75873. * @param y value to transform
  75874. * @param z value to transform
  75875. * @param w value to transform
  75876. * @param transformation the transformation matrix to apply
  75877. * @param result the vector to store the results in
  75878. */
  75879. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  75880. /**
  75881. * Creates a new Vector4 from a Vector3
  75882. * @param source defines the source data
  75883. * @param w defines the 4th component (default is 0)
  75884. * @returns a new Vector4
  75885. */
  75886. static FromVector3(source: Vector3, w?: number): Vector4;
  75887. }
  75888. /**
  75889. * Class used to store quaternion data
  75890. * @see https://en.wikipedia.org/wiki/Quaternion
  75891. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  75892. */
  75893. export class Quaternion {
  75894. /** defines the first component (0 by default) */
  75895. x: number;
  75896. /** defines the second component (0 by default) */
  75897. y: number;
  75898. /** defines the third component (0 by default) */
  75899. z: number;
  75900. /** defines the fourth component (1.0 by default) */
  75901. w: number;
  75902. /**
  75903. * Creates a new Quaternion from the given floats
  75904. * @param x defines the first component (0 by default)
  75905. * @param y defines the second component (0 by default)
  75906. * @param z defines the third component (0 by default)
  75907. * @param w defines the fourth component (1.0 by default)
  75908. */
  75909. constructor(
  75910. /** defines the first component (0 by default) */
  75911. x?: number,
  75912. /** defines the second component (0 by default) */
  75913. y?: number,
  75914. /** defines the third component (0 by default) */
  75915. z?: number,
  75916. /** defines the fourth component (1.0 by default) */
  75917. w?: number);
  75918. /**
  75919. * Gets a string representation for the current quaternion
  75920. * @returns a string with the Quaternion coordinates
  75921. */
  75922. toString(): string;
  75923. /**
  75924. * Gets the class name of the quaternion
  75925. * @returns the string "Quaternion"
  75926. */
  75927. getClassName(): string;
  75928. /**
  75929. * Gets a hash code for this quaternion
  75930. * @returns the quaternion hash code
  75931. */
  75932. getHashCode(): number;
  75933. /**
  75934. * Copy the quaternion to an array
  75935. * @returns a new array populated with 4 elements from the quaternion coordinates
  75936. */
  75937. asArray(): number[];
  75938. /**
  75939. * Check if two quaternions are equals
  75940. * @param otherQuaternion defines the second operand
  75941. * @return true if the current quaternion and the given one coordinates are strictly equals
  75942. */
  75943. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  75944. /**
  75945. * Gets a boolean if two quaternions are equals (using an epsilon value)
  75946. * @param otherQuaternion defines the other quaternion
  75947. * @param epsilon defines the minimal distance to consider equality
  75948. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  75949. */
  75950. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  75951. /**
  75952. * Clone the current quaternion
  75953. * @returns a new quaternion copied from the current one
  75954. */
  75955. clone(): Quaternion;
  75956. /**
  75957. * Copy a quaternion to the current one
  75958. * @param other defines the other quaternion
  75959. * @returns the updated current quaternion
  75960. */
  75961. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  75962. /**
  75963. * Updates the current quaternion with the given float coordinates
  75964. * @param x defines the x coordinate
  75965. * @param y defines the y coordinate
  75966. * @param z defines the z coordinate
  75967. * @param w defines the w coordinate
  75968. * @returns the updated current quaternion
  75969. */
  75970. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  75971. /**
  75972. * Updates the current quaternion from the given float coordinates
  75973. * @param x defines the x coordinate
  75974. * @param y defines the y coordinate
  75975. * @param z defines the z coordinate
  75976. * @param w defines the w coordinate
  75977. * @returns the updated current quaternion
  75978. */
  75979. set(x: number, y: number, z: number, w: number): Quaternion;
  75980. /**
  75981. * Adds two quaternions
  75982. * @param other defines the second operand
  75983. * @returns a new quaternion as the addition result of the given one and the current quaternion
  75984. */
  75985. add(other: DeepImmutable<Quaternion>): Quaternion;
  75986. /**
  75987. * Add a quaternion to the current one
  75988. * @param other defines the quaternion to add
  75989. * @returns the current quaternion
  75990. */
  75991. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  75992. /**
  75993. * Subtract two quaternions
  75994. * @param other defines the second operand
  75995. * @returns a new quaternion as the subtraction result of the given one from the current one
  75996. */
  75997. subtract(other: Quaternion): Quaternion;
  75998. /**
  75999. * Multiplies the current quaternion by a scale factor
  76000. * @param value defines the scale factor
  76001. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76002. */
  76003. scale(value: number): Quaternion;
  76004. /**
  76005. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76006. * @param scale defines the scale factor
  76007. * @param result defines the Quaternion object where to store the result
  76008. * @returns the unmodified current quaternion
  76009. */
  76010. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76011. /**
  76012. * Multiplies in place the current quaternion by a scale factor
  76013. * @param value defines the scale factor
  76014. * @returns the current modified quaternion
  76015. */
  76016. scaleInPlace(value: number): Quaternion;
  76017. /**
  76018. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76019. * @param scale defines the scale factor
  76020. * @param result defines the Quaternion object where to store the result
  76021. * @returns the unmodified current quaternion
  76022. */
  76023. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76024. /**
  76025. * Multiplies two quaternions
  76026. * @param q1 defines the second operand
  76027. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76028. */
  76029. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76030. /**
  76031. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76032. * @param q1 defines the second operand
  76033. * @param result defines the target quaternion
  76034. * @returns the current quaternion
  76035. */
  76036. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76037. /**
  76038. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76039. * @param q1 defines the second operand
  76040. * @returns the currentupdated quaternion
  76041. */
  76042. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76043. /**
  76044. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76045. * @param ref defines the target quaternion
  76046. * @returns the current quaternion
  76047. */
  76048. conjugateToRef(ref: Quaternion): Quaternion;
  76049. /**
  76050. * Conjugates in place (1-q) the current quaternion
  76051. * @returns the current updated quaternion
  76052. */
  76053. conjugateInPlace(): Quaternion;
  76054. /**
  76055. * Conjugates in place (1-q) the current quaternion
  76056. * @returns a new quaternion
  76057. */
  76058. conjugate(): Quaternion;
  76059. /**
  76060. * Gets length of current quaternion
  76061. * @returns the quaternion length (float)
  76062. */
  76063. length(): number;
  76064. /**
  76065. * Normalize in place the current quaternion
  76066. * @returns the current updated quaternion
  76067. */
  76068. normalize(): Quaternion;
  76069. /**
  76070. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76071. * @param order is a reserved parameter and is ignore for now
  76072. * @returns a new Vector3 containing the Euler angles
  76073. */
  76074. toEulerAngles(order?: string): Vector3;
  76075. /**
  76076. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76077. * @param result defines the vector which will be filled with the Euler angles
  76078. * @param order is a reserved parameter and is ignore for now
  76079. * @returns the current unchanged quaternion
  76080. */
  76081. toEulerAnglesToRef(result: Vector3): Quaternion;
  76082. /**
  76083. * Updates the given rotation matrix with the current quaternion values
  76084. * @param result defines the target matrix
  76085. * @returns the current unchanged quaternion
  76086. */
  76087. toRotationMatrix(result: Matrix): Quaternion;
  76088. /**
  76089. * Updates the current quaternion from the given rotation matrix values
  76090. * @param matrix defines the source matrix
  76091. * @returns the current updated quaternion
  76092. */
  76093. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76094. /**
  76095. * Creates a new quaternion from a rotation matrix
  76096. * @param matrix defines the source matrix
  76097. * @returns a new quaternion created from the given rotation matrix values
  76098. */
  76099. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76100. /**
  76101. * Updates the given quaternion with the given rotation matrix values
  76102. * @param matrix defines the source matrix
  76103. * @param result defines the target quaternion
  76104. */
  76105. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76106. /**
  76107. * Returns the dot product (float) between the quaternions "left" and "right"
  76108. * @param left defines the left operand
  76109. * @param right defines the right operand
  76110. * @returns the dot product
  76111. */
  76112. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76113. /**
  76114. * Checks if the two quaternions are close to each other
  76115. * @param quat0 defines the first quaternion to check
  76116. * @param quat1 defines the second quaternion to check
  76117. * @returns true if the two quaternions are close to each other
  76118. */
  76119. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76120. /**
  76121. * Creates an empty quaternion
  76122. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76123. */
  76124. static Zero(): Quaternion;
  76125. /**
  76126. * Inverse a given quaternion
  76127. * @param q defines the source quaternion
  76128. * @returns a new quaternion as the inverted current quaternion
  76129. */
  76130. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76131. /**
  76132. * Inverse a given quaternion
  76133. * @param q defines the source quaternion
  76134. * @param result the quaternion the result will be stored in
  76135. * @returns the result quaternion
  76136. */
  76137. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76138. /**
  76139. * Creates an identity quaternion
  76140. * @returns the identity quaternion
  76141. */
  76142. static Identity(): Quaternion;
  76143. /**
  76144. * Gets a boolean indicating if the given quaternion is identity
  76145. * @param quaternion defines the quaternion to check
  76146. * @returns true if the quaternion is identity
  76147. */
  76148. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76149. /**
  76150. * Creates a quaternion from a rotation around an axis
  76151. * @param axis defines the axis to use
  76152. * @param angle defines the angle to use
  76153. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76154. */
  76155. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76156. /**
  76157. * Creates a rotation around an axis and stores it into the given quaternion
  76158. * @param axis defines the axis to use
  76159. * @param angle defines the angle to use
  76160. * @param result defines the target quaternion
  76161. * @returns the target quaternion
  76162. */
  76163. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76164. /**
  76165. * Creates a new quaternion from data stored into an array
  76166. * @param array defines the data source
  76167. * @param offset defines the offset in the source array where the data starts
  76168. * @returns a new quaternion
  76169. */
  76170. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76171. /**
  76172. * Create a quaternion from Euler rotation angles
  76173. * @param x Pitch
  76174. * @param y Yaw
  76175. * @param z Roll
  76176. * @returns the new Quaternion
  76177. */
  76178. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76179. /**
  76180. * Updates a quaternion from Euler rotation angles
  76181. * @param x Pitch
  76182. * @param y Yaw
  76183. * @param z Roll
  76184. * @param result the quaternion to store the result
  76185. * @returns the updated quaternion
  76186. */
  76187. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76188. /**
  76189. * Create a quaternion from Euler rotation vector
  76190. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76191. * @returns the new Quaternion
  76192. */
  76193. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76194. /**
  76195. * Updates a quaternion from Euler rotation vector
  76196. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76197. * @param result the quaternion to store the result
  76198. * @returns the updated quaternion
  76199. */
  76200. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76201. /**
  76202. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76203. * @param yaw defines the rotation around Y axis
  76204. * @param pitch defines the rotation around X axis
  76205. * @param roll defines the rotation around Z axis
  76206. * @returns the new quaternion
  76207. */
  76208. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76209. /**
  76210. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76211. * @param yaw defines the rotation around Y axis
  76212. * @param pitch defines the rotation around X axis
  76213. * @param roll defines the rotation around Z axis
  76214. * @param result defines the target quaternion
  76215. */
  76216. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  76217. /**
  76218. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  76219. * @param alpha defines the rotation around first axis
  76220. * @param beta defines the rotation around second axis
  76221. * @param gamma defines the rotation around third axis
  76222. * @returns the new quaternion
  76223. */
  76224. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  76225. /**
  76226. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  76227. * @param alpha defines the rotation around first axis
  76228. * @param beta defines the rotation around second axis
  76229. * @param gamma defines the rotation around third axis
  76230. * @param result defines the target quaternion
  76231. */
  76232. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  76233. /**
  76234. * 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)
  76235. * @param axis1 defines the first axis
  76236. * @param axis2 defines the second axis
  76237. * @param axis3 defines the third axis
  76238. * @returns the new quaternion
  76239. */
  76240. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  76241. /**
  76242. * 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
  76243. * @param axis1 defines the first axis
  76244. * @param axis2 defines the second axis
  76245. * @param axis3 defines the third axis
  76246. * @param ref defines the target quaternion
  76247. */
  76248. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  76249. /**
  76250. * Interpolates between two quaternions
  76251. * @param left defines first quaternion
  76252. * @param right defines second quaternion
  76253. * @param amount defines the gradient to use
  76254. * @returns the new interpolated quaternion
  76255. */
  76256. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76257. /**
  76258. * Interpolates between two quaternions and stores it into a target quaternion
  76259. * @param left defines first quaternion
  76260. * @param right defines second quaternion
  76261. * @param amount defines the gradient to use
  76262. * @param result defines the target quaternion
  76263. */
  76264. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  76265. /**
  76266. * Interpolate between two quaternions using Hermite interpolation
  76267. * @param value1 defines first quaternion
  76268. * @param tangent1 defines the incoming tangent
  76269. * @param value2 defines second quaternion
  76270. * @param tangent2 defines the outgoing tangent
  76271. * @param amount defines the target quaternion
  76272. * @returns the new interpolated quaternion
  76273. */
  76274. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76275. }
  76276. /**
  76277. * Class used to store matrix data (4x4)
  76278. */
  76279. export class Matrix {
  76280. private static _updateFlagSeed;
  76281. private static _identityReadOnly;
  76282. private _isIdentity;
  76283. private _isIdentityDirty;
  76284. private _isIdentity3x2;
  76285. private _isIdentity3x2Dirty;
  76286. /**
  76287. * Gets the update flag of the matrix which is an unique number for the matrix.
  76288. * It will be incremented every time the matrix data change.
  76289. * You can use it to speed the comparison between two versions of the same matrix.
  76290. */
  76291. updateFlag: number;
  76292. private readonly _m;
  76293. /**
  76294. * Gets the internal data of the matrix
  76295. */
  76296. get m(): DeepImmutable<Float32Array>;
  76297. /** @hidden */
  76298. _markAsUpdated(): void;
  76299. /** @hidden */
  76300. private _updateIdentityStatus;
  76301. /**
  76302. * Creates an empty matrix (filled with zeros)
  76303. */
  76304. constructor();
  76305. /**
  76306. * Check if the current matrix is identity
  76307. * @returns true is the matrix is the identity matrix
  76308. */
  76309. isIdentity(): boolean;
  76310. /**
  76311. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  76312. * @returns true is the matrix is the identity matrix
  76313. */
  76314. isIdentityAs3x2(): boolean;
  76315. /**
  76316. * Gets the determinant of the matrix
  76317. * @returns the matrix determinant
  76318. */
  76319. determinant(): number;
  76320. /**
  76321. * Returns the matrix as a Float32Array
  76322. * @returns the matrix underlying array
  76323. */
  76324. toArray(): DeepImmutable<Float32Array>;
  76325. /**
  76326. * Returns the matrix as a Float32Array
  76327. * @returns the matrix underlying array.
  76328. */
  76329. asArray(): DeepImmutable<Float32Array>;
  76330. /**
  76331. * Inverts the current matrix in place
  76332. * @returns the current inverted matrix
  76333. */
  76334. invert(): Matrix;
  76335. /**
  76336. * Sets all the matrix elements to zero
  76337. * @returns the current matrix
  76338. */
  76339. reset(): Matrix;
  76340. /**
  76341. * Adds the current matrix with a second one
  76342. * @param other defines the matrix to add
  76343. * @returns a new matrix as the addition of the current matrix and the given one
  76344. */
  76345. add(other: DeepImmutable<Matrix>): Matrix;
  76346. /**
  76347. * Sets the given matrix "result" to the addition of the current matrix and the given one
  76348. * @param other defines the matrix to add
  76349. * @param result defines the target matrix
  76350. * @returns the current matrix
  76351. */
  76352. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76353. /**
  76354. * Adds in place the given matrix to the current matrix
  76355. * @param other defines the second operand
  76356. * @returns the current updated matrix
  76357. */
  76358. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  76359. /**
  76360. * Sets the given matrix to the current inverted Matrix
  76361. * @param other defines the target matrix
  76362. * @returns the unmodified current matrix
  76363. */
  76364. invertToRef(other: Matrix): Matrix;
  76365. /**
  76366. * add a value at the specified position in the current Matrix
  76367. * @param index the index of the value within the matrix. between 0 and 15.
  76368. * @param value the value to be added
  76369. * @returns the current updated matrix
  76370. */
  76371. addAtIndex(index: number, value: number): Matrix;
  76372. /**
  76373. * mutiply the specified position in the current Matrix by a value
  76374. * @param index the index of the value within the matrix. between 0 and 15.
  76375. * @param value the value to be added
  76376. * @returns the current updated matrix
  76377. */
  76378. multiplyAtIndex(index: number, value: number): Matrix;
  76379. /**
  76380. * Inserts the translation vector (using 3 floats) in the current matrix
  76381. * @param x defines the 1st component of the translation
  76382. * @param y defines the 2nd component of the translation
  76383. * @param z defines the 3rd component of the translation
  76384. * @returns the current updated matrix
  76385. */
  76386. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76387. /**
  76388. * Adds the translation vector (using 3 floats) in the current matrix
  76389. * @param x defines the 1st component of the translation
  76390. * @param y defines the 2nd component of the translation
  76391. * @param z defines the 3rd component of the translation
  76392. * @returns the current updated matrix
  76393. */
  76394. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76395. /**
  76396. * Inserts the translation vector in the current matrix
  76397. * @param vector3 defines the translation to insert
  76398. * @returns the current updated matrix
  76399. */
  76400. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  76401. /**
  76402. * Gets the translation value of the current matrix
  76403. * @returns a new Vector3 as the extracted translation from the matrix
  76404. */
  76405. getTranslation(): Vector3;
  76406. /**
  76407. * Fill a Vector3 with the extracted translation from the matrix
  76408. * @param result defines the Vector3 where to store the translation
  76409. * @returns the current matrix
  76410. */
  76411. getTranslationToRef(result: Vector3): Matrix;
  76412. /**
  76413. * Remove rotation and scaling part from the matrix
  76414. * @returns the updated matrix
  76415. */
  76416. removeRotationAndScaling(): Matrix;
  76417. /**
  76418. * Multiply two matrices
  76419. * @param other defines the second operand
  76420. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  76421. */
  76422. multiply(other: DeepImmutable<Matrix>): Matrix;
  76423. /**
  76424. * Copy the current matrix from the given one
  76425. * @param other defines the source matrix
  76426. * @returns the current updated matrix
  76427. */
  76428. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  76429. /**
  76430. * Populates the given array from the starting index with the current matrix values
  76431. * @param array defines the target array
  76432. * @param offset defines the offset in the target array where to start storing values
  76433. * @returns the current matrix
  76434. */
  76435. copyToArray(array: Float32Array, offset?: number): Matrix;
  76436. /**
  76437. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  76438. * @param other defines the second operand
  76439. * @param result defines the matrix where to store the multiplication
  76440. * @returns the current matrix
  76441. */
  76442. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76443. /**
  76444. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  76445. * @param other defines the second operand
  76446. * @param result defines the array where to store the multiplication
  76447. * @param offset defines the offset in the target array where to start storing values
  76448. * @returns the current matrix
  76449. */
  76450. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  76451. /**
  76452. * Check equality between this matrix and a second one
  76453. * @param value defines the second matrix to compare
  76454. * @returns true is the current matrix and the given one values are strictly equal
  76455. */
  76456. equals(value: DeepImmutable<Matrix>): boolean;
  76457. /**
  76458. * Clone the current matrix
  76459. * @returns a new matrix from the current matrix
  76460. */
  76461. clone(): Matrix;
  76462. /**
  76463. * Returns the name of the current matrix class
  76464. * @returns the string "Matrix"
  76465. */
  76466. getClassName(): string;
  76467. /**
  76468. * Gets the hash code of the current matrix
  76469. * @returns the hash code
  76470. */
  76471. getHashCode(): number;
  76472. /**
  76473. * Decomposes the current Matrix into a translation, rotation and scaling components
  76474. * @param scale defines the scale vector3 given as a reference to update
  76475. * @param rotation defines the rotation quaternion given as a reference to update
  76476. * @param translation defines the translation vector3 given as a reference to update
  76477. * @returns true if operation was successful
  76478. */
  76479. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  76480. /**
  76481. * Gets specific row of the matrix
  76482. * @param index defines the number of the row to get
  76483. * @returns the index-th row of the current matrix as a new Vector4
  76484. */
  76485. getRow(index: number): Nullable<Vector4>;
  76486. /**
  76487. * Sets the index-th row of the current matrix to the vector4 values
  76488. * @param index defines the number of the row to set
  76489. * @param row defines the target vector4
  76490. * @returns the updated current matrix
  76491. */
  76492. setRow(index: number, row: Vector4): Matrix;
  76493. /**
  76494. * Compute the transpose of the matrix
  76495. * @returns the new transposed matrix
  76496. */
  76497. transpose(): Matrix;
  76498. /**
  76499. * Compute the transpose of the matrix and store it in a given matrix
  76500. * @param result defines the target matrix
  76501. * @returns the current matrix
  76502. */
  76503. transposeToRef(result: Matrix): Matrix;
  76504. /**
  76505. * Sets the index-th row of the current matrix with the given 4 x float values
  76506. * @param index defines the row index
  76507. * @param x defines the x component to set
  76508. * @param y defines the y component to set
  76509. * @param z defines the z component to set
  76510. * @param w defines the w component to set
  76511. * @returns the updated current matrix
  76512. */
  76513. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  76514. /**
  76515. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  76516. * @param scale defines the scale factor
  76517. * @returns a new matrix
  76518. */
  76519. scale(scale: number): Matrix;
  76520. /**
  76521. * Scale the current matrix values by a factor to a given result matrix
  76522. * @param scale defines the scale factor
  76523. * @param result defines the matrix to store the result
  76524. * @returns the current matrix
  76525. */
  76526. scaleToRef(scale: number, result: Matrix): Matrix;
  76527. /**
  76528. * Scale the current matrix values by a factor and add the result to a given matrix
  76529. * @param scale defines the scale factor
  76530. * @param result defines the Matrix to store the result
  76531. * @returns the current matrix
  76532. */
  76533. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  76534. /**
  76535. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  76536. * @param ref matrix to store the result
  76537. */
  76538. toNormalMatrix(ref: Matrix): void;
  76539. /**
  76540. * Gets only rotation part of the current matrix
  76541. * @returns a new matrix sets to the extracted rotation matrix from the current one
  76542. */
  76543. getRotationMatrix(): Matrix;
  76544. /**
  76545. * Extracts the rotation matrix from the current one and sets it as the given "result"
  76546. * @param result defines the target matrix to store data to
  76547. * @returns the current matrix
  76548. */
  76549. getRotationMatrixToRef(result: Matrix): Matrix;
  76550. /**
  76551. * Toggles model matrix from being right handed to left handed in place and vice versa
  76552. */
  76553. toggleModelMatrixHandInPlace(): void;
  76554. /**
  76555. * Toggles projection matrix from being right handed to left handed in place and vice versa
  76556. */
  76557. toggleProjectionMatrixHandInPlace(): void;
  76558. /**
  76559. * Creates a matrix from an array
  76560. * @param array defines the source array
  76561. * @param offset defines an offset in the source array
  76562. * @returns a new Matrix set from the starting index of the given array
  76563. */
  76564. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  76565. /**
  76566. * Copy the content of an array into a given matrix
  76567. * @param array defines the source array
  76568. * @param offset defines an offset in the source array
  76569. * @param result defines the target matrix
  76570. */
  76571. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  76572. /**
  76573. * Stores an array into a matrix after having multiplied each component by a given factor
  76574. * @param array defines the source array
  76575. * @param offset defines the offset in the source array
  76576. * @param scale defines the scaling factor
  76577. * @param result defines the target matrix
  76578. */
  76579. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  76580. /**
  76581. * Gets an identity matrix that must not be updated
  76582. */
  76583. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  76584. /**
  76585. * Stores a list of values (16) inside a given matrix
  76586. * @param initialM11 defines 1st value of 1st row
  76587. * @param initialM12 defines 2nd value of 1st row
  76588. * @param initialM13 defines 3rd value of 1st row
  76589. * @param initialM14 defines 4th value of 1st row
  76590. * @param initialM21 defines 1st value of 2nd row
  76591. * @param initialM22 defines 2nd value of 2nd row
  76592. * @param initialM23 defines 3rd value of 2nd row
  76593. * @param initialM24 defines 4th value of 2nd row
  76594. * @param initialM31 defines 1st value of 3rd row
  76595. * @param initialM32 defines 2nd value of 3rd row
  76596. * @param initialM33 defines 3rd value of 3rd row
  76597. * @param initialM34 defines 4th value of 3rd row
  76598. * @param initialM41 defines 1st value of 4th row
  76599. * @param initialM42 defines 2nd value of 4th row
  76600. * @param initialM43 defines 3rd value of 4th row
  76601. * @param initialM44 defines 4th value of 4th row
  76602. * @param result defines the target matrix
  76603. */
  76604. 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;
  76605. /**
  76606. * Creates new matrix from a list of values (16)
  76607. * @param initialM11 defines 1st value of 1st row
  76608. * @param initialM12 defines 2nd value of 1st row
  76609. * @param initialM13 defines 3rd value of 1st row
  76610. * @param initialM14 defines 4th value of 1st row
  76611. * @param initialM21 defines 1st value of 2nd row
  76612. * @param initialM22 defines 2nd value of 2nd row
  76613. * @param initialM23 defines 3rd value of 2nd row
  76614. * @param initialM24 defines 4th value of 2nd row
  76615. * @param initialM31 defines 1st value of 3rd row
  76616. * @param initialM32 defines 2nd value of 3rd row
  76617. * @param initialM33 defines 3rd value of 3rd row
  76618. * @param initialM34 defines 4th value of 3rd row
  76619. * @param initialM41 defines 1st value of 4th row
  76620. * @param initialM42 defines 2nd value of 4th row
  76621. * @param initialM43 defines 3rd value of 4th row
  76622. * @param initialM44 defines 4th value of 4th row
  76623. * @returns the new matrix
  76624. */
  76625. 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;
  76626. /**
  76627. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76628. * @param scale defines the scale vector3
  76629. * @param rotation defines the rotation quaternion
  76630. * @param translation defines the translation vector3
  76631. * @returns a new matrix
  76632. */
  76633. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  76634. /**
  76635. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76636. * @param scale defines the scale vector3
  76637. * @param rotation defines the rotation quaternion
  76638. * @param translation defines the translation vector3
  76639. * @param result defines the target matrix
  76640. */
  76641. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  76642. /**
  76643. * Creates a new identity matrix
  76644. * @returns a new identity matrix
  76645. */
  76646. static Identity(): Matrix;
  76647. /**
  76648. * Creates a new identity matrix and stores the result in a given matrix
  76649. * @param result defines the target matrix
  76650. */
  76651. static IdentityToRef(result: Matrix): void;
  76652. /**
  76653. * Creates a new zero matrix
  76654. * @returns a new zero matrix
  76655. */
  76656. static Zero(): Matrix;
  76657. /**
  76658. * Creates a new rotation matrix for "angle" radians around the X axis
  76659. * @param angle defines the angle (in radians) to use
  76660. * @return the new matrix
  76661. */
  76662. static RotationX(angle: number): Matrix;
  76663. /**
  76664. * Creates a new matrix as the invert of a given matrix
  76665. * @param source defines the source matrix
  76666. * @returns the new matrix
  76667. */
  76668. static Invert(source: DeepImmutable<Matrix>): Matrix;
  76669. /**
  76670. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  76671. * @param angle defines the angle (in radians) to use
  76672. * @param result defines the target matrix
  76673. */
  76674. static RotationXToRef(angle: number, result: Matrix): void;
  76675. /**
  76676. * Creates a new rotation matrix for "angle" radians around the Y axis
  76677. * @param angle defines the angle (in radians) to use
  76678. * @return the new matrix
  76679. */
  76680. static RotationY(angle: number): Matrix;
  76681. /**
  76682. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  76683. * @param angle defines the angle (in radians) to use
  76684. * @param result defines the target matrix
  76685. */
  76686. static RotationYToRef(angle: number, result: Matrix): void;
  76687. /**
  76688. * Creates a new rotation matrix for "angle" radians around the Z axis
  76689. * @param angle defines the angle (in radians) to use
  76690. * @return the new matrix
  76691. */
  76692. static RotationZ(angle: number): Matrix;
  76693. /**
  76694. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  76695. * @param angle defines the angle (in radians) to use
  76696. * @param result defines the target matrix
  76697. */
  76698. static RotationZToRef(angle: number, result: Matrix): void;
  76699. /**
  76700. * Creates a new rotation matrix for "angle" radians around the given axis
  76701. * @param axis defines the axis to use
  76702. * @param angle defines the angle (in radians) to use
  76703. * @return the new matrix
  76704. */
  76705. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  76706. /**
  76707. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  76708. * @param axis defines the axis to use
  76709. * @param angle defines the angle (in radians) to use
  76710. * @param result defines the target matrix
  76711. */
  76712. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  76713. /**
  76714. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  76715. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  76716. * @param from defines the vector to align
  76717. * @param to defines the vector to align to
  76718. * @param result defines the target matrix
  76719. */
  76720. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  76721. /**
  76722. * Creates a rotation matrix
  76723. * @param yaw defines the yaw angle in radians (Y axis)
  76724. * @param pitch defines the pitch angle in radians (X axis)
  76725. * @param roll defines the roll angle in radians (X axis)
  76726. * @returns the new rotation matrix
  76727. */
  76728. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  76729. /**
  76730. * Creates a rotation matrix and stores it in a given matrix
  76731. * @param yaw defines the yaw angle in radians (Y axis)
  76732. * @param pitch defines the pitch angle in radians (X axis)
  76733. * @param roll defines the roll angle in radians (X axis)
  76734. * @param result defines the target matrix
  76735. */
  76736. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  76737. /**
  76738. * Creates a scaling matrix
  76739. * @param x defines the scale factor on X axis
  76740. * @param y defines the scale factor on Y axis
  76741. * @param z defines the scale factor on Z axis
  76742. * @returns the new matrix
  76743. */
  76744. static Scaling(x: number, y: number, z: number): Matrix;
  76745. /**
  76746. * Creates a scaling matrix and stores it in a given matrix
  76747. * @param x defines the scale factor on X axis
  76748. * @param y defines the scale factor on Y axis
  76749. * @param z defines the scale factor on Z axis
  76750. * @param result defines the target matrix
  76751. */
  76752. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  76753. /**
  76754. * Creates a translation matrix
  76755. * @param x defines the translation on X axis
  76756. * @param y defines the translation on Y axis
  76757. * @param z defines the translationon Z axis
  76758. * @returns the new matrix
  76759. */
  76760. static Translation(x: number, y: number, z: number): Matrix;
  76761. /**
  76762. * Creates a translation matrix and stores it in a given matrix
  76763. * @param x defines the translation on X axis
  76764. * @param y defines the translation on Y axis
  76765. * @param z defines the translationon Z axis
  76766. * @param result defines the target matrix
  76767. */
  76768. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  76769. /**
  76770. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76771. * @param startValue defines the start value
  76772. * @param endValue defines the end value
  76773. * @param gradient defines the gradient factor
  76774. * @returns the new matrix
  76775. */
  76776. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  76777. /**
  76778. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76779. * @param startValue defines the start value
  76780. * @param endValue defines the end value
  76781. * @param gradient defines the gradient factor
  76782. * @param result defines the Matrix object where to store data
  76783. */
  76784. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  76785. /**
  76786. * Builds a new matrix whose values are computed by:
  76787. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76788. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76789. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76790. * @param startValue defines the first matrix
  76791. * @param endValue defines the second matrix
  76792. * @param gradient defines the gradient between the two matrices
  76793. * @returns the new matrix
  76794. */
  76795. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  76796. /**
  76797. * Update a matrix to values which are computed by:
  76798. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76799. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76800. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76801. * @param startValue defines the first matrix
  76802. * @param endValue defines the second matrix
  76803. * @param gradient defines the gradient between the two matrices
  76804. * @param result defines the target matrix
  76805. */
  76806. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  76807. /**
  76808. * 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"
  76809. * This function works in left handed mode
  76810. * @param eye defines the final position of the entity
  76811. * @param target defines where the entity should look at
  76812. * @param up defines the up vector for the entity
  76813. * @returns the new matrix
  76814. */
  76815. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  76816. /**
  76817. * 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".
  76818. * This function works in left handed mode
  76819. * @param eye defines the final position of the entity
  76820. * @param target defines where the entity should look at
  76821. * @param up defines the up vector for the entity
  76822. * @param result defines the target matrix
  76823. */
  76824. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  76825. /**
  76826. * 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"
  76827. * This function works in right handed mode
  76828. * @param eye defines the final position of the entity
  76829. * @param target defines where the entity should look at
  76830. * @param up defines the up vector for the entity
  76831. * @returns the new matrix
  76832. */
  76833. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  76834. /**
  76835. * 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".
  76836. * This function works in right handed mode
  76837. * @param eye defines the final position of the entity
  76838. * @param target defines where the entity should look at
  76839. * @param up defines the up vector for the entity
  76840. * @param result defines the target matrix
  76841. */
  76842. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  76843. /**
  76844. * Create a left-handed orthographic projection matrix
  76845. * @param width defines the viewport width
  76846. * @param height defines the viewport height
  76847. * @param znear defines the near clip plane
  76848. * @param zfar defines the far clip plane
  76849. * @returns a new matrix as a left-handed orthographic projection matrix
  76850. */
  76851. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  76852. /**
  76853. * Store a left-handed orthographic projection to a given matrix
  76854. * @param width defines the viewport width
  76855. * @param height defines the viewport height
  76856. * @param znear defines the near clip plane
  76857. * @param zfar defines the far clip plane
  76858. * @param result defines the target matrix
  76859. */
  76860. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  76861. /**
  76862. * Create a left-handed orthographic projection matrix
  76863. * @param left defines the viewport left coordinate
  76864. * @param right defines the viewport right coordinate
  76865. * @param bottom defines the viewport bottom coordinate
  76866. * @param top defines the viewport top coordinate
  76867. * @param znear defines the near clip plane
  76868. * @param zfar defines the far clip plane
  76869. * @returns a new matrix as a left-handed orthographic projection matrix
  76870. */
  76871. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  76872. /**
  76873. * Stores a left-handed orthographic projection into a given matrix
  76874. * @param left defines the viewport left coordinate
  76875. * @param right defines the viewport right coordinate
  76876. * @param bottom defines the viewport bottom coordinate
  76877. * @param top defines the viewport top coordinate
  76878. * @param znear defines the near clip plane
  76879. * @param zfar defines the far clip plane
  76880. * @param result defines the target matrix
  76881. */
  76882. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  76883. /**
  76884. * Creates a right-handed orthographic projection matrix
  76885. * @param left defines the viewport left coordinate
  76886. * @param right defines the viewport right coordinate
  76887. * @param bottom defines the viewport bottom coordinate
  76888. * @param top defines the viewport top coordinate
  76889. * @param znear defines the near clip plane
  76890. * @param zfar defines the far clip plane
  76891. * @returns a new matrix as a right-handed orthographic projection matrix
  76892. */
  76893. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  76894. /**
  76895. * Stores a right-handed orthographic projection into a given matrix
  76896. * @param left defines the viewport left coordinate
  76897. * @param right defines the viewport right coordinate
  76898. * @param bottom defines the viewport bottom coordinate
  76899. * @param top defines the viewport top coordinate
  76900. * @param znear defines the near clip plane
  76901. * @param zfar defines the far clip plane
  76902. * @param result defines the target matrix
  76903. */
  76904. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  76905. /**
  76906. * Creates a left-handed perspective projection matrix
  76907. * @param width defines the viewport width
  76908. * @param height defines the viewport height
  76909. * @param znear defines the near clip plane
  76910. * @param zfar defines the far clip plane
  76911. * @returns a new matrix as a left-handed perspective projection matrix
  76912. */
  76913. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  76914. /**
  76915. * Creates a left-handed perspective projection matrix
  76916. * @param fov defines the horizontal field of view
  76917. * @param aspect defines the aspect ratio
  76918. * @param znear defines the near clip plane
  76919. * @param zfar defines the far clip plane
  76920. * @returns a new matrix as a left-handed perspective projection matrix
  76921. */
  76922. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  76923. /**
  76924. * Stores a left-handed perspective projection into a given matrix
  76925. * @param fov defines the horizontal field of view
  76926. * @param aspect defines the aspect ratio
  76927. * @param znear defines the near clip plane
  76928. * @param zfar defines the far clip plane
  76929. * @param result defines the target matrix
  76930. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76931. */
  76932. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76933. /**
  76934. * Stores a left-handed perspective projection into a given matrix with depth reversed
  76935. * @param fov defines the horizontal field of view
  76936. * @param aspect defines the aspect ratio
  76937. * @param znear defines the near clip plane
  76938. * @param zfar not used as infinity is used as far clip
  76939. * @param result defines the target matrix
  76940. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76941. */
  76942. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76943. /**
  76944. * Creates a right-handed perspective projection matrix
  76945. * @param fov defines the horizontal field of view
  76946. * @param aspect defines the aspect ratio
  76947. * @param znear defines the near clip plane
  76948. * @param zfar defines the far clip plane
  76949. * @returns a new matrix as a right-handed perspective projection matrix
  76950. */
  76951. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  76952. /**
  76953. * Stores a right-handed perspective projection into a given matrix
  76954. * @param fov defines the horizontal field of view
  76955. * @param aspect defines the aspect ratio
  76956. * @param znear defines the near clip plane
  76957. * @param zfar defines the far clip plane
  76958. * @param result defines the target matrix
  76959. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76960. */
  76961. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76962. /**
  76963. * Stores a right-handed perspective projection into a given matrix
  76964. * @param fov defines the horizontal field of view
  76965. * @param aspect defines the aspect ratio
  76966. * @param znear defines the near clip plane
  76967. * @param zfar not used as infinity is used as far clip
  76968. * @param result defines the target matrix
  76969. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76970. */
  76971. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76972. /**
  76973. * Stores a perspective projection for WebVR info a given matrix
  76974. * @param fov defines the field of view
  76975. * @param znear defines the near clip plane
  76976. * @param zfar defines the far clip plane
  76977. * @param result defines the target matrix
  76978. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  76979. */
  76980. static PerspectiveFovWebVRToRef(fov: {
  76981. upDegrees: number;
  76982. downDegrees: number;
  76983. leftDegrees: number;
  76984. rightDegrees: number;
  76985. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  76986. /**
  76987. * Computes a complete transformation matrix
  76988. * @param viewport defines the viewport to use
  76989. * @param world defines the world matrix
  76990. * @param view defines the view matrix
  76991. * @param projection defines the projection matrix
  76992. * @param zmin defines the near clip plane
  76993. * @param zmax defines the far clip plane
  76994. * @returns the transformation matrix
  76995. */
  76996. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  76997. /**
  76998. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  76999. * @param matrix defines the matrix to use
  77000. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77001. */
  77002. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77003. /**
  77004. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77005. * @param matrix defines the matrix to use
  77006. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77007. */
  77008. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77009. /**
  77010. * Compute the transpose of a given matrix
  77011. * @param matrix defines the matrix to transpose
  77012. * @returns the new matrix
  77013. */
  77014. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77015. /**
  77016. * Compute the transpose of a matrix and store it in a target matrix
  77017. * @param matrix defines the matrix to transpose
  77018. * @param result defines the target matrix
  77019. */
  77020. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77021. /**
  77022. * Computes a reflection matrix from a plane
  77023. * @param plane defines the reflection plane
  77024. * @returns a new matrix
  77025. */
  77026. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77027. /**
  77028. * Computes a reflection matrix from a plane
  77029. * @param plane defines the reflection plane
  77030. * @param result defines the target matrix
  77031. */
  77032. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77033. /**
  77034. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77035. * @param xaxis defines the value of the 1st axis
  77036. * @param yaxis defines the value of the 2nd axis
  77037. * @param zaxis defines the value of the 3rd axis
  77038. * @param result defines the target matrix
  77039. */
  77040. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77041. /**
  77042. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77043. * @param quat defines the quaternion to use
  77044. * @param result defines the target matrix
  77045. */
  77046. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77047. }
  77048. /**
  77049. * @hidden
  77050. */
  77051. export class TmpVectors {
  77052. static Vector2: Vector2[];
  77053. static Vector3: Vector3[];
  77054. static Vector4: Vector4[];
  77055. static Quaternion: Quaternion[];
  77056. static Matrix: Matrix[];
  77057. }
  77058. }
  77059. declare module BABYLON {
  77060. /**
  77061. * Defines potential orientation for back face culling
  77062. */
  77063. export enum Orientation {
  77064. /**
  77065. * Clockwise
  77066. */
  77067. CW = 0,
  77068. /** Counter clockwise */
  77069. CCW = 1
  77070. }
  77071. /** Class used to represent a Bezier curve */
  77072. export class BezierCurve {
  77073. /**
  77074. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77075. * @param t defines the time
  77076. * @param x1 defines the left coordinate on X axis
  77077. * @param y1 defines the left coordinate on Y axis
  77078. * @param x2 defines the right coordinate on X axis
  77079. * @param y2 defines the right coordinate on Y axis
  77080. * @returns the interpolated value
  77081. */
  77082. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77083. }
  77084. /**
  77085. * Defines angle representation
  77086. */
  77087. export class Angle {
  77088. private _radians;
  77089. /**
  77090. * Creates an Angle object of "radians" radians (float).
  77091. * @param radians the angle in radians
  77092. */
  77093. constructor(radians: number);
  77094. /**
  77095. * Get value in degrees
  77096. * @returns the Angle value in degrees (float)
  77097. */
  77098. degrees(): number;
  77099. /**
  77100. * Get value in radians
  77101. * @returns the Angle value in radians (float)
  77102. */
  77103. radians(): number;
  77104. /**
  77105. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77106. * @param a defines first vector
  77107. * @param b defines second vector
  77108. * @returns a new Angle
  77109. */
  77110. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77111. /**
  77112. * Gets a new Angle object from the given float in radians
  77113. * @param radians defines the angle value in radians
  77114. * @returns a new Angle
  77115. */
  77116. static FromRadians(radians: number): Angle;
  77117. /**
  77118. * Gets a new Angle object from the given float in degrees
  77119. * @param degrees defines the angle value in degrees
  77120. * @returns a new Angle
  77121. */
  77122. static FromDegrees(degrees: number): Angle;
  77123. }
  77124. /**
  77125. * This represents an arc in a 2d space.
  77126. */
  77127. export class Arc2 {
  77128. /** Defines the start point of the arc */
  77129. startPoint: Vector2;
  77130. /** Defines the mid point of the arc */
  77131. midPoint: Vector2;
  77132. /** Defines the end point of the arc */
  77133. endPoint: Vector2;
  77134. /**
  77135. * Defines the center point of the arc.
  77136. */
  77137. centerPoint: Vector2;
  77138. /**
  77139. * Defines the radius of the arc.
  77140. */
  77141. radius: number;
  77142. /**
  77143. * Defines the angle of the arc (from mid point to end point).
  77144. */
  77145. angle: Angle;
  77146. /**
  77147. * Defines the start angle of the arc (from start point to middle point).
  77148. */
  77149. startAngle: Angle;
  77150. /**
  77151. * Defines the orientation of the arc (clock wise/counter clock wise).
  77152. */
  77153. orientation: Orientation;
  77154. /**
  77155. * Creates an Arc object from the three given points : start, middle and end.
  77156. * @param startPoint Defines the start point of the arc
  77157. * @param midPoint Defines the midlle point of the arc
  77158. * @param endPoint Defines the end point of the arc
  77159. */
  77160. constructor(
  77161. /** Defines the start point of the arc */
  77162. startPoint: Vector2,
  77163. /** Defines the mid point of the arc */
  77164. midPoint: Vector2,
  77165. /** Defines the end point of the arc */
  77166. endPoint: Vector2);
  77167. }
  77168. /**
  77169. * Represents a 2D path made up of multiple 2D points
  77170. */
  77171. export class Path2 {
  77172. private _points;
  77173. private _length;
  77174. /**
  77175. * If the path start and end point are the same
  77176. */
  77177. closed: boolean;
  77178. /**
  77179. * Creates a Path2 object from the starting 2D coordinates x and y.
  77180. * @param x the starting points x value
  77181. * @param y the starting points y value
  77182. */
  77183. constructor(x: number, y: number);
  77184. /**
  77185. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77186. * @param x the added points x value
  77187. * @param y the added points y value
  77188. * @returns the updated Path2.
  77189. */
  77190. addLineTo(x: number, y: number): Path2;
  77191. /**
  77192. * 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.
  77193. * @param midX middle point x value
  77194. * @param midY middle point y value
  77195. * @param endX end point x value
  77196. * @param endY end point y value
  77197. * @param numberOfSegments (default: 36)
  77198. * @returns the updated Path2.
  77199. */
  77200. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77201. /**
  77202. * Closes the Path2.
  77203. * @returns the Path2.
  77204. */
  77205. close(): Path2;
  77206. /**
  77207. * Gets the sum of the distance between each sequential point in the path
  77208. * @returns the Path2 total length (float).
  77209. */
  77210. length(): number;
  77211. /**
  77212. * Gets the points which construct the path
  77213. * @returns the Path2 internal array of points.
  77214. */
  77215. getPoints(): Vector2[];
  77216. /**
  77217. * Retreives the point at the distance aways from the starting point
  77218. * @param normalizedLengthPosition the length along the path to retreive the point from
  77219. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77220. */
  77221. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  77222. /**
  77223. * Creates a new path starting from an x and y position
  77224. * @param x starting x value
  77225. * @param y starting y value
  77226. * @returns a new Path2 starting at the coordinates (x, y).
  77227. */
  77228. static StartingAt(x: number, y: number): Path2;
  77229. }
  77230. /**
  77231. * Represents a 3D path made up of multiple 3D points
  77232. */
  77233. export class Path3D {
  77234. /**
  77235. * an array of Vector3, the curve axis of the Path3D
  77236. */
  77237. path: Vector3[];
  77238. private _curve;
  77239. private _distances;
  77240. private _tangents;
  77241. private _normals;
  77242. private _binormals;
  77243. private _raw;
  77244. private _alignTangentsWithPath;
  77245. private readonly _pointAtData;
  77246. /**
  77247. * new Path3D(path, normal, raw)
  77248. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77249. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77250. * @param path an array of Vector3, the curve axis of the Path3D
  77251. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77252. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77253. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  77254. */
  77255. constructor(
  77256. /**
  77257. * an array of Vector3, the curve axis of the Path3D
  77258. */
  77259. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  77260. /**
  77261. * Returns the Path3D array of successive Vector3 designing its curve.
  77262. * @returns the Path3D array of successive Vector3 designing its curve.
  77263. */
  77264. getCurve(): Vector3[];
  77265. /**
  77266. * Returns the Path3D array of successive Vector3 designing its curve.
  77267. * @returns the Path3D array of successive Vector3 designing its curve.
  77268. */
  77269. getPoints(): Vector3[];
  77270. /**
  77271. * @returns the computed length (float) of the path.
  77272. */
  77273. length(): number;
  77274. /**
  77275. * Returns an array populated with tangent vectors on each Path3D curve point.
  77276. * @returns an array populated with tangent vectors on each Path3D curve point.
  77277. */
  77278. getTangents(): Vector3[];
  77279. /**
  77280. * Returns an array populated with normal vectors on each Path3D curve point.
  77281. * @returns an array populated with normal vectors on each Path3D curve point.
  77282. */
  77283. getNormals(): Vector3[];
  77284. /**
  77285. * Returns an array populated with binormal vectors on each Path3D curve point.
  77286. * @returns an array populated with binormal vectors on each Path3D curve point.
  77287. */
  77288. getBinormals(): Vector3[];
  77289. /**
  77290. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77291. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77292. */
  77293. getDistances(): number[];
  77294. /**
  77295. * Returns an interpolated point along this path
  77296. * @param position the position of the point along this path, from 0.0 to 1.0
  77297. * @returns a new Vector3 as the point
  77298. */
  77299. getPointAt(position: number): Vector3;
  77300. /**
  77301. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77302. * @param position the position of the point along this path, from 0.0 to 1.0
  77303. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  77304. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  77305. */
  77306. getTangentAt(position: number, interpolated?: boolean): Vector3;
  77307. /**
  77308. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77309. * @param position the position of the point along this path, from 0.0 to 1.0
  77310. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  77311. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  77312. */
  77313. getNormalAt(position: number, interpolated?: boolean): Vector3;
  77314. /**
  77315. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  77316. * @param position the position of the point along this path, from 0.0 to 1.0
  77317. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  77318. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  77319. */
  77320. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  77321. /**
  77322. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  77323. * @param position the position of the point along this path, from 0.0 to 1.0
  77324. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  77325. */
  77326. getDistanceAt(position: number): number;
  77327. /**
  77328. * Returns the array index of the previous point of an interpolated point along this path
  77329. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77330. * @returns the array index
  77331. */
  77332. getPreviousPointIndexAt(position: number): number;
  77333. /**
  77334. * 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)
  77335. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77336. * @returns the sub position
  77337. */
  77338. getSubPositionAt(position: number): number;
  77339. /**
  77340. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  77341. * @param target the vector of which to get the closest position to
  77342. * @returns the position of the closest virtual point on this path to the target vector
  77343. */
  77344. getClosestPositionTo(target: Vector3): number;
  77345. /**
  77346. * Returns a sub path (slice) of this path
  77347. * @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
  77348. * @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
  77349. * @returns a sub path (slice) of this path
  77350. */
  77351. slice(start?: number, end?: number): Path3D;
  77352. /**
  77353. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77354. * @param path path which all values are copied into the curves points
  77355. * @param firstNormal which should be projected onto the curve
  77356. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  77357. * @returns the same object updated.
  77358. */
  77359. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  77360. private _compute;
  77361. private _getFirstNonNullVector;
  77362. private _getLastNonNullVector;
  77363. private _normalVector;
  77364. /**
  77365. * Updates the point at data for an interpolated point along this curve
  77366. * @param position the position of the point along this curve, from 0.0 to 1.0
  77367. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  77368. * @returns the (updated) point at data
  77369. */
  77370. private _updatePointAtData;
  77371. /**
  77372. * Updates the point at data from the specified parameters
  77373. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  77374. * @param point the interpolated point
  77375. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  77376. */
  77377. private _setPointAtData;
  77378. /**
  77379. * Updates the point at interpolation matrix for the tangents, normals and binormals
  77380. */
  77381. private _updateInterpolationMatrix;
  77382. }
  77383. /**
  77384. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77385. * A Curve3 is designed from a series of successive Vector3.
  77386. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77387. */
  77388. export class Curve3 {
  77389. private _points;
  77390. private _length;
  77391. /**
  77392. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77393. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77394. * @param v1 (Vector3) the control point
  77395. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77396. * @param nbPoints (integer) the wanted number of points in the curve
  77397. * @returns the created Curve3
  77398. */
  77399. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77400. /**
  77401. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77402. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77403. * @param v1 (Vector3) the first control point
  77404. * @param v2 (Vector3) the second control point
  77405. * @param v3 (Vector3) the end point of the Cubic Bezier
  77406. * @param nbPoints (integer) the wanted number of points in the curve
  77407. * @returns the created Curve3
  77408. */
  77409. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77410. /**
  77411. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77412. * @param p1 (Vector3) the origin point of the Hermite Spline
  77413. * @param t1 (Vector3) the tangent vector at the origin point
  77414. * @param p2 (Vector3) the end point of the Hermite Spline
  77415. * @param t2 (Vector3) the tangent vector at the end point
  77416. * @param nbPoints (integer) the wanted number of points in the curve
  77417. * @returns the created Curve3
  77418. */
  77419. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77420. /**
  77421. * Returns a Curve3 object along a CatmullRom Spline curve :
  77422. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77423. * @param nbPoints (integer) the wanted number of points between each curve control points
  77424. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77425. * @returns the created Curve3
  77426. */
  77427. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  77428. /**
  77429. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77430. * A Curve3 is designed from a series of successive Vector3.
  77431. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77432. * @param points points which make up the curve
  77433. */
  77434. constructor(points: Vector3[]);
  77435. /**
  77436. * @returns the Curve3 stored array of successive Vector3
  77437. */
  77438. getPoints(): Vector3[];
  77439. /**
  77440. * @returns the computed length (float) of the curve.
  77441. */
  77442. length(): number;
  77443. /**
  77444. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77445. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77446. * curveA and curveB keep unchanged.
  77447. * @param curve the curve to continue from this curve
  77448. * @returns the newly constructed curve
  77449. */
  77450. continue(curve: DeepImmutable<Curve3>): Curve3;
  77451. private _computeLength;
  77452. }
  77453. }
  77454. declare module BABYLON {
  77455. /**
  77456. * This represents the main contract an easing function should follow.
  77457. * Easing functions are used throughout the animation system.
  77458. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77459. */
  77460. export interface IEasingFunction {
  77461. /**
  77462. * Given an input gradient between 0 and 1, this returns the corrseponding value
  77463. * of the easing function.
  77464. * The link below provides some of the most common examples of easing functions.
  77465. * @see https://easings.net/
  77466. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77467. * @returns the corresponding value on the curve defined by the easing function
  77468. */
  77469. ease(gradient: number): number;
  77470. }
  77471. /**
  77472. * Base class used for every default easing function.
  77473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77474. */
  77475. export class EasingFunction implements IEasingFunction {
  77476. /**
  77477. * Interpolation follows the mathematical formula associated with the easing function.
  77478. */
  77479. static readonly EASINGMODE_EASEIN: number;
  77480. /**
  77481. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  77482. */
  77483. static readonly EASINGMODE_EASEOUT: number;
  77484. /**
  77485. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  77486. */
  77487. static readonly EASINGMODE_EASEINOUT: number;
  77488. private _easingMode;
  77489. /**
  77490. * Sets the easing mode of the current function.
  77491. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  77492. */
  77493. setEasingMode(easingMode: number): void;
  77494. /**
  77495. * Gets the current easing mode.
  77496. * @returns the easing mode
  77497. */
  77498. getEasingMode(): number;
  77499. /**
  77500. * @hidden
  77501. */
  77502. easeInCore(gradient: number): number;
  77503. /**
  77504. * Given an input gradient between 0 and 1, this returns the corresponding value
  77505. * of the easing function.
  77506. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77507. * @returns the corresponding value on the curve defined by the easing function
  77508. */
  77509. ease(gradient: number): number;
  77510. }
  77511. /**
  77512. * Easing function with a circle shape (see link below).
  77513. * @see https://easings.net/#easeInCirc
  77514. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77515. */
  77516. export class CircleEase extends EasingFunction implements IEasingFunction {
  77517. /** @hidden */
  77518. easeInCore(gradient: number): number;
  77519. }
  77520. /**
  77521. * Easing function with a ease back shape (see link below).
  77522. * @see https://easings.net/#easeInBack
  77523. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77524. */
  77525. export class BackEase extends EasingFunction implements IEasingFunction {
  77526. /** Defines the amplitude of the function */
  77527. amplitude: number;
  77528. /**
  77529. * Instantiates a back ease easing
  77530. * @see https://easings.net/#easeInBack
  77531. * @param amplitude Defines the amplitude of the function
  77532. */
  77533. constructor(
  77534. /** Defines the amplitude of the function */
  77535. amplitude?: number);
  77536. /** @hidden */
  77537. easeInCore(gradient: number): number;
  77538. }
  77539. /**
  77540. * Easing function with a bouncing shape (see link below).
  77541. * @see https://easings.net/#easeInBounce
  77542. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77543. */
  77544. export class BounceEase extends EasingFunction implements IEasingFunction {
  77545. /** Defines the number of bounces */
  77546. bounces: number;
  77547. /** Defines the amplitude of the bounce */
  77548. bounciness: number;
  77549. /**
  77550. * Instantiates a bounce easing
  77551. * @see https://easings.net/#easeInBounce
  77552. * @param bounces Defines the number of bounces
  77553. * @param bounciness Defines the amplitude of the bounce
  77554. */
  77555. constructor(
  77556. /** Defines the number of bounces */
  77557. bounces?: number,
  77558. /** Defines the amplitude of the bounce */
  77559. bounciness?: number);
  77560. /** @hidden */
  77561. easeInCore(gradient: number): number;
  77562. }
  77563. /**
  77564. * Easing function with a power of 3 shape (see link below).
  77565. * @see https://easings.net/#easeInCubic
  77566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77567. */
  77568. export class CubicEase extends EasingFunction implements IEasingFunction {
  77569. /** @hidden */
  77570. easeInCore(gradient: number): number;
  77571. }
  77572. /**
  77573. * Easing function with an elastic shape (see link below).
  77574. * @see https://easings.net/#easeInElastic
  77575. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77576. */
  77577. export class ElasticEase extends EasingFunction implements IEasingFunction {
  77578. /** Defines the number of oscillations*/
  77579. oscillations: number;
  77580. /** Defines the amplitude of the oscillations*/
  77581. springiness: number;
  77582. /**
  77583. * Instantiates an elastic easing function
  77584. * @see https://easings.net/#easeInElastic
  77585. * @param oscillations Defines the number of oscillations
  77586. * @param springiness Defines the amplitude of the oscillations
  77587. */
  77588. constructor(
  77589. /** Defines the number of oscillations*/
  77590. oscillations?: number,
  77591. /** Defines the amplitude of the oscillations*/
  77592. springiness?: number);
  77593. /** @hidden */
  77594. easeInCore(gradient: number): number;
  77595. }
  77596. /**
  77597. * Easing function with an exponential shape (see link below).
  77598. * @see https://easings.net/#easeInExpo
  77599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77600. */
  77601. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  77602. /** Defines the exponent of the function */
  77603. exponent: number;
  77604. /**
  77605. * Instantiates an exponential easing function
  77606. * @see https://easings.net/#easeInExpo
  77607. * @param exponent Defines the exponent of the function
  77608. */
  77609. constructor(
  77610. /** Defines the exponent of the function */
  77611. exponent?: number);
  77612. /** @hidden */
  77613. easeInCore(gradient: number): number;
  77614. }
  77615. /**
  77616. * Easing function with a power shape (see link below).
  77617. * @see https://easings.net/#easeInQuad
  77618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77619. */
  77620. export class PowerEase extends EasingFunction implements IEasingFunction {
  77621. /** Defines the power of the function */
  77622. power: number;
  77623. /**
  77624. * Instantiates an power base easing function
  77625. * @see https://easings.net/#easeInQuad
  77626. * @param power Defines the power of the function
  77627. */
  77628. constructor(
  77629. /** Defines the power of the function */
  77630. power?: number);
  77631. /** @hidden */
  77632. easeInCore(gradient: number): number;
  77633. }
  77634. /**
  77635. * Easing function with a power of 2 shape (see link below).
  77636. * @see https://easings.net/#easeInQuad
  77637. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77638. */
  77639. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  77640. /** @hidden */
  77641. easeInCore(gradient: number): number;
  77642. }
  77643. /**
  77644. * Easing function with a power of 4 shape (see link below).
  77645. * @see https://easings.net/#easeInQuart
  77646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77647. */
  77648. export class QuarticEase extends EasingFunction implements IEasingFunction {
  77649. /** @hidden */
  77650. easeInCore(gradient: number): number;
  77651. }
  77652. /**
  77653. * Easing function with a power of 5 shape (see link below).
  77654. * @see https://easings.net/#easeInQuint
  77655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77656. */
  77657. export class QuinticEase extends EasingFunction implements IEasingFunction {
  77658. /** @hidden */
  77659. easeInCore(gradient: number): number;
  77660. }
  77661. /**
  77662. * Easing function with a sin shape (see link below).
  77663. * @see https://easings.net/#easeInSine
  77664. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77665. */
  77666. export class SineEase extends EasingFunction implements IEasingFunction {
  77667. /** @hidden */
  77668. easeInCore(gradient: number): number;
  77669. }
  77670. /**
  77671. * Easing function with a bezier shape (see link below).
  77672. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  77673. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77674. */
  77675. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  77676. /** Defines the x component of the start tangent in the bezier curve */
  77677. x1: number;
  77678. /** Defines the y component of the start tangent in the bezier curve */
  77679. y1: number;
  77680. /** Defines the x component of the end tangent in the bezier curve */
  77681. x2: number;
  77682. /** Defines the y component of the end tangent in the bezier curve */
  77683. y2: number;
  77684. /**
  77685. * Instantiates a bezier function
  77686. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  77687. * @param x1 Defines the x component of the start tangent in the bezier curve
  77688. * @param y1 Defines the y component of the start tangent in the bezier curve
  77689. * @param x2 Defines the x component of the end tangent in the bezier curve
  77690. * @param y2 Defines the y component of the end tangent in the bezier curve
  77691. */
  77692. constructor(
  77693. /** Defines the x component of the start tangent in the bezier curve */
  77694. x1?: number,
  77695. /** Defines the y component of the start tangent in the bezier curve */
  77696. y1?: number,
  77697. /** Defines the x component of the end tangent in the bezier curve */
  77698. x2?: number,
  77699. /** Defines the y component of the end tangent in the bezier curve */
  77700. y2?: number);
  77701. /** @hidden */
  77702. easeInCore(gradient: number): number;
  77703. }
  77704. }
  77705. declare module BABYLON {
  77706. /**
  77707. * Class used to hold a RBG color
  77708. */
  77709. export class Color3 {
  77710. /**
  77711. * Defines the red component (between 0 and 1, default is 0)
  77712. */
  77713. r: number;
  77714. /**
  77715. * Defines the green component (between 0 and 1, default is 0)
  77716. */
  77717. g: number;
  77718. /**
  77719. * Defines the blue component (between 0 and 1, default is 0)
  77720. */
  77721. b: number;
  77722. /**
  77723. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  77724. * @param r defines the red component (between 0 and 1, default is 0)
  77725. * @param g defines the green component (between 0 and 1, default is 0)
  77726. * @param b defines the blue component (between 0 and 1, default is 0)
  77727. */
  77728. constructor(
  77729. /**
  77730. * Defines the red component (between 0 and 1, default is 0)
  77731. */
  77732. r?: number,
  77733. /**
  77734. * Defines the green component (between 0 and 1, default is 0)
  77735. */
  77736. g?: number,
  77737. /**
  77738. * Defines the blue component (between 0 and 1, default is 0)
  77739. */
  77740. b?: number);
  77741. /**
  77742. * Creates a string with the Color3 current values
  77743. * @returns the string representation of the Color3 object
  77744. */
  77745. toString(): string;
  77746. /**
  77747. * Returns the string "Color3"
  77748. * @returns "Color3"
  77749. */
  77750. getClassName(): string;
  77751. /**
  77752. * Compute the Color3 hash code
  77753. * @returns an unique number that can be used to hash Color3 objects
  77754. */
  77755. getHashCode(): number;
  77756. /**
  77757. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  77758. * @param array defines the array where to store the r,g,b components
  77759. * @param index defines an optional index in the target array to define where to start storing values
  77760. * @returns the current Color3 object
  77761. */
  77762. toArray(array: FloatArray, index?: number): Color3;
  77763. /**
  77764. * Returns a new Color4 object from the current Color3 and the given alpha
  77765. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  77766. * @returns a new Color4 object
  77767. */
  77768. toColor4(alpha?: number): Color4;
  77769. /**
  77770. * Returns a new array populated with 3 numeric elements : red, green and blue values
  77771. * @returns the new array
  77772. */
  77773. asArray(): number[];
  77774. /**
  77775. * Returns the luminance value
  77776. * @returns a float value
  77777. */
  77778. toLuminance(): number;
  77779. /**
  77780. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  77781. * @param otherColor defines the second operand
  77782. * @returns the new Color3 object
  77783. */
  77784. multiply(otherColor: DeepImmutable<Color3>): Color3;
  77785. /**
  77786. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  77787. * @param otherColor defines the second operand
  77788. * @param result defines the Color3 object where to store the result
  77789. * @returns the current Color3
  77790. */
  77791. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77792. /**
  77793. * Determines equality between Color3 objects
  77794. * @param otherColor defines the second operand
  77795. * @returns true if the rgb values are equal to the given ones
  77796. */
  77797. equals(otherColor: DeepImmutable<Color3>): boolean;
  77798. /**
  77799. * Determines equality between the current Color3 object and a set of r,b,g values
  77800. * @param r defines the red component to check
  77801. * @param g defines the green component to check
  77802. * @param b defines the blue component to check
  77803. * @returns true if the rgb values are equal to the given ones
  77804. */
  77805. equalsFloats(r: number, g: number, b: number): boolean;
  77806. /**
  77807. * Multiplies in place each rgb value by scale
  77808. * @param scale defines the scaling factor
  77809. * @returns the updated Color3
  77810. */
  77811. scale(scale: number): Color3;
  77812. /**
  77813. * Multiplies the rgb values by scale and stores the result into "result"
  77814. * @param scale defines the scaling factor
  77815. * @param result defines the Color3 object where to store the result
  77816. * @returns the unmodified current Color3
  77817. */
  77818. scaleToRef(scale: number, result: Color3): Color3;
  77819. /**
  77820. * Scale the current Color3 values by a factor and add the result to a given Color3
  77821. * @param scale defines the scale factor
  77822. * @param result defines color to store the result into
  77823. * @returns the unmodified current Color3
  77824. */
  77825. scaleAndAddToRef(scale: number, result: Color3): Color3;
  77826. /**
  77827. * Clamps the rgb values by the min and max values and stores the result into "result"
  77828. * @param min defines minimum clamping value (default is 0)
  77829. * @param max defines maximum clamping value (default is 1)
  77830. * @param result defines color to store the result into
  77831. * @returns the original Color3
  77832. */
  77833. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  77834. /**
  77835. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  77836. * @param otherColor defines the second operand
  77837. * @returns the new Color3
  77838. */
  77839. add(otherColor: DeepImmutable<Color3>): Color3;
  77840. /**
  77841. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  77842. * @param otherColor defines the second operand
  77843. * @param result defines Color3 object to store the result into
  77844. * @returns the unmodified current Color3
  77845. */
  77846. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77847. /**
  77848. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  77849. * @param otherColor defines the second operand
  77850. * @returns the new Color3
  77851. */
  77852. subtract(otherColor: DeepImmutable<Color3>): Color3;
  77853. /**
  77854. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  77855. * @param otherColor defines the second operand
  77856. * @param result defines Color3 object to store the result into
  77857. * @returns the unmodified current Color3
  77858. */
  77859. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77860. /**
  77861. * Copy the current object
  77862. * @returns a new Color3 copied the current one
  77863. */
  77864. clone(): Color3;
  77865. /**
  77866. * Copies the rgb values from the source in the current Color3
  77867. * @param source defines the source Color3 object
  77868. * @returns the updated Color3 object
  77869. */
  77870. copyFrom(source: DeepImmutable<Color3>): Color3;
  77871. /**
  77872. * Updates the Color3 rgb values from the given floats
  77873. * @param r defines the red component to read from
  77874. * @param g defines the green component to read from
  77875. * @param b defines the blue component to read from
  77876. * @returns the current Color3 object
  77877. */
  77878. copyFromFloats(r: number, g: number, b: number): Color3;
  77879. /**
  77880. * Updates the Color3 rgb values from the given floats
  77881. * @param r defines the red component to read from
  77882. * @param g defines the green component to read from
  77883. * @param b defines the blue component to read from
  77884. * @returns the current Color3 object
  77885. */
  77886. set(r: number, g: number, b: number): Color3;
  77887. /**
  77888. * Compute the Color3 hexadecimal code as a string
  77889. * @returns a string containing the hexadecimal representation of the Color3 object
  77890. */
  77891. toHexString(): string;
  77892. /**
  77893. * Computes a new Color3 converted from the current one to linear space
  77894. * @returns a new Color3 object
  77895. */
  77896. toLinearSpace(): Color3;
  77897. /**
  77898. * Converts current color in rgb space to HSV values
  77899. * @returns a new color3 representing the HSV values
  77900. */
  77901. toHSV(): Color3;
  77902. /**
  77903. * Converts current color in rgb space to HSV values
  77904. * @param result defines the Color3 where to store the HSV values
  77905. */
  77906. toHSVToRef(result: Color3): void;
  77907. /**
  77908. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  77909. * @param convertedColor defines the Color3 object where to store the linear space version
  77910. * @returns the unmodified Color3
  77911. */
  77912. toLinearSpaceToRef(convertedColor: Color3): Color3;
  77913. /**
  77914. * Computes a new Color3 converted from the current one to gamma space
  77915. * @returns a new Color3 object
  77916. */
  77917. toGammaSpace(): Color3;
  77918. /**
  77919. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  77920. * @param convertedColor defines the Color3 object where to store the gamma space version
  77921. * @returns the unmodified Color3
  77922. */
  77923. toGammaSpaceToRef(convertedColor: Color3): Color3;
  77924. private static _BlackReadOnly;
  77925. /**
  77926. * Convert Hue, saturation and value to a Color3 (RGB)
  77927. * @param hue defines the hue
  77928. * @param saturation defines the saturation
  77929. * @param value defines the value
  77930. * @param result defines the Color3 where to store the RGB values
  77931. */
  77932. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  77933. /**
  77934. * Creates a new Color3 from the string containing valid hexadecimal values
  77935. * @param hex defines a string containing valid hexadecimal values
  77936. * @returns a new Color3 object
  77937. */
  77938. static FromHexString(hex: string): Color3;
  77939. /**
  77940. * Creates a new Color3 from the starting index of the given array
  77941. * @param array defines the source array
  77942. * @param offset defines an offset in the source array
  77943. * @returns a new Color3 object
  77944. */
  77945. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  77946. /**
  77947. * Creates a new Color3 from integer values (< 256)
  77948. * @param r defines the red component to read from (value between 0 and 255)
  77949. * @param g defines the green component to read from (value between 0 and 255)
  77950. * @param b defines the blue component to read from (value between 0 and 255)
  77951. * @returns a new Color3 object
  77952. */
  77953. static FromInts(r: number, g: number, b: number): Color3;
  77954. /**
  77955. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  77956. * @param start defines the start Color3 value
  77957. * @param end defines the end Color3 value
  77958. * @param amount defines the gradient value between start and end
  77959. * @returns a new Color3 object
  77960. */
  77961. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  77962. /**
  77963. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  77964. * @param left defines the start value
  77965. * @param right defines the end value
  77966. * @param amount defines the gradient factor
  77967. * @param result defines the Color3 object where to store the result
  77968. */
  77969. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  77970. /**
  77971. * Returns a Color3 value containing a red color
  77972. * @returns a new Color3 object
  77973. */
  77974. static Red(): Color3;
  77975. /**
  77976. * Returns a Color3 value containing a green color
  77977. * @returns a new Color3 object
  77978. */
  77979. static Green(): Color3;
  77980. /**
  77981. * Returns a Color3 value containing a blue color
  77982. * @returns a new Color3 object
  77983. */
  77984. static Blue(): Color3;
  77985. /**
  77986. * Returns a Color3 value containing a black color
  77987. * @returns a new Color3 object
  77988. */
  77989. static Black(): Color3;
  77990. /**
  77991. * Gets a Color3 value containing a black color that must not be updated
  77992. */
  77993. static get BlackReadOnly(): DeepImmutable<Color3>;
  77994. /**
  77995. * Returns a Color3 value containing a white color
  77996. * @returns a new Color3 object
  77997. */
  77998. static White(): Color3;
  77999. /**
  78000. * Returns a Color3 value containing a purple color
  78001. * @returns a new Color3 object
  78002. */
  78003. static Purple(): Color3;
  78004. /**
  78005. * Returns a Color3 value containing a magenta color
  78006. * @returns a new Color3 object
  78007. */
  78008. static Magenta(): Color3;
  78009. /**
  78010. * Returns a Color3 value containing a yellow color
  78011. * @returns a new Color3 object
  78012. */
  78013. static Yellow(): Color3;
  78014. /**
  78015. * Returns a Color3 value containing a gray color
  78016. * @returns a new Color3 object
  78017. */
  78018. static Gray(): Color3;
  78019. /**
  78020. * Returns a Color3 value containing a teal color
  78021. * @returns a new Color3 object
  78022. */
  78023. static Teal(): Color3;
  78024. /**
  78025. * Returns a Color3 value containing a random color
  78026. * @returns a new Color3 object
  78027. */
  78028. static Random(): Color3;
  78029. }
  78030. /**
  78031. * Class used to hold a RBGA color
  78032. */
  78033. export class Color4 {
  78034. /**
  78035. * Defines the red component (between 0 and 1, default is 0)
  78036. */
  78037. r: number;
  78038. /**
  78039. * Defines the green component (between 0 and 1, default is 0)
  78040. */
  78041. g: number;
  78042. /**
  78043. * Defines the blue component (between 0 and 1, default is 0)
  78044. */
  78045. b: number;
  78046. /**
  78047. * Defines the alpha component (between 0 and 1, default is 1)
  78048. */
  78049. a: number;
  78050. /**
  78051. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78052. * @param r defines the red component (between 0 and 1, default is 0)
  78053. * @param g defines the green component (between 0 and 1, default is 0)
  78054. * @param b defines the blue component (between 0 and 1, default is 0)
  78055. * @param a defines the alpha component (between 0 and 1, default is 1)
  78056. */
  78057. constructor(
  78058. /**
  78059. * Defines the red component (between 0 and 1, default is 0)
  78060. */
  78061. r?: number,
  78062. /**
  78063. * Defines the green component (between 0 and 1, default is 0)
  78064. */
  78065. g?: number,
  78066. /**
  78067. * Defines the blue component (between 0 and 1, default is 0)
  78068. */
  78069. b?: number,
  78070. /**
  78071. * Defines the alpha component (between 0 and 1, default is 1)
  78072. */
  78073. a?: number);
  78074. /**
  78075. * Adds in place the given Color4 values to the current Color4 object
  78076. * @param right defines the second operand
  78077. * @returns the current updated Color4 object
  78078. */
  78079. addInPlace(right: DeepImmutable<Color4>): Color4;
  78080. /**
  78081. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78082. * @returns the new array
  78083. */
  78084. asArray(): number[];
  78085. /**
  78086. * Stores from the starting index in the given array the Color4 successive values
  78087. * @param array defines the array where to store the r,g,b components
  78088. * @param index defines an optional index in the target array to define where to start storing values
  78089. * @returns the current Color4 object
  78090. */
  78091. toArray(array: number[], index?: number): Color4;
  78092. /**
  78093. * Determines equality between Color4 objects
  78094. * @param otherColor defines the second operand
  78095. * @returns true if the rgba values are equal to the given ones
  78096. */
  78097. equals(otherColor: DeepImmutable<Color4>): boolean;
  78098. /**
  78099. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78100. * @param right defines the second operand
  78101. * @returns a new Color4 object
  78102. */
  78103. add(right: DeepImmutable<Color4>): Color4;
  78104. /**
  78105. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78106. * @param right defines the second operand
  78107. * @returns a new Color4 object
  78108. */
  78109. subtract(right: DeepImmutable<Color4>): Color4;
  78110. /**
  78111. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78112. * @param right defines the second operand
  78113. * @param result defines the Color4 object where to store the result
  78114. * @returns the current Color4 object
  78115. */
  78116. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78117. /**
  78118. * Creates a new Color4 with the current Color4 values multiplied by scale
  78119. * @param scale defines the scaling factor to apply
  78120. * @returns a new Color4 object
  78121. */
  78122. scale(scale: number): Color4;
  78123. /**
  78124. * Multiplies the current Color4 values by scale and stores the result in "result"
  78125. * @param scale defines the scaling factor to apply
  78126. * @param result defines the Color4 object where to store the result
  78127. * @returns the current unmodified Color4
  78128. */
  78129. scaleToRef(scale: number, result: Color4): Color4;
  78130. /**
  78131. * Scale the current Color4 values by a factor and add the result to a given Color4
  78132. * @param scale defines the scale factor
  78133. * @param result defines the Color4 object where to store the result
  78134. * @returns the unmodified current Color4
  78135. */
  78136. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78137. /**
  78138. * Clamps the rgb values by the min and max values and stores the result into "result"
  78139. * @param min defines minimum clamping value (default is 0)
  78140. * @param max defines maximum clamping value (default is 1)
  78141. * @param result defines color to store the result into.
  78142. * @returns the cuurent Color4
  78143. */
  78144. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78145. /**
  78146. * Multipy an Color4 value by another and return a new Color4 object
  78147. * @param color defines the Color4 value to multiply by
  78148. * @returns a new Color4 object
  78149. */
  78150. multiply(color: Color4): Color4;
  78151. /**
  78152. * Multipy a Color4 value by another and push the result in a reference value
  78153. * @param color defines the Color4 value to multiply by
  78154. * @param result defines the Color4 to fill the result in
  78155. * @returns the result Color4
  78156. */
  78157. multiplyToRef(color: Color4, result: Color4): Color4;
  78158. /**
  78159. * Creates a string with the Color4 current values
  78160. * @returns the string representation of the Color4 object
  78161. */
  78162. toString(): string;
  78163. /**
  78164. * Returns the string "Color4"
  78165. * @returns "Color4"
  78166. */
  78167. getClassName(): string;
  78168. /**
  78169. * Compute the Color4 hash code
  78170. * @returns an unique number that can be used to hash Color4 objects
  78171. */
  78172. getHashCode(): number;
  78173. /**
  78174. * Creates a new Color4 copied from the current one
  78175. * @returns a new Color4 object
  78176. */
  78177. clone(): Color4;
  78178. /**
  78179. * Copies the given Color4 values into the current one
  78180. * @param source defines the source Color4 object
  78181. * @returns the current updated Color4 object
  78182. */
  78183. copyFrom(source: Color4): Color4;
  78184. /**
  78185. * Copies the given float values into the current one
  78186. * @param r defines the red component to read from
  78187. * @param g defines the green component to read from
  78188. * @param b defines the blue component to read from
  78189. * @param a defines the alpha component to read from
  78190. * @returns the current updated Color4 object
  78191. */
  78192. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78193. /**
  78194. * Copies the given float values into the current one
  78195. * @param r defines the red component to read from
  78196. * @param g defines the green component to read from
  78197. * @param b defines the blue component to read from
  78198. * @param a defines the alpha component to read from
  78199. * @returns the current updated Color4 object
  78200. */
  78201. set(r: number, g: number, b: number, a: number): Color4;
  78202. /**
  78203. * Compute the Color4 hexadecimal code as a string
  78204. * @returns a string containing the hexadecimal representation of the Color4 object
  78205. */
  78206. toHexString(): string;
  78207. /**
  78208. * Computes a new Color4 converted from the current one to linear space
  78209. * @returns a new Color4 object
  78210. */
  78211. toLinearSpace(): Color4;
  78212. /**
  78213. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  78214. * @param convertedColor defines the Color4 object where to store the linear space version
  78215. * @returns the unmodified Color4
  78216. */
  78217. toLinearSpaceToRef(convertedColor: Color4): Color4;
  78218. /**
  78219. * Computes a new Color4 converted from the current one to gamma space
  78220. * @returns a new Color4 object
  78221. */
  78222. toGammaSpace(): Color4;
  78223. /**
  78224. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  78225. * @param convertedColor defines the Color4 object where to store the gamma space version
  78226. * @returns the unmodified Color4
  78227. */
  78228. toGammaSpaceToRef(convertedColor: Color4): Color4;
  78229. /**
  78230. * Creates a new Color4 from the string containing valid hexadecimal values
  78231. * @param hex defines a string containing valid hexadecimal values
  78232. * @returns a new Color4 object
  78233. */
  78234. static FromHexString(hex: string): Color4;
  78235. /**
  78236. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78237. * @param left defines the start value
  78238. * @param right defines the end value
  78239. * @param amount defines the gradient factor
  78240. * @returns a new Color4 object
  78241. */
  78242. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  78243. /**
  78244. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78245. * @param left defines the start value
  78246. * @param right defines the end value
  78247. * @param amount defines the gradient factor
  78248. * @param result defines the Color4 object where to store data
  78249. */
  78250. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  78251. /**
  78252. * Creates a new Color4 from a Color3 and an alpha value
  78253. * @param color3 defines the source Color3 to read from
  78254. * @param alpha defines the alpha component (1.0 by default)
  78255. * @returns a new Color4 object
  78256. */
  78257. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  78258. /**
  78259. * Creates a new Color4 from the starting index element of the given array
  78260. * @param array defines the source array to read from
  78261. * @param offset defines the offset in the source array
  78262. * @returns a new Color4 object
  78263. */
  78264. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  78265. /**
  78266. * Creates a new Color3 from integer values (< 256)
  78267. * @param r defines the red component to read from (value between 0 and 255)
  78268. * @param g defines the green component to read from (value between 0 and 255)
  78269. * @param b defines the blue component to read from (value between 0 and 255)
  78270. * @param a defines the alpha component to read from (value between 0 and 255)
  78271. * @returns a new Color3 object
  78272. */
  78273. static FromInts(r: number, g: number, b: number, a: number): Color4;
  78274. /**
  78275. * Check the content of a given array and convert it to an array containing RGBA data
  78276. * If the original array was already containing count * 4 values then it is returned directly
  78277. * @param colors defines the array to check
  78278. * @param count defines the number of RGBA data to expect
  78279. * @returns an array containing count * 4 values (RGBA)
  78280. */
  78281. static CheckColors4(colors: number[], count: number): number[];
  78282. }
  78283. /**
  78284. * @hidden
  78285. */
  78286. export class TmpColors {
  78287. static Color3: Color3[];
  78288. static Color4: Color4[];
  78289. }
  78290. }
  78291. declare module BABYLON {
  78292. /**
  78293. * Defines an interface which represents an animation key frame
  78294. */
  78295. export interface IAnimationKey {
  78296. /**
  78297. * Frame of the key frame
  78298. */
  78299. frame: number;
  78300. /**
  78301. * Value at the specifies key frame
  78302. */
  78303. value: any;
  78304. /**
  78305. * The input tangent for the cubic hermite spline
  78306. */
  78307. inTangent?: any;
  78308. /**
  78309. * The output tangent for the cubic hermite spline
  78310. */
  78311. outTangent?: any;
  78312. /**
  78313. * The animation interpolation type
  78314. */
  78315. interpolation?: AnimationKeyInterpolation;
  78316. }
  78317. /**
  78318. * Enum for the animation key frame interpolation type
  78319. */
  78320. export enum AnimationKeyInterpolation {
  78321. /**
  78322. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  78323. */
  78324. STEP = 1
  78325. }
  78326. }
  78327. declare module BABYLON {
  78328. /**
  78329. * Represents the range of an animation
  78330. */
  78331. export class AnimationRange {
  78332. /**The name of the animation range**/
  78333. name: string;
  78334. /**The starting frame of the animation */
  78335. from: number;
  78336. /**The ending frame of the animation*/
  78337. to: number;
  78338. /**
  78339. * Initializes the range of an animation
  78340. * @param name The name of the animation range
  78341. * @param from The starting frame of the animation
  78342. * @param to The ending frame of the animation
  78343. */
  78344. constructor(
  78345. /**The name of the animation range**/
  78346. name: string,
  78347. /**The starting frame of the animation */
  78348. from: number,
  78349. /**The ending frame of the animation*/
  78350. to: number);
  78351. /**
  78352. * Makes a copy of the animation range
  78353. * @returns A copy of the animation range
  78354. */
  78355. clone(): AnimationRange;
  78356. }
  78357. }
  78358. declare module BABYLON {
  78359. /**
  78360. * Composed of a frame, and an action function
  78361. */
  78362. export class AnimationEvent {
  78363. /** The frame for which the event is triggered **/
  78364. frame: number;
  78365. /** The event to perform when triggered **/
  78366. action: (currentFrame: number) => void;
  78367. /** Specifies if the event should be triggered only once**/
  78368. onlyOnce?: boolean | undefined;
  78369. /**
  78370. * Specifies if the animation event is done
  78371. */
  78372. isDone: boolean;
  78373. /**
  78374. * Initializes the animation event
  78375. * @param frame The frame for which the event is triggered
  78376. * @param action The event to perform when triggered
  78377. * @param onlyOnce Specifies if the event should be triggered only once
  78378. */
  78379. constructor(
  78380. /** The frame for which the event is triggered **/
  78381. frame: number,
  78382. /** The event to perform when triggered **/
  78383. action: (currentFrame: number) => void,
  78384. /** Specifies if the event should be triggered only once**/
  78385. onlyOnce?: boolean | undefined);
  78386. /** @hidden */
  78387. _clone(): AnimationEvent;
  78388. }
  78389. }
  78390. declare module BABYLON {
  78391. /**
  78392. * Interface used to define a behavior
  78393. */
  78394. export interface Behavior<T> {
  78395. /** gets or sets behavior's name */
  78396. name: string;
  78397. /**
  78398. * Function called when the behavior needs to be initialized (after attaching it to a target)
  78399. */
  78400. init(): void;
  78401. /**
  78402. * Called when the behavior is attached to a target
  78403. * @param target defines the target where the behavior is attached to
  78404. */
  78405. attach(target: T): void;
  78406. /**
  78407. * Called when the behavior is detached from its target
  78408. */
  78409. detach(): void;
  78410. }
  78411. /**
  78412. * Interface implemented by classes supporting behaviors
  78413. */
  78414. export interface IBehaviorAware<T> {
  78415. /**
  78416. * Attach a behavior
  78417. * @param behavior defines the behavior to attach
  78418. * @returns the current host
  78419. */
  78420. addBehavior(behavior: Behavior<T>): T;
  78421. /**
  78422. * Remove a behavior from the current object
  78423. * @param behavior defines the behavior to detach
  78424. * @returns the current host
  78425. */
  78426. removeBehavior(behavior: Behavior<T>): T;
  78427. /**
  78428. * Gets a behavior using its name to search
  78429. * @param name defines the name to search
  78430. * @returns the behavior or null if not found
  78431. */
  78432. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  78433. }
  78434. }
  78435. declare module BABYLON {
  78436. /**
  78437. * Defines an array and its length.
  78438. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  78439. */
  78440. export interface ISmartArrayLike<T> {
  78441. /**
  78442. * The data of the array.
  78443. */
  78444. data: Array<T>;
  78445. /**
  78446. * The active length of the array.
  78447. */
  78448. length: number;
  78449. }
  78450. /**
  78451. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78452. */
  78453. export class SmartArray<T> implements ISmartArrayLike<T> {
  78454. /**
  78455. * The full set of data from the array.
  78456. */
  78457. data: Array<T>;
  78458. /**
  78459. * The active length of the array.
  78460. */
  78461. length: number;
  78462. protected _id: number;
  78463. /**
  78464. * Instantiates a Smart Array.
  78465. * @param capacity defines the default capacity of the array.
  78466. */
  78467. constructor(capacity: number);
  78468. /**
  78469. * Pushes a value at the end of the active data.
  78470. * @param value defines the object to push in the array.
  78471. */
  78472. push(value: T): void;
  78473. /**
  78474. * Iterates over the active data and apply the lambda to them.
  78475. * @param func defines the action to apply on each value.
  78476. */
  78477. forEach(func: (content: T) => void): void;
  78478. /**
  78479. * Sorts the full sets of data.
  78480. * @param compareFn defines the comparison function to apply.
  78481. */
  78482. sort(compareFn: (a: T, b: T) => number): void;
  78483. /**
  78484. * Resets the active data to an empty array.
  78485. */
  78486. reset(): void;
  78487. /**
  78488. * Releases all the data from the array as well as the array.
  78489. */
  78490. dispose(): void;
  78491. /**
  78492. * Concats the active data with a given array.
  78493. * @param array defines the data to concatenate with.
  78494. */
  78495. concat(array: any): void;
  78496. /**
  78497. * Returns the position of a value in the active data.
  78498. * @param value defines the value to find the index for
  78499. * @returns the index if found in the active data otherwise -1
  78500. */
  78501. indexOf(value: T): number;
  78502. /**
  78503. * Returns whether an element is part of the active data.
  78504. * @param value defines the value to look for
  78505. * @returns true if found in the active data otherwise false
  78506. */
  78507. contains(value: T): boolean;
  78508. private static _GlobalId;
  78509. }
  78510. /**
  78511. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78512. * The data in this array can only be present once
  78513. */
  78514. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  78515. private _duplicateId;
  78516. /**
  78517. * Pushes a value at the end of the active data.
  78518. * THIS DOES NOT PREVENT DUPPLICATE DATA
  78519. * @param value defines the object to push in the array.
  78520. */
  78521. push(value: T): void;
  78522. /**
  78523. * Pushes a value at the end of the active data.
  78524. * If the data is already present, it won t be added again
  78525. * @param value defines the object to push in the array.
  78526. * @returns true if added false if it was already present
  78527. */
  78528. pushNoDuplicate(value: T): boolean;
  78529. /**
  78530. * Resets the active data to an empty array.
  78531. */
  78532. reset(): void;
  78533. /**
  78534. * Concats the active data with a given array.
  78535. * This ensures no dupplicate will be present in the result.
  78536. * @param array defines the data to concatenate with.
  78537. */
  78538. concatWithNoDuplicate(array: any): void;
  78539. }
  78540. }
  78541. declare module BABYLON {
  78542. /**
  78543. * @ignore
  78544. * This is a list of all the different input types that are available in the application.
  78545. * Fo instance: ArcRotateCameraGamepadInput...
  78546. */
  78547. export var CameraInputTypes: {};
  78548. /**
  78549. * This is the contract to implement in order to create a new input class.
  78550. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  78551. */
  78552. export interface ICameraInput<TCamera extends Camera> {
  78553. /**
  78554. * Defines the camera the input is attached to.
  78555. */
  78556. camera: Nullable<TCamera>;
  78557. /**
  78558. * Gets the class name of the current intput.
  78559. * @returns the class name
  78560. */
  78561. getClassName(): string;
  78562. /**
  78563. * Get the friendly name associated with the input class.
  78564. * @returns the input friendly name
  78565. */
  78566. getSimpleName(): string;
  78567. /**
  78568. * Attach the input controls to a specific dom element to get the input from.
  78569. * @param element Defines the element the controls should be listened from
  78570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78571. */
  78572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78573. /**
  78574. * Detach the current controls from the specified dom element.
  78575. * @param element Defines the element to stop listening the inputs from
  78576. */
  78577. detachControl(element: Nullable<HTMLElement>): void;
  78578. /**
  78579. * Update the current camera state depending on the inputs that have been used this frame.
  78580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78581. */
  78582. checkInputs?: () => void;
  78583. }
  78584. /**
  78585. * Represents a map of input types to input instance or input index to input instance.
  78586. */
  78587. export interface CameraInputsMap<TCamera extends Camera> {
  78588. /**
  78589. * Accessor to the input by input type.
  78590. */
  78591. [name: string]: ICameraInput<TCamera>;
  78592. /**
  78593. * Accessor to the input by input index.
  78594. */
  78595. [idx: number]: ICameraInput<TCamera>;
  78596. }
  78597. /**
  78598. * This represents the input manager used within a camera.
  78599. * It helps dealing with all the different kind of input attached to a camera.
  78600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78601. */
  78602. export class CameraInputsManager<TCamera extends Camera> {
  78603. /**
  78604. * Defines the list of inputs attahed to the camera.
  78605. */
  78606. attached: CameraInputsMap<TCamera>;
  78607. /**
  78608. * Defines the dom element the camera is collecting inputs from.
  78609. * This is null if the controls have not been attached.
  78610. */
  78611. attachedElement: Nullable<HTMLElement>;
  78612. /**
  78613. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78614. */
  78615. noPreventDefault: boolean;
  78616. /**
  78617. * Defined the camera the input manager belongs to.
  78618. */
  78619. camera: TCamera;
  78620. /**
  78621. * Update the current camera state depending on the inputs that have been used this frame.
  78622. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78623. */
  78624. checkInputs: () => void;
  78625. /**
  78626. * Instantiate a new Camera Input Manager.
  78627. * @param camera Defines the camera the input manager blongs to
  78628. */
  78629. constructor(camera: TCamera);
  78630. /**
  78631. * Add an input method to a camera
  78632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78633. * @param input camera input method
  78634. */
  78635. add(input: ICameraInput<TCamera>): void;
  78636. /**
  78637. * Remove a specific input method from a camera
  78638. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  78639. * @param inputToRemove camera input method
  78640. */
  78641. remove(inputToRemove: ICameraInput<TCamera>): void;
  78642. /**
  78643. * Remove a specific input type from a camera
  78644. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  78645. * @param inputType the type of the input to remove
  78646. */
  78647. removeByType(inputType: string): void;
  78648. private _addCheckInputs;
  78649. /**
  78650. * Attach the input controls to the currently attached dom element to listen the events from.
  78651. * @param input Defines the input to attach
  78652. */
  78653. attachInput(input: ICameraInput<TCamera>): void;
  78654. /**
  78655. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  78656. * @param element Defines the dom element to collect the events from
  78657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78658. */
  78659. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  78660. /**
  78661. * Detach the current manager inputs controls from a specific dom element.
  78662. * @param element Defines the dom element to collect the events from
  78663. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  78664. */
  78665. detachElement(element: HTMLElement, disconnect?: boolean): void;
  78666. /**
  78667. * Rebuild the dynamic inputCheck function from the current list of
  78668. * defined inputs in the manager.
  78669. */
  78670. rebuildInputCheck(): void;
  78671. /**
  78672. * Remove all attached input methods from a camera
  78673. */
  78674. clear(): void;
  78675. /**
  78676. * Serialize the current input manager attached to a camera.
  78677. * This ensures than once parsed,
  78678. * the input associated to the camera will be identical to the current ones
  78679. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  78680. */
  78681. serialize(serializedCamera: any): void;
  78682. /**
  78683. * Parses an input manager serialized JSON to restore the previous list of inputs
  78684. * and states associated to a camera.
  78685. * @param parsedCamera Defines the JSON to parse
  78686. */
  78687. parse(parsedCamera: any): void;
  78688. }
  78689. }
  78690. declare module BABYLON {
  78691. /**
  78692. * Class used to store data that will be store in GPU memory
  78693. */
  78694. export class Buffer {
  78695. private _engine;
  78696. private _buffer;
  78697. /** @hidden */
  78698. _data: Nullable<DataArray>;
  78699. private _updatable;
  78700. private _instanced;
  78701. private _divisor;
  78702. /**
  78703. * Gets the byte stride.
  78704. */
  78705. readonly byteStride: number;
  78706. /**
  78707. * Constructor
  78708. * @param engine the engine
  78709. * @param data the data to use for this buffer
  78710. * @param updatable whether the data is updatable
  78711. * @param stride the stride (optional)
  78712. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  78713. * @param instanced whether the buffer is instanced (optional)
  78714. * @param useBytes set to true if the stride in in bytes (optional)
  78715. * @param divisor sets an optional divisor for instances (1 by default)
  78716. */
  78717. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  78718. /**
  78719. * Create a new VertexBuffer based on the current buffer
  78720. * @param kind defines the vertex buffer kind (position, normal, etc.)
  78721. * @param offset defines offset in the buffer (0 by default)
  78722. * @param size defines the size in floats of attributes (position is 3 for instance)
  78723. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  78724. * @param instanced defines if the vertex buffer contains indexed data
  78725. * @param useBytes defines if the offset and stride are in bytes *
  78726. * @param divisor sets an optional divisor for instances (1 by default)
  78727. * @returns the new vertex buffer
  78728. */
  78729. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  78730. /**
  78731. * Gets a boolean indicating if the Buffer is updatable?
  78732. * @returns true if the buffer is updatable
  78733. */
  78734. isUpdatable(): boolean;
  78735. /**
  78736. * Gets current buffer's data
  78737. * @returns a DataArray or null
  78738. */
  78739. getData(): Nullable<DataArray>;
  78740. /**
  78741. * Gets underlying native buffer
  78742. * @returns underlying native buffer
  78743. */
  78744. getBuffer(): Nullable<DataBuffer>;
  78745. /**
  78746. * Gets the stride in float32 units (i.e. byte stride / 4).
  78747. * May not be an integer if the byte stride is not divisible by 4.
  78748. * @returns the stride in float32 units
  78749. * @deprecated Please use byteStride instead.
  78750. */
  78751. getStrideSize(): number;
  78752. /**
  78753. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  78754. * @param data defines the data to store
  78755. */
  78756. create(data?: Nullable<DataArray>): void;
  78757. /** @hidden */
  78758. _rebuild(): void;
  78759. /**
  78760. * Update current buffer data
  78761. * @param data defines the data to store
  78762. */
  78763. update(data: DataArray): void;
  78764. /**
  78765. * Updates the data directly.
  78766. * @param data the new data
  78767. * @param offset the new offset
  78768. * @param vertexCount the vertex count (optional)
  78769. * @param useBytes set to true if the offset is in bytes
  78770. */
  78771. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  78772. /**
  78773. * Release all resources
  78774. */
  78775. dispose(): void;
  78776. }
  78777. /**
  78778. * Specialized buffer used to store vertex data
  78779. */
  78780. export class VertexBuffer {
  78781. /** @hidden */
  78782. _buffer: Buffer;
  78783. private _kind;
  78784. private _size;
  78785. private _ownsBuffer;
  78786. private _instanced;
  78787. private _instanceDivisor;
  78788. /**
  78789. * The byte type.
  78790. */
  78791. static readonly BYTE: number;
  78792. /**
  78793. * The unsigned byte type.
  78794. */
  78795. static readonly UNSIGNED_BYTE: number;
  78796. /**
  78797. * The short type.
  78798. */
  78799. static readonly SHORT: number;
  78800. /**
  78801. * The unsigned short type.
  78802. */
  78803. static readonly UNSIGNED_SHORT: number;
  78804. /**
  78805. * The integer type.
  78806. */
  78807. static readonly INT: number;
  78808. /**
  78809. * The unsigned integer type.
  78810. */
  78811. static readonly UNSIGNED_INT: number;
  78812. /**
  78813. * The float type.
  78814. */
  78815. static readonly FLOAT: number;
  78816. /**
  78817. * Gets or sets the instance divisor when in instanced mode
  78818. */
  78819. get instanceDivisor(): number;
  78820. set instanceDivisor(value: number);
  78821. /**
  78822. * Gets the byte stride.
  78823. */
  78824. readonly byteStride: number;
  78825. /**
  78826. * Gets the byte offset.
  78827. */
  78828. readonly byteOffset: number;
  78829. /**
  78830. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  78831. */
  78832. readonly normalized: boolean;
  78833. /**
  78834. * Gets the data type of each component in the array.
  78835. */
  78836. readonly type: number;
  78837. /**
  78838. * Constructor
  78839. * @param engine the engine
  78840. * @param data the data to use for this vertex buffer
  78841. * @param kind the vertex buffer kind
  78842. * @param updatable whether the data is updatable
  78843. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  78844. * @param stride the stride (optional)
  78845. * @param instanced whether the buffer is instanced (optional)
  78846. * @param offset the offset of the data (optional)
  78847. * @param size the number of components (optional)
  78848. * @param type the type of the component (optional)
  78849. * @param normalized whether the data contains normalized data (optional)
  78850. * @param useBytes set to true if stride and offset are in bytes (optional)
  78851. * @param divisor defines the instance divisor to use (1 by default)
  78852. */
  78853. 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);
  78854. /** @hidden */
  78855. _rebuild(): void;
  78856. /**
  78857. * Returns the kind of the VertexBuffer (string)
  78858. * @returns a string
  78859. */
  78860. getKind(): string;
  78861. /**
  78862. * Gets a boolean indicating if the VertexBuffer is updatable?
  78863. * @returns true if the buffer is updatable
  78864. */
  78865. isUpdatable(): boolean;
  78866. /**
  78867. * Gets current buffer's data
  78868. * @returns a DataArray or null
  78869. */
  78870. getData(): Nullable<DataArray>;
  78871. /**
  78872. * Gets underlying native buffer
  78873. * @returns underlying native buffer
  78874. */
  78875. getBuffer(): Nullable<DataBuffer>;
  78876. /**
  78877. * Gets the stride in float32 units (i.e. byte stride / 4).
  78878. * May not be an integer if the byte stride is not divisible by 4.
  78879. * @returns the stride in float32 units
  78880. * @deprecated Please use byteStride instead.
  78881. */
  78882. getStrideSize(): number;
  78883. /**
  78884. * Returns the offset as a multiple of the type byte length.
  78885. * @returns the offset in bytes
  78886. * @deprecated Please use byteOffset instead.
  78887. */
  78888. getOffset(): number;
  78889. /**
  78890. * Returns the number of components per vertex attribute (integer)
  78891. * @returns the size in float
  78892. */
  78893. getSize(): number;
  78894. /**
  78895. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  78896. * @returns true if this buffer is instanced
  78897. */
  78898. getIsInstanced(): boolean;
  78899. /**
  78900. * Returns the instancing divisor, zero for non-instanced (integer).
  78901. * @returns a number
  78902. */
  78903. getInstanceDivisor(): number;
  78904. /**
  78905. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  78906. * @param data defines the data to store
  78907. */
  78908. create(data?: DataArray): void;
  78909. /**
  78910. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  78911. * This function will create a new buffer if the current one is not updatable
  78912. * @param data defines the data to store
  78913. */
  78914. update(data: DataArray): void;
  78915. /**
  78916. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  78917. * Returns the directly updated WebGLBuffer.
  78918. * @param data the new data
  78919. * @param offset the new offset
  78920. * @param useBytes set to true if the offset is in bytes
  78921. */
  78922. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  78923. /**
  78924. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  78925. */
  78926. dispose(): void;
  78927. /**
  78928. * Enumerates each value of this vertex buffer as numbers.
  78929. * @param count the number of values to enumerate
  78930. * @param callback the callback function called for each value
  78931. */
  78932. forEach(count: number, callback: (value: number, index: number) => void): void;
  78933. /**
  78934. * Positions
  78935. */
  78936. static readonly PositionKind: string;
  78937. /**
  78938. * Normals
  78939. */
  78940. static readonly NormalKind: string;
  78941. /**
  78942. * Tangents
  78943. */
  78944. static readonly TangentKind: string;
  78945. /**
  78946. * Texture coordinates
  78947. */
  78948. static readonly UVKind: string;
  78949. /**
  78950. * Texture coordinates 2
  78951. */
  78952. static readonly UV2Kind: string;
  78953. /**
  78954. * Texture coordinates 3
  78955. */
  78956. static readonly UV3Kind: string;
  78957. /**
  78958. * Texture coordinates 4
  78959. */
  78960. static readonly UV4Kind: string;
  78961. /**
  78962. * Texture coordinates 5
  78963. */
  78964. static readonly UV5Kind: string;
  78965. /**
  78966. * Texture coordinates 6
  78967. */
  78968. static readonly UV6Kind: string;
  78969. /**
  78970. * Colors
  78971. */
  78972. static readonly ColorKind: string;
  78973. /**
  78974. * Matrix indices (for bones)
  78975. */
  78976. static readonly MatricesIndicesKind: string;
  78977. /**
  78978. * Matrix weights (for bones)
  78979. */
  78980. static readonly MatricesWeightsKind: string;
  78981. /**
  78982. * Additional matrix indices (for bones)
  78983. */
  78984. static readonly MatricesIndicesExtraKind: string;
  78985. /**
  78986. * Additional matrix weights (for bones)
  78987. */
  78988. static readonly MatricesWeightsExtraKind: string;
  78989. /**
  78990. * Deduces the stride given a kind.
  78991. * @param kind The kind string to deduce
  78992. * @returns The deduced stride
  78993. */
  78994. static DeduceStride(kind: string): number;
  78995. /**
  78996. * Gets the byte length of the given type.
  78997. * @param type the type
  78998. * @returns the number of bytes
  78999. */
  79000. static GetTypeByteLength(type: number): number;
  79001. /**
  79002. * Enumerates each value of the given parameters as numbers.
  79003. * @param data the data to enumerate
  79004. * @param byteOffset the byte offset of the data
  79005. * @param byteStride the byte stride of the data
  79006. * @param componentCount the number of components per element
  79007. * @param componentType the type of the component
  79008. * @param count the number of values to enumerate
  79009. * @param normalized whether the data is normalized
  79010. * @param callback the callback function called for each value
  79011. */
  79012. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79013. private static _GetFloatValue;
  79014. }
  79015. }
  79016. declare module BABYLON {
  79017. /**
  79018. * @hidden
  79019. */
  79020. export class IntersectionInfo {
  79021. bu: Nullable<number>;
  79022. bv: Nullable<number>;
  79023. distance: number;
  79024. faceId: number;
  79025. subMeshId: number;
  79026. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79027. }
  79028. }
  79029. declare module BABYLON {
  79030. /**
  79031. * Represens a plane by the equation ax + by + cz + d = 0
  79032. */
  79033. export class Plane {
  79034. private static _TmpMatrix;
  79035. /**
  79036. * Normal of the plane (a,b,c)
  79037. */
  79038. normal: Vector3;
  79039. /**
  79040. * d component of the plane
  79041. */
  79042. d: number;
  79043. /**
  79044. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79045. * @param a a component of the plane
  79046. * @param b b component of the plane
  79047. * @param c c component of the plane
  79048. * @param d d component of the plane
  79049. */
  79050. constructor(a: number, b: number, c: number, d: number);
  79051. /**
  79052. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79053. */
  79054. asArray(): number[];
  79055. /**
  79056. * @returns a new plane copied from the current Plane.
  79057. */
  79058. clone(): Plane;
  79059. /**
  79060. * @returns the string "Plane".
  79061. */
  79062. getClassName(): string;
  79063. /**
  79064. * @returns the Plane hash code.
  79065. */
  79066. getHashCode(): number;
  79067. /**
  79068. * Normalize the current Plane in place.
  79069. * @returns the updated Plane.
  79070. */
  79071. normalize(): Plane;
  79072. /**
  79073. * Applies a transformation the plane and returns the result
  79074. * @param transformation the transformation matrix to be applied to the plane
  79075. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79076. */
  79077. transform(transformation: DeepImmutable<Matrix>): Plane;
  79078. /**
  79079. * Calcualtte the dot product between the point and the plane normal
  79080. * @param point point to calculate the dot product with
  79081. * @returns the dot product (float) of the point coordinates and the plane normal.
  79082. */
  79083. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79084. /**
  79085. * Updates the current Plane from the plane defined by the three given points.
  79086. * @param point1 one of the points used to contruct the plane
  79087. * @param point2 one of the points used to contruct the plane
  79088. * @param point3 one of the points used to contruct the plane
  79089. * @returns the updated Plane.
  79090. */
  79091. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79092. /**
  79093. * Checks if the plane is facing a given direction
  79094. * @param direction the direction to check if the plane is facing
  79095. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79096. * @returns True is the vector "direction" is the same side than the plane normal.
  79097. */
  79098. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79099. /**
  79100. * Calculates the distance to a point
  79101. * @param point point to calculate distance to
  79102. * @returns the signed distance (float) from the given point to the Plane.
  79103. */
  79104. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79105. /**
  79106. * Creates a plane from an array
  79107. * @param array the array to create a plane from
  79108. * @returns a new Plane from the given array.
  79109. */
  79110. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79111. /**
  79112. * Creates a plane from three points
  79113. * @param point1 point used to create the plane
  79114. * @param point2 point used to create the plane
  79115. * @param point3 point used to create the plane
  79116. * @returns a new Plane defined by the three given points.
  79117. */
  79118. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79119. /**
  79120. * Creates a plane from an origin point and a normal
  79121. * @param origin origin of the plane to be constructed
  79122. * @param normal normal of the plane to be constructed
  79123. * @returns a new Plane the normal vector to this plane at the given origin point.
  79124. * Note : the vector "normal" is updated because normalized.
  79125. */
  79126. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79127. /**
  79128. * Calculates the distance from a plane and a point
  79129. * @param origin origin of the plane to be constructed
  79130. * @param normal normal of the plane to be constructed
  79131. * @param point point to calculate distance to
  79132. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79133. */
  79134. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79135. }
  79136. }
  79137. declare module BABYLON {
  79138. /**
  79139. * Class used to store bounding sphere information
  79140. */
  79141. export class BoundingSphere {
  79142. /**
  79143. * Gets the center of the bounding sphere in local space
  79144. */
  79145. readonly center: Vector3;
  79146. /**
  79147. * Radius of the bounding sphere in local space
  79148. */
  79149. radius: number;
  79150. /**
  79151. * Gets the center of the bounding sphere in world space
  79152. */
  79153. readonly centerWorld: Vector3;
  79154. /**
  79155. * Radius of the bounding sphere in world space
  79156. */
  79157. radiusWorld: number;
  79158. /**
  79159. * Gets the minimum vector in local space
  79160. */
  79161. readonly minimum: Vector3;
  79162. /**
  79163. * Gets the maximum vector in local space
  79164. */
  79165. readonly maximum: Vector3;
  79166. private _worldMatrix;
  79167. private static readonly TmpVector3;
  79168. /**
  79169. * Creates a new bounding sphere
  79170. * @param min defines the minimum vector (in local space)
  79171. * @param max defines the maximum vector (in local space)
  79172. * @param worldMatrix defines the new world matrix
  79173. */
  79174. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79175. /**
  79176. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79177. * @param min defines the new minimum vector (in local space)
  79178. * @param max defines the new maximum vector (in local space)
  79179. * @param worldMatrix defines the new world matrix
  79180. */
  79181. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79182. /**
  79183. * Scale the current bounding sphere by applying a scale factor
  79184. * @param factor defines the scale factor to apply
  79185. * @returns the current bounding box
  79186. */
  79187. scale(factor: number): BoundingSphere;
  79188. /**
  79189. * Gets the world matrix of the bounding box
  79190. * @returns a matrix
  79191. */
  79192. getWorldMatrix(): DeepImmutable<Matrix>;
  79193. /** @hidden */
  79194. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79195. /**
  79196. * Tests if the bounding sphere is intersecting the frustum planes
  79197. * @param frustumPlanes defines the frustum planes to test
  79198. * @returns true if there is an intersection
  79199. */
  79200. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79201. /**
  79202. * Tests if the bounding sphere center is in between the frustum planes.
  79203. * Used for optimistic fast inclusion.
  79204. * @param frustumPlanes defines the frustum planes to test
  79205. * @returns true if the sphere center is in between the frustum planes
  79206. */
  79207. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79208. /**
  79209. * Tests if a point is inside the bounding sphere
  79210. * @param point defines the point to test
  79211. * @returns true if the point is inside the bounding sphere
  79212. */
  79213. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79214. /**
  79215. * Checks if two sphere intersct
  79216. * @param sphere0 sphere 0
  79217. * @param sphere1 sphere 1
  79218. * @returns true if the speres intersect
  79219. */
  79220. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  79221. }
  79222. }
  79223. declare module BABYLON {
  79224. /**
  79225. * Class used to store bounding box information
  79226. */
  79227. export class BoundingBox implements ICullable {
  79228. /**
  79229. * Gets the 8 vectors representing the bounding box in local space
  79230. */
  79231. readonly vectors: Vector3[];
  79232. /**
  79233. * Gets the center of the bounding box in local space
  79234. */
  79235. readonly center: Vector3;
  79236. /**
  79237. * Gets the center of the bounding box in world space
  79238. */
  79239. readonly centerWorld: Vector3;
  79240. /**
  79241. * Gets the extend size in local space
  79242. */
  79243. readonly extendSize: Vector3;
  79244. /**
  79245. * Gets the extend size in world space
  79246. */
  79247. readonly extendSizeWorld: Vector3;
  79248. /**
  79249. * Gets the OBB (object bounding box) directions
  79250. */
  79251. readonly directions: Vector3[];
  79252. /**
  79253. * Gets the 8 vectors representing the bounding box in world space
  79254. */
  79255. readonly vectorsWorld: Vector3[];
  79256. /**
  79257. * Gets the minimum vector in world space
  79258. */
  79259. readonly minimumWorld: Vector3;
  79260. /**
  79261. * Gets the maximum vector in world space
  79262. */
  79263. readonly maximumWorld: Vector3;
  79264. /**
  79265. * Gets the minimum vector in local space
  79266. */
  79267. readonly minimum: Vector3;
  79268. /**
  79269. * Gets the maximum vector in local space
  79270. */
  79271. readonly maximum: Vector3;
  79272. private _worldMatrix;
  79273. private static readonly TmpVector3;
  79274. /**
  79275. * @hidden
  79276. */
  79277. _tag: number;
  79278. /**
  79279. * Creates a new bounding box
  79280. * @param min defines the minimum vector (in local space)
  79281. * @param max defines the maximum vector (in local space)
  79282. * @param worldMatrix defines the new world matrix
  79283. */
  79284. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79285. /**
  79286. * Recreates the entire bounding box from scratch as if we call the constructor in place
  79287. * @param min defines the new minimum vector (in local space)
  79288. * @param max defines the new maximum vector (in local space)
  79289. * @param worldMatrix defines the new world matrix
  79290. */
  79291. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79292. /**
  79293. * Scale the current bounding box by applying a scale factor
  79294. * @param factor defines the scale factor to apply
  79295. * @returns the current bounding box
  79296. */
  79297. scale(factor: number): BoundingBox;
  79298. /**
  79299. * Gets the world matrix of the bounding box
  79300. * @returns a matrix
  79301. */
  79302. getWorldMatrix(): DeepImmutable<Matrix>;
  79303. /** @hidden */
  79304. _update(world: DeepImmutable<Matrix>): void;
  79305. /**
  79306. * Tests if the bounding box is intersecting the frustum planes
  79307. * @param frustumPlanes defines the frustum planes to test
  79308. * @returns true if there is an intersection
  79309. */
  79310. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79311. /**
  79312. * Tests if the bounding box is entirely inside the frustum planes
  79313. * @param frustumPlanes defines the frustum planes to test
  79314. * @returns true if there is an inclusion
  79315. */
  79316. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79317. /**
  79318. * Tests if a point is inside the bounding box
  79319. * @param point defines the point to test
  79320. * @returns true if the point is inside the bounding box
  79321. */
  79322. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79323. /**
  79324. * Tests if the bounding box intersects with a bounding sphere
  79325. * @param sphere defines the sphere to test
  79326. * @returns true if there is an intersection
  79327. */
  79328. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  79329. /**
  79330. * Tests if the bounding box intersects with a box defined by a min and max vectors
  79331. * @param min defines the min vector to use
  79332. * @param max defines the max vector to use
  79333. * @returns true if there is an intersection
  79334. */
  79335. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  79336. /**
  79337. * Tests if two bounding boxes are intersections
  79338. * @param box0 defines the first box to test
  79339. * @param box1 defines the second box to test
  79340. * @returns true if there is an intersection
  79341. */
  79342. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  79343. /**
  79344. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  79345. * @param minPoint defines the minimum vector of the bounding box
  79346. * @param maxPoint defines the maximum vector of the bounding box
  79347. * @param sphereCenter defines the sphere center
  79348. * @param sphereRadius defines the sphere radius
  79349. * @returns true if there is an intersection
  79350. */
  79351. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  79352. /**
  79353. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  79354. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79355. * @param frustumPlanes defines the frustum planes to test
  79356. * @return true if there is an inclusion
  79357. */
  79358. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79359. /**
  79360. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  79361. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79362. * @param frustumPlanes defines the frustum planes to test
  79363. * @return true if there is an intersection
  79364. */
  79365. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79366. }
  79367. }
  79368. declare module BABYLON {
  79369. /** @hidden */
  79370. export class Collider {
  79371. /** Define if a collision was found */
  79372. collisionFound: boolean;
  79373. /**
  79374. * Define last intersection point in local space
  79375. */
  79376. intersectionPoint: Vector3;
  79377. /**
  79378. * Define last collided mesh
  79379. */
  79380. collidedMesh: Nullable<AbstractMesh>;
  79381. private _collisionPoint;
  79382. private _planeIntersectionPoint;
  79383. private _tempVector;
  79384. private _tempVector2;
  79385. private _tempVector3;
  79386. private _tempVector4;
  79387. private _edge;
  79388. private _baseToVertex;
  79389. private _destinationPoint;
  79390. private _slidePlaneNormal;
  79391. private _displacementVector;
  79392. /** @hidden */
  79393. _radius: Vector3;
  79394. /** @hidden */
  79395. _retry: number;
  79396. private _velocity;
  79397. private _basePoint;
  79398. private _epsilon;
  79399. /** @hidden */
  79400. _velocityWorldLength: number;
  79401. /** @hidden */
  79402. _basePointWorld: Vector3;
  79403. private _velocityWorld;
  79404. private _normalizedVelocity;
  79405. /** @hidden */
  79406. _initialVelocity: Vector3;
  79407. /** @hidden */
  79408. _initialPosition: Vector3;
  79409. private _nearestDistance;
  79410. private _collisionMask;
  79411. get collisionMask(): number;
  79412. set collisionMask(mask: number);
  79413. /**
  79414. * Gets the plane normal used to compute the sliding response (in local space)
  79415. */
  79416. get slidePlaneNormal(): Vector3;
  79417. /** @hidden */
  79418. _initialize(source: Vector3, dir: Vector3, e: number): void;
  79419. /** @hidden */
  79420. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  79421. /** @hidden */
  79422. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  79423. /** @hidden */
  79424. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79425. /** @hidden */
  79426. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79427. /** @hidden */
  79428. _getResponse(pos: Vector3, vel: Vector3): void;
  79429. }
  79430. }
  79431. declare module BABYLON {
  79432. /**
  79433. * Interface for cullable objects
  79434. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  79435. */
  79436. export interface ICullable {
  79437. /**
  79438. * Checks if the object or part of the object is in the frustum
  79439. * @param frustumPlanes Camera near/planes
  79440. * @returns true if the object is in frustum otherwise false
  79441. */
  79442. isInFrustum(frustumPlanes: Plane[]): boolean;
  79443. /**
  79444. * Checks if a cullable object (mesh...) is in the camera frustum
  79445. * Unlike isInFrustum this cheks the full bounding box
  79446. * @param frustumPlanes Camera near/planes
  79447. * @returns true if the object is in frustum otherwise false
  79448. */
  79449. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79450. }
  79451. /**
  79452. * Info for a bounding data of a mesh
  79453. */
  79454. export class BoundingInfo implements ICullable {
  79455. /**
  79456. * Bounding box for the mesh
  79457. */
  79458. readonly boundingBox: BoundingBox;
  79459. /**
  79460. * Bounding sphere for the mesh
  79461. */
  79462. readonly boundingSphere: BoundingSphere;
  79463. private _isLocked;
  79464. private static readonly TmpVector3;
  79465. /**
  79466. * Constructs bounding info
  79467. * @param minimum min vector of the bounding box/sphere
  79468. * @param maximum max vector of the bounding box/sphere
  79469. * @param worldMatrix defines the new world matrix
  79470. */
  79471. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79472. /**
  79473. * Recreates the entire bounding info from scratch as if we call the constructor in place
  79474. * @param min defines the new minimum vector (in local space)
  79475. * @param max defines the new maximum vector (in local space)
  79476. * @param worldMatrix defines the new world matrix
  79477. */
  79478. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79479. /**
  79480. * min vector of the bounding box/sphere
  79481. */
  79482. get minimum(): Vector3;
  79483. /**
  79484. * max vector of the bounding box/sphere
  79485. */
  79486. get maximum(): Vector3;
  79487. /**
  79488. * If the info is locked and won't be updated to avoid perf overhead
  79489. */
  79490. get isLocked(): boolean;
  79491. set isLocked(value: boolean);
  79492. /**
  79493. * Updates the bounding sphere and box
  79494. * @param world world matrix to be used to update
  79495. */
  79496. update(world: DeepImmutable<Matrix>): void;
  79497. /**
  79498. * Recreate the bounding info to be centered around a specific point given a specific extend.
  79499. * @param center New center of the bounding info
  79500. * @param extend New extend of the bounding info
  79501. * @returns the current bounding info
  79502. */
  79503. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  79504. /**
  79505. * Scale the current bounding info by applying a scale factor
  79506. * @param factor defines the scale factor to apply
  79507. * @returns the current bounding info
  79508. */
  79509. scale(factor: number): BoundingInfo;
  79510. /**
  79511. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  79512. * @param frustumPlanes defines the frustum to test
  79513. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  79514. * @returns true if the bounding info is in the frustum planes
  79515. */
  79516. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  79517. /**
  79518. * Gets the world distance between the min and max points of the bounding box
  79519. */
  79520. get diagonalLength(): number;
  79521. /**
  79522. * Checks if a cullable object (mesh...) is in the camera frustum
  79523. * Unlike isInFrustum this cheks the full bounding box
  79524. * @param frustumPlanes Camera near/planes
  79525. * @returns true if the object is in frustum otherwise false
  79526. */
  79527. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79528. /** @hidden */
  79529. _checkCollision(collider: Collider): boolean;
  79530. /**
  79531. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  79532. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79533. * @param point the point to check intersection with
  79534. * @returns if the point intersects
  79535. */
  79536. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79537. /**
  79538. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  79539. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79540. * @param boundingInfo the bounding info to check intersection with
  79541. * @param precise if the intersection should be done using OBB
  79542. * @returns if the bounding info intersects
  79543. */
  79544. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  79545. }
  79546. }
  79547. declare module BABYLON {
  79548. /**
  79549. * Extracts minimum and maximum values from a list of indexed positions
  79550. * @param positions defines the positions to use
  79551. * @param indices defines the indices to the positions
  79552. * @param indexStart defines the start index
  79553. * @param indexCount defines the end index
  79554. * @param bias defines bias value to add to the result
  79555. * @return minimum and maximum values
  79556. */
  79557. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  79558. minimum: Vector3;
  79559. maximum: Vector3;
  79560. };
  79561. /**
  79562. * Extracts minimum and maximum values from a list of positions
  79563. * @param positions defines the positions to use
  79564. * @param start defines the start index in the positions array
  79565. * @param count defines the number of positions to handle
  79566. * @param bias defines bias value to add to the result
  79567. * @param stride defines the stride size to use (distance between two positions in the positions array)
  79568. * @return minimum and maximum values
  79569. */
  79570. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  79571. minimum: Vector3;
  79572. maximum: Vector3;
  79573. };
  79574. }
  79575. declare module BABYLON {
  79576. /** @hidden */
  79577. export class WebGLDataBuffer extends DataBuffer {
  79578. private _buffer;
  79579. constructor(resource: WebGLBuffer);
  79580. get underlyingResource(): any;
  79581. }
  79582. }
  79583. declare module BABYLON {
  79584. /** @hidden */
  79585. export class WebGLPipelineContext implements IPipelineContext {
  79586. engine: ThinEngine;
  79587. program: Nullable<WebGLProgram>;
  79588. context?: WebGLRenderingContext;
  79589. vertexShader?: WebGLShader;
  79590. fragmentShader?: WebGLShader;
  79591. isParallelCompiled: boolean;
  79592. onCompiled?: () => void;
  79593. transformFeedback?: WebGLTransformFeedback | null;
  79594. vertexCompilationError: Nullable<string>;
  79595. fragmentCompilationError: Nullable<string>;
  79596. programLinkError: Nullable<string>;
  79597. programValidationError: Nullable<string>;
  79598. get isAsync(): boolean;
  79599. get isReady(): boolean;
  79600. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  79601. }
  79602. }
  79603. declare module BABYLON {
  79604. interface ThinEngine {
  79605. /**
  79606. * Create an uniform buffer
  79607. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79608. * @param elements defines the content of the uniform buffer
  79609. * @returns the webGL uniform buffer
  79610. */
  79611. createUniformBuffer(elements: FloatArray): DataBuffer;
  79612. /**
  79613. * Create a dynamic uniform buffer
  79614. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79615. * @param elements defines the content of the uniform buffer
  79616. * @returns the webGL uniform buffer
  79617. */
  79618. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  79619. /**
  79620. * Update an existing uniform buffer
  79621. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79622. * @param uniformBuffer defines the target uniform buffer
  79623. * @param elements defines the content to update
  79624. * @param offset defines the offset in the uniform buffer where update should start
  79625. * @param count defines the size of the data to update
  79626. */
  79627. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  79628. /**
  79629. * Bind an uniform buffer to the current webGL context
  79630. * @param buffer defines the buffer to bind
  79631. */
  79632. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  79633. /**
  79634. * Bind a buffer to the current webGL context at a given location
  79635. * @param buffer defines the buffer to bind
  79636. * @param location defines the index where to bind the buffer
  79637. */
  79638. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  79639. /**
  79640. * Bind a specific block at a given index in a specific shader program
  79641. * @param pipelineContext defines the pipeline context to use
  79642. * @param blockName defines the block name
  79643. * @param index defines the index where to bind the block
  79644. */
  79645. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  79646. }
  79647. }
  79648. declare module BABYLON {
  79649. /**
  79650. * Uniform buffer objects.
  79651. *
  79652. * Handles blocks of uniform on the GPU.
  79653. *
  79654. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79655. *
  79656. * For more information, please refer to :
  79657. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79658. */
  79659. export class UniformBuffer {
  79660. private _engine;
  79661. private _buffer;
  79662. private _data;
  79663. private _bufferData;
  79664. private _dynamic?;
  79665. private _uniformLocations;
  79666. private _uniformSizes;
  79667. private _uniformLocationPointer;
  79668. private _needSync;
  79669. private _noUBO;
  79670. private _currentEffect;
  79671. /** @hidden */
  79672. _alreadyBound: boolean;
  79673. private static _MAX_UNIFORM_SIZE;
  79674. private static _tempBuffer;
  79675. /**
  79676. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  79677. * This is dynamic to allow compat with webgl 1 and 2.
  79678. * You will need to pass the name of the uniform as well as the value.
  79679. */
  79680. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  79681. /**
  79682. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  79683. * This is dynamic to allow compat with webgl 1 and 2.
  79684. * You will need to pass the name of the uniform as well as the value.
  79685. */
  79686. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  79687. /**
  79688. * Lambda to Update a single float in a uniform buffer.
  79689. * This is dynamic to allow compat with webgl 1 and 2.
  79690. * You will need to pass the name of the uniform as well as the value.
  79691. */
  79692. updateFloat: (name: string, x: number) => void;
  79693. /**
  79694. * Lambda to Update a vec2 of float in a uniform buffer.
  79695. * This is dynamic to allow compat with webgl 1 and 2.
  79696. * You will need to pass the name of the uniform as well as the value.
  79697. */
  79698. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  79699. /**
  79700. * Lambda to Update a vec3 of float in a uniform buffer.
  79701. * This is dynamic to allow compat with webgl 1 and 2.
  79702. * You will need to pass the name of the uniform as well as the value.
  79703. */
  79704. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  79705. /**
  79706. * Lambda to Update a vec4 of float in a uniform buffer.
  79707. * This is dynamic to allow compat with webgl 1 and 2.
  79708. * You will need to pass the name of the uniform as well as the value.
  79709. */
  79710. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  79711. /**
  79712. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  79713. * This is dynamic to allow compat with webgl 1 and 2.
  79714. * You will need to pass the name of the uniform as well as the value.
  79715. */
  79716. updateMatrix: (name: string, mat: Matrix) => void;
  79717. /**
  79718. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  79719. * This is dynamic to allow compat with webgl 1 and 2.
  79720. * You will need to pass the name of the uniform as well as the value.
  79721. */
  79722. updateVector3: (name: string, vector: Vector3) => void;
  79723. /**
  79724. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  79725. * This is dynamic to allow compat with webgl 1 and 2.
  79726. * You will need to pass the name of the uniform as well as the value.
  79727. */
  79728. updateVector4: (name: string, vector: Vector4) => void;
  79729. /**
  79730. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  79731. * This is dynamic to allow compat with webgl 1 and 2.
  79732. * You will need to pass the name of the uniform as well as the value.
  79733. */
  79734. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  79735. /**
  79736. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  79737. * This is dynamic to allow compat with webgl 1 and 2.
  79738. * You will need to pass the name of the uniform as well as the value.
  79739. */
  79740. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  79741. /**
  79742. * Instantiates a new Uniform buffer objects.
  79743. *
  79744. * Handles blocks of uniform on the GPU.
  79745. *
  79746. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79747. *
  79748. * For more information, please refer to :
  79749. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79750. * @param engine Define the engine the buffer is associated with
  79751. * @param data Define the data contained in the buffer
  79752. * @param dynamic Define if the buffer is updatable
  79753. */
  79754. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  79755. /**
  79756. * Indicates if the buffer is using the WebGL2 UBO implementation,
  79757. * or just falling back on setUniformXXX calls.
  79758. */
  79759. get useUbo(): boolean;
  79760. /**
  79761. * Indicates if the WebGL underlying uniform buffer is in sync
  79762. * with the javascript cache data.
  79763. */
  79764. get isSync(): boolean;
  79765. /**
  79766. * Indicates if the WebGL underlying uniform buffer is dynamic.
  79767. * Also, a dynamic UniformBuffer will disable cache verification and always
  79768. * update the underlying WebGL uniform buffer to the GPU.
  79769. * @returns if Dynamic, otherwise false
  79770. */
  79771. isDynamic(): boolean;
  79772. /**
  79773. * The data cache on JS side.
  79774. * @returns the underlying data as a float array
  79775. */
  79776. getData(): Float32Array;
  79777. /**
  79778. * The underlying WebGL Uniform buffer.
  79779. * @returns the webgl buffer
  79780. */
  79781. getBuffer(): Nullable<DataBuffer>;
  79782. /**
  79783. * std140 layout specifies how to align data within an UBO structure.
  79784. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  79785. * for specs.
  79786. */
  79787. private _fillAlignment;
  79788. /**
  79789. * Adds an uniform in the buffer.
  79790. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  79791. * for the layout to be correct !
  79792. * @param name Name of the uniform, as used in the uniform block in the shader.
  79793. * @param size Data size, or data directly.
  79794. */
  79795. addUniform(name: string, size: number | number[]): void;
  79796. /**
  79797. * Adds a Matrix 4x4 to the uniform buffer.
  79798. * @param name Name of the uniform, as used in the uniform block in the shader.
  79799. * @param mat A 4x4 matrix.
  79800. */
  79801. addMatrix(name: string, mat: Matrix): void;
  79802. /**
  79803. * Adds a vec2 to the uniform buffer.
  79804. * @param name Name of the uniform, as used in the uniform block in the shader.
  79805. * @param x Define the x component value of the vec2
  79806. * @param y Define the y component value of the vec2
  79807. */
  79808. addFloat2(name: string, x: number, y: number): void;
  79809. /**
  79810. * Adds a vec3 to the uniform buffer.
  79811. * @param name Name of the uniform, as used in the uniform block in the shader.
  79812. * @param x Define the x component value of the vec3
  79813. * @param y Define the y component value of the vec3
  79814. * @param z Define the z component value of the vec3
  79815. */
  79816. addFloat3(name: string, x: number, y: number, z: number): void;
  79817. /**
  79818. * Adds a vec3 to the uniform buffer.
  79819. * @param name Name of the uniform, as used in the uniform block in the shader.
  79820. * @param color Define the vec3 from a Color
  79821. */
  79822. addColor3(name: string, color: Color3): void;
  79823. /**
  79824. * Adds a vec4 to the uniform buffer.
  79825. * @param name Name of the uniform, as used in the uniform block in the shader.
  79826. * @param color Define the rgb components from a Color
  79827. * @param alpha Define the a component of the vec4
  79828. */
  79829. addColor4(name: string, color: Color3, alpha: number): void;
  79830. /**
  79831. * Adds a vec3 to the uniform buffer.
  79832. * @param name Name of the uniform, as used in the uniform block in the shader.
  79833. * @param vector Define the vec3 components from a Vector
  79834. */
  79835. addVector3(name: string, vector: Vector3): void;
  79836. /**
  79837. * Adds a Matrix 3x3 to the uniform buffer.
  79838. * @param name Name of the uniform, as used in the uniform block in the shader.
  79839. */
  79840. addMatrix3x3(name: string): void;
  79841. /**
  79842. * Adds a Matrix 2x2 to the uniform buffer.
  79843. * @param name Name of the uniform, as used in the uniform block in the shader.
  79844. */
  79845. addMatrix2x2(name: string): void;
  79846. /**
  79847. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  79848. */
  79849. create(): void;
  79850. /** @hidden */
  79851. _rebuild(): void;
  79852. /**
  79853. * Updates the WebGL Uniform Buffer on the GPU.
  79854. * If the `dynamic` flag is set to true, no cache comparison is done.
  79855. * Otherwise, the buffer will be updated only if the cache differs.
  79856. */
  79857. update(): void;
  79858. /**
  79859. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  79860. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  79861. * @param data Define the flattened data
  79862. * @param size Define the size of the data.
  79863. */
  79864. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  79865. private _valueCache;
  79866. private _cacheMatrix;
  79867. private _updateMatrix3x3ForUniform;
  79868. private _updateMatrix3x3ForEffect;
  79869. private _updateMatrix2x2ForEffect;
  79870. private _updateMatrix2x2ForUniform;
  79871. private _updateFloatForEffect;
  79872. private _updateFloatForUniform;
  79873. private _updateFloat2ForEffect;
  79874. private _updateFloat2ForUniform;
  79875. private _updateFloat3ForEffect;
  79876. private _updateFloat3ForUniform;
  79877. private _updateFloat4ForEffect;
  79878. private _updateFloat4ForUniform;
  79879. private _updateMatrixForEffect;
  79880. private _updateMatrixForUniform;
  79881. private _updateVector3ForEffect;
  79882. private _updateVector3ForUniform;
  79883. private _updateVector4ForEffect;
  79884. private _updateVector4ForUniform;
  79885. private _updateColor3ForEffect;
  79886. private _updateColor3ForUniform;
  79887. private _updateColor4ForEffect;
  79888. private _updateColor4ForUniform;
  79889. /**
  79890. * Sets a sampler uniform on the effect.
  79891. * @param name Define the name of the sampler.
  79892. * @param texture Define the texture to set in the sampler
  79893. */
  79894. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  79895. /**
  79896. * Directly updates the value of the uniform in the cache AND on the GPU.
  79897. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  79898. * @param data Define the flattened data
  79899. */
  79900. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  79901. /**
  79902. * Binds this uniform buffer to an effect.
  79903. * @param effect Define the effect to bind the buffer to
  79904. * @param name Name of the uniform block in the shader.
  79905. */
  79906. bindToEffect(effect: Effect, name: string): void;
  79907. /**
  79908. * Disposes the uniform buffer.
  79909. */
  79910. dispose(): void;
  79911. }
  79912. }
  79913. declare module BABYLON {
  79914. /**
  79915. * Enum that determines the text-wrapping mode to use.
  79916. */
  79917. export enum InspectableType {
  79918. /**
  79919. * Checkbox for booleans
  79920. */
  79921. Checkbox = 0,
  79922. /**
  79923. * Sliders for numbers
  79924. */
  79925. Slider = 1,
  79926. /**
  79927. * Vector3
  79928. */
  79929. Vector3 = 2,
  79930. /**
  79931. * Quaternions
  79932. */
  79933. Quaternion = 3,
  79934. /**
  79935. * Color3
  79936. */
  79937. Color3 = 4,
  79938. /**
  79939. * String
  79940. */
  79941. String = 5
  79942. }
  79943. /**
  79944. * Interface used to define custom inspectable properties.
  79945. * This interface is used by the inspector to display custom property grids
  79946. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79947. */
  79948. export interface IInspectable {
  79949. /**
  79950. * Gets the label to display
  79951. */
  79952. label: string;
  79953. /**
  79954. * Gets the name of the property to edit
  79955. */
  79956. propertyName: string;
  79957. /**
  79958. * Gets the type of the editor to use
  79959. */
  79960. type: InspectableType;
  79961. /**
  79962. * Gets the minimum value of the property when using in "slider" mode
  79963. */
  79964. min?: number;
  79965. /**
  79966. * Gets the maximum value of the property when using in "slider" mode
  79967. */
  79968. max?: number;
  79969. /**
  79970. * Gets the setp to use when using in "slider" mode
  79971. */
  79972. step?: number;
  79973. }
  79974. }
  79975. declare module BABYLON {
  79976. /**
  79977. * Class used to provide helper for timing
  79978. */
  79979. export class TimingTools {
  79980. /**
  79981. * Polyfill for setImmediate
  79982. * @param action defines the action to execute after the current execution block
  79983. */
  79984. static SetImmediate(action: () => void): void;
  79985. }
  79986. }
  79987. declare module BABYLON {
  79988. /**
  79989. * Class used to enable instatition of objects by class name
  79990. */
  79991. export class InstantiationTools {
  79992. /**
  79993. * Use this object to register external classes like custom textures or material
  79994. * to allow the laoders to instantiate them
  79995. */
  79996. static RegisteredExternalClasses: {
  79997. [key: string]: Object;
  79998. };
  79999. /**
  80000. * Tries to instantiate a new object from a given class name
  80001. * @param className defines the class name to instantiate
  80002. * @returns the new object or null if the system was not able to do the instantiation
  80003. */
  80004. static Instantiate(className: string): any;
  80005. }
  80006. }
  80007. declare module BABYLON {
  80008. /**
  80009. * Define options used to create a depth texture
  80010. */
  80011. export class DepthTextureCreationOptions {
  80012. /** Specifies whether or not a stencil should be allocated in the texture */
  80013. generateStencil?: boolean;
  80014. /** Specifies whether or not bilinear filtering is enable on the texture */
  80015. bilinearFiltering?: boolean;
  80016. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80017. comparisonFunction?: number;
  80018. /** Specifies if the created texture is a cube texture */
  80019. isCube?: boolean;
  80020. }
  80021. }
  80022. declare module BABYLON {
  80023. interface ThinEngine {
  80024. /**
  80025. * Creates a depth stencil cube texture.
  80026. * This is only available in WebGL 2.
  80027. * @param size The size of face edge in the cube texture.
  80028. * @param options The options defining the cube texture.
  80029. * @returns The cube texture
  80030. */
  80031. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80032. /**
  80033. * Creates a cube texture
  80034. * @param rootUrl defines the url where the files to load is located
  80035. * @param scene defines the current scene
  80036. * @param files defines the list of files to load (1 per face)
  80037. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80038. * @param onLoad defines an optional callback raised when the texture is loaded
  80039. * @param onError defines an optional callback raised if there is an issue to load the texture
  80040. * @param format defines the format of the data
  80041. * @param forcedExtension defines the extension to use to pick the right loader
  80042. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80043. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80044. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80045. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80046. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80047. * @returns the cube texture as an InternalTexture
  80048. */
  80049. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  80050. /**
  80051. * Creates a cube texture
  80052. * @param rootUrl defines the url where the files to load is located
  80053. * @param scene defines the current scene
  80054. * @param files defines the list of files to load (1 per face)
  80055. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80056. * @param onLoad defines an optional callback raised when the texture is loaded
  80057. * @param onError defines an optional callback raised if there is an issue to load the texture
  80058. * @param format defines the format of the data
  80059. * @param forcedExtension defines the extension to use to pick the right loader
  80060. * @returns the cube texture as an InternalTexture
  80061. */
  80062. 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;
  80063. /**
  80064. * Creates a cube texture
  80065. * @param rootUrl defines the url where the files to load is located
  80066. * @param scene defines the current scene
  80067. * @param files defines the list of files to load (1 per face)
  80068. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80069. * @param onLoad defines an optional callback raised when the texture is loaded
  80070. * @param onError defines an optional callback raised if there is an issue to load the texture
  80071. * @param format defines the format of the data
  80072. * @param forcedExtension defines the extension to use to pick the right loader
  80073. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80074. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80075. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80076. * @returns the cube texture as an InternalTexture
  80077. */
  80078. 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;
  80079. /** @hidden */
  80080. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80081. /** @hidden */
  80082. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80083. /** @hidden */
  80084. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80085. /** @hidden */
  80086. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80087. /**
  80088. * @hidden
  80089. */
  80090. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80091. }
  80092. }
  80093. declare module BABYLON {
  80094. /**
  80095. * Class for creating a cube texture
  80096. */
  80097. export class CubeTexture extends BaseTexture {
  80098. private _delayedOnLoad;
  80099. /**
  80100. * The url of the texture
  80101. */
  80102. url: string;
  80103. /**
  80104. * Gets or sets the center of the bounding box associated with the cube texture.
  80105. * It must define where the camera used to render the texture was set
  80106. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80107. */
  80108. boundingBoxPosition: Vector3;
  80109. private _boundingBoxSize;
  80110. /**
  80111. * Gets or sets the size of the bounding box associated with the cube texture
  80112. * When defined, the cubemap will switch to local mode
  80113. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80114. * @example https://www.babylonjs-playground.com/#RNASML
  80115. */
  80116. set boundingBoxSize(value: Vector3);
  80117. /**
  80118. * Returns the bounding box size
  80119. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80120. */
  80121. get boundingBoxSize(): Vector3;
  80122. protected _rotationY: number;
  80123. /**
  80124. * Sets texture matrix rotation angle around Y axis in radians.
  80125. */
  80126. set rotationY(value: number);
  80127. /**
  80128. * Gets texture matrix rotation angle around Y axis radians.
  80129. */
  80130. get rotationY(): number;
  80131. /**
  80132. * Are mip maps generated for this texture or not.
  80133. */
  80134. get noMipmap(): boolean;
  80135. private _noMipmap;
  80136. private _files;
  80137. protected _forcedExtension: Nullable<string>;
  80138. private _extensions;
  80139. private _textureMatrix;
  80140. private _format;
  80141. private _createPolynomials;
  80142. /** @hidden */
  80143. _prefiltered: boolean;
  80144. /**
  80145. * Creates a cube texture from an array of image urls
  80146. * @param files defines an array of image urls
  80147. * @param scene defines the hosting scene
  80148. * @param noMipmap specifies if mip maps are not used
  80149. * @returns a cube texture
  80150. */
  80151. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80152. /**
  80153. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80154. * @param url defines the url of the prefiltered texture
  80155. * @param scene defines the scene the texture is attached to
  80156. * @param forcedExtension defines the extension of the file if different from the url
  80157. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80158. * @return the prefiltered texture
  80159. */
  80160. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80161. /**
  80162. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80163. * as prefiltered data.
  80164. * @param rootUrl defines the url of the texture or the root name of the six images
  80165. * @param scene defines the scene the texture is attached to
  80166. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80167. * @param noMipmap defines if mipmaps should be created or not
  80168. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80169. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80170. * @param onError defines a callback triggered in case of error during load
  80171. * @param format defines the internal format to use for the texture once loaded
  80172. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80173. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80174. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80175. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80176. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80177. * @return the cube texture
  80178. */
  80179. 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);
  80180. /**
  80181. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80182. */
  80183. get isPrefiltered(): boolean;
  80184. /**
  80185. * Get the current class name of the texture useful for serialization or dynamic coding.
  80186. * @returns "CubeTexture"
  80187. */
  80188. getClassName(): string;
  80189. /**
  80190. * Update the url (and optional buffer) of this texture if url was null during construction.
  80191. * @param url the url of the texture
  80192. * @param forcedExtension defines the extension to use
  80193. * @param onLoad callback called when the texture is loaded (defaults to null)
  80194. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80195. */
  80196. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80197. /**
  80198. * Delays loading of the cube texture
  80199. * @param forcedExtension defines the extension to use
  80200. */
  80201. delayLoad(forcedExtension?: string): void;
  80202. /**
  80203. * Returns the reflection texture matrix
  80204. * @returns the reflection texture matrix
  80205. */
  80206. getReflectionTextureMatrix(): Matrix;
  80207. /**
  80208. * Sets the reflection texture matrix
  80209. * @param value Reflection texture matrix
  80210. */
  80211. setReflectionTextureMatrix(value: Matrix): void;
  80212. /**
  80213. * Parses text to create a cube texture
  80214. * @param parsedTexture define the serialized text to read from
  80215. * @param scene defines the hosting scene
  80216. * @param rootUrl defines the root url of the cube texture
  80217. * @returns a cube texture
  80218. */
  80219. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  80220. /**
  80221. * Makes a clone, or deep copy, of the cube texture
  80222. * @returns a new cube texture
  80223. */
  80224. clone(): CubeTexture;
  80225. }
  80226. }
  80227. declare module BABYLON {
  80228. /**
  80229. * Manages the defines for the Material
  80230. */
  80231. export class MaterialDefines {
  80232. /** @hidden */
  80233. protected _keys: string[];
  80234. private _isDirty;
  80235. /** @hidden */
  80236. _renderId: number;
  80237. /** @hidden */
  80238. _areLightsDirty: boolean;
  80239. /** @hidden */
  80240. _areLightsDisposed: boolean;
  80241. /** @hidden */
  80242. _areAttributesDirty: boolean;
  80243. /** @hidden */
  80244. _areTexturesDirty: boolean;
  80245. /** @hidden */
  80246. _areFresnelDirty: boolean;
  80247. /** @hidden */
  80248. _areMiscDirty: boolean;
  80249. /** @hidden */
  80250. _areImageProcessingDirty: boolean;
  80251. /** @hidden */
  80252. _normals: boolean;
  80253. /** @hidden */
  80254. _uvs: boolean;
  80255. /** @hidden */
  80256. _needNormals: boolean;
  80257. /** @hidden */
  80258. _needUVs: boolean;
  80259. [id: string]: any;
  80260. /**
  80261. * Specifies if the material needs to be re-calculated
  80262. */
  80263. get isDirty(): boolean;
  80264. /**
  80265. * Marks the material to indicate that it has been re-calculated
  80266. */
  80267. markAsProcessed(): void;
  80268. /**
  80269. * Marks the material to indicate that it needs to be re-calculated
  80270. */
  80271. markAsUnprocessed(): void;
  80272. /**
  80273. * Marks the material to indicate all of its defines need to be re-calculated
  80274. */
  80275. markAllAsDirty(): void;
  80276. /**
  80277. * Marks the material to indicate that image processing needs to be re-calculated
  80278. */
  80279. markAsImageProcessingDirty(): void;
  80280. /**
  80281. * Marks the material to indicate the lights need to be re-calculated
  80282. * @param disposed Defines whether the light is dirty due to dispose or not
  80283. */
  80284. markAsLightDirty(disposed?: boolean): void;
  80285. /**
  80286. * Marks the attribute state as changed
  80287. */
  80288. markAsAttributesDirty(): void;
  80289. /**
  80290. * Marks the texture state as changed
  80291. */
  80292. markAsTexturesDirty(): void;
  80293. /**
  80294. * Marks the fresnel state as changed
  80295. */
  80296. markAsFresnelDirty(): void;
  80297. /**
  80298. * Marks the misc state as changed
  80299. */
  80300. markAsMiscDirty(): void;
  80301. /**
  80302. * Rebuilds the material defines
  80303. */
  80304. rebuild(): void;
  80305. /**
  80306. * Specifies if two material defines are equal
  80307. * @param other - A material define instance to compare to
  80308. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  80309. */
  80310. isEqual(other: MaterialDefines): boolean;
  80311. /**
  80312. * Clones this instance's defines to another instance
  80313. * @param other - material defines to clone values to
  80314. */
  80315. cloneTo(other: MaterialDefines): void;
  80316. /**
  80317. * Resets the material define values
  80318. */
  80319. reset(): void;
  80320. /**
  80321. * Converts the material define values to a string
  80322. * @returns - String of material define information
  80323. */
  80324. toString(): string;
  80325. }
  80326. }
  80327. declare module BABYLON {
  80328. /**
  80329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  80330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  80331. * 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;
  80332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  80333. */
  80334. export class ColorCurves {
  80335. private _dirty;
  80336. private _tempColor;
  80337. private _globalCurve;
  80338. private _highlightsCurve;
  80339. private _midtonesCurve;
  80340. private _shadowsCurve;
  80341. private _positiveCurve;
  80342. private _negativeCurve;
  80343. private _globalHue;
  80344. private _globalDensity;
  80345. private _globalSaturation;
  80346. private _globalExposure;
  80347. /**
  80348. * Gets the global Hue value.
  80349. * 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).
  80350. */
  80351. get globalHue(): number;
  80352. /**
  80353. * Sets the global Hue value.
  80354. * 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).
  80355. */
  80356. set globalHue(value: number);
  80357. /**
  80358. * Gets the global Density value.
  80359. * 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.
  80360. * Values less than zero provide a filter of opposite hue.
  80361. */
  80362. get globalDensity(): number;
  80363. /**
  80364. * Sets the global Density value.
  80365. * 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.
  80366. * Values less than zero provide a filter of opposite hue.
  80367. */
  80368. set globalDensity(value: number);
  80369. /**
  80370. * Gets the global Saturation value.
  80371. * 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.
  80372. */
  80373. get globalSaturation(): number;
  80374. /**
  80375. * Sets the global Saturation value.
  80376. * 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.
  80377. */
  80378. set globalSaturation(value: number);
  80379. /**
  80380. * Gets the global Exposure value.
  80381. * 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.
  80382. */
  80383. get globalExposure(): number;
  80384. /**
  80385. * Sets the global Exposure value.
  80386. * 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.
  80387. */
  80388. set globalExposure(value: number);
  80389. private _highlightsHue;
  80390. private _highlightsDensity;
  80391. private _highlightsSaturation;
  80392. private _highlightsExposure;
  80393. /**
  80394. * Gets the highlights Hue value.
  80395. * 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).
  80396. */
  80397. get highlightsHue(): number;
  80398. /**
  80399. * Sets the highlights Hue value.
  80400. * 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).
  80401. */
  80402. set highlightsHue(value: number);
  80403. /**
  80404. * Gets the highlights Density value.
  80405. * 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.
  80406. * Values less than zero provide a filter of opposite hue.
  80407. */
  80408. get highlightsDensity(): number;
  80409. /**
  80410. * Sets the highlights Density value.
  80411. * 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.
  80412. * Values less than zero provide a filter of opposite hue.
  80413. */
  80414. set highlightsDensity(value: number);
  80415. /**
  80416. * Gets the highlights Saturation value.
  80417. * 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.
  80418. */
  80419. get highlightsSaturation(): number;
  80420. /**
  80421. * Sets the highlights Saturation value.
  80422. * 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.
  80423. */
  80424. set highlightsSaturation(value: number);
  80425. /**
  80426. * Gets the highlights Exposure value.
  80427. * 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.
  80428. */
  80429. get highlightsExposure(): number;
  80430. /**
  80431. * Sets the highlights Exposure value.
  80432. * 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.
  80433. */
  80434. set highlightsExposure(value: number);
  80435. private _midtonesHue;
  80436. private _midtonesDensity;
  80437. private _midtonesSaturation;
  80438. private _midtonesExposure;
  80439. /**
  80440. * Gets the midtones Hue value.
  80441. * 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).
  80442. */
  80443. get midtonesHue(): number;
  80444. /**
  80445. * Sets the midtones Hue value.
  80446. * 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).
  80447. */
  80448. set midtonesHue(value: number);
  80449. /**
  80450. * Gets the midtones Density value.
  80451. * 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.
  80452. * Values less than zero provide a filter of opposite hue.
  80453. */
  80454. get midtonesDensity(): number;
  80455. /**
  80456. * Sets the midtones Density value.
  80457. * 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.
  80458. * Values less than zero provide a filter of opposite hue.
  80459. */
  80460. set midtonesDensity(value: number);
  80461. /**
  80462. * Gets the midtones Saturation value.
  80463. * 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.
  80464. */
  80465. get midtonesSaturation(): number;
  80466. /**
  80467. * Sets the midtones Saturation value.
  80468. * 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.
  80469. */
  80470. set midtonesSaturation(value: number);
  80471. /**
  80472. * Gets the midtones Exposure value.
  80473. * 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.
  80474. */
  80475. get midtonesExposure(): number;
  80476. /**
  80477. * Sets the midtones Exposure value.
  80478. * 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.
  80479. */
  80480. set midtonesExposure(value: number);
  80481. private _shadowsHue;
  80482. private _shadowsDensity;
  80483. private _shadowsSaturation;
  80484. private _shadowsExposure;
  80485. /**
  80486. * Gets the shadows Hue value.
  80487. * 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).
  80488. */
  80489. get shadowsHue(): number;
  80490. /**
  80491. * Sets the shadows Hue value.
  80492. * 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).
  80493. */
  80494. set shadowsHue(value: number);
  80495. /**
  80496. * Gets the shadows Density value.
  80497. * 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.
  80498. * Values less than zero provide a filter of opposite hue.
  80499. */
  80500. get shadowsDensity(): number;
  80501. /**
  80502. * Sets the shadows Density value.
  80503. * 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.
  80504. * Values less than zero provide a filter of opposite hue.
  80505. */
  80506. set shadowsDensity(value: number);
  80507. /**
  80508. * Gets the shadows Saturation value.
  80509. * 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.
  80510. */
  80511. get shadowsSaturation(): number;
  80512. /**
  80513. * Sets the shadows Saturation value.
  80514. * 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.
  80515. */
  80516. set shadowsSaturation(value: number);
  80517. /**
  80518. * Gets the shadows Exposure value.
  80519. * 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.
  80520. */
  80521. get shadowsExposure(): number;
  80522. /**
  80523. * Sets the shadows Exposure value.
  80524. * 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.
  80525. */
  80526. set shadowsExposure(value: number);
  80527. /**
  80528. * Returns the class name
  80529. * @returns The class name
  80530. */
  80531. getClassName(): string;
  80532. /**
  80533. * Binds the color curves to the shader.
  80534. * @param colorCurves The color curve to bind
  80535. * @param effect The effect to bind to
  80536. * @param positiveUniform The positive uniform shader parameter
  80537. * @param neutralUniform The neutral uniform shader parameter
  80538. * @param negativeUniform The negative uniform shader parameter
  80539. */
  80540. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  80541. /**
  80542. * Prepare the list of uniforms associated with the ColorCurves effects.
  80543. * @param uniformsList The list of uniforms used in the effect
  80544. */
  80545. static PrepareUniforms(uniformsList: string[]): void;
  80546. /**
  80547. * Returns color grading data based on a hue, density, saturation and exposure value.
  80548. * @param filterHue The hue of the color filter.
  80549. * @param filterDensity The density of the color filter.
  80550. * @param saturation The saturation.
  80551. * @param exposure The exposure.
  80552. * @param result The result data container.
  80553. */
  80554. private getColorGradingDataToRef;
  80555. /**
  80556. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  80557. * @param value The input slider value in range [-100,100].
  80558. * @returns Adjusted value.
  80559. */
  80560. private static applyColorGradingSliderNonlinear;
  80561. /**
  80562. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  80563. * @param hue The hue (H) input.
  80564. * @param saturation The saturation (S) input.
  80565. * @param brightness The brightness (B) input.
  80566. * @result An RGBA color represented as Vector4.
  80567. */
  80568. private static fromHSBToRef;
  80569. /**
  80570. * Returns a value clamped between min and max
  80571. * @param value The value to clamp
  80572. * @param min The minimum of value
  80573. * @param max The maximum of value
  80574. * @returns The clamped value.
  80575. */
  80576. private static clamp;
  80577. /**
  80578. * Clones the current color curve instance.
  80579. * @return The cloned curves
  80580. */
  80581. clone(): ColorCurves;
  80582. /**
  80583. * Serializes the current color curve instance to a json representation.
  80584. * @return a JSON representation
  80585. */
  80586. serialize(): any;
  80587. /**
  80588. * Parses the color curve from a json representation.
  80589. * @param source the JSON source to parse
  80590. * @return The parsed curves
  80591. */
  80592. static Parse(source: any): ColorCurves;
  80593. }
  80594. }
  80595. declare module BABYLON {
  80596. /**
  80597. * Interface to follow in your material defines to integrate easily the
  80598. * Image proccessing functions.
  80599. * @hidden
  80600. */
  80601. export interface IImageProcessingConfigurationDefines {
  80602. IMAGEPROCESSING: boolean;
  80603. VIGNETTE: boolean;
  80604. VIGNETTEBLENDMODEMULTIPLY: boolean;
  80605. VIGNETTEBLENDMODEOPAQUE: boolean;
  80606. TONEMAPPING: boolean;
  80607. TONEMAPPING_ACES: boolean;
  80608. CONTRAST: boolean;
  80609. EXPOSURE: boolean;
  80610. COLORCURVES: boolean;
  80611. COLORGRADING: boolean;
  80612. COLORGRADING3D: boolean;
  80613. SAMPLER3DGREENDEPTH: boolean;
  80614. SAMPLER3DBGRMAP: boolean;
  80615. IMAGEPROCESSINGPOSTPROCESS: boolean;
  80616. }
  80617. /**
  80618. * @hidden
  80619. */
  80620. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  80621. IMAGEPROCESSING: boolean;
  80622. VIGNETTE: boolean;
  80623. VIGNETTEBLENDMODEMULTIPLY: boolean;
  80624. VIGNETTEBLENDMODEOPAQUE: boolean;
  80625. TONEMAPPING: boolean;
  80626. TONEMAPPING_ACES: boolean;
  80627. CONTRAST: boolean;
  80628. COLORCURVES: boolean;
  80629. COLORGRADING: boolean;
  80630. COLORGRADING3D: boolean;
  80631. SAMPLER3DGREENDEPTH: boolean;
  80632. SAMPLER3DBGRMAP: boolean;
  80633. IMAGEPROCESSINGPOSTPROCESS: boolean;
  80634. EXPOSURE: boolean;
  80635. constructor();
  80636. }
  80637. /**
  80638. * This groups together the common properties used for image processing either in direct forward pass
  80639. * or through post processing effect depending on the use of the image processing pipeline in your scene
  80640. * or not.
  80641. */
  80642. export class ImageProcessingConfiguration {
  80643. /**
  80644. * Default tone mapping applied in BabylonJS.
  80645. */
  80646. static readonly TONEMAPPING_STANDARD: number;
  80647. /**
  80648. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  80649. * to other engines rendering to increase portability.
  80650. */
  80651. static readonly TONEMAPPING_ACES: number;
  80652. /**
  80653. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  80654. */
  80655. colorCurves: Nullable<ColorCurves>;
  80656. private _colorCurvesEnabled;
  80657. /**
  80658. * Gets wether the color curves effect is enabled.
  80659. */
  80660. get colorCurvesEnabled(): boolean;
  80661. /**
  80662. * Sets wether the color curves effect is enabled.
  80663. */
  80664. set colorCurvesEnabled(value: boolean);
  80665. private _colorGradingTexture;
  80666. /**
  80667. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  80668. */
  80669. get colorGradingTexture(): Nullable<BaseTexture>;
  80670. /**
  80671. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  80672. */
  80673. set colorGradingTexture(value: Nullable<BaseTexture>);
  80674. private _colorGradingEnabled;
  80675. /**
  80676. * Gets wether the color grading effect is enabled.
  80677. */
  80678. get colorGradingEnabled(): boolean;
  80679. /**
  80680. * Sets wether the color grading effect is enabled.
  80681. */
  80682. set colorGradingEnabled(value: boolean);
  80683. private _colorGradingWithGreenDepth;
  80684. /**
  80685. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  80686. */
  80687. get colorGradingWithGreenDepth(): boolean;
  80688. /**
  80689. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  80690. */
  80691. set colorGradingWithGreenDepth(value: boolean);
  80692. private _colorGradingBGR;
  80693. /**
  80694. * Gets wether the color grading texture contains BGR values.
  80695. */
  80696. get colorGradingBGR(): boolean;
  80697. /**
  80698. * Sets wether the color grading texture contains BGR values.
  80699. */
  80700. set colorGradingBGR(value: boolean);
  80701. /** @hidden */
  80702. _exposure: number;
  80703. /**
  80704. * Gets the Exposure used in the effect.
  80705. */
  80706. get exposure(): number;
  80707. /**
  80708. * Sets the Exposure used in the effect.
  80709. */
  80710. set exposure(value: number);
  80711. private _toneMappingEnabled;
  80712. /**
  80713. * Gets wether the tone mapping effect is enabled.
  80714. */
  80715. get toneMappingEnabled(): boolean;
  80716. /**
  80717. * Sets wether the tone mapping effect is enabled.
  80718. */
  80719. set toneMappingEnabled(value: boolean);
  80720. private _toneMappingType;
  80721. /**
  80722. * Gets the type of tone mapping effect.
  80723. */
  80724. get toneMappingType(): number;
  80725. /**
  80726. * Sets the type of tone mapping effect used in BabylonJS.
  80727. */
  80728. set toneMappingType(value: number);
  80729. protected _contrast: number;
  80730. /**
  80731. * Gets the contrast used in the effect.
  80732. */
  80733. get contrast(): number;
  80734. /**
  80735. * Sets the contrast used in the effect.
  80736. */
  80737. set contrast(value: number);
  80738. /**
  80739. * Vignette stretch size.
  80740. */
  80741. vignetteStretch: number;
  80742. /**
  80743. * Vignette centre X Offset.
  80744. */
  80745. vignetteCentreX: number;
  80746. /**
  80747. * Vignette centre Y Offset.
  80748. */
  80749. vignetteCentreY: number;
  80750. /**
  80751. * Vignette weight or intensity of the vignette effect.
  80752. */
  80753. vignetteWeight: number;
  80754. /**
  80755. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  80756. * if vignetteEnabled is set to true.
  80757. */
  80758. vignetteColor: Color4;
  80759. /**
  80760. * Camera field of view used by the Vignette effect.
  80761. */
  80762. vignetteCameraFov: number;
  80763. private _vignetteBlendMode;
  80764. /**
  80765. * Gets the vignette blend mode allowing different kind of effect.
  80766. */
  80767. get vignetteBlendMode(): number;
  80768. /**
  80769. * Sets the vignette blend mode allowing different kind of effect.
  80770. */
  80771. set vignetteBlendMode(value: number);
  80772. private _vignetteEnabled;
  80773. /**
  80774. * Gets wether the vignette effect is enabled.
  80775. */
  80776. get vignetteEnabled(): boolean;
  80777. /**
  80778. * Sets wether the vignette effect is enabled.
  80779. */
  80780. set vignetteEnabled(value: boolean);
  80781. private _applyByPostProcess;
  80782. /**
  80783. * Gets wether the image processing is applied through a post process or not.
  80784. */
  80785. get applyByPostProcess(): boolean;
  80786. /**
  80787. * Sets wether the image processing is applied through a post process or not.
  80788. */
  80789. set applyByPostProcess(value: boolean);
  80790. private _isEnabled;
  80791. /**
  80792. * Gets wether the image processing is enabled or not.
  80793. */
  80794. get isEnabled(): boolean;
  80795. /**
  80796. * Sets wether the image processing is enabled or not.
  80797. */
  80798. set isEnabled(value: boolean);
  80799. /**
  80800. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  80801. */
  80802. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  80803. /**
  80804. * Method called each time the image processing information changes requires to recompile the effect.
  80805. */
  80806. protected _updateParameters(): void;
  80807. /**
  80808. * Gets the current class name.
  80809. * @return "ImageProcessingConfiguration"
  80810. */
  80811. getClassName(): string;
  80812. /**
  80813. * Prepare the list of uniforms associated with the Image Processing effects.
  80814. * @param uniforms The list of uniforms used in the effect
  80815. * @param defines the list of defines currently in use
  80816. */
  80817. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  80818. /**
  80819. * Prepare the list of samplers associated with the Image Processing effects.
  80820. * @param samplersList The list of uniforms used in the effect
  80821. * @param defines the list of defines currently in use
  80822. */
  80823. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  80824. /**
  80825. * Prepare the list of defines associated to the shader.
  80826. * @param defines the list of defines to complete
  80827. * @param forPostProcess Define if we are currently in post process mode or not
  80828. */
  80829. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  80830. /**
  80831. * Returns true if all the image processing information are ready.
  80832. * @returns True if ready, otherwise, false
  80833. */
  80834. isReady(): boolean;
  80835. /**
  80836. * Binds the image processing to the shader.
  80837. * @param effect The effect to bind to
  80838. * @param overrideAspectRatio Override the aspect ratio of the effect
  80839. */
  80840. bind(effect: Effect, overrideAspectRatio?: number): void;
  80841. /**
  80842. * Clones the current image processing instance.
  80843. * @return The cloned image processing
  80844. */
  80845. clone(): ImageProcessingConfiguration;
  80846. /**
  80847. * Serializes the current image processing instance to a json representation.
  80848. * @return a JSON representation
  80849. */
  80850. serialize(): any;
  80851. /**
  80852. * Parses the image processing from a json representation.
  80853. * @param source the JSON source to parse
  80854. * @return The parsed image processing
  80855. */
  80856. static Parse(source: any): ImageProcessingConfiguration;
  80857. private static _VIGNETTEMODE_MULTIPLY;
  80858. private static _VIGNETTEMODE_OPAQUE;
  80859. /**
  80860. * Used to apply the vignette as a mix with the pixel color.
  80861. */
  80862. static get VIGNETTEMODE_MULTIPLY(): number;
  80863. /**
  80864. * Used to apply the vignette as a replacement of the pixel color.
  80865. */
  80866. static get VIGNETTEMODE_OPAQUE(): number;
  80867. }
  80868. }
  80869. declare module BABYLON {
  80870. /** @hidden */
  80871. export var postprocessVertexShader: {
  80872. name: string;
  80873. shader: string;
  80874. };
  80875. }
  80876. declare module BABYLON {
  80877. interface ThinEngine {
  80878. /**
  80879. * Creates a new render target texture
  80880. * @param size defines the size of the texture
  80881. * @param options defines the options used to create the texture
  80882. * @returns a new render target texture stored in an InternalTexture
  80883. */
  80884. createRenderTargetTexture(size: number | {
  80885. width: number;
  80886. height: number;
  80887. layers?: number;
  80888. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  80889. /**
  80890. * Creates a depth stencil texture.
  80891. * This is only available in WebGL 2 or with the depth texture extension available.
  80892. * @param size The size of face edge in the texture.
  80893. * @param options The options defining the texture.
  80894. * @returns The texture
  80895. */
  80896. createDepthStencilTexture(size: number | {
  80897. width: number;
  80898. height: number;
  80899. layers?: number;
  80900. }, options: DepthTextureCreationOptions): InternalTexture;
  80901. /** @hidden */
  80902. _createDepthStencilTexture(size: number | {
  80903. width: number;
  80904. height: number;
  80905. layers?: number;
  80906. }, options: DepthTextureCreationOptions): InternalTexture;
  80907. }
  80908. }
  80909. declare module BABYLON {
  80910. /** Defines supported spaces */
  80911. export enum Space {
  80912. /** Local (object) space */
  80913. LOCAL = 0,
  80914. /** World space */
  80915. WORLD = 1,
  80916. /** Bone space */
  80917. BONE = 2
  80918. }
  80919. /** Defines the 3 main axes */
  80920. export class Axis {
  80921. /** X axis */
  80922. static X: Vector3;
  80923. /** Y axis */
  80924. static Y: Vector3;
  80925. /** Z axis */
  80926. static Z: Vector3;
  80927. }
  80928. }
  80929. declare module BABYLON {
  80930. /**
  80931. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  80932. * This is the base of the follow, arc rotate cameras and Free camera
  80933. * @see http://doc.babylonjs.com/features/cameras
  80934. */
  80935. export class TargetCamera extends Camera {
  80936. private static _RigCamTransformMatrix;
  80937. private static _TargetTransformMatrix;
  80938. private static _TargetFocalPoint;
  80939. /**
  80940. * Define the current direction the camera is moving to
  80941. */
  80942. cameraDirection: Vector3;
  80943. /**
  80944. * Define the current rotation the camera is rotating to
  80945. */
  80946. cameraRotation: Vector2;
  80947. /**
  80948. * When set, the up vector of the camera will be updated by the rotation of the camera
  80949. */
  80950. updateUpVectorFromRotation: boolean;
  80951. private _tmpQuaternion;
  80952. /**
  80953. * Define the current rotation of the camera
  80954. */
  80955. rotation: Vector3;
  80956. /**
  80957. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  80958. */
  80959. rotationQuaternion: Quaternion;
  80960. /**
  80961. * Define the current speed of the camera
  80962. */
  80963. speed: number;
  80964. /**
  80965. * Add constraint to the camera to prevent it to move freely in all directions and
  80966. * around all axis.
  80967. */
  80968. noRotationConstraint: boolean;
  80969. /**
  80970. * Define the current target of the camera as an object or a position.
  80971. */
  80972. lockedTarget: any;
  80973. /** @hidden */
  80974. _currentTarget: Vector3;
  80975. /** @hidden */
  80976. _initialFocalDistance: number;
  80977. /** @hidden */
  80978. _viewMatrix: Matrix;
  80979. /** @hidden */
  80980. _camMatrix: Matrix;
  80981. /** @hidden */
  80982. _cameraTransformMatrix: Matrix;
  80983. /** @hidden */
  80984. _cameraRotationMatrix: Matrix;
  80985. /** @hidden */
  80986. _referencePoint: Vector3;
  80987. /** @hidden */
  80988. _transformedReferencePoint: Vector3;
  80989. protected _globalCurrentTarget: Vector3;
  80990. protected _globalCurrentUpVector: Vector3;
  80991. /** @hidden */
  80992. _reset: () => void;
  80993. private _defaultUp;
  80994. /**
  80995. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  80996. * This is the base of the follow, arc rotate cameras and Free camera
  80997. * @see http://doc.babylonjs.com/features/cameras
  80998. * @param name Defines the name of the camera in the scene
  80999. * @param position Defines the start position of the camera in the scene
  81000. * @param scene Defines the scene the camera belongs to
  81001. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81002. */
  81003. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81004. /**
  81005. * Gets the position in front of the camera at a given distance.
  81006. * @param distance The distance from the camera we want the position to be
  81007. * @returns the position
  81008. */
  81009. getFrontPosition(distance: number): Vector3;
  81010. /** @hidden */
  81011. _getLockedTargetPosition(): Nullable<Vector3>;
  81012. private _storedPosition;
  81013. private _storedRotation;
  81014. private _storedRotationQuaternion;
  81015. /**
  81016. * Store current camera state of the camera (fov, position, rotation, etc..)
  81017. * @returns the camera
  81018. */
  81019. storeState(): Camera;
  81020. /**
  81021. * Restored camera state. You must call storeState() first
  81022. * @returns whether it was successful or not
  81023. * @hidden
  81024. */
  81025. _restoreStateValues(): boolean;
  81026. /** @hidden */
  81027. _initCache(): void;
  81028. /** @hidden */
  81029. _updateCache(ignoreParentClass?: boolean): void;
  81030. /** @hidden */
  81031. _isSynchronizedViewMatrix(): boolean;
  81032. /** @hidden */
  81033. _computeLocalCameraSpeed(): number;
  81034. /**
  81035. * Defines the target the camera should look at.
  81036. * @param target Defines the new target as a Vector or a mesh
  81037. */
  81038. setTarget(target: Vector3): void;
  81039. /**
  81040. * Return the current target position of the camera. This value is expressed in local space.
  81041. * @returns the target position
  81042. */
  81043. getTarget(): Vector3;
  81044. /** @hidden */
  81045. _decideIfNeedsToMove(): boolean;
  81046. /** @hidden */
  81047. _updatePosition(): void;
  81048. /** @hidden */
  81049. _checkInputs(): void;
  81050. protected _updateCameraRotationMatrix(): void;
  81051. /**
  81052. * 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)
  81053. * @returns the current camera
  81054. */
  81055. private _rotateUpVectorWithCameraRotationMatrix;
  81056. private _cachedRotationZ;
  81057. private _cachedQuaternionRotationZ;
  81058. /** @hidden */
  81059. _getViewMatrix(): Matrix;
  81060. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81061. /**
  81062. * @hidden
  81063. */
  81064. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81065. /**
  81066. * @hidden
  81067. */
  81068. _updateRigCameras(): void;
  81069. private _getRigCamPositionAndTarget;
  81070. /**
  81071. * Gets the current object class name.
  81072. * @return the class name
  81073. */
  81074. getClassName(): string;
  81075. }
  81076. }
  81077. declare module BABYLON {
  81078. /**
  81079. * Gather the list of keyboard event types as constants.
  81080. */
  81081. export class KeyboardEventTypes {
  81082. /**
  81083. * The keydown event is fired when a key becomes active (pressed).
  81084. */
  81085. static readonly KEYDOWN: number;
  81086. /**
  81087. * The keyup event is fired when a key has been released.
  81088. */
  81089. static readonly KEYUP: number;
  81090. }
  81091. /**
  81092. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81093. */
  81094. export class KeyboardInfo {
  81095. /**
  81096. * Defines the type of event (KeyboardEventTypes)
  81097. */
  81098. type: number;
  81099. /**
  81100. * Defines the related dom event
  81101. */
  81102. event: KeyboardEvent;
  81103. /**
  81104. * Instantiates a new keyboard info.
  81105. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81106. * @param type Defines the type of event (KeyboardEventTypes)
  81107. * @param event Defines the related dom event
  81108. */
  81109. constructor(
  81110. /**
  81111. * Defines the type of event (KeyboardEventTypes)
  81112. */
  81113. type: number,
  81114. /**
  81115. * Defines the related dom event
  81116. */
  81117. event: KeyboardEvent);
  81118. }
  81119. /**
  81120. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81121. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81122. */
  81123. export class KeyboardInfoPre extends KeyboardInfo {
  81124. /**
  81125. * Defines the type of event (KeyboardEventTypes)
  81126. */
  81127. type: number;
  81128. /**
  81129. * Defines the related dom event
  81130. */
  81131. event: KeyboardEvent;
  81132. /**
  81133. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81134. */
  81135. skipOnPointerObservable: boolean;
  81136. /**
  81137. * Instantiates a new keyboard pre info.
  81138. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81139. * @param type Defines the type of event (KeyboardEventTypes)
  81140. * @param event Defines the related dom event
  81141. */
  81142. constructor(
  81143. /**
  81144. * Defines the type of event (KeyboardEventTypes)
  81145. */
  81146. type: number,
  81147. /**
  81148. * Defines the related dom event
  81149. */
  81150. event: KeyboardEvent);
  81151. }
  81152. }
  81153. declare module BABYLON {
  81154. /**
  81155. * Manage the keyboard inputs to control the movement of a free camera.
  81156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81157. */
  81158. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81159. /**
  81160. * Defines the camera the input is attached to.
  81161. */
  81162. camera: FreeCamera;
  81163. /**
  81164. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81165. */
  81166. keysUp: number[];
  81167. /**
  81168. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81169. */
  81170. keysDown: number[];
  81171. /**
  81172. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81173. */
  81174. keysLeft: number[];
  81175. /**
  81176. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81177. */
  81178. keysRight: number[];
  81179. private _keys;
  81180. private _onCanvasBlurObserver;
  81181. private _onKeyboardObserver;
  81182. private _engine;
  81183. private _scene;
  81184. /**
  81185. * Attach the input controls to a specific dom element to get the input from.
  81186. * @param element Defines the element the controls should be listened from
  81187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81188. */
  81189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81190. /**
  81191. * Detach the current controls from the specified dom element.
  81192. * @param element Defines the element to stop listening the inputs from
  81193. */
  81194. detachControl(element: Nullable<HTMLElement>): void;
  81195. /**
  81196. * Update the current camera state depending on the inputs that have been used this frame.
  81197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81198. */
  81199. checkInputs(): void;
  81200. /**
  81201. * Gets the class name of the current intput.
  81202. * @returns the class name
  81203. */
  81204. getClassName(): string;
  81205. /** @hidden */
  81206. _onLostFocus(): void;
  81207. /**
  81208. * Get the friendly name associated with the input class.
  81209. * @returns the input friendly name
  81210. */
  81211. getSimpleName(): string;
  81212. }
  81213. }
  81214. declare module BABYLON {
  81215. /**
  81216. * Interface describing all the common properties and methods a shadow light needs to implement.
  81217. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  81218. * as well as binding the different shadow properties to the effects.
  81219. */
  81220. export interface IShadowLight extends Light {
  81221. /**
  81222. * The light id in the scene (used in scene.findLighById for instance)
  81223. */
  81224. id: string;
  81225. /**
  81226. * The position the shdow will be casted from.
  81227. */
  81228. position: Vector3;
  81229. /**
  81230. * In 2d mode (needCube being false), the direction used to cast the shadow.
  81231. */
  81232. direction: Vector3;
  81233. /**
  81234. * The transformed position. Position of the light in world space taking parenting in account.
  81235. */
  81236. transformedPosition: Vector3;
  81237. /**
  81238. * The transformed direction. Direction of the light in world space taking parenting in account.
  81239. */
  81240. transformedDirection: Vector3;
  81241. /**
  81242. * The friendly name of the light in the scene.
  81243. */
  81244. name: string;
  81245. /**
  81246. * Defines the shadow projection clipping minimum z value.
  81247. */
  81248. shadowMinZ: number;
  81249. /**
  81250. * Defines the shadow projection clipping maximum z value.
  81251. */
  81252. shadowMaxZ: number;
  81253. /**
  81254. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81255. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81256. */
  81257. computeTransformedInformation(): boolean;
  81258. /**
  81259. * Gets the scene the light belongs to.
  81260. * @returns The scene
  81261. */
  81262. getScene(): Scene;
  81263. /**
  81264. * Callback defining a custom Projection Matrix Builder.
  81265. * This can be used to override the default projection matrix computation.
  81266. */
  81267. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81268. /**
  81269. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81270. * @param matrix The materix to updated with the projection information
  81271. * @param viewMatrix The transform matrix of the light
  81272. * @param renderList The list of mesh to render in the map
  81273. * @returns The current light
  81274. */
  81275. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81276. /**
  81277. * Gets the current depth scale used in ESM.
  81278. * @returns The scale
  81279. */
  81280. getDepthScale(): number;
  81281. /**
  81282. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81283. * @returns true if a cube texture needs to be use
  81284. */
  81285. needCube(): boolean;
  81286. /**
  81287. * Detects if the projection matrix requires to be recomputed this frame.
  81288. * @returns true if it requires to be recomputed otherwise, false.
  81289. */
  81290. needProjectionMatrixCompute(): boolean;
  81291. /**
  81292. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81293. */
  81294. forceProjectionMatrixCompute(): void;
  81295. /**
  81296. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81297. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81298. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81299. */
  81300. getShadowDirection(faceIndex?: number): Vector3;
  81301. /**
  81302. * Gets the minZ used for shadow according to both the scene and the light.
  81303. * @param activeCamera The camera we are returning the min for
  81304. * @returns the depth min z
  81305. */
  81306. getDepthMinZ(activeCamera: Camera): number;
  81307. /**
  81308. * Gets the maxZ used for shadow according to both the scene and the light.
  81309. * @param activeCamera The camera we are returning the max for
  81310. * @returns the depth max z
  81311. */
  81312. getDepthMaxZ(activeCamera: Camera): number;
  81313. }
  81314. /**
  81315. * Base implementation IShadowLight
  81316. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  81317. */
  81318. export abstract class ShadowLight extends Light implements IShadowLight {
  81319. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  81320. protected _position: Vector3;
  81321. protected _setPosition(value: Vector3): void;
  81322. /**
  81323. * Sets the position the shadow will be casted from. Also use as the light position for both
  81324. * point and spot lights.
  81325. */
  81326. get position(): Vector3;
  81327. /**
  81328. * Sets the position the shadow will be casted from. Also use as the light position for both
  81329. * point and spot lights.
  81330. */
  81331. set position(value: Vector3);
  81332. protected _direction: Vector3;
  81333. protected _setDirection(value: Vector3): void;
  81334. /**
  81335. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  81336. * Also use as the light direction on spot and directional lights.
  81337. */
  81338. get direction(): Vector3;
  81339. /**
  81340. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  81341. * Also use as the light direction on spot and directional lights.
  81342. */
  81343. set direction(value: Vector3);
  81344. protected _shadowMinZ: number;
  81345. /**
  81346. * Gets the shadow projection clipping minimum z value.
  81347. */
  81348. get shadowMinZ(): number;
  81349. /**
  81350. * Sets the shadow projection clipping minimum z value.
  81351. */
  81352. set shadowMinZ(value: number);
  81353. protected _shadowMaxZ: number;
  81354. /**
  81355. * Sets the shadow projection clipping maximum z value.
  81356. */
  81357. get shadowMaxZ(): number;
  81358. /**
  81359. * Gets the shadow projection clipping maximum z value.
  81360. */
  81361. set shadowMaxZ(value: number);
  81362. /**
  81363. * Callback defining a custom Projection Matrix Builder.
  81364. * This can be used to override the default projection matrix computation.
  81365. */
  81366. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81367. /**
  81368. * The transformed position. Position of the light in world space taking parenting in account.
  81369. */
  81370. transformedPosition: Vector3;
  81371. /**
  81372. * The transformed direction. Direction of the light in world space taking parenting in account.
  81373. */
  81374. transformedDirection: Vector3;
  81375. private _needProjectionMatrixCompute;
  81376. /**
  81377. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81378. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81379. */
  81380. computeTransformedInformation(): boolean;
  81381. /**
  81382. * Return the depth scale used for the shadow map.
  81383. * @returns the depth scale.
  81384. */
  81385. getDepthScale(): number;
  81386. /**
  81387. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81388. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81389. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81390. */
  81391. getShadowDirection(faceIndex?: number): Vector3;
  81392. /**
  81393. * Returns the ShadowLight absolute position in the World.
  81394. * @returns the position vector in world space
  81395. */
  81396. getAbsolutePosition(): Vector3;
  81397. /**
  81398. * Sets the ShadowLight direction toward the passed target.
  81399. * @param target The point to target in local space
  81400. * @returns the updated ShadowLight direction
  81401. */
  81402. setDirectionToTarget(target: Vector3): Vector3;
  81403. /**
  81404. * Returns the light rotation in euler definition.
  81405. * @returns the x y z rotation in local space.
  81406. */
  81407. getRotation(): Vector3;
  81408. /**
  81409. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81410. * @returns true if a cube texture needs to be use
  81411. */
  81412. needCube(): boolean;
  81413. /**
  81414. * Detects if the projection matrix requires to be recomputed this frame.
  81415. * @returns true if it requires to be recomputed otherwise, false.
  81416. */
  81417. needProjectionMatrixCompute(): boolean;
  81418. /**
  81419. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81420. */
  81421. forceProjectionMatrixCompute(): void;
  81422. /** @hidden */
  81423. _initCache(): void;
  81424. /** @hidden */
  81425. _isSynchronized(): boolean;
  81426. /**
  81427. * Computes the world matrix of the node
  81428. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81429. * @returns the world matrix
  81430. */
  81431. computeWorldMatrix(force?: boolean): Matrix;
  81432. /**
  81433. * Gets the minZ used for shadow according to both the scene and the light.
  81434. * @param activeCamera The camera we are returning the min for
  81435. * @returns the depth min z
  81436. */
  81437. getDepthMinZ(activeCamera: Camera): number;
  81438. /**
  81439. * Gets the maxZ used for shadow according to both the scene and the light.
  81440. * @param activeCamera The camera we are returning the max for
  81441. * @returns the depth max z
  81442. */
  81443. getDepthMaxZ(activeCamera: Camera): number;
  81444. /**
  81445. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81446. * @param matrix The materix to updated with the projection information
  81447. * @param viewMatrix The transform matrix of the light
  81448. * @param renderList The list of mesh to render in the map
  81449. * @returns The current light
  81450. */
  81451. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81452. }
  81453. }
  81454. declare module BABYLON {
  81455. /**
  81456. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  81457. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  81458. */
  81459. export class EffectFallbacks implements IEffectFallbacks {
  81460. private _defines;
  81461. private _currentRank;
  81462. private _maxRank;
  81463. private _mesh;
  81464. /**
  81465. * Removes the fallback from the bound mesh.
  81466. */
  81467. unBindMesh(): void;
  81468. /**
  81469. * Adds a fallback on the specified property.
  81470. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81471. * @param define The name of the define in the shader
  81472. */
  81473. addFallback(rank: number, define: string): void;
  81474. /**
  81475. * Sets the mesh to use CPU skinning when needing to fallback.
  81476. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81477. * @param mesh The mesh to use the fallbacks.
  81478. */
  81479. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  81480. /**
  81481. * Checks to see if more fallbacks are still availible.
  81482. */
  81483. get hasMoreFallbacks(): boolean;
  81484. /**
  81485. * Removes the defines that should be removed when falling back.
  81486. * @param currentDefines defines the current define statements for the shader.
  81487. * @param effect defines the current effect we try to compile
  81488. * @returns The resulting defines with defines of the current rank removed.
  81489. */
  81490. reduce(currentDefines: string, effect: Effect): string;
  81491. }
  81492. }
  81493. declare module BABYLON {
  81494. /**
  81495. * "Static Class" containing the most commonly used helper while dealing with material for
  81496. * rendering purpose.
  81497. *
  81498. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  81499. *
  81500. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  81501. */
  81502. export class MaterialHelper {
  81503. /**
  81504. * Bind the current view position to an effect.
  81505. * @param effect The effect to be bound
  81506. * @param scene The scene the eyes position is used from
  81507. */
  81508. static BindEyePosition(effect: Effect, scene: Scene): void;
  81509. /**
  81510. * Helps preparing the defines values about the UVs in used in the effect.
  81511. * UVs are shared as much as we can accross channels in the shaders.
  81512. * @param texture The texture we are preparing the UVs for
  81513. * @param defines The defines to update
  81514. * @param key The channel key "diffuse", "specular"... used in the shader
  81515. */
  81516. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  81517. /**
  81518. * Binds a texture matrix value to its corrsponding uniform
  81519. * @param texture The texture to bind the matrix for
  81520. * @param uniformBuffer The uniform buffer receivin the data
  81521. * @param key The channel key "diffuse", "specular"... used in the shader
  81522. */
  81523. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  81524. /**
  81525. * Gets the current status of the fog (should it be enabled?)
  81526. * @param mesh defines the mesh to evaluate for fog support
  81527. * @param scene defines the hosting scene
  81528. * @returns true if fog must be enabled
  81529. */
  81530. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  81531. /**
  81532. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  81533. * @param mesh defines the current mesh
  81534. * @param scene defines the current scene
  81535. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  81536. * @param pointsCloud defines if point cloud rendering has to be turned on
  81537. * @param fogEnabled defines if fog has to be turned on
  81538. * @param alphaTest defines if alpha testing has to be turned on
  81539. * @param defines defines the current list of defines
  81540. */
  81541. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  81542. /**
  81543. * Helper used to prepare the list of defines associated with frame values for shader compilation
  81544. * @param scene defines the current scene
  81545. * @param engine defines the current engine
  81546. * @param defines specifies the list of active defines
  81547. * @param useInstances defines if instances have to be turned on
  81548. * @param useClipPlane defines if clip plane have to be turned on
  81549. */
  81550. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  81551. /**
  81552. * Prepares the defines for bones
  81553. * @param mesh The mesh containing the geometry data we will draw
  81554. * @param defines The defines to update
  81555. */
  81556. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  81557. /**
  81558. * Prepares the defines for morph targets
  81559. * @param mesh The mesh containing the geometry data we will draw
  81560. * @param defines The defines to update
  81561. */
  81562. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  81563. /**
  81564. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  81565. * @param mesh The mesh containing the geometry data we will draw
  81566. * @param defines The defines to update
  81567. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  81568. * @param useBones Precise whether bones should be used or not (override mesh info)
  81569. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  81570. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  81571. * @returns false if defines are considered not dirty and have not been checked
  81572. */
  81573. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  81574. /**
  81575. * Prepares the defines related to multiview
  81576. * @param scene The scene we are intending to draw
  81577. * @param defines The defines to update
  81578. */
  81579. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  81580. /**
  81581. * Prepares the defines related to the light information passed in parameter
  81582. * @param scene The scene we are intending to draw
  81583. * @param mesh The mesh the effect is compiling for
  81584. * @param light The light the effect is compiling for
  81585. * @param lightIndex The index of the light
  81586. * @param defines The defines to update
  81587. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  81588. * @param state Defines the current state regarding what is needed (normals, etc...)
  81589. */
  81590. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  81591. needNormals: boolean;
  81592. needRebuild: boolean;
  81593. shadowEnabled: boolean;
  81594. specularEnabled: boolean;
  81595. lightmapMode: boolean;
  81596. }): void;
  81597. /**
  81598. * Prepares the defines related to the light information passed in parameter
  81599. * @param scene The scene we are intending to draw
  81600. * @param mesh The mesh the effect is compiling for
  81601. * @param defines The defines to update
  81602. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  81603. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  81604. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  81605. * @returns true if normals will be required for the rest of the effect
  81606. */
  81607. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  81608. /**
  81609. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  81610. * @param lightIndex defines the light index
  81611. * @param uniformsList The uniform list
  81612. * @param samplersList The sampler list
  81613. * @param projectedLightTexture defines if projected texture must be used
  81614. * @param uniformBuffersList defines an optional list of uniform buffers
  81615. */
  81616. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  81617. /**
  81618. * Prepares the uniforms and samplers list to be used in the effect
  81619. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  81620. * @param samplersList The sampler list
  81621. * @param defines The defines helping in the list generation
  81622. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  81623. */
  81624. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  81625. /**
  81626. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  81627. * @param defines The defines to update while falling back
  81628. * @param fallbacks The authorized effect fallbacks
  81629. * @param maxSimultaneousLights The maximum number of lights allowed
  81630. * @param rank the current rank of the Effect
  81631. * @returns The newly affected rank
  81632. */
  81633. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  81634. private static _TmpMorphInfluencers;
  81635. /**
  81636. * Prepares the list of attributes required for morph targets according to the effect defines.
  81637. * @param attribs The current list of supported attribs
  81638. * @param mesh The mesh to prepare the morph targets attributes for
  81639. * @param influencers The number of influencers
  81640. */
  81641. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  81642. /**
  81643. * Prepares the list of attributes required for morph targets according to the effect defines.
  81644. * @param attribs The current list of supported attribs
  81645. * @param mesh The mesh to prepare the morph targets attributes for
  81646. * @param defines The current Defines of the effect
  81647. */
  81648. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  81649. /**
  81650. * Prepares the list of attributes required for bones according to the effect defines.
  81651. * @param attribs The current list of supported attribs
  81652. * @param mesh The mesh to prepare the bones attributes for
  81653. * @param defines The current Defines of the effect
  81654. * @param fallbacks The current efffect fallback strategy
  81655. */
  81656. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  81657. /**
  81658. * Check and prepare the list of attributes required for instances according to the effect defines.
  81659. * @param attribs The current list of supported attribs
  81660. * @param defines The current MaterialDefines of the effect
  81661. */
  81662. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  81663. /**
  81664. * Add the list of attributes required for instances to the attribs array.
  81665. * @param attribs The current list of supported attribs
  81666. */
  81667. static PushAttributesForInstances(attribs: string[]): void;
  81668. /**
  81669. * Binds the light information to the effect.
  81670. * @param light The light containing the generator
  81671. * @param effect The effect we are binding the data to
  81672. * @param lightIndex The light index in the effect used to render
  81673. */
  81674. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  81675. /**
  81676. * Binds the lights information from the scene to the effect for the given mesh.
  81677. * @param light Light to bind
  81678. * @param lightIndex Light index
  81679. * @param scene The scene where the light belongs to
  81680. * @param effect The effect we are binding the data to
  81681. * @param useSpecular Defines if specular is supported
  81682. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81683. */
  81684. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  81685. /**
  81686. * Binds the lights information from the scene to the effect for the given mesh.
  81687. * @param scene The scene the lights belongs to
  81688. * @param mesh The mesh we are binding the information to render
  81689. * @param effect The effect we are binding the data to
  81690. * @param defines The generated defines for the effect
  81691. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  81692. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81693. */
  81694. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  81695. private static _tempFogColor;
  81696. /**
  81697. * Binds the fog information from the scene to the effect for the given mesh.
  81698. * @param scene The scene the lights belongs to
  81699. * @param mesh The mesh we are binding the information to render
  81700. * @param effect The effect we are binding the data to
  81701. * @param linearSpace Defines if the fog effect is applied in linear space
  81702. */
  81703. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  81704. /**
  81705. * Binds the bones information from the mesh to the effect.
  81706. * @param mesh The mesh we are binding the information to render
  81707. * @param effect The effect we are binding the data to
  81708. */
  81709. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  81710. /**
  81711. * Binds the morph targets information from the mesh to the effect.
  81712. * @param abstractMesh The mesh we are binding the information to render
  81713. * @param effect The effect we are binding the data to
  81714. */
  81715. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  81716. /**
  81717. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  81718. * @param defines The generated defines used in the effect
  81719. * @param effect The effect we are binding the data to
  81720. * @param scene The scene we are willing to render with logarithmic scale for
  81721. */
  81722. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  81723. /**
  81724. * Binds the clip plane information from the scene to the effect.
  81725. * @param scene The scene the clip plane information are extracted from
  81726. * @param effect The effect we are binding the data to
  81727. */
  81728. static BindClipPlane(effect: Effect, scene: Scene): void;
  81729. }
  81730. }
  81731. declare module BABYLON {
  81732. /** @hidden */
  81733. export var packingFunctions: {
  81734. name: string;
  81735. shader: string;
  81736. };
  81737. }
  81738. declare module BABYLON {
  81739. /** @hidden */
  81740. export var shadowMapPixelShader: {
  81741. name: string;
  81742. shader: string;
  81743. };
  81744. }
  81745. declare module BABYLON {
  81746. /** @hidden */
  81747. export var bonesDeclaration: {
  81748. name: string;
  81749. shader: string;
  81750. };
  81751. }
  81752. declare module BABYLON {
  81753. /** @hidden */
  81754. export var morphTargetsVertexGlobalDeclaration: {
  81755. name: string;
  81756. shader: string;
  81757. };
  81758. }
  81759. declare module BABYLON {
  81760. /** @hidden */
  81761. export var morphTargetsVertexDeclaration: {
  81762. name: string;
  81763. shader: string;
  81764. };
  81765. }
  81766. declare module BABYLON {
  81767. /** @hidden */
  81768. export var instancesDeclaration: {
  81769. name: string;
  81770. shader: string;
  81771. };
  81772. }
  81773. declare module BABYLON {
  81774. /** @hidden */
  81775. export var helperFunctions: {
  81776. name: string;
  81777. shader: string;
  81778. };
  81779. }
  81780. declare module BABYLON {
  81781. /** @hidden */
  81782. export var morphTargetsVertex: {
  81783. name: string;
  81784. shader: string;
  81785. };
  81786. }
  81787. declare module BABYLON {
  81788. /** @hidden */
  81789. export var instancesVertex: {
  81790. name: string;
  81791. shader: string;
  81792. };
  81793. }
  81794. declare module BABYLON {
  81795. /** @hidden */
  81796. export var bonesVertex: {
  81797. name: string;
  81798. shader: string;
  81799. };
  81800. }
  81801. declare module BABYLON {
  81802. /** @hidden */
  81803. export var shadowMapVertexShader: {
  81804. name: string;
  81805. shader: string;
  81806. };
  81807. }
  81808. declare module BABYLON {
  81809. /** @hidden */
  81810. export var depthBoxBlurPixelShader: {
  81811. name: string;
  81812. shader: string;
  81813. };
  81814. }
  81815. declare module BABYLON {
  81816. /**
  81817. * Defines the options associated with the creation of a custom shader for a shadow generator.
  81818. */
  81819. export interface ICustomShaderOptions {
  81820. /**
  81821. * Gets or sets the custom shader name to use
  81822. */
  81823. shaderName: string;
  81824. /**
  81825. * The list of attribute names used in the shader
  81826. */
  81827. attributes?: string[];
  81828. /**
  81829. * The list of unifrom names used in the shader
  81830. */
  81831. uniforms?: string[];
  81832. /**
  81833. * The list of sampler names used in the shader
  81834. */
  81835. samplers?: string[];
  81836. /**
  81837. * The list of defines used in the shader
  81838. */
  81839. defines?: string[];
  81840. }
  81841. /**
  81842. * Interface to implement to create a shadow generator compatible with BJS.
  81843. */
  81844. export interface IShadowGenerator {
  81845. /**
  81846. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  81847. * @returns The render target texture if present otherwise, null
  81848. */
  81849. getShadowMap(): Nullable<RenderTargetTexture>;
  81850. /**
  81851. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  81852. * @param subMesh The submesh we want to render in the shadow map
  81853. * @param useInstances Defines wether will draw in the map using instances
  81854. * @returns true if ready otherwise, false
  81855. */
  81856. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  81857. /**
  81858. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  81859. * @param defines Defines of the material we want to update
  81860. * @param lightIndex Index of the light in the enabled light list of the material
  81861. */
  81862. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  81863. /**
  81864. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  81865. * defined in the generator but impacting the effect).
  81866. * It implies the unifroms available on the materials are the standard BJS ones.
  81867. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  81868. * @param effect The effect we are binfing the information for
  81869. */
  81870. bindShadowLight(lightIndex: string, effect: Effect): void;
  81871. /**
  81872. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  81873. * (eq to shadow prjection matrix * light transform matrix)
  81874. * @returns The transform matrix used to create the shadow map
  81875. */
  81876. getTransformMatrix(): Matrix;
  81877. /**
  81878. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  81879. * Cube and 2D textures for instance.
  81880. */
  81881. recreateShadowMap(): void;
  81882. /**
  81883. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81884. * @param onCompiled Callback triggered at the and of the effects compilation
  81885. * @param options Sets of optional options forcing the compilation with different modes
  81886. */
  81887. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  81888. useInstances: boolean;
  81889. }>): void;
  81890. /**
  81891. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81892. * @param options Sets of optional options forcing the compilation with different modes
  81893. * @returns A promise that resolves when the compilation completes
  81894. */
  81895. forceCompilationAsync(options?: Partial<{
  81896. useInstances: boolean;
  81897. }>): Promise<void>;
  81898. /**
  81899. * Serializes the shadow generator setup to a json object.
  81900. * @returns The serialized JSON object
  81901. */
  81902. serialize(): any;
  81903. /**
  81904. * Disposes the Shadow map and related Textures and effects.
  81905. */
  81906. dispose(): void;
  81907. }
  81908. /**
  81909. * Default implementation IShadowGenerator.
  81910. * This is the main object responsible of generating shadows in the framework.
  81911. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  81912. */
  81913. export class ShadowGenerator implements IShadowGenerator {
  81914. /**
  81915. * Shadow generator mode None: no filtering applied.
  81916. */
  81917. static readonly FILTER_NONE: number;
  81918. /**
  81919. * Shadow generator mode ESM: Exponential Shadow Mapping.
  81920. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81921. */
  81922. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  81923. /**
  81924. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  81925. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  81926. */
  81927. static readonly FILTER_POISSONSAMPLING: number;
  81928. /**
  81929. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  81930. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81931. */
  81932. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  81933. /**
  81934. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  81935. * edge artifacts on steep falloff.
  81936. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81937. */
  81938. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  81939. /**
  81940. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  81941. * edge artifacts on steep falloff.
  81942. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81943. */
  81944. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  81945. /**
  81946. * Shadow generator mode PCF: Percentage Closer Filtering
  81947. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  81948. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  81949. */
  81950. static readonly FILTER_PCF: number;
  81951. /**
  81952. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  81953. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  81954. * Contact Hardening
  81955. */
  81956. static readonly FILTER_PCSS: number;
  81957. /**
  81958. * Reserved for PCF and PCSS
  81959. * Highest Quality.
  81960. *
  81961. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  81962. *
  81963. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  81964. */
  81965. static readonly QUALITY_HIGH: number;
  81966. /**
  81967. * Reserved for PCF and PCSS
  81968. * Good tradeoff for quality/perf cross devices
  81969. *
  81970. * Execute PCF on a 3*3 kernel.
  81971. *
  81972. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  81973. */
  81974. static readonly QUALITY_MEDIUM: number;
  81975. /**
  81976. * Reserved for PCF and PCSS
  81977. * The lowest quality but the fastest.
  81978. *
  81979. * Execute PCF on a 1*1 kernel.
  81980. *
  81981. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  81982. */
  81983. static readonly QUALITY_LOW: number;
  81984. /** Gets or sets the custom shader name to use */
  81985. customShaderOptions: ICustomShaderOptions;
  81986. /**
  81987. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  81988. */
  81989. onBeforeShadowMapRenderObservable: Observable<Effect>;
  81990. /**
  81991. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  81992. */
  81993. onAfterShadowMapRenderObservable: Observable<Effect>;
  81994. /**
  81995. * Observable triggered before a mesh is rendered in the shadow map.
  81996. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  81997. */
  81998. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  81999. /**
  82000. * Observable triggered after a mesh is rendered in the shadow map.
  82001. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  82002. */
  82003. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  82004. private _bias;
  82005. /**
  82006. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  82007. */
  82008. get bias(): number;
  82009. /**
  82010. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  82011. */
  82012. set bias(bias: number);
  82013. private _normalBias;
  82014. /**
  82015. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82016. */
  82017. get normalBias(): number;
  82018. /**
  82019. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82020. */
  82021. set normalBias(normalBias: number);
  82022. private _blurBoxOffset;
  82023. /**
  82024. * Gets the blur box offset: offset applied during the blur pass.
  82025. * Only useful if useKernelBlur = false
  82026. */
  82027. get blurBoxOffset(): number;
  82028. /**
  82029. * Sets the blur box offset: offset applied during the blur pass.
  82030. * Only useful if useKernelBlur = false
  82031. */
  82032. set blurBoxOffset(value: number);
  82033. private _blurScale;
  82034. /**
  82035. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  82036. * 2 means half of the size.
  82037. */
  82038. get blurScale(): number;
  82039. /**
  82040. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  82041. * 2 means half of the size.
  82042. */
  82043. set blurScale(value: number);
  82044. private _blurKernel;
  82045. /**
  82046. * Gets the blur kernel: kernel size of the blur pass.
  82047. * Only useful if useKernelBlur = true
  82048. */
  82049. get blurKernel(): number;
  82050. /**
  82051. * Sets the blur kernel: kernel size of the blur pass.
  82052. * Only useful if useKernelBlur = true
  82053. */
  82054. set blurKernel(value: number);
  82055. private _useKernelBlur;
  82056. /**
  82057. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  82058. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82059. */
  82060. get useKernelBlur(): boolean;
  82061. /**
  82062. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  82063. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82064. */
  82065. set useKernelBlur(value: boolean);
  82066. private _depthScale;
  82067. /**
  82068. * Gets the depth scale used in ESM mode.
  82069. */
  82070. get depthScale(): number;
  82071. /**
  82072. * Sets the depth scale used in ESM mode.
  82073. * This can override the scale stored on the light.
  82074. */
  82075. set depthScale(value: number);
  82076. private _filter;
  82077. /**
  82078. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  82079. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82080. */
  82081. get filter(): number;
  82082. /**
  82083. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  82084. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82085. */
  82086. set filter(value: number);
  82087. /**
  82088. * Gets if the current filter is set to Poisson Sampling.
  82089. */
  82090. get usePoissonSampling(): boolean;
  82091. /**
  82092. * Sets the current filter to Poisson Sampling.
  82093. */
  82094. set usePoissonSampling(value: boolean);
  82095. /**
  82096. * Gets if the current filter is set to ESM.
  82097. */
  82098. get useExponentialShadowMap(): boolean;
  82099. /**
  82100. * Sets the current filter is to ESM.
  82101. */
  82102. set useExponentialShadowMap(value: boolean);
  82103. /**
  82104. * Gets if the current filter is set to filtered ESM.
  82105. */
  82106. get useBlurExponentialShadowMap(): boolean;
  82107. /**
  82108. * Gets if the current filter is set to filtered ESM.
  82109. */
  82110. set useBlurExponentialShadowMap(value: boolean);
  82111. /**
  82112. * Gets if the current filter is set to "close ESM" (using the inverse of the
  82113. * exponential to prevent steep falloff artifacts).
  82114. */
  82115. get useCloseExponentialShadowMap(): boolean;
  82116. /**
  82117. * Sets the current filter to "close ESM" (using the inverse of the
  82118. * exponential to prevent steep falloff artifacts).
  82119. */
  82120. set useCloseExponentialShadowMap(value: boolean);
  82121. /**
  82122. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  82123. * exponential to prevent steep falloff artifacts).
  82124. */
  82125. get useBlurCloseExponentialShadowMap(): boolean;
  82126. /**
  82127. * Sets the current filter to filtered "close ESM" (using the inverse of the
  82128. * exponential to prevent steep falloff artifacts).
  82129. */
  82130. set useBlurCloseExponentialShadowMap(value: boolean);
  82131. /**
  82132. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  82133. */
  82134. get usePercentageCloserFiltering(): boolean;
  82135. /**
  82136. * Sets the current filter to "PCF" (percentage closer filtering).
  82137. */
  82138. set usePercentageCloserFiltering(value: boolean);
  82139. private _filteringQuality;
  82140. /**
  82141. * Gets the PCF or PCSS Quality.
  82142. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82143. */
  82144. get filteringQuality(): number;
  82145. /**
  82146. * Sets the PCF or PCSS Quality.
  82147. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82148. */
  82149. set filteringQuality(filteringQuality: number);
  82150. /**
  82151. * Gets if the current filter is set to "PCSS" (contact hardening).
  82152. */
  82153. get useContactHardeningShadow(): boolean;
  82154. /**
  82155. * Sets the current filter to "PCSS" (contact hardening).
  82156. */
  82157. set useContactHardeningShadow(value: boolean);
  82158. private _contactHardeningLightSizeUVRatio;
  82159. /**
  82160. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82161. * Using a ratio helps keeping shape stability independently of the map size.
  82162. *
  82163. * It does not account for the light projection as it was having too much
  82164. * instability during the light setup or during light position changes.
  82165. *
  82166. * Only valid if useContactHardeningShadow is true.
  82167. */
  82168. get contactHardeningLightSizeUVRatio(): number;
  82169. /**
  82170. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82171. * Using a ratio helps keeping shape stability independently of the map size.
  82172. *
  82173. * It does not account for the light projection as it was having too much
  82174. * instability during the light setup or during light position changes.
  82175. *
  82176. * Only valid if useContactHardeningShadow is true.
  82177. */
  82178. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  82179. private _darkness;
  82180. /** Gets or sets the actual darkness of a shadow */
  82181. get darkness(): number;
  82182. set darkness(value: number);
  82183. /**
  82184. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  82185. * 0 means strongest and 1 would means no shadow.
  82186. * @returns the darkness.
  82187. */
  82188. getDarkness(): number;
  82189. /**
  82190. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  82191. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  82192. * @returns the shadow generator allowing fluent coding.
  82193. */
  82194. setDarkness(darkness: number): ShadowGenerator;
  82195. private _transparencyShadow;
  82196. /** Gets or sets the ability to have transparent shadow */
  82197. get transparencyShadow(): boolean;
  82198. set transparencyShadow(value: boolean);
  82199. /**
  82200. * Sets the ability to have transparent shadow (boolean).
  82201. * @param transparent True if transparent else False
  82202. * @returns the shadow generator allowing fluent coding
  82203. */
  82204. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  82205. private _shadowMap;
  82206. private _shadowMap2;
  82207. /**
  82208. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82209. * @returns The render target texture if present otherwise, null
  82210. */
  82211. getShadowMap(): Nullable<RenderTargetTexture>;
  82212. /**
  82213. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  82214. * @returns The render target texture if the shadow map is present otherwise, null
  82215. */
  82216. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  82217. /**
  82218. * Gets the class name of that object
  82219. * @returns "ShadowGenerator"
  82220. */
  82221. getClassName(): string;
  82222. /**
  82223. * Helper function to add a mesh and its descendants to the list of shadow casters.
  82224. * @param mesh Mesh to add
  82225. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  82226. * @returns the Shadow Generator itself
  82227. */
  82228. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82229. /**
  82230. * Helper function to remove a mesh and its descendants from the list of shadow casters
  82231. * @param mesh Mesh to remove
  82232. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  82233. * @returns the Shadow Generator itself
  82234. */
  82235. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82236. /**
  82237. * Controls the extent to which the shadows fade out at the edge of the frustum
  82238. * Used only by directionals and spots
  82239. */
  82240. frustumEdgeFalloff: number;
  82241. private _light;
  82242. /**
  82243. * Returns the associated light object.
  82244. * @returns the light generating the shadow
  82245. */
  82246. getLight(): IShadowLight;
  82247. /**
  82248. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  82249. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  82250. * It might on the other hand introduce peter panning.
  82251. */
  82252. forceBackFacesOnly: boolean;
  82253. private _scene;
  82254. private _lightDirection;
  82255. private _effect;
  82256. private _viewMatrix;
  82257. private _projectionMatrix;
  82258. private _transformMatrix;
  82259. private _cachedPosition;
  82260. private _cachedDirection;
  82261. private _cachedDefines;
  82262. private _currentRenderID;
  82263. private _boxBlurPostprocess;
  82264. private _kernelBlurXPostprocess;
  82265. private _kernelBlurYPostprocess;
  82266. private _blurPostProcesses;
  82267. private _mapSize;
  82268. private _currentFaceIndex;
  82269. private _currentFaceIndexCache;
  82270. private _textureType;
  82271. private _defaultTextureMatrix;
  82272. private _storedUniqueId;
  82273. /** @hidden */
  82274. static _SceneComponentInitialization: (scene: Scene) => void;
  82275. /**
  82276. * Creates a ShadowGenerator object.
  82277. * A ShadowGenerator is the required tool to use the shadows.
  82278. * Each light casting shadows needs to use its own ShadowGenerator.
  82279. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  82280. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  82281. * @param light The light object generating the shadows.
  82282. * @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.
  82283. */
  82284. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  82285. private _initializeGenerator;
  82286. private _initializeShadowMap;
  82287. private _initializeBlurRTTAndPostProcesses;
  82288. private _renderForShadowMap;
  82289. private _renderSubMeshForShadowMap;
  82290. private _applyFilterValues;
  82291. /**
  82292. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82293. * @param onCompiled Callback triggered at the and of the effects compilation
  82294. * @param options Sets of optional options forcing the compilation with different modes
  82295. */
  82296. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82297. useInstances: boolean;
  82298. }>): void;
  82299. /**
  82300. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82301. * @param options Sets of optional options forcing the compilation with different modes
  82302. * @returns A promise that resolves when the compilation completes
  82303. */
  82304. forceCompilationAsync(options?: Partial<{
  82305. useInstances: boolean;
  82306. }>): Promise<void>;
  82307. /**
  82308. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82309. * @param subMesh The submesh we want to render in the shadow map
  82310. * @param useInstances Defines wether will draw in the map using instances
  82311. * @returns true if ready otherwise, false
  82312. */
  82313. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82314. /**
  82315. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82316. * @param defines Defines of the material we want to update
  82317. * @param lightIndex Index of the light in the enabled light list of the material
  82318. */
  82319. prepareDefines(defines: any, lightIndex: number): void;
  82320. /**
  82321. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82322. * defined in the generator but impacting the effect).
  82323. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82324. * @param effect The effect we are binfing the information for
  82325. */
  82326. bindShadowLight(lightIndex: string, effect: Effect): void;
  82327. /**
  82328. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82329. * (eq to shadow prjection matrix * light transform matrix)
  82330. * @returns The transform matrix used to create the shadow map
  82331. */
  82332. getTransformMatrix(): Matrix;
  82333. /**
  82334. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82335. * Cube and 2D textures for instance.
  82336. */
  82337. recreateShadowMap(): void;
  82338. private _disposeBlurPostProcesses;
  82339. private _disposeRTTandPostProcesses;
  82340. /**
  82341. * Disposes the ShadowGenerator.
  82342. * Returns nothing.
  82343. */
  82344. dispose(): void;
  82345. /**
  82346. * Serializes the shadow generator setup to a json object.
  82347. * @returns The serialized JSON object
  82348. */
  82349. serialize(): any;
  82350. /**
  82351. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  82352. * @param parsedShadowGenerator The JSON object to parse
  82353. * @param scene The scene to create the shadow map for
  82354. * @returns The parsed shadow generator
  82355. */
  82356. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  82357. }
  82358. }
  82359. declare module BABYLON {
  82360. /**
  82361. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  82362. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  82363. * 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.
  82364. */
  82365. export abstract class Light extends Node {
  82366. /**
  82367. * Falloff Default: light is falling off following the material specification:
  82368. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  82369. */
  82370. static readonly FALLOFF_DEFAULT: number;
  82371. /**
  82372. * Falloff Physical: light is falling off following the inverse squared distance law.
  82373. */
  82374. static readonly FALLOFF_PHYSICAL: number;
  82375. /**
  82376. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  82377. * to enhance interoperability with other engines.
  82378. */
  82379. static readonly FALLOFF_GLTF: number;
  82380. /**
  82381. * Falloff Standard: light is falling off like in the standard material
  82382. * to enhance interoperability with other materials.
  82383. */
  82384. static readonly FALLOFF_STANDARD: number;
  82385. /**
  82386. * If every light affecting the material is in this lightmapMode,
  82387. * material.lightmapTexture adds or multiplies
  82388. * (depends on material.useLightmapAsShadowmap)
  82389. * after every other light calculations.
  82390. */
  82391. static readonly LIGHTMAP_DEFAULT: number;
  82392. /**
  82393. * material.lightmapTexture as only diffuse lighting from this light
  82394. * adds only specular lighting from this light
  82395. * adds dynamic shadows
  82396. */
  82397. static readonly LIGHTMAP_SPECULAR: number;
  82398. /**
  82399. * material.lightmapTexture as only lighting
  82400. * no light calculation from this light
  82401. * only adds dynamic shadows from this light
  82402. */
  82403. static readonly LIGHTMAP_SHADOWSONLY: number;
  82404. /**
  82405. * Each light type uses the default quantity according to its type:
  82406. * point/spot lights use luminous intensity
  82407. * directional lights use illuminance
  82408. */
  82409. static readonly INTENSITYMODE_AUTOMATIC: number;
  82410. /**
  82411. * lumen (lm)
  82412. */
  82413. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  82414. /**
  82415. * candela (lm/sr)
  82416. */
  82417. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  82418. /**
  82419. * lux (lm/m^2)
  82420. */
  82421. static readonly INTENSITYMODE_ILLUMINANCE: number;
  82422. /**
  82423. * nit (cd/m^2)
  82424. */
  82425. static readonly INTENSITYMODE_LUMINANCE: number;
  82426. /**
  82427. * Light type const id of the point light.
  82428. */
  82429. static readonly LIGHTTYPEID_POINTLIGHT: number;
  82430. /**
  82431. * Light type const id of the directional light.
  82432. */
  82433. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  82434. /**
  82435. * Light type const id of the spot light.
  82436. */
  82437. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  82438. /**
  82439. * Light type const id of the hemispheric light.
  82440. */
  82441. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  82442. /**
  82443. * Diffuse gives the basic color to an object.
  82444. */
  82445. diffuse: Color3;
  82446. /**
  82447. * Specular produces a highlight color on an object.
  82448. * Note: This is note affecting PBR materials.
  82449. */
  82450. specular: Color3;
  82451. /**
  82452. * Defines the falloff type for this light. This lets overrriding how punctual light are
  82453. * falling off base on range or angle.
  82454. * This can be set to any values in Light.FALLOFF_x.
  82455. *
  82456. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  82457. * other types of materials.
  82458. */
  82459. falloffType: number;
  82460. /**
  82461. * Strength of the light.
  82462. * Note: By default it is define in the framework own unit.
  82463. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  82464. */
  82465. intensity: number;
  82466. private _range;
  82467. protected _inverseSquaredRange: number;
  82468. /**
  82469. * Defines how far from the source the light is impacting in scene units.
  82470. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82471. */
  82472. get range(): number;
  82473. /**
  82474. * Defines how far from the source the light is impacting in scene units.
  82475. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82476. */
  82477. set range(value: number);
  82478. /**
  82479. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  82480. * of light.
  82481. */
  82482. private _photometricScale;
  82483. private _intensityMode;
  82484. /**
  82485. * Gets the photometric scale used to interpret the intensity.
  82486. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82487. */
  82488. get intensityMode(): number;
  82489. /**
  82490. * Sets the photometric scale used to interpret the intensity.
  82491. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82492. */
  82493. set intensityMode(value: number);
  82494. private _radius;
  82495. /**
  82496. * Gets the light radius used by PBR Materials to simulate soft area lights.
  82497. */
  82498. get radius(): number;
  82499. /**
  82500. * sets the light radius used by PBR Materials to simulate soft area lights.
  82501. */
  82502. set radius(value: number);
  82503. private _renderPriority;
  82504. /**
  82505. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  82506. * exceeding the number allowed of the materials.
  82507. */
  82508. renderPriority: number;
  82509. private _shadowEnabled;
  82510. /**
  82511. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82512. * the current shadow generator.
  82513. */
  82514. get shadowEnabled(): boolean;
  82515. /**
  82516. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82517. * the current shadow generator.
  82518. */
  82519. set shadowEnabled(value: boolean);
  82520. private _includedOnlyMeshes;
  82521. /**
  82522. * Gets the only meshes impacted by this light.
  82523. */
  82524. get includedOnlyMeshes(): AbstractMesh[];
  82525. /**
  82526. * Sets the only meshes impacted by this light.
  82527. */
  82528. set includedOnlyMeshes(value: AbstractMesh[]);
  82529. private _excludedMeshes;
  82530. /**
  82531. * Gets the meshes not impacted by this light.
  82532. */
  82533. get excludedMeshes(): AbstractMesh[];
  82534. /**
  82535. * Sets the meshes not impacted by this light.
  82536. */
  82537. set excludedMeshes(value: AbstractMesh[]);
  82538. private _excludeWithLayerMask;
  82539. /**
  82540. * Gets the layer id use to find what meshes are not impacted by the light.
  82541. * Inactive if 0
  82542. */
  82543. get excludeWithLayerMask(): number;
  82544. /**
  82545. * Sets the layer id use to find what meshes are not impacted by the light.
  82546. * Inactive if 0
  82547. */
  82548. set excludeWithLayerMask(value: number);
  82549. private _includeOnlyWithLayerMask;
  82550. /**
  82551. * Gets the layer id use to find what meshes are impacted by the light.
  82552. * Inactive if 0
  82553. */
  82554. get includeOnlyWithLayerMask(): number;
  82555. /**
  82556. * Sets the layer id use to find what meshes are impacted by the light.
  82557. * Inactive if 0
  82558. */
  82559. set includeOnlyWithLayerMask(value: number);
  82560. private _lightmapMode;
  82561. /**
  82562. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  82563. */
  82564. get lightmapMode(): number;
  82565. /**
  82566. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  82567. */
  82568. set lightmapMode(value: number);
  82569. /**
  82570. * Shadow generator associted to the light.
  82571. * @hidden Internal use only.
  82572. */
  82573. _shadowGenerator: Nullable<IShadowGenerator>;
  82574. /**
  82575. * @hidden Internal use only.
  82576. */
  82577. _excludedMeshesIds: string[];
  82578. /**
  82579. * @hidden Internal use only.
  82580. */
  82581. _includedOnlyMeshesIds: string[];
  82582. /**
  82583. * The current light unifom buffer.
  82584. * @hidden Internal use only.
  82585. */
  82586. _uniformBuffer: UniformBuffer;
  82587. /** @hidden */
  82588. _renderId: number;
  82589. /**
  82590. * Creates a Light object in the scene.
  82591. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82592. * @param name The firendly name of the light
  82593. * @param scene The scene the light belongs too
  82594. */
  82595. constructor(name: string, scene: Scene);
  82596. protected abstract _buildUniformLayout(): void;
  82597. /**
  82598. * Sets the passed Effect "effect" with the Light information.
  82599. * @param effect The effect to update
  82600. * @param lightIndex The index of the light in the effect to update
  82601. * @returns The light
  82602. */
  82603. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  82604. /**
  82605. * Sets the passed Effect "effect" with the Light textures.
  82606. * @param effect The effect to update
  82607. * @param lightIndex The index of the light in the effect to update
  82608. * @returns The light
  82609. */
  82610. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  82611. /**
  82612. * Binds the lights information from the scene to the effect for the given mesh.
  82613. * @param lightIndex Light index
  82614. * @param scene The scene where the light belongs to
  82615. * @param effect The effect we are binding the data to
  82616. * @param useSpecular Defines if specular is supported
  82617. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82618. */
  82619. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82620. /**
  82621. * Sets the passed Effect "effect" with the Light information.
  82622. * @param effect The effect to update
  82623. * @param lightDataUniformName The uniform used to store light data (position or direction)
  82624. * @returns The light
  82625. */
  82626. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  82627. /**
  82628. * Returns the string "Light".
  82629. * @returns the class name
  82630. */
  82631. getClassName(): string;
  82632. /** @hidden */
  82633. readonly _isLight: boolean;
  82634. /**
  82635. * Converts the light information to a readable string for debug purpose.
  82636. * @param fullDetails Supports for multiple levels of logging within scene loading
  82637. * @returns the human readable light info
  82638. */
  82639. toString(fullDetails?: boolean): string;
  82640. /** @hidden */
  82641. protected _syncParentEnabledState(): void;
  82642. /**
  82643. * Set the enabled state of this node.
  82644. * @param value - the new enabled state
  82645. */
  82646. setEnabled(value: boolean): void;
  82647. /**
  82648. * Returns the Light associated shadow generator if any.
  82649. * @return the associated shadow generator.
  82650. */
  82651. getShadowGenerator(): Nullable<IShadowGenerator>;
  82652. /**
  82653. * Returns a Vector3, the absolute light position in the World.
  82654. * @returns the world space position of the light
  82655. */
  82656. getAbsolutePosition(): Vector3;
  82657. /**
  82658. * Specifies if the light will affect the passed mesh.
  82659. * @param mesh The mesh to test against the light
  82660. * @return true the mesh is affected otherwise, false.
  82661. */
  82662. canAffectMesh(mesh: AbstractMesh): boolean;
  82663. /**
  82664. * Sort function to order lights for rendering.
  82665. * @param a First Light object to compare to second.
  82666. * @param b Second Light object to compare first.
  82667. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  82668. */
  82669. static CompareLightsPriority(a: Light, b: Light): number;
  82670. /**
  82671. * Releases resources associated with this node.
  82672. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82673. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82674. */
  82675. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82676. /**
  82677. * Returns the light type ID (integer).
  82678. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82679. */
  82680. getTypeID(): number;
  82681. /**
  82682. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  82683. * @returns the scaled intensity in intensity mode unit
  82684. */
  82685. getScaledIntensity(): number;
  82686. /**
  82687. * Returns a new Light object, named "name", from the current one.
  82688. * @param name The name of the cloned light
  82689. * @returns the new created light
  82690. */
  82691. clone(name: string): Nullable<Light>;
  82692. /**
  82693. * Serializes the current light into a Serialization object.
  82694. * @returns the serialized object.
  82695. */
  82696. serialize(): any;
  82697. /**
  82698. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  82699. * This new light is named "name" and added to the passed scene.
  82700. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  82701. * @param name The friendly name of the light
  82702. * @param scene The scene the new light will belong to
  82703. * @returns the constructor function
  82704. */
  82705. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  82706. /**
  82707. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  82708. * @param parsedLight The JSON representation of the light
  82709. * @param scene The scene to create the parsed light in
  82710. * @returns the created light after parsing
  82711. */
  82712. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  82713. private _hookArrayForExcluded;
  82714. private _hookArrayForIncludedOnly;
  82715. private _resyncMeshes;
  82716. /**
  82717. * Forces the meshes to update their light related information in their rendering used effects
  82718. * @hidden Internal Use Only
  82719. */
  82720. _markMeshesAsLightDirty(): void;
  82721. /**
  82722. * Recomputes the cached photometric scale if needed.
  82723. */
  82724. private _computePhotometricScale;
  82725. /**
  82726. * Returns the Photometric Scale according to the light type and intensity mode.
  82727. */
  82728. private _getPhotometricScale;
  82729. /**
  82730. * Reorder the light in the scene according to their defined priority.
  82731. * @hidden Internal Use Only
  82732. */
  82733. _reorderLightsInScene(): void;
  82734. /**
  82735. * Prepares the list of defines specific to the light type.
  82736. * @param defines the list of defines
  82737. * @param lightIndex defines the index of the light for the effect
  82738. */
  82739. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82740. }
  82741. }
  82742. declare module BABYLON {
  82743. /**
  82744. * Interface used to define Action
  82745. */
  82746. export interface IAction {
  82747. /**
  82748. * Trigger for the action
  82749. */
  82750. trigger: number;
  82751. /** Options of the trigger */
  82752. triggerOptions: any;
  82753. /**
  82754. * Gets the trigger parameters
  82755. * @returns the trigger parameters
  82756. */
  82757. getTriggerParameter(): any;
  82758. /**
  82759. * Internal only - executes current action event
  82760. * @hidden
  82761. */
  82762. _executeCurrent(evt?: ActionEvent): void;
  82763. /**
  82764. * Serialize placeholder for child classes
  82765. * @param parent of child
  82766. * @returns the serialized object
  82767. */
  82768. serialize(parent: any): any;
  82769. /**
  82770. * Internal only
  82771. * @hidden
  82772. */
  82773. _prepare(): void;
  82774. /**
  82775. * Internal only - manager for action
  82776. * @hidden
  82777. */
  82778. _actionManager: AbstractActionManager;
  82779. /**
  82780. * Adds action to chain of actions, may be a DoNothingAction
  82781. * @param action defines the next action to execute
  82782. * @returns The action passed in
  82783. * @see https://www.babylonjs-playground.com/#1T30HR#0
  82784. */
  82785. then(action: IAction): IAction;
  82786. }
  82787. /**
  82788. * The action to be carried out following a trigger
  82789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  82790. */
  82791. export class Action implements IAction {
  82792. /** the trigger, with or without parameters, for the action */
  82793. triggerOptions: any;
  82794. /**
  82795. * Trigger for the action
  82796. */
  82797. trigger: number;
  82798. /**
  82799. * Internal only - manager for action
  82800. * @hidden
  82801. */
  82802. _actionManager: ActionManager;
  82803. private _nextActiveAction;
  82804. private _child;
  82805. private _condition?;
  82806. private _triggerParameter;
  82807. /**
  82808. * An event triggered prior to action being executed.
  82809. */
  82810. onBeforeExecuteObservable: Observable<Action>;
  82811. /**
  82812. * Creates a new Action
  82813. * @param triggerOptions the trigger, with or without parameters, for the action
  82814. * @param condition an optional determinant of action
  82815. */
  82816. constructor(
  82817. /** the trigger, with or without parameters, for the action */
  82818. triggerOptions: any, condition?: Condition);
  82819. /**
  82820. * Internal only
  82821. * @hidden
  82822. */
  82823. _prepare(): void;
  82824. /**
  82825. * Gets the trigger parameters
  82826. * @returns the trigger parameters
  82827. */
  82828. getTriggerParameter(): any;
  82829. /**
  82830. * Internal only - executes current action event
  82831. * @hidden
  82832. */
  82833. _executeCurrent(evt?: ActionEvent): void;
  82834. /**
  82835. * Execute placeholder for child classes
  82836. * @param evt optional action event
  82837. */
  82838. execute(evt?: ActionEvent): void;
  82839. /**
  82840. * Skips to next active action
  82841. */
  82842. skipToNextActiveAction(): void;
  82843. /**
  82844. * Adds action to chain of actions, may be a DoNothingAction
  82845. * @param action defines the next action to execute
  82846. * @returns The action passed in
  82847. * @see https://www.babylonjs-playground.com/#1T30HR#0
  82848. */
  82849. then(action: Action): Action;
  82850. /**
  82851. * Internal only
  82852. * @hidden
  82853. */
  82854. _getProperty(propertyPath: string): string;
  82855. /**
  82856. * Internal only
  82857. * @hidden
  82858. */
  82859. _getEffectiveTarget(target: any, propertyPath: string): any;
  82860. /**
  82861. * Serialize placeholder for child classes
  82862. * @param parent of child
  82863. * @returns the serialized object
  82864. */
  82865. serialize(parent: any): any;
  82866. /**
  82867. * Internal only called by serialize
  82868. * @hidden
  82869. */
  82870. protected _serialize(serializedAction: any, parent?: any): any;
  82871. /**
  82872. * Internal only
  82873. * @hidden
  82874. */
  82875. static _SerializeValueAsString: (value: any) => string;
  82876. /**
  82877. * Internal only
  82878. * @hidden
  82879. */
  82880. static _GetTargetProperty: (target: Node | Scene) => {
  82881. name: string;
  82882. targetType: string;
  82883. value: string;
  82884. };
  82885. }
  82886. }
  82887. declare module BABYLON {
  82888. /**
  82889. * A Condition applied to an Action
  82890. */
  82891. export class Condition {
  82892. /**
  82893. * Internal only - manager for action
  82894. * @hidden
  82895. */
  82896. _actionManager: ActionManager;
  82897. /**
  82898. * Internal only
  82899. * @hidden
  82900. */
  82901. _evaluationId: number;
  82902. /**
  82903. * Internal only
  82904. * @hidden
  82905. */
  82906. _currentResult: boolean;
  82907. /**
  82908. * Creates a new Condition
  82909. * @param actionManager the manager of the action the condition is applied to
  82910. */
  82911. constructor(actionManager: ActionManager);
  82912. /**
  82913. * Check if the current condition is valid
  82914. * @returns a boolean
  82915. */
  82916. isValid(): boolean;
  82917. /**
  82918. * Internal only
  82919. * @hidden
  82920. */
  82921. _getProperty(propertyPath: string): string;
  82922. /**
  82923. * Internal only
  82924. * @hidden
  82925. */
  82926. _getEffectiveTarget(target: any, propertyPath: string): any;
  82927. /**
  82928. * Serialize placeholder for child classes
  82929. * @returns the serialized object
  82930. */
  82931. serialize(): any;
  82932. /**
  82933. * Internal only
  82934. * @hidden
  82935. */
  82936. protected _serialize(serializedCondition: any): any;
  82937. }
  82938. /**
  82939. * Defines specific conditional operators as extensions of Condition
  82940. */
  82941. export class ValueCondition extends Condition {
  82942. /** path to specify the property of the target the conditional operator uses */
  82943. propertyPath: string;
  82944. /** the value compared by the conditional operator against the current value of the property */
  82945. value: any;
  82946. /** the conditional operator, default ValueCondition.IsEqual */
  82947. operator: number;
  82948. /**
  82949. * Internal only
  82950. * @hidden
  82951. */
  82952. private static _IsEqual;
  82953. /**
  82954. * Internal only
  82955. * @hidden
  82956. */
  82957. private static _IsDifferent;
  82958. /**
  82959. * Internal only
  82960. * @hidden
  82961. */
  82962. private static _IsGreater;
  82963. /**
  82964. * Internal only
  82965. * @hidden
  82966. */
  82967. private static _IsLesser;
  82968. /**
  82969. * returns the number for IsEqual
  82970. */
  82971. static get IsEqual(): number;
  82972. /**
  82973. * Returns the number for IsDifferent
  82974. */
  82975. static get IsDifferent(): number;
  82976. /**
  82977. * Returns the number for IsGreater
  82978. */
  82979. static get IsGreater(): number;
  82980. /**
  82981. * Returns the number for IsLesser
  82982. */
  82983. static get IsLesser(): number;
  82984. /**
  82985. * Internal only The action manager for the condition
  82986. * @hidden
  82987. */
  82988. _actionManager: ActionManager;
  82989. /**
  82990. * Internal only
  82991. * @hidden
  82992. */
  82993. private _target;
  82994. /**
  82995. * Internal only
  82996. * @hidden
  82997. */
  82998. private _effectiveTarget;
  82999. /**
  83000. * Internal only
  83001. * @hidden
  83002. */
  83003. private _property;
  83004. /**
  83005. * Creates a new ValueCondition
  83006. * @param actionManager manager for the action the condition applies to
  83007. * @param target for the action
  83008. * @param propertyPath path to specify the property of the target the conditional operator uses
  83009. * @param value the value compared by the conditional operator against the current value of the property
  83010. * @param operator the conditional operator, default ValueCondition.IsEqual
  83011. */
  83012. constructor(actionManager: ActionManager, target: any,
  83013. /** path to specify the property of the target the conditional operator uses */
  83014. propertyPath: string,
  83015. /** the value compared by the conditional operator against the current value of the property */
  83016. value: any,
  83017. /** the conditional operator, default ValueCondition.IsEqual */
  83018. operator?: number);
  83019. /**
  83020. * Compares the given value with the property value for the specified conditional operator
  83021. * @returns the result of the comparison
  83022. */
  83023. isValid(): boolean;
  83024. /**
  83025. * Serialize the ValueCondition into a JSON compatible object
  83026. * @returns serialization object
  83027. */
  83028. serialize(): any;
  83029. /**
  83030. * Gets the name of the conditional operator for the ValueCondition
  83031. * @param operator the conditional operator
  83032. * @returns the name
  83033. */
  83034. static GetOperatorName(operator: number): string;
  83035. }
  83036. /**
  83037. * Defines a predicate condition as an extension of Condition
  83038. */
  83039. export class PredicateCondition extends Condition {
  83040. /** defines the predicate function used to validate the condition */
  83041. predicate: () => boolean;
  83042. /**
  83043. * Internal only - manager for action
  83044. * @hidden
  83045. */
  83046. _actionManager: ActionManager;
  83047. /**
  83048. * Creates a new PredicateCondition
  83049. * @param actionManager manager for the action the condition applies to
  83050. * @param predicate defines the predicate function used to validate the condition
  83051. */
  83052. constructor(actionManager: ActionManager,
  83053. /** defines the predicate function used to validate the condition */
  83054. predicate: () => boolean);
  83055. /**
  83056. * @returns the validity of the predicate condition
  83057. */
  83058. isValid(): boolean;
  83059. }
  83060. /**
  83061. * Defines a state condition as an extension of Condition
  83062. */
  83063. export class StateCondition extends Condition {
  83064. /** Value to compare with target state */
  83065. value: string;
  83066. /**
  83067. * Internal only - manager for action
  83068. * @hidden
  83069. */
  83070. _actionManager: ActionManager;
  83071. /**
  83072. * Internal only
  83073. * @hidden
  83074. */
  83075. private _target;
  83076. /**
  83077. * Creates a new StateCondition
  83078. * @param actionManager manager for the action the condition applies to
  83079. * @param target of the condition
  83080. * @param value to compare with target state
  83081. */
  83082. constructor(actionManager: ActionManager, target: any,
  83083. /** Value to compare with target state */
  83084. value: string);
  83085. /**
  83086. * Gets a boolean indicating if the current condition is met
  83087. * @returns the validity of the state
  83088. */
  83089. isValid(): boolean;
  83090. /**
  83091. * Serialize the StateCondition into a JSON compatible object
  83092. * @returns serialization object
  83093. */
  83094. serialize(): any;
  83095. }
  83096. }
  83097. declare module BABYLON {
  83098. /**
  83099. * This defines an action responsible to toggle a boolean once triggered.
  83100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83101. */
  83102. export class SwitchBooleanAction extends Action {
  83103. /**
  83104. * The path to the boolean property in the target object
  83105. */
  83106. propertyPath: string;
  83107. private _target;
  83108. private _effectiveTarget;
  83109. private _property;
  83110. /**
  83111. * Instantiate the action
  83112. * @param triggerOptions defines the trigger options
  83113. * @param target defines the object containing the boolean
  83114. * @param propertyPath defines the path to the boolean property in the target object
  83115. * @param condition defines the trigger related conditions
  83116. */
  83117. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  83118. /** @hidden */
  83119. _prepare(): void;
  83120. /**
  83121. * Execute the action toggle the boolean value.
  83122. */
  83123. execute(): void;
  83124. /**
  83125. * Serializes the actions and its related information.
  83126. * @param parent defines the object to serialize in
  83127. * @returns the serialized object
  83128. */
  83129. serialize(parent: any): any;
  83130. }
  83131. /**
  83132. * This defines an action responsible to set a the state field of the target
  83133. * to a desired value once triggered.
  83134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83135. */
  83136. export class SetStateAction extends Action {
  83137. /**
  83138. * The value to store in the state field.
  83139. */
  83140. value: string;
  83141. private _target;
  83142. /**
  83143. * Instantiate the action
  83144. * @param triggerOptions defines the trigger options
  83145. * @param target defines the object containing the state property
  83146. * @param value defines the value to store in the state field
  83147. * @param condition defines the trigger related conditions
  83148. */
  83149. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  83150. /**
  83151. * Execute the action and store the value on the target state property.
  83152. */
  83153. execute(): void;
  83154. /**
  83155. * Serializes the actions and its related information.
  83156. * @param parent defines the object to serialize in
  83157. * @returns the serialized object
  83158. */
  83159. serialize(parent: any): any;
  83160. }
  83161. /**
  83162. * This defines an action responsible to set a property of the target
  83163. * to a desired value once triggered.
  83164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83165. */
  83166. export class SetValueAction extends Action {
  83167. /**
  83168. * The path of the property to set in the target.
  83169. */
  83170. propertyPath: string;
  83171. /**
  83172. * The value to set in the property
  83173. */
  83174. value: any;
  83175. private _target;
  83176. private _effectiveTarget;
  83177. private _property;
  83178. /**
  83179. * Instantiate the action
  83180. * @param triggerOptions defines the trigger options
  83181. * @param target defines the object containing the property
  83182. * @param propertyPath defines the path of the property to set in the target
  83183. * @param value defines the value to set in the property
  83184. * @param condition defines the trigger related conditions
  83185. */
  83186. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83187. /** @hidden */
  83188. _prepare(): void;
  83189. /**
  83190. * Execute the action and set the targetted property to the desired value.
  83191. */
  83192. execute(): void;
  83193. /**
  83194. * Serializes the actions and its related information.
  83195. * @param parent defines the object to serialize in
  83196. * @returns the serialized object
  83197. */
  83198. serialize(parent: any): any;
  83199. }
  83200. /**
  83201. * This defines an action responsible to increment the target value
  83202. * to a desired value once triggered.
  83203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83204. */
  83205. export class IncrementValueAction extends Action {
  83206. /**
  83207. * The path of the property to increment in the target.
  83208. */
  83209. propertyPath: string;
  83210. /**
  83211. * The value we should increment the property by.
  83212. */
  83213. value: any;
  83214. private _target;
  83215. private _effectiveTarget;
  83216. private _property;
  83217. /**
  83218. * Instantiate the action
  83219. * @param triggerOptions defines the trigger options
  83220. * @param target defines the object containing the property
  83221. * @param propertyPath defines the path of the property to increment in the target
  83222. * @param value defines the value value we should increment the property by
  83223. * @param condition defines the trigger related conditions
  83224. */
  83225. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83226. /** @hidden */
  83227. _prepare(): void;
  83228. /**
  83229. * Execute the action and increment the target of the value amount.
  83230. */
  83231. execute(): void;
  83232. /**
  83233. * Serializes the actions and its related information.
  83234. * @param parent defines the object to serialize in
  83235. * @returns the serialized object
  83236. */
  83237. serialize(parent: any): any;
  83238. }
  83239. /**
  83240. * This defines an action responsible to start an animation once triggered.
  83241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83242. */
  83243. export class PlayAnimationAction extends Action {
  83244. /**
  83245. * Where the animation should start (animation frame)
  83246. */
  83247. from: number;
  83248. /**
  83249. * Where the animation should stop (animation frame)
  83250. */
  83251. to: number;
  83252. /**
  83253. * Define if the animation should loop or stop after the first play.
  83254. */
  83255. loop?: boolean;
  83256. private _target;
  83257. /**
  83258. * Instantiate the action
  83259. * @param triggerOptions defines the trigger options
  83260. * @param target defines the target animation or animation name
  83261. * @param from defines from where the animation should start (animation frame)
  83262. * @param end defines where the animation should stop (animation frame)
  83263. * @param loop defines if the animation should loop or stop after the first play
  83264. * @param condition defines the trigger related conditions
  83265. */
  83266. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  83267. /** @hidden */
  83268. _prepare(): void;
  83269. /**
  83270. * Execute the action and play the animation.
  83271. */
  83272. execute(): void;
  83273. /**
  83274. * Serializes the actions and its related information.
  83275. * @param parent defines the object to serialize in
  83276. * @returns the serialized object
  83277. */
  83278. serialize(parent: any): any;
  83279. }
  83280. /**
  83281. * This defines an action responsible to stop an animation once triggered.
  83282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83283. */
  83284. export class StopAnimationAction extends Action {
  83285. private _target;
  83286. /**
  83287. * Instantiate the action
  83288. * @param triggerOptions defines the trigger options
  83289. * @param target defines the target animation or animation name
  83290. * @param condition defines the trigger related conditions
  83291. */
  83292. constructor(triggerOptions: any, target: any, condition?: Condition);
  83293. /** @hidden */
  83294. _prepare(): void;
  83295. /**
  83296. * Execute the action and stop the animation.
  83297. */
  83298. execute(): void;
  83299. /**
  83300. * Serializes the actions and its related information.
  83301. * @param parent defines the object to serialize in
  83302. * @returns the serialized object
  83303. */
  83304. serialize(parent: any): any;
  83305. }
  83306. /**
  83307. * This defines an action responsible that does nothing once triggered.
  83308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83309. */
  83310. export class DoNothingAction extends Action {
  83311. /**
  83312. * Instantiate the action
  83313. * @param triggerOptions defines the trigger options
  83314. * @param condition defines the trigger related conditions
  83315. */
  83316. constructor(triggerOptions?: any, condition?: Condition);
  83317. /**
  83318. * Execute the action and do nothing.
  83319. */
  83320. execute(): void;
  83321. /**
  83322. * Serializes the actions and its related information.
  83323. * @param parent defines the object to serialize in
  83324. * @returns the serialized object
  83325. */
  83326. serialize(parent: any): any;
  83327. }
  83328. /**
  83329. * This defines an action responsible to trigger several actions once triggered.
  83330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83331. */
  83332. export class CombineAction extends Action {
  83333. /**
  83334. * The list of aggregated animations to run.
  83335. */
  83336. children: Action[];
  83337. /**
  83338. * Instantiate the action
  83339. * @param triggerOptions defines the trigger options
  83340. * @param children defines the list of aggregated animations to run
  83341. * @param condition defines the trigger related conditions
  83342. */
  83343. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  83344. /** @hidden */
  83345. _prepare(): void;
  83346. /**
  83347. * Execute the action and executes all the aggregated actions.
  83348. */
  83349. execute(evt: ActionEvent): void;
  83350. /**
  83351. * Serializes the actions and its related information.
  83352. * @param parent defines the object to serialize in
  83353. * @returns the serialized object
  83354. */
  83355. serialize(parent: any): any;
  83356. }
  83357. /**
  83358. * This defines an action responsible to run code (external event) once triggered.
  83359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83360. */
  83361. export class ExecuteCodeAction extends Action {
  83362. /**
  83363. * The callback function to run.
  83364. */
  83365. func: (evt: ActionEvent) => void;
  83366. /**
  83367. * Instantiate the action
  83368. * @param triggerOptions defines the trigger options
  83369. * @param func defines the callback function to run
  83370. * @param condition defines the trigger related conditions
  83371. */
  83372. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  83373. /**
  83374. * Execute the action and run the attached code.
  83375. */
  83376. execute(evt: ActionEvent): void;
  83377. }
  83378. /**
  83379. * This defines an action responsible to set the parent property of the target once triggered.
  83380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83381. */
  83382. export class SetParentAction extends Action {
  83383. private _parent;
  83384. private _target;
  83385. /**
  83386. * Instantiate the action
  83387. * @param triggerOptions defines the trigger options
  83388. * @param target defines the target containing the parent property
  83389. * @param parent defines from where the animation should start (animation frame)
  83390. * @param condition defines the trigger related conditions
  83391. */
  83392. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  83393. /** @hidden */
  83394. _prepare(): void;
  83395. /**
  83396. * Execute the action and set the parent property.
  83397. */
  83398. execute(): void;
  83399. /**
  83400. * Serializes the actions and its related information.
  83401. * @param parent defines the object to serialize in
  83402. * @returns the serialized object
  83403. */
  83404. serialize(parent: any): any;
  83405. }
  83406. }
  83407. declare module BABYLON {
  83408. /**
  83409. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  83410. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  83411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83412. */
  83413. export class ActionManager extends AbstractActionManager {
  83414. /**
  83415. * Nothing
  83416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83417. */
  83418. static readonly NothingTrigger: number;
  83419. /**
  83420. * On pick
  83421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83422. */
  83423. static readonly OnPickTrigger: number;
  83424. /**
  83425. * On left pick
  83426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83427. */
  83428. static readonly OnLeftPickTrigger: number;
  83429. /**
  83430. * On right pick
  83431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83432. */
  83433. static readonly OnRightPickTrigger: number;
  83434. /**
  83435. * On center pick
  83436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83437. */
  83438. static readonly OnCenterPickTrigger: number;
  83439. /**
  83440. * On pick down
  83441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83442. */
  83443. static readonly OnPickDownTrigger: number;
  83444. /**
  83445. * On double pick
  83446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83447. */
  83448. static readonly OnDoublePickTrigger: number;
  83449. /**
  83450. * On pick up
  83451. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83452. */
  83453. static readonly OnPickUpTrigger: number;
  83454. /**
  83455. * On pick out.
  83456. * This trigger will only be raised if you also declared a OnPickDown
  83457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83458. */
  83459. static readonly OnPickOutTrigger: number;
  83460. /**
  83461. * On long press
  83462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83463. */
  83464. static readonly OnLongPressTrigger: number;
  83465. /**
  83466. * On pointer over
  83467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83468. */
  83469. static readonly OnPointerOverTrigger: number;
  83470. /**
  83471. * On pointer out
  83472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83473. */
  83474. static readonly OnPointerOutTrigger: number;
  83475. /**
  83476. * On every frame
  83477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83478. */
  83479. static readonly OnEveryFrameTrigger: number;
  83480. /**
  83481. * On intersection enter
  83482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83483. */
  83484. static readonly OnIntersectionEnterTrigger: number;
  83485. /**
  83486. * On intersection exit
  83487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83488. */
  83489. static readonly OnIntersectionExitTrigger: number;
  83490. /**
  83491. * On key down
  83492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83493. */
  83494. static readonly OnKeyDownTrigger: number;
  83495. /**
  83496. * On key up
  83497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83498. */
  83499. static readonly OnKeyUpTrigger: number;
  83500. private _scene;
  83501. /**
  83502. * Creates a new action manager
  83503. * @param scene defines the hosting scene
  83504. */
  83505. constructor(scene: Scene);
  83506. /**
  83507. * Releases all associated resources
  83508. */
  83509. dispose(): void;
  83510. /**
  83511. * Gets hosting scene
  83512. * @returns the hosting scene
  83513. */
  83514. getScene(): Scene;
  83515. /**
  83516. * Does this action manager handles actions of any of the given triggers
  83517. * @param triggers defines the triggers to be tested
  83518. * @return a boolean indicating whether one (or more) of the triggers is handled
  83519. */
  83520. hasSpecificTriggers(triggers: number[]): boolean;
  83521. /**
  83522. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83523. * speed.
  83524. * @param triggerA defines the trigger to be tested
  83525. * @param triggerB defines the trigger to be tested
  83526. * @return a boolean indicating whether one (or more) of the triggers is handled
  83527. */
  83528. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83529. /**
  83530. * Does this action manager handles actions of a given trigger
  83531. * @param trigger defines the trigger to be tested
  83532. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83533. * @return whether the trigger is handled
  83534. */
  83535. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83536. /**
  83537. * Does this action manager has pointer triggers
  83538. */
  83539. get hasPointerTriggers(): boolean;
  83540. /**
  83541. * Does this action manager has pick triggers
  83542. */
  83543. get hasPickTriggers(): boolean;
  83544. /**
  83545. * Registers an action to this action manager
  83546. * @param action defines the action to be registered
  83547. * @return the action amended (prepared) after registration
  83548. */
  83549. registerAction(action: IAction): Nullable<IAction>;
  83550. /**
  83551. * Unregisters an action to this action manager
  83552. * @param action defines the action to be unregistered
  83553. * @return a boolean indicating whether the action has been unregistered
  83554. */
  83555. unregisterAction(action: IAction): Boolean;
  83556. /**
  83557. * Process a specific trigger
  83558. * @param trigger defines the trigger to process
  83559. * @param evt defines the event details to be processed
  83560. */
  83561. processTrigger(trigger: number, evt?: IActionEvent): void;
  83562. /** @hidden */
  83563. _getEffectiveTarget(target: any, propertyPath: string): any;
  83564. /** @hidden */
  83565. _getProperty(propertyPath: string): string;
  83566. /**
  83567. * Serialize this manager to a JSON object
  83568. * @param name defines the property name to store this manager
  83569. * @returns a JSON representation of this manager
  83570. */
  83571. serialize(name: string): any;
  83572. /**
  83573. * Creates a new ActionManager from a JSON data
  83574. * @param parsedActions defines the JSON data to read from
  83575. * @param object defines the hosting mesh
  83576. * @param scene defines the hosting scene
  83577. */
  83578. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  83579. /**
  83580. * Get a trigger name by index
  83581. * @param trigger defines the trigger index
  83582. * @returns a trigger name
  83583. */
  83584. static GetTriggerName(trigger: number): string;
  83585. }
  83586. }
  83587. declare module BABYLON {
  83588. /**
  83589. * Class representing a ray with position and direction
  83590. */
  83591. export class Ray {
  83592. /** origin point */
  83593. origin: Vector3;
  83594. /** direction */
  83595. direction: Vector3;
  83596. /** length of the ray */
  83597. length: number;
  83598. private static readonly TmpVector3;
  83599. private _tmpRay;
  83600. /**
  83601. * Creates a new ray
  83602. * @param origin origin point
  83603. * @param direction direction
  83604. * @param length length of the ray
  83605. */
  83606. constructor(
  83607. /** origin point */
  83608. origin: Vector3,
  83609. /** direction */
  83610. direction: Vector3,
  83611. /** length of the ray */
  83612. length?: number);
  83613. /**
  83614. * Checks if the ray intersects a box
  83615. * @param minimum bound of the box
  83616. * @param maximum bound of the box
  83617. * @param intersectionTreshold extra extend to be added to the box in all direction
  83618. * @returns if the box was hit
  83619. */
  83620. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83621. /**
  83622. * Checks if the ray intersects a box
  83623. * @param box the bounding box to check
  83624. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83625. * @returns if the box was hit
  83626. */
  83627. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83628. /**
  83629. * If the ray hits a sphere
  83630. * @param sphere the bounding sphere to check
  83631. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83632. * @returns true if it hits the sphere
  83633. */
  83634. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83635. /**
  83636. * If the ray hits a triange
  83637. * @param vertex0 triangle vertex
  83638. * @param vertex1 triangle vertex
  83639. * @param vertex2 triangle vertex
  83640. * @returns intersection information if hit
  83641. */
  83642. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83643. /**
  83644. * Checks if ray intersects a plane
  83645. * @param plane the plane to check
  83646. * @returns the distance away it was hit
  83647. */
  83648. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83649. /**
  83650. * Calculate the intercept of a ray on a given axis
  83651. * @param axis to check 'x' | 'y' | 'z'
  83652. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83653. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83654. */
  83655. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83656. /**
  83657. * Checks if ray intersects a mesh
  83658. * @param mesh the mesh to check
  83659. * @param fastCheck if only the bounding box should checked
  83660. * @returns picking info of the intersecton
  83661. */
  83662. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83663. /**
  83664. * Checks if ray intersects a mesh
  83665. * @param meshes the meshes to check
  83666. * @param fastCheck if only the bounding box should checked
  83667. * @param results array to store result in
  83668. * @returns Array of picking infos
  83669. */
  83670. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83671. private _comparePickingInfo;
  83672. private static smallnum;
  83673. private static rayl;
  83674. /**
  83675. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83676. * @param sega the first point of the segment to test the intersection against
  83677. * @param segb the second point of the segment to test the intersection against
  83678. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83679. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83680. */
  83681. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83682. /**
  83683. * Update the ray from viewport position
  83684. * @param x position
  83685. * @param y y position
  83686. * @param viewportWidth viewport width
  83687. * @param viewportHeight viewport height
  83688. * @param world world matrix
  83689. * @param view view matrix
  83690. * @param projection projection matrix
  83691. * @returns this ray updated
  83692. */
  83693. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83694. /**
  83695. * Creates a ray with origin and direction of 0,0,0
  83696. * @returns the new ray
  83697. */
  83698. static Zero(): Ray;
  83699. /**
  83700. * Creates a new ray from screen space and viewport
  83701. * @param x position
  83702. * @param y y position
  83703. * @param viewportWidth viewport width
  83704. * @param viewportHeight viewport height
  83705. * @param world world matrix
  83706. * @param view view matrix
  83707. * @param projection projection matrix
  83708. * @returns new ray
  83709. */
  83710. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83711. /**
  83712. * 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
  83713. * transformed to the given world matrix.
  83714. * @param origin The origin point
  83715. * @param end The end point
  83716. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83717. * @returns the new ray
  83718. */
  83719. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83720. /**
  83721. * Transforms a ray by a matrix
  83722. * @param ray ray to transform
  83723. * @param matrix matrix to apply
  83724. * @returns the resulting new ray
  83725. */
  83726. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83727. /**
  83728. * Transforms a ray by a matrix
  83729. * @param ray ray to transform
  83730. * @param matrix matrix to apply
  83731. * @param result ray to store result in
  83732. */
  83733. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83734. /**
  83735. * Unproject a ray from screen space to object space
  83736. * @param sourceX defines the screen space x coordinate to use
  83737. * @param sourceY defines the screen space y coordinate to use
  83738. * @param viewportWidth defines the current width of the viewport
  83739. * @param viewportHeight defines the current height of the viewport
  83740. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83741. * @param view defines the view matrix to use
  83742. * @param projection defines the projection matrix to use
  83743. */
  83744. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83745. }
  83746. /**
  83747. * Type used to define predicate used to select faces when a mesh intersection is detected
  83748. */
  83749. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83750. interface Scene {
  83751. /** @hidden */
  83752. _tempPickingRay: Nullable<Ray>;
  83753. /** @hidden */
  83754. _cachedRayForTransform: Ray;
  83755. /** @hidden */
  83756. _pickWithRayInverseMatrix: Matrix;
  83757. /** @hidden */
  83758. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83759. /** @hidden */
  83760. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83761. }
  83762. }
  83763. declare module BABYLON {
  83764. /**
  83765. * Groups all the scene component constants in one place to ease maintenance.
  83766. * @hidden
  83767. */
  83768. export class SceneComponentConstants {
  83769. static readonly NAME_EFFECTLAYER: string;
  83770. static readonly NAME_LAYER: string;
  83771. static readonly NAME_LENSFLARESYSTEM: string;
  83772. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83773. static readonly NAME_PARTICLESYSTEM: string;
  83774. static readonly NAME_GAMEPAD: string;
  83775. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83776. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83777. static readonly NAME_DEPTHRENDERER: string;
  83778. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83779. static readonly NAME_SPRITE: string;
  83780. static readonly NAME_OUTLINERENDERER: string;
  83781. static readonly NAME_PROCEDURALTEXTURE: string;
  83782. static readonly NAME_SHADOWGENERATOR: string;
  83783. static readonly NAME_OCTREE: string;
  83784. static readonly NAME_PHYSICSENGINE: string;
  83785. static readonly NAME_AUDIO: string;
  83786. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83787. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83788. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83789. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83790. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83791. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83792. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83793. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83794. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83795. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83796. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83797. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83798. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83799. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83800. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83801. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83802. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83803. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83804. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83805. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83806. static readonly STEP_AFTERRENDER_AUDIO: number;
  83807. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83808. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83809. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83810. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83811. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83812. static readonly STEP_POINTERMOVE_SPRITE: number;
  83813. static readonly STEP_POINTERDOWN_SPRITE: number;
  83814. static readonly STEP_POINTERUP_SPRITE: number;
  83815. }
  83816. /**
  83817. * This represents a scene component.
  83818. *
  83819. * This is used to decouple the dependency the scene is having on the different workloads like
  83820. * layers, post processes...
  83821. */
  83822. export interface ISceneComponent {
  83823. /**
  83824. * The name of the component. Each component must have a unique name.
  83825. */
  83826. name: string;
  83827. /**
  83828. * The scene the component belongs to.
  83829. */
  83830. scene: Scene;
  83831. /**
  83832. * Register the component to one instance of a scene.
  83833. */
  83834. register(): void;
  83835. /**
  83836. * Rebuilds the elements related to this component in case of
  83837. * context lost for instance.
  83838. */
  83839. rebuild(): void;
  83840. /**
  83841. * Disposes the component and the associated ressources.
  83842. */
  83843. dispose(): void;
  83844. }
  83845. /**
  83846. * This represents a SERIALIZABLE scene component.
  83847. *
  83848. * This extends Scene Component to add Serialization methods on top.
  83849. */
  83850. export interface ISceneSerializableComponent extends ISceneComponent {
  83851. /**
  83852. * Adds all the elements from the container to the scene
  83853. * @param container the container holding the elements
  83854. */
  83855. addFromContainer(container: AbstractScene): void;
  83856. /**
  83857. * Removes all the elements in the container from the scene
  83858. * @param container contains the elements to remove
  83859. * @param dispose if the removed element should be disposed (default: false)
  83860. */
  83861. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83862. /**
  83863. * Serializes the component data to the specified json object
  83864. * @param serializationObject The object to serialize to
  83865. */
  83866. serialize(serializationObject: any): void;
  83867. }
  83868. /**
  83869. * Strong typing of a Mesh related stage step action
  83870. */
  83871. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83872. /**
  83873. * Strong typing of a Evaluate Sub Mesh related stage step action
  83874. */
  83875. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83876. /**
  83877. * Strong typing of a Active Mesh related stage step action
  83878. */
  83879. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83880. /**
  83881. * Strong typing of a Camera related stage step action
  83882. */
  83883. export type CameraStageAction = (camera: Camera) => void;
  83884. /**
  83885. * Strong typing of a Camera Frame buffer related stage step action
  83886. */
  83887. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83888. /**
  83889. * Strong typing of a Render Target related stage step action
  83890. */
  83891. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83892. /**
  83893. * Strong typing of a RenderingGroup related stage step action
  83894. */
  83895. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83896. /**
  83897. * Strong typing of a Mesh Render related stage step action
  83898. */
  83899. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83900. /**
  83901. * Strong typing of a simple stage step action
  83902. */
  83903. export type SimpleStageAction = () => void;
  83904. /**
  83905. * Strong typing of a render target action.
  83906. */
  83907. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83908. /**
  83909. * Strong typing of a pointer move action.
  83910. */
  83911. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83912. /**
  83913. * Strong typing of a pointer up/down action.
  83914. */
  83915. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83916. /**
  83917. * Representation of a stage in the scene (Basically a list of ordered steps)
  83918. * @hidden
  83919. */
  83920. export class Stage<T extends Function> extends Array<{
  83921. index: number;
  83922. component: ISceneComponent;
  83923. action: T;
  83924. }> {
  83925. /**
  83926. * Hide ctor from the rest of the world.
  83927. * @param items The items to add.
  83928. */
  83929. private constructor();
  83930. /**
  83931. * Creates a new Stage.
  83932. * @returns A new instance of a Stage
  83933. */
  83934. static Create<T extends Function>(): Stage<T>;
  83935. /**
  83936. * Registers a step in an ordered way in the targeted stage.
  83937. * @param index Defines the position to register the step in
  83938. * @param component Defines the component attached to the step
  83939. * @param action Defines the action to launch during the step
  83940. */
  83941. registerStep(index: number, component: ISceneComponent, action: T): void;
  83942. /**
  83943. * Clears all the steps from the stage.
  83944. */
  83945. clear(): void;
  83946. }
  83947. }
  83948. declare module BABYLON {
  83949. interface Scene {
  83950. /** @hidden */
  83951. _pointerOverSprite: Nullable<Sprite>;
  83952. /** @hidden */
  83953. _pickedDownSprite: Nullable<Sprite>;
  83954. /** @hidden */
  83955. _tempSpritePickingRay: Nullable<Ray>;
  83956. /**
  83957. * All of the sprite managers added to this scene
  83958. * @see http://doc.babylonjs.com/babylon101/sprites
  83959. */
  83960. spriteManagers: Array<ISpriteManager>;
  83961. /**
  83962. * An event triggered when sprites rendering is about to start
  83963. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83964. */
  83965. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83966. /**
  83967. * An event triggered when sprites rendering is done
  83968. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83969. */
  83970. onAfterSpritesRenderingObservable: Observable<Scene>;
  83971. /** @hidden */
  83972. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83973. /** Launch a ray to try to pick a sprite in the scene
  83974. * @param x position on screen
  83975. * @param y position on screen
  83976. * @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
  83977. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83978. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83979. * @returns a PickingInfo
  83980. */
  83981. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83982. /** Use the given ray to pick a sprite in the scene
  83983. * @param ray The ray (in world space) to use to pick meshes
  83984. * @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
  83985. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83986. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83987. * @returns a PickingInfo
  83988. */
  83989. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83990. /** @hidden */
  83991. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83992. /** Launch a ray to try to pick sprites in the scene
  83993. * @param x position on screen
  83994. * @param y position on screen
  83995. * @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
  83996. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83997. * @returns a PickingInfo array
  83998. */
  83999. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84000. /** Use the given ray to pick sprites in the scene
  84001. * @param ray The ray (in world space) to use to pick meshes
  84002. * @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
  84003. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84004. * @returns a PickingInfo array
  84005. */
  84006. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84007. /**
  84008. * Force the sprite under the pointer
  84009. * @param sprite defines the sprite to use
  84010. */
  84011. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84012. /**
  84013. * Gets the sprite under the pointer
  84014. * @returns a Sprite or null if no sprite is under the pointer
  84015. */
  84016. getPointerOverSprite(): Nullable<Sprite>;
  84017. }
  84018. /**
  84019. * Defines the sprite scene component responsible to manage sprites
  84020. * in a given scene.
  84021. */
  84022. export class SpriteSceneComponent implements ISceneComponent {
  84023. /**
  84024. * The component name helpfull to identify the component in the list of scene components.
  84025. */
  84026. readonly name: string;
  84027. /**
  84028. * The scene the component belongs to.
  84029. */
  84030. scene: Scene;
  84031. /** @hidden */
  84032. private _spritePredicate;
  84033. /**
  84034. * Creates a new instance of the component for the given scene
  84035. * @param scene Defines the scene to register the component in
  84036. */
  84037. constructor(scene: Scene);
  84038. /**
  84039. * Registers the component in a given scene
  84040. */
  84041. register(): void;
  84042. /**
  84043. * Rebuilds the elements related to this component in case of
  84044. * context lost for instance.
  84045. */
  84046. rebuild(): void;
  84047. /**
  84048. * Disposes the component and the associated ressources.
  84049. */
  84050. dispose(): void;
  84051. private _pickSpriteButKeepRay;
  84052. private _pointerMove;
  84053. private _pointerDown;
  84054. private _pointerUp;
  84055. }
  84056. }
  84057. declare module BABYLON {
  84058. /** @hidden */
  84059. export var fogFragmentDeclaration: {
  84060. name: string;
  84061. shader: string;
  84062. };
  84063. }
  84064. declare module BABYLON {
  84065. /** @hidden */
  84066. export var fogFragment: {
  84067. name: string;
  84068. shader: string;
  84069. };
  84070. }
  84071. declare module BABYLON {
  84072. /** @hidden */
  84073. export var spritesPixelShader: {
  84074. name: string;
  84075. shader: string;
  84076. };
  84077. }
  84078. declare module BABYLON {
  84079. /** @hidden */
  84080. export var fogVertexDeclaration: {
  84081. name: string;
  84082. shader: string;
  84083. };
  84084. }
  84085. declare module BABYLON {
  84086. /** @hidden */
  84087. export var spritesVertexShader: {
  84088. name: string;
  84089. shader: string;
  84090. };
  84091. }
  84092. declare module BABYLON {
  84093. /**
  84094. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84095. */
  84096. export interface ISpriteManager extends IDisposable {
  84097. /**
  84098. * Restricts the camera to viewing objects with the same layerMask.
  84099. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84100. */
  84101. layerMask: number;
  84102. /**
  84103. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84104. */
  84105. isPickable: boolean;
  84106. /**
  84107. * Specifies the rendering group id for this mesh (0 by default)
  84108. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84109. */
  84110. renderingGroupId: number;
  84111. /**
  84112. * Defines the list of sprites managed by the manager.
  84113. */
  84114. sprites: Array<Sprite>;
  84115. /**
  84116. * Tests the intersection of a sprite with a specific ray.
  84117. * @param ray The ray we are sending to test the collision
  84118. * @param camera The camera space we are sending rays in
  84119. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84120. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84121. * @returns picking info or null.
  84122. */
  84123. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84124. /**
  84125. * Intersects the sprites with a ray
  84126. * @param ray defines the ray to intersect with
  84127. * @param camera defines the current active camera
  84128. * @param predicate defines a predicate used to select candidate sprites
  84129. * @returns null if no hit or a PickingInfo array
  84130. */
  84131. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84132. /**
  84133. * Renders the list of sprites on screen.
  84134. */
  84135. render(): void;
  84136. }
  84137. /**
  84138. * Class used to manage multiple sprites on the same spritesheet
  84139. * @see http://doc.babylonjs.com/babylon101/sprites
  84140. */
  84141. export class SpriteManager implements ISpriteManager {
  84142. /** defines the manager's name */
  84143. name: string;
  84144. /** Gets the list of sprites */
  84145. sprites: Sprite[];
  84146. /** Gets or sets the rendering group id (0 by default) */
  84147. renderingGroupId: number;
  84148. /** Gets or sets camera layer mask */
  84149. layerMask: number;
  84150. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84151. fogEnabled: boolean;
  84152. /** Gets or sets a boolean indicating if the sprites are pickable */
  84153. isPickable: boolean;
  84154. /** Defines the default width of a cell in the spritesheet */
  84155. cellWidth: number;
  84156. /** Defines the default height of a cell in the spritesheet */
  84157. cellHeight: number;
  84158. /** Associative array from JSON sprite data file */
  84159. private _cellData;
  84160. /** Array of sprite names from JSON sprite data file */
  84161. private _spriteMap;
  84162. /** True when packed cell data from JSON file is ready*/
  84163. private _packedAndReady;
  84164. /**
  84165. * An event triggered when the manager is disposed.
  84166. */
  84167. onDisposeObservable: Observable<SpriteManager>;
  84168. private _onDisposeObserver;
  84169. /**
  84170. * Callback called when the manager is disposed
  84171. */
  84172. set onDispose(callback: () => void);
  84173. private _capacity;
  84174. private _fromPacked;
  84175. private _spriteTexture;
  84176. private _epsilon;
  84177. private _scene;
  84178. private _vertexData;
  84179. private _buffer;
  84180. private _vertexBuffers;
  84181. private _indexBuffer;
  84182. private _effectBase;
  84183. private _effectFog;
  84184. /**
  84185. * Gets or sets the spritesheet texture
  84186. */
  84187. get texture(): Texture;
  84188. set texture(value: Texture);
  84189. /**
  84190. * Creates a new sprite manager
  84191. * @param name defines the manager's name
  84192. * @param imgUrl defines the sprite sheet url
  84193. * @param capacity defines the maximum allowed number of sprites
  84194. * @param cellSize defines the size of a sprite cell
  84195. * @param scene defines the hosting scene
  84196. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84197. * @param samplingMode defines the smapling mode to use with spritesheet
  84198. * @param fromPacked set to false; do not alter
  84199. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84200. */
  84201. constructor(
  84202. /** defines the manager's name */
  84203. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84204. private _makePacked;
  84205. private _appendSpriteVertex;
  84206. /**
  84207. * Intersects the sprites with a ray
  84208. * @param ray defines the ray to intersect with
  84209. * @param camera defines the current active camera
  84210. * @param predicate defines a predicate used to select candidate sprites
  84211. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84212. * @returns null if no hit or a PickingInfo
  84213. */
  84214. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84215. /**
  84216. * Intersects the sprites with a ray
  84217. * @param ray defines the ray to intersect with
  84218. * @param camera defines the current active camera
  84219. * @param predicate defines a predicate used to select candidate sprites
  84220. * @returns null if no hit or a PickingInfo array
  84221. */
  84222. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84223. /**
  84224. * Render all child sprites
  84225. */
  84226. render(): void;
  84227. /**
  84228. * Release associated resources
  84229. */
  84230. dispose(): void;
  84231. }
  84232. }
  84233. declare module BABYLON {
  84234. /**
  84235. * Class used to represent a sprite
  84236. * @see http://doc.babylonjs.com/babylon101/sprites
  84237. */
  84238. export class Sprite {
  84239. /** defines the name */
  84240. name: string;
  84241. /** Gets or sets the current world position */
  84242. position: Vector3;
  84243. /** Gets or sets the main color */
  84244. color: Color4;
  84245. /** Gets or sets the width */
  84246. width: number;
  84247. /** Gets or sets the height */
  84248. height: number;
  84249. /** Gets or sets rotation angle */
  84250. angle: number;
  84251. /** Gets or sets the cell index in the sprite sheet */
  84252. cellIndex: number;
  84253. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  84254. cellRef: string;
  84255. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  84256. invertU: number;
  84257. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  84258. invertV: number;
  84259. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  84260. disposeWhenFinishedAnimating: boolean;
  84261. /** Gets the list of attached animations */
  84262. animations: Animation[];
  84263. /** Gets or sets a boolean indicating if the sprite can be picked */
  84264. isPickable: boolean;
  84265. /**
  84266. * Gets or sets the associated action manager
  84267. */
  84268. actionManager: Nullable<ActionManager>;
  84269. private _animationStarted;
  84270. private _loopAnimation;
  84271. private _fromIndex;
  84272. private _toIndex;
  84273. private _delay;
  84274. private _direction;
  84275. private _manager;
  84276. private _time;
  84277. private _onAnimationEnd;
  84278. /**
  84279. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  84280. */
  84281. isVisible: boolean;
  84282. /**
  84283. * Gets or sets the sprite size
  84284. */
  84285. get size(): number;
  84286. set size(value: number);
  84287. /**
  84288. * Creates a new Sprite
  84289. * @param name defines the name
  84290. * @param manager defines the manager
  84291. */
  84292. constructor(
  84293. /** defines the name */
  84294. name: string, manager: ISpriteManager);
  84295. /**
  84296. * Starts an animation
  84297. * @param from defines the initial key
  84298. * @param to defines the end key
  84299. * @param loop defines if the animation must loop
  84300. * @param delay defines the start delay (in ms)
  84301. * @param onAnimationEnd defines a callback to call when animation ends
  84302. */
  84303. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  84304. /** Stops current animation (if any) */
  84305. stopAnimation(): void;
  84306. /** @hidden */
  84307. _animate(deltaTime: number): void;
  84308. /** Release associated resources */
  84309. dispose(): void;
  84310. }
  84311. }
  84312. declare module BABYLON {
  84313. /**
  84314. * Information about the result of picking within a scene
  84315. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  84316. */
  84317. export class PickingInfo {
  84318. /** @hidden */
  84319. _pickingUnavailable: boolean;
  84320. /**
  84321. * If the pick collided with an object
  84322. */
  84323. hit: boolean;
  84324. /**
  84325. * Distance away where the pick collided
  84326. */
  84327. distance: number;
  84328. /**
  84329. * The location of pick collision
  84330. */
  84331. pickedPoint: Nullable<Vector3>;
  84332. /**
  84333. * The mesh corresponding the the pick collision
  84334. */
  84335. pickedMesh: Nullable<AbstractMesh>;
  84336. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  84337. bu: number;
  84338. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  84339. bv: number;
  84340. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  84341. faceId: number;
  84342. /** Id of the the submesh that was picked */
  84343. subMeshId: number;
  84344. /** If a sprite was picked, this will be the sprite the pick collided with */
  84345. pickedSprite: Nullable<Sprite>;
  84346. /**
  84347. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  84348. */
  84349. originMesh: Nullable<AbstractMesh>;
  84350. /**
  84351. * The ray that was used to perform the picking.
  84352. */
  84353. ray: Nullable<Ray>;
  84354. /**
  84355. * Gets the normal correspodning to the face the pick collided with
  84356. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  84357. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  84358. * @returns The normal correspodning to the face the pick collided with
  84359. */
  84360. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  84361. /**
  84362. * Gets the texture coordinates of where the pick occured
  84363. * @returns the vector containing the coordnates of the texture
  84364. */
  84365. getTextureCoordinates(): Nullable<Vector2>;
  84366. }
  84367. }
  84368. declare module BABYLON {
  84369. /**
  84370. * Gather the list of pointer event types as constants.
  84371. */
  84372. export class PointerEventTypes {
  84373. /**
  84374. * 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.
  84375. */
  84376. static readonly POINTERDOWN: number;
  84377. /**
  84378. * The pointerup event is fired when a pointer is no longer active.
  84379. */
  84380. static readonly POINTERUP: number;
  84381. /**
  84382. * The pointermove event is fired when a pointer changes coordinates.
  84383. */
  84384. static readonly POINTERMOVE: number;
  84385. /**
  84386. * The pointerwheel event is fired when a mouse wheel has been rotated.
  84387. */
  84388. static readonly POINTERWHEEL: number;
  84389. /**
  84390. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  84391. */
  84392. static readonly POINTERPICK: number;
  84393. /**
  84394. * The pointertap event is fired when a the object has been touched and released without drag.
  84395. */
  84396. static readonly POINTERTAP: number;
  84397. /**
  84398. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  84399. */
  84400. static readonly POINTERDOUBLETAP: number;
  84401. }
  84402. /**
  84403. * Base class of pointer info types.
  84404. */
  84405. export class PointerInfoBase {
  84406. /**
  84407. * Defines the type of event (PointerEventTypes)
  84408. */
  84409. type: number;
  84410. /**
  84411. * Defines the related dom event
  84412. */
  84413. event: PointerEvent | MouseWheelEvent;
  84414. /**
  84415. * Instantiates the base class of pointers info.
  84416. * @param type Defines the type of event (PointerEventTypes)
  84417. * @param event Defines the related dom event
  84418. */
  84419. constructor(
  84420. /**
  84421. * Defines the type of event (PointerEventTypes)
  84422. */
  84423. type: number,
  84424. /**
  84425. * Defines the related dom event
  84426. */
  84427. event: PointerEvent | MouseWheelEvent);
  84428. }
  84429. /**
  84430. * This class is used to store pointer related info for the onPrePointerObservable event.
  84431. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  84432. */
  84433. export class PointerInfoPre extends PointerInfoBase {
  84434. /**
  84435. * Ray from a pointer if availible (eg. 6dof controller)
  84436. */
  84437. ray: Nullable<Ray>;
  84438. /**
  84439. * Defines the local position of the pointer on the canvas.
  84440. */
  84441. localPosition: Vector2;
  84442. /**
  84443. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  84444. */
  84445. skipOnPointerObservable: boolean;
  84446. /**
  84447. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  84448. * @param type Defines the type of event (PointerEventTypes)
  84449. * @param event Defines the related dom event
  84450. * @param localX Defines the local x coordinates of the pointer when the event occured
  84451. * @param localY Defines the local y coordinates of the pointer when the event occured
  84452. */
  84453. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  84454. }
  84455. /**
  84456. * This type contains all the data related to a pointer event in Babylon.js.
  84457. * 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.
  84458. */
  84459. export class PointerInfo extends PointerInfoBase {
  84460. /**
  84461. * Defines the picking info associated to the info (if any)\
  84462. */
  84463. pickInfo: Nullable<PickingInfo>;
  84464. /**
  84465. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  84466. * @param type Defines the type of event (PointerEventTypes)
  84467. * @param event Defines the related dom event
  84468. * @param pickInfo Defines the picking info associated to the info (if any)\
  84469. */
  84470. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  84471. /**
  84472. * Defines the picking info associated to the info (if any)\
  84473. */
  84474. pickInfo: Nullable<PickingInfo>);
  84475. }
  84476. /**
  84477. * Data relating to a touch event on the screen.
  84478. */
  84479. export interface PointerTouch {
  84480. /**
  84481. * X coordinate of touch.
  84482. */
  84483. x: number;
  84484. /**
  84485. * Y coordinate of touch.
  84486. */
  84487. y: number;
  84488. /**
  84489. * Id of touch. Unique for each finger.
  84490. */
  84491. pointerId: number;
  84492. /**
  84493. * Event type passed from DOM.
  84494. */
  84495. type: any;
  84496. }
  84497. }
  84498. declare module BABYLON {
  84499. /**
  84500. * Manage the mouse inputs to control the movement of a free camera.
  84501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84502. */
  84503. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  84504. /**
  84505. * Define if touch is enabled in the mouse input
  84506. */
  84507. touchEnabled: boolean;
  84508. /**
  84509. * Defines the camera the input is attached to.
  84510. */
  84511. camera: FreeCamera;
  84512. /**
  84513. * Defines the buttons associated with the input to handle camera move.
  84514. */
  84515. buttons: number[];
  84516. /**
  84517. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  84518. */
  84519. angularSensibility: number;
  84520. private _pointerInput;
  84521. private _onMouseMove;
  84522. private _observer;
  84523. private previousPosition;
  84524. /**
  84525. * Observable for when a pointer move event occurs containing the move offset
  84526. */
  84527. onPointerMovedObservable: Observable<{
  84528. offsetX: number;
  84529. offsetY: number;
  84530. }>;
  84531. /**
  84532. * @hidden
  84533. * If the camera should be rotated automatically based on pointer movement
  84534. */
  84535. _allowCameraRotation: boolean;
  84536. /**
  84537. * Manage the mouse inputs to control the movement of a free camera.
  84538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84539. * @param touchEnabled Defines if touch is enabled or not
  84540. */
  84541. constructor(
  84542. /**
  84543. * Define if touch is enabled in the mouse input
  84544. */
  84545. touchEnabled?: boolean);
  84546. /**
  84547. * Attach the input controls to a specific dom element to get the input from.
  84548. * @param element Defines the element the controls should be listened from
  84549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84550. */
  84551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84552. /**
  84553. * Called on JS contextmenu event.
  84554. * Override this method to provide functionality.
  84555. */
  84556. protected onContextMenu(evt: PointerEvent): void;
  84557. /**
  84558. * Detach the current controls from the specified dom element.
  84559. * @param element Defines the element to stop listening the inputs from
  84560. */
  84561. detachControl(element: Nullable<HTMLElement>): void;
  84562. /**
  84563. * Gets the class name of the current intput.
  84564. * @returns the class name
  84565. */
  84566. getClassName(): string;
  84567. /**
  84568. * Get the friendly name associated with the input class.
  84569. * @returns the input friendly name
  84570. */
  84571. getSimpleName(): string;
  84572. }
  84573. }
  84574. declare module BABYLON {
  84575. /**
  84576. * Manage the touch inputs to control the movement of a free camera.
  84577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84578. */
  84579. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  84580. /**
  84581. * Defines the camera the input is attached to.
  84582. */
  84583. camera: FreeCamera;
  84584. /**
  84585. * Defines the touch sensibility for rotation.
  84586. * The higher the faster.
  84587. */
  84588. touchAngularSensibility: number;
  84589. /**
  84590. * Defines the touch sensibility for move.
  84591. * The higher the faster.
  84592. */
  84593. touchMoveSensibility: number;
  84594. private _offsetX;
  84595. private _offsetY;
  84596. private _pointerPressed;
  84597. private _pointerInput;
  84598. private _observer;
  84599. private _onLostFocus;
  84600. /**
  84601. * Attach the input controls to a specific dom element to get the input from.
  84602. * @param element Defines the element the controls should be listened from
  84603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84604. */
  84605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84606. /**
  84607. * Detach the current controls from the specified dom element.
  84608. * @param element Defines the element to stop listening the inputs from
  84609. */
  84610. detachControl(element: Nullable<HTMLElement>): void;
  84611. /**
  84612. * Update the current camera state depending on the inputs that have been used this frame.
  84613. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84614. */
  84615. checkInputs(): void;
  84616. /**
  84617. * Gets the class name of the current intput.
  84618. * @returns the class name
  84619. */
  84620. getClassName(): string;
  84621. /**
  84622. * Get the friendly name associated with the input class.
  84623. * @returns the input friendly name
  84624. */
  84625. getSimpleName(): string;
  84626. }
  84627. }
  84628. declare module BABYLON {
  84629. /**
  84630. * Default Inputs manager for the FreeCamera.
  84631. * It groups all the default supported inputs for ease of use.
  84632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84633. */
  84634. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  84635. /**
  84636. * @hidden
  84637. */
  84638. _mouseInput: Nullable<FreeCameraMouseInput>;
  84639. /**
  84640. * Instantiates a new FreeCameraInputsManager.
  84641. * @param camera Defines the camera the inputs belong to
  84642. */
  84643. constructor(camera: FreeCamera);
  84644. /**
  84645. * Add keyboard input support to the input manager.
  84646. * @returns the current input manager
  84647. */
  84648. addKeyboard(): FreeCameraInputsManager;
  84649. /**
  84650. * Add mouse input support to the input manager.
  84651. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  84652. * @returns the current input manager
  84653. */
  84654. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  84655. /**
  84656. * Removes the mouse input support from the manager
  84657. * @returns the current input manager
  84658. */
  84659. removeMouse(): FreeCameraInputsManager;
  84660. /**
  84661. * Add touch input support to the input manager.
  84662. * @returns the current input manager
  84663. */
  84664. addTouch(): FreeCameraInputsManager;
  84665. /**
  84666. * Remove all attached input methods from a camera
  84667. */
  84668. clear(): void;
  84669. }
  84670. }
  84671. declare module BABYLON {
  84672. /**
  84673. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  84674. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  84675. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  84676. */
  84677. export class FreeCamera extends TargetCamera {
  84678. /**
  84679. * Define the collision ellipsoid of the camera.
  84680. * This is helpful to simulate a camera body like the player body around the camera
  84681. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  84682. */
  84683. ellipsoid: Vector3;
  84684. /**
  84685. * Define an offset for the position of the ellipsoid around the camera.
  84686. * This can be helpful to determine the center of the body near the gravity center of the body
  84687. * instead of its head.
  84688. */
  84689. ellipsoidOffset: Vector3;
  84690. /**
  84691. * Enable or disable collisions of the camera with the rest of the scene objects.
  84692. */
  84693. checkCollisions: boolean;
  84694. /**
  84695. * Enable or disable gravity on the camera.
  84696. */
  84697. applyGravity: boolean;
  84698. /**
  84699. * Define the input manager associated to the camera.
  84700. */
  84701. inputs: FreeCameraInputsManager;
  84702. /**
  84703. * Gets the input sensibility for a mouse input. (default is 2000.0)
  84704. * Higher values reduce sensitivity.
  84705. */
  84706. get angularSensibility(): number;
  84707. /**
  84708. * Sets the input sensibility for a mouse input. (default is 2000.0)
  84709. * Higher values reduce sensitivity.
  84710. */
  84711. set angularSensibility(value: number);
  84712. /**
  84713. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84714. */
  84715. get keysUp(): number[];
  84716. set keysUp(value: number[]);
  84717. /**
  84718. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84719. */
  84720. get keysDown(): number[];
  84721. set keysDown(value: number[]);
  84722. /**
  84723. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84724. */
  84725. get keysLeft(): number[];
  84726. set keysLeft(value: number[]);
  84727. /**
  84728. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84729. */
  84730. get keysRight(): number[];
  84731. set keysRight(value: number[]);
  84732. /**
  84733. * Event raised when the camera collide with a mesh in the scene.
  84734. */
  84735. onCollide: (collidedMesh: AbstractMesh) => void;
  84736. private _collider;
  84737. private _needMoveForGravity;
  84738. private _oldPosition;
  84739. private _diffPosition;
  84740. private _newPosition;
  84741. /** @hidden */
  84742. _localDirection: Vector3;
  84743. /** @hidden */
  84744. _transformedDirection: Vector3;
  84745. /**
  84746. * Instantiates a Free Camera.
  84747. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  84748. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  84749. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  84750. * @param name Define the name of the camera in the scene
  84751. * @param position Define the start position of the camera in the scene
  84752. * @param scene Define the scene the camera belongs to
  84753. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84754. */
  84755. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84756. /**
  84757. * Attached controls to the current camera.
  84758. * @param element Defines the element the controls should be listened from
  84759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84760. */
  84761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84762. /**
  84763. * Detach the current controls from the camera.
  84764. * The camera will stop reacting to inputs.
  84765. * @param element Defines the element to stop listening the inputs from
  84766. */
  84767. detachControl(element: HTMLElement): void;
  84768. private _collisionMask;
  84769. /**
  84770. * Define a collision mask to limit the list of object the camera can collide with
  84771. */
  84772. get collisionMask(): number;
  84773. set collisionMask(mask: number);
  84774. /** @hidden */
  84775. _collideWithWorld(displacement: Vector3): void;
  84776. private _onCollisionPositionChange;
  84777. /** @hidden */
  84778. _checkInputs(): void;
  84779. /** @hidden */
  84780. _decideIfNeedsToMove(): boolean;
  84781. /** @hidden */
  84782. _updatePosition(): void;
  84783. /**
  84784. * Destroy the camera and release the current resources hold by it.
  84785. */
  84786. dispose(): void;
  84787. /**
  84788. * Gets the current object class name.
  84789. * @return the class name
  84790. */
  84791. getClassName(): string;
  84792. }
  84793. }
  84794. declare module BABYLON {
  84795. /**
  84796. * Represents a gamepad control stick position
  84797. */
  84798. export class StickValues {
  84799. /**
  84800. * The x component of the control stick
  84801. */
  84802. x: number;
  84803. /**
  84804. * The y component of the control stick
  84805. */
  84806. y: number;
  84807. /**
  84808. * Initializes the gamepad x and y control stick values
  84809. * @param x The x component of the gamepad control stick value
  84810. * @param y The y component of the gamepad control stick value
  84811. */
  84812. constructor(
  84813. /**
  84814. * The x component of the control stick
  84815. */
  84816. x: number,
  84817. /**
  84818. * The y component of the control stick
  84819. */
  84820. y: number);
  84821. }
  84822. /**
  84823. * An interface which manages callbacks for gamepad button changes
  84824. */
  84825. export interface GamepadButtonChanges {
  84826. /**
  84827. * Called when a gamepad has been changed
  84828. */
  84829. changed: boolean;
  84830. /**
  84831. * Called when a gamepad press event has been triggered
  84832. */
  84833. pressChanged: boolean;
  84834. /**
  84835. * Called when a touch event has been triggered
  84836. */
  84837. touchChanged: boolean;
  84838. /**
  84839. * Called when a value has changed
  84840. */
  84841. valueChanged: boolean;
  84842. }
  84843. /**
  84844. * Represents a gamepad
  84845. */
  84846. export class Gamepad {
  84847. /**
  84848. * The id of the gamepad
  84849. */
  84850. id: string;
  84851. /**
  84852. * The index of the gamepad
  84853. */
  84854. index: number;
  84855. /**
  84856. * The browser gamepad
  84857. */
  84858. browserGamepad: any;
  84859. /**
  84860. * Specifies what type of gamepad this represents
  84861. */
  84862. type: number;
  84863. private _leftStick;
  84864. private _rightStick;
  84865. /** @hidden */
  84866. _isConnected: boolean;
  84867. private _leftStickAxisX;
  84868. private _leftStickAxisY;
  84869. private _rightStickAxisX;
  84870. private _rightStickAxisY;
  84871. /**
  84872. * Triggered when the left control stick has been changed
  84873. */
  84874. private _onleftstickchanged;
  84875. /**
  84876. * Triggered when the right control stick has been changed
  84877. */
  84878. private _onrightstickchanged;
  84879. /**
  84880. * Represents a gamepad controller
  84881. */
  84882. static GAMEPAD: number;
  84883. /**
  84884. * Represents a generic controller
  84885. */
  84886. static GENERIC: number;
  84887. /**
  84888. * Represents an XBox controller
  84889. */
  84890. static XBOX: number;
  84891. /**
  84892. * Represents a pose-enabled controller
  84893. */
  84894. static POSE_ENABLED: number;
  84895. /**
  84896. * Represents an Dual Shock controller
  84897. */
  84898. static DUALSHOCK: number;
  84899. /**
  84900. * Specifies whether the left control stick should be Y-inverted
  84901. */
  84902. protected _invertLeftStickY: boolean;
  84903. /**
  84904. * Specifies if the gamepad has been connected
  84905. */
  84906. get isConnected(): boolean;
  84907. /**
  84908. * Initializes the gamepad
  84909. * @param id The id of the gamepad
  84910. * @param index The index of the gamepad
  84911. * @param browserGamepad The browser gamepad
  84912. * @param leftStickX The x component of the left joystick
  84913. * @param leftStickY The y component of the left joystick
  84914. * @param rightStickX The x component of the right joystick
  84915. * @param rightStickY The y component of the right joystick
  84916. */
  84917. constructor(
  84918. /**
  84919. * The id of the gamepad
  84920. */
  84921. id: string,
  84922. /**
  84923. * The index of the gamepad
  84924. */
  84925. index: number,
  84926. /**
  84927. * The browser gamepad
  84928. */
  84929. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  84930. /**
  84931. * Callback triggered when the left joystick has changed
  84932. * @param callback
  84933. */
  84934. onleftstickchanged(callback: (values: StickValues) => void): void;
  84935. /**
  84936. * Callback triggered when the right joystick has changed
  84937. * @param callback
  84938. */
  84939. onrightstickchanged(callback: (values: StickValues) => void): void;
  84940. /**
  84941. * Gets the left joystick
  84942. */
  84943. get leftStick(): StickValues;
  84944. /**
  84945. * Sets the left joystick values
  84946. */
  84947. set leftStick(newValues: StickValues);
  84948. /**
  84949. * Gets the right joystick
  84950. */
  84951. get rightStick(): StickValues;
  84952. /**
  84953. * Sets the right joystick value
  84954. */
  84955. set rightStick(newValues: StickValues);
  84956. /**
  84957. * Updates the gamepad joystick positions
  84958. */
  84959. update(): void;
  84960. /**
  84961. * Disposes the gamepad
  84962. */
  84963. dispose(): void;
  84964. }
  84965. /**
  84966. * Represents a generic gamepad
  84967. */
  84968. export class GenericPad extends Gamepad {
  84969. private _buttons;
  84970. private _onbuttondown;
  84971. private _onbuttonup;
  84972. /**
  84973. * Observable triggered when a button has been pressed
  84974. */
  84975. onButtonDownObservable: Observable<number>;
  84976. /**
  84977. * Observable triggered when a button has been released
  84978. */
  84979. onButtonUpObservable: Observable<number>;
  84980. /**
  84981. * Callback triggered when a button has been pressed
  84982. * @param callback Called when a button has been pressed
  84983. */
  84984. onbuttondown(callback: (buttonPressed: number) => void): void;
  84985. /**
  84986. * Callback triggered when a button has been released
  84987. * @param callback Called when a button has been released
  84988. */
  84989. onbuttonup(callback: (buttonReleased: number) => void): void;
  84990. /**
  84991. * Initializes the generic gamepad
  84992. * @param id The id of the generic gamepad
  84993. * @param index The index of the generic gamepad
  84994. * @param browserGamepad The browser gamepad
  84995. */
  84996. constructor(id: string, index: number, browserGamepad: any);
  84997. private _setButtonValue;
  84998. /**
  84999. * Updates the generic gamepad
  85000. */
  85001. update(): void;
  85002. /**
  85003. * Disposes the generic gamepad
  85004. */
  85005. dispose(): void;
  85006. }
  85007. }
  85008. declare module BABYLON {
  85009. interface Engine {
  85010. /**
  85011. * Creates a raw texture
  85012. * @param data defines the data to store in the texture
  85013. * @param width defines the width of the texture
  85014. * @param height defines the height of the texture
  85015. * @param format defines the format of the data
  85016. * @param generateMipMaps defines if the engine should generate the mip levels
  85017. * @param invertY defines if data must be stored with Y axis inverted
  85018. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85019. * @param compression defines the compression used (null by default)
  85020. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85021. * @returns the raw texture inside an InternalTexture
  85022. */
  85023. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85024. /**
  85025. * Update a raw texture
  85026. * @param texture defines the texture to update
  85027. * @param data defines the data to store in the texture
  85028. * @param format defines the format of the data
  85029. * @param invertY defines if data must be stored with Y axis inverted
  85030. */
  85031. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85032. /**
  85033. * Update a raw texture
  85034. * @param texture defines the texture to update
  85035. * @param data defines the data to store in the texture
  85036. * @param format defines the format of the data
  85037. * @param invertY defines if data must be stored with Y axis inverted
  85038. * @param compression defines the compression used (null by default)
  85039. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85040. */
  85041. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85042. /**
  85043. * Creates a new raw cube texture
  85044. * @param data defines the array of data to use to create each face
  85045. * @param size defines the size of the textures
  85046. * @param format defines the format of the data
  85047. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85048. * @param generateMipMaps defines if the engine should generate the mip levels
  85049. * @param invertY defines if data must be stored with Y axis inverted
  85050. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85051. * @param compression defines the compression used (null by default)
  85052. * @returns the cube texture as an InternalTexture
  85053. */
  85054. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  85055. /**
  85056. * Update a raw cube texture
  85057. * @param texture defines the texture to udpdate
  85058. * @param data defines the data to store
  85059. * @param format defines the data format
  85060. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85061. * @param invertY defines if data must be stored with Y axis inverted
  85062. */
  85063. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  85064. /**
  85065. * Update a raw cube texture
  85066. * @param texture defines the texture to udpdate
  85067. * @param data defines the data to store
  85068. * @param format defines the data format
  85069. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85070. * @param invertY defines if data must be stored with Y axis inverted
  85071. * @param compression defines the compression used (null by default)
  85072. */
  85073. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  85074. /**
  85075. * Update a raw cube texture
  85076. * @param texture defines the texture to udpdate
  85077. * @param data defines the data to store
  85078. * @param format defines the data format
  85079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85080. * @param invertY defines if data must be stored with Y axis inverted
  85081. * @param compression defines the compression used (null by default)
  85082. * @param level defines which level of the texture to update
  85083. */
  85084. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  85085. /**
  85086. * Creates a new raw cube texture from a specified url
  85087. * @param url defines the url where the data is located
  85088. * @param scene defines the current scene
  85089. * @param size defines the size of the textures
  85090. * @param format defines the format of the data
  85091. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85092. * @param noMipmap defines if the engine should avoid generating the mip levels
  85093. * @param callback defines a callback used to extract texture data from loaded data
  85094. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85095. * @param onLoad defines a callback called when texture is loaded
  85096. * @param onError defines a callback called if there is an error
  85097. * @returns the cube texture as an InternalTexture
  85098. */
  85099. 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;
  85100. /**
  85101. * Creates a new raw cube texture from a specified url
  85102. * @param url defines the url where the data is located
  85103. * @param scene defines the current scene
  85104. * @param size defines the size of the textures
  85105. * @param format defines the format of the data
  85106. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85107. * @param noMipmap defines if the engine should avoid generating the mip levels
  85108. * @param callback defines a callback used to extract texture data from loaded data
  85109. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85110. * @param onLoad defines a callback called when texture is loaded
  85111. * @param onError defines a callback called if there is an error
  85112. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85113. * @param invertY defines if data must be stored with Y axis inverted
  85114. * @returns the cube texture as an InternalTexture
  85115. */
  85116. 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;
  85117. /**
  85118. * Creates a new raw 3D texture
  85119. * @param data defines the data used to create the texture
  85120. * @param width defines the width of the texture
  85121. * @param height defines the height of the texture
  85122. * @param depth defines the depth of the texture
  85123. * @param format defines the format of the texture
  85124. * @param generateMipMaps defines if the engine must generate mip levels
  85125. * @param invertY defines if data must be stored with Y axis inverted
  85126. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85127. * @param compression defines the compressed used (can be null)
  85128. * @param textureType defines the compressed used (can be null)
  85129. * @returns a new raw 3D texture (stored in an InternalTexture)
  85130. */
  85131. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85132. /**
  85133. * Update a raw 3D texture
  85134. * @param texture defines the texture to update
  85135. * @param data defines the data to store
  85136. * @param format defines the data format
  85137. * @param invertY defines if data must be stored with Y axis inverted
  85138. */
  85139. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85140. /**
  85141. * Update a raw 3D texture
  85142. * @param texture defines the texture to update
  85143. * @param data defines the data to store
  85144. * @param format defines the data format
  85145. * @param invertY defines if data must be stored with Y axis inverted
  85146. * @param compression defines the used compression (can be null)
  85147. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85148. */
  85149. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85150. /**
  85151. * Creates a new raw 2D array texture
  85152. * @param data defines the data used to create the texture
  85153. * @param width defines the width of the texture
  85154. * @param height defines the height of the texture
  85155. * @param depth defines the number of layers of the texture
  85156. * @param format defines the format of the texture
  85157. * @param generateMipMaps defines if the engine must generate mip levels
  85158. * @param invertY defines if data must be stored with Y axis inverted
  85159. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85160. * @param compression defines the compressed used (can be null)
  85161. * @param textureType defines the compressed used (can be null)
  85162. * @returns a new raw 2D array texture (stored in an InternalTexture)
  85163. */
  85164. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85165. /**
  85166. * Update a raw 2D array texture
  85167. * @param texture defines the texture to update
  85168. * @param data defines the data to store
  85169. * @param format defines the data format
  85170. * @param invertY defines if data must be stored with Y axis inverted
  85171. */
  85172. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85173. /**
  85174. * Update a raw 2D array texture
  85175. * @param texture defines the texture to update
  85176. * @param data defines the data to store
  85177. * @param format defines the data format
  85178. * @param invertY defines if data must be stored with Y axis inverted
  85179. * @param compression defines the used compression (can be null)
  85180. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85181. */
  85182. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85183. }
  85184. }
  85185. declare module BABYLON {
  85186. /**
  85187. * Raw texture can help creating a texture directly from an array of data.
  85188. * This can be super useful if you either get the data from an uncompressed source or
  85189. * if you wish to create your texture pixel by pixel.
  85190. */
  85191. export class RawTexture extends Texture {
  85192. /**
  85193. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85194. */
  85195. format: number;
  85196. private _engine;
  85197. /**
  85198. * Instantiates a new RawTexture.
  85199. * Raw texture can help creating a texture directly from an array of data.
  85200. * This can be super useful if you either get the data from an uncompressed source or
  85201. * if you wish to create your texture pixel by pixel.
  85202. * @param data define the array of data to use to create the texture
  85203. * @param width define the width of the texture
  85204. * @param height define the height of the texture
  85205. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85206. * @param scene define the scene the texture belongs to
  85207. * @param generateMipMaps define whether mip maps should be generated or not
  85208. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85209. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85210. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85211. */
  85212. constructor(data: ArrayBufferView, width: number, height: number,
  85213. /**
  85214. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85215. */
  85216. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  85217. /**
  85218. * Updates the texture underlying data.
  85219. * @param data Define the new data of the texture
  85220. */
  85221. update(data: ArrayBufferView): void;
  85222. /**
  85223. * Creates a luminance texture from some data.
  85224. * @param data Define the texture data
  85225. * @param width Define the width of the texture
  85226. * @param height Define the height of the texture
  85227. * @param scene Define the scene the texture belongs to
  85228. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85229. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85230. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85231. * @returns the luminance texture
  85232. */
  85233. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85234. /**
  85235. * Creates a luminance alpha texture from some data.
  85236. * @param data Define the texture data
  85237. * @param width Define the width of the texture
  85238. * @param height Define the height of the texture
  85239. * @param scene Define the scene the texture belongs to
  85240. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85241. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85242. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85243. * @returns the luminance alpha texture
  85244. */
  85245. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85246. /**
  85247. * Creates an alpha texture from some data.
  85248. * @param data Define the texture data
  85249. * @param width Define the width of the texture
  85250. * @param height Define the height of the texture
  85251. * @param scene Define the scene the texture belongs to
  85252. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85253. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85254. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85255. * @returns the alpha texture
  85256. */
  85257. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85258. /**
  85259. * Creates a RGB texture from some data.
  85260. * @param data Define the texture data
  85261. * @param width Define the width of the texture
  85262. * @param height Define the height of the texture
  85263. * @param scene Define the scene the texture belongs to
  85264. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85265. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85266. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85267. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85268. * @returns the RGB alpha texture
  85269. */
  85270. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85271. /**
  85272. * Creates a RGBA texture from some data.
  85273. * @param data Define the texture data
  85274. * @param width Define the width of the texture
  85275. * @param height Define the height of the texture
  85276. * @param scene Define the scene the texture belongs to
  85277. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85278. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85279. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85280. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85281. * @returns the RGBA texture
  85282. */
  85283. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85284. /**
  85285. * Creates a R texture from some data.
  85286. * @param data Define the texture data
  85287. * @param width Define the width of the texture
  85288. * @param height Define the height of the texture
  85289. * @param scene Define the scene the texture belongs to
  85290. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85291. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85292. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85293. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85294. * @returns the R texture
  85295. */
  85296. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85297. }
  85298. }
  85299. declare module BABYLON {
  85300. /**
  85301. * Interface for the size containing width and height
  85302. */
  85303. export interface ISize {
  85304. /**
  85305. * Width
  85306. */
  85307. width: number;
  85308. /**
  85309. * Heighht
  85310. */
  85311. height: number;
  85312. }
  85313. /**
  85314. * Size containing widht and height
  85315. */
  85316. export class Size implements ISize {
  85317. /**
  85318. * Width
  85319. */
  85320. width: number;
  85321. /**
  85322. * Height
  85323. */
  85324. height: number;
  85325. /**
  85326. * Creates a Size object from the given width and height (floats).
  85327. * @param width width of the new size
  85328. * @param height height of the new size
  85329. */
  85330. constructor(width: number, height: number);
  85331. /**
  85332. * Returns a string with the Size width and height
  85333. * @returns a string with the Size width and height
  85334. */
  85335. toString(): string;
  85336. /**
  85337. * "Size"
  85338. * @returns the string "Size"
  85339. */
  85340. getClassName(): string;
  85341. /**
  85342. * Returns the Size hash code.
  85343. * @returns a hash code for a unique width and height
  85344. */
  85345. getHashCode(): number;
  85346. /**
  85347. * Updates the current size from the given one.
  85348. * @param src the given size
  85349. */
  85350. copyFrom(src: Size): void;
  85351. /**
  85352. * Updates in place the current Size from the given floats.
  85353. * @param width width of the new size
  85354. * @param height height of the new size
  85355. * @returns the updated Size.
  85356. */
  85357. copyFromFloats(width: number, height: number): Size;
  85358. /**
  85359. * Updates in place the current Size from the given floats.
  85360. * @param width width to set
  85361. * @param height height to set
  85362. * @returns the updated Size.
  85363. */
  85364. set(width: number, height: number): Size;
  85365. /**
  85366. * Multiplies the width and height by numbers
  85367. * @param w factor to multiple the width by
  85368. * @param h factor to multiple the height by
  85369. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85370. */
  85371. multiplyByFloats(w: number, h: number): Size;
  85372. /**
  85373. * Clones the size
  85374. * @returns a new Size copied from the given one.
  85375. */
  85376. clone(): Size;
  85377. /**
  85378. * True if the current Size and the given one width and height are strictly equal.
  85379. * @param other the other size to compare against
  85380. * @returns True if the current Size and the given one width and height are strictly equal.
  85381. */
  85382. equals(other: Size): boolean;
  85383. /**
  85384. * The surface of the Size : width * height (float).
  85385. */
  85386. get surface(): number;
  85387. /**
  85388. * Create a new size of zero
  85389. * @returns a new Size set to (0.0, 0.0)
  85390. */
  85391. static Zero(): Size;
  85392. /**
  85393. * Sums the width and height of two sizes
  85394. * @param otherSize size to add to this size
  85395. * @returns a new Size set as the addition result of the current Size and the given one.
  85396. */
  85397. add(otherSize: Size): Size;
  85398. /**
  85399. * Subtracts the width and height of two
  85400. * @param otherSize size to subtract to this size
  85401. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85402. */
  85403. subtract(otherSize: Size): Size;
  85404. /**
  85405. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85406. * @param start starting size to lerp between
  85407. * @param end end size to lerp between
  85408. * @param amount amount to lerp between the start and end values
  85409. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85410. */
  85411. static Lerp(start: Size, end: Size, amount: number): Size;
  85412. }
  85413. }
  85414. declare module BABYLON {
  85415. /**
  85416. * Defines a runtime animation
  85417. */
  85418. export class RuntimeAnimation {
  85419. private _events;
  85420. /**
  85421. * The current frame of the runtime animation
  85422. */
  85423. private _currentFrame;
  85424. /**
  85425. * The animation used by the runtime animation
  85426. */
  85427. private _animation;
  85428. /**
  85429. * The target of the runtime animation
  85430. */
  85431. private _target;
  85432. /**
  85433. * The initiating animatable
  85434. */
  85435. private _host;
  85436. /**
  85437. * The original value of the runtime animation
  85438. */
  85439. private _originalValue;
  85440. /**
  85441. * The original blend value of the runtime animation
  85442. */
  85443. private _originalBlendValue;
  85444. /**
  85445. * The offsets cache of the runtime animation
  85446. */
  85447. private _offsetsCache;
  85448. /**
  85449. * The high limits cache of the runtime animation
  85450. */
  85451. private _highLimitsCache;
  85452. /**
  85453. * Specifies if the runtime animation has been stopped
  85454. */
  85455. private _stopped;
  85456. /**
  85457. * The blending factor of the runtime animation
  85458. */
  85459. private _blendingFactor;
  85460. /**
  85461. * The BabylonJS scene
  85462. */
  85463. private _scene;
  85464. /**
  85465. * The current value of the runtime animation
  85466. */
  85467. private _currentValue;
  85468. /** @hidden */
  85469. _animationState: _IAnimationState;
  85470. /**
  85471. * The active target of the runtime animation
  85472. */
  85473. private _activeTargets;
  85474. private _currentActiveTarget;
  85475. private _directTarget;
  85476. /**
  85477. * The target path of the runtime animation
  85478. */
  85479. private _targetPath;
  85480. /**
  85481. * The weight of the runtime animation
  85482. */
  85483. private _weight;
  85484. /**
  85485. * The ratio offset of the runtime animation
  85486. */
  85487. private _ratioOffset;
  85488. /**
  85489. * The previous delay of the runtime animation
  85490. */
  85491. private _previousDelay;
  85492. /**
  85493. * The previous ratio of the runtime animation
  85494. */
  85495. private _previousRatio;
  85496. private _enableBlending;
  85497. private _keys;
  85498. private _minFrame;
  85499. private _maxFrame;
  85500. private _minValue;
  85501. private _maxValue;
  85502. private _targetIsArray;
  85503. /**
  85504. * Gets the current frame of the runtime animation
  85505. */
  85506. get currentFrame(): number;
  85507. /**
  85508. * Gets the weight of the runtime animation
  85509. */
  85510. get weight(): number;
  85511. /**
  85512. * Gets the current value of the runtime animation
  85513. */
  85514. get currentValue(): any;
  85515. /**
  85516. * Gets the target path of the runtime animation
  85517. */
  85518. get targetPath(): string;
  85519. /**
  85520. * Gets the actual target of the runtime animation
  85521. */
  85522. get target(): any;
  85523. /** @hidden */
  85524. _onLoop: () => void;
  85525. /**
  85526. * Create a new RuntimeAnimation object
  85527. * @param target defines the target of the animation
  85528. * @param animation defines the source animation object
  85529. * @param scene defines the hosting scene
  85530. * @param host defines the initiating Animatable
  85531. */
  85532. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  85533. private _preparePath;
  85534. /**
  85535. * Gets the animation from the runtime animation
  85536. */
  85537. get animation(): Animation;
  85538. /**
  85539. * Resets the runtime animation to the beginning
  85540. * @param restoreOriginal defines whether to restore the target property to the original value
  85541. */
  85542. reset(restoreOriginal?: boolean): void;
  85543. /**
  85544. * Specifies if the runtime animation is stopped
  85545. * @returns Boolean specifying if the runtime animation is stopped
  85546. */
  85547. isStopped(): boolean;
  85548. /**
  85549. * Disposes of the runtime animation
  85550. */
  85551. dispose(): void;
  85552. /**
  85553. * Apply the interpolated value to the target
  85554. * @param currentValue defines the value computed by the animation
  85555. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  85556. */
  85557. setValue(currentValue: any, weight: number): void;
  85558. private _getOriginalValues;
  85559. private _setValue;
  85560. /**
  85561. * Gets the loop pmode of the runtime animation
  85562. * @returns Loop Mode
  85563. */
  85564. private _getCorrectLoopMode;
  85565. /**
  85566. * Move the current animation to a given frame
  85567. * @param frame defines the frame to move to
  85568. */
  85569. goToFrame(frame: number): void;
  85570. /**
  85571. * @hidden Internal use only
  85572. */
  85573. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  85574. /**
  85575. * Execute the current animation
  85576. * @param delay defines the delay to add to the current frame
  85577. * @param from defines the lower bound of the animation range
  85578. * @param to defines the upper bound of the animation range
  85579. * @param loop defines if the current animation must loop
  85580. * @param speedRatio defines the current speed ratio
  85581. * @param weight defines the weight of the animation (default is -1 so no weight)
  85582. * @param onLoop optional callback called when animation loops
  85583. * @returns a boolean indicating if the animation is running
  85584. */
  85585. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  85586. }
  85587. }
  85588. declare module BABYLON {
  85589. /**
  85590. * Class used to store an actual running animation
  85591. */
  85592. export class Animatable {
  85593. /** defines the target object */
  85594. target: any;
  85595. /** defines the starting frame number (default is 0) */
  85596. fromFrame: number;
  85597. /** defines the ending frame number (default is 100) */
  85598. toFrame: number;
  85599. /** defines if the animation must loop (default is false) */
  85600. loopAnimation: boolean;
  85601. /** defines a callback to call when animation ends if it is not looping */
  85602. onAnimationEnd?: (() => void) | null | undefined;
  85603. /** defines a callback to call when animation loops */
  85604. onAnimationLoop?: (() => void) | null | undefined;
  85605. private _localDelayOffset;
  85606. private _pausedDelay;
  85607. private _runtimeAnimations;
  85608. private _paused;
  85609. private _scene;
  85610. private _speedRatio;
  85611. private _weight;
  85612. private _syncRoot;
  85613. /**
  85614. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  85615. * This will only apply for non looping animation (default is true)
  85616. */
  85617. disposeOnEnd: boolean;
  85618. /**
  85619. * Gets a boolean indicating if the animation has started
  85620. */
  85621. animationStarted: boolean;
  85622. /**
  85623. * Observer raised when the animation ends
  85624. */
  85625. onAnimationEndObservable: Observable<Animatable>;
  85626. /**
  85627. * Observer raised when the animation loops
  85628. */
  85629. onAnimationLoopObservable: Observable<Animatable>;
  85630. /**
  85631. * Gets the root Animatable used to synchronize and normalize animations
  85632. */
  85633. get syncRoot(): Nullable<Animatable>;
  85634. /**
  85635. * Gets the current frame of the first RuntimeAnimation
  85636. * Used to synchronize Animatables
  85637. */
  85638. get masterFrame(): number;
  85639. /**
  85640. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  85641. */
  85642. get weight(): number;
  85643. set weight(value: number);
  85644. /**
  85645. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  85646. */
  85647. get speedRatio(): number;
  85648. set speedRatio(value: number);
  85649. /**
  85650. * Creates a new Animatable
  85651. * @param scene defines the hosting scene
  85652. * @param target defines the target object
  85653. * @param fromFrame defines the starting frame number (default is 0)
  85654. * @param toFrame defines the ending frame number (default is 100)
  85655. * @param loopAnimation defines if the animation must loop (default is false)
  85656. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  85657. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  85658. * @param animations defines a group of animation to add to the new Animatable
  85659. * @param onAnimationLoop defines a callback to call when animation loops
  85660. */
  85661. constructor(scene: Scene,
  85662. /** defines the target object */
  85663. target: any,
  85664. /** defines the starting frame number (default is 0) */
  85665. fromFrame?: number,
  85666. /** defines the ending frame number (default is 100) */
  85667. toFrame?: number,
  85668. /** defines if the animation must loop (default is false) */
  85669. loopAnimation?: boolean, speedRatio?: number,
  85670. /** defines a callback to call when animation ends if it is not looping */
  85671. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  85672. /** defines a callback to call when animation loops */
  85673. onAnimationLoop?: (() => void) | null | undefined);
  85674. /**
  85675. * Synchronize and normalize current Animatable with a source Animatable
  85676. * This is useful when using animation weights and when animations are not of the same length
  85677. * @param root defines the root Animatable to synchronize with
  85678. * @returns the current Animatable
  85679. */
  85680. syncWith(root: Animatable): Animatable;
  85681. /**
  85682. * Gets the list of runtime animations
  85683. * @returns an array of RuntimeAnimation
  85684. */
  85685. getAnimations(): RuntimeAnimation[];
  85686. /**
  85687. * Adds more animations to the current animatable
  85688. * @param target defines the target of the animations
  85689. * @param animations defines the new animations to add
  85690. */
  85691. appendAnimations(target: any, animations: Animation[]): void;
  85692. /**
  85693. * Gets the source animation for a specific property
  85694. * @param property defines the propertyu to look for
  85695. * @returns null or the source animation for the given property
  85696. */
  85697. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  85698. /**
  85699. * Gets the runtime animation for a specific property
  85700. * @param property defines the propertyu to look for
  85701. * @returns null or the runtime animation for the given property
  85702. */
  85703. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  85704. /**
  85705. * Resets the animatable to its original state
  85706. */
  85707. reset(): void;
  85708. /**
  85709. * Allows the animatable to blend with current running animations
  85710. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85711. * @param blendingSpeed defines the blending speed to use
  85712. */
  85713. enableBlending(blendingSpeed: number): void;
  85714. /**
  85715. * Disable animation blending
  85716. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85717. */
  85718. disableBlending(): void;
  85719. /**
  85720. * Jump directly to a given frame
  85721. * @param frame defines the frame to jump to
  85722. */
  85723. goToFrame(frame: number): void;
  85724. /**
  85725. * Pause the animation
  85726. */
  85727. pause(): void;
  85728. /**
  85729. * Restart the animation
  85730. */
  85731. restart(): void;
  85732. private _raiseOnAnimationEnd;
  85733. /**
  85734. * Stop and delete the current animation
  85735. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  85736. * @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)
  85737. */
  85738. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  85739. /**
  85740. * Wait asynchronously for the animation to end
  85741. * @returns a promise which will be fullfilled when the animation ends
  85742. */
  85743. waitAsync(): Promise<Animatable>;
  85744. /** @hidden */
  85745. _animate(delay: number): boolean;
  85746. }
  85747. interface Scene {
  85748. /** @hidden */
  85749. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  85750. /** @hidden */
  85751. _processLateAnimationBindingsForMatrices(holder: {
  85752. totalWeight: number;
  85753. animations: RuntimeAnimation[];
  85754. originalValue: Matrix;
  85755. }): any;
  85756. /** @hidden */
  85757. _processLateAnimationBindingsForQuaternions(holder: {
  85758. totalWeight: number;
  85759. animations: RuntimeAnimation[];
  85760. originalValue: Quaternion;
  85761. }, refQuaternion: Quaternion): Quaternion;
  85762. /** @hidden */
  85763. _processLateAnimationBindings(): void;
  85764. /**
  85765. * Will start the animation sequence of a given target
  85766. * @param target defines the target
  85767. * @param from defines from which frame should animation start
  85768. * @param to defines until which frame should animation run.
  85769. * @param weight defines the weight to apply to the animation (1.0 by default)
  85770. * @param loop defines if the animation loops
  85771. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85772. * @param onAnimationEnd defines the function to be executed when the animation ends
  85773. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85774. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  85775. * @param onAnimationLoop defines the callback to call when an animation loops
  85776. * @returns the animatable object created for this animation
  85777. */
  85778. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  85779. /**
  85780. * Will start the animation sequence of a given target
  85781. * @param target defines the target
  85782. * @param from defines from which frame should animation start
  85783. * @param to defines until which frame should animation run.
  85784. * @param loop defines if the animation loops
  85785. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85786. * @param onAnimationEnd defines the function to be executed when the animation ends
  85787. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85788. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  85789. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  85790. * @param onAnimationLoop defines the callback to call when an animation loops
  85791. * @returns the animatable object created for this animation
  85792. */
  85793. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  85794. /**
  85795. * Will start the animation sequence of a given target and its hierarchy
  85796. * @param target defines the target
  85797. * @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.
  85798. * @param from defines from which frame should animation start
  85799. * @param to defines until which frame should animation run.
  85800. * @param loop defines if the animation loops
  85801. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85802. * @param onAnimationEnd defines the function to be executed when the animation ends
  85803. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85804. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  85805. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  85806. * @param onAnimationLoop defines the callback to call when an animation loops
  85807. * @returns the list of created animatables
  85808. */
  85809. 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[];
  85810. /**
  85811. * Begin a new animation on a given node
  85812. * @param target defines the target where the animation will take place
  85813. * @param animations defines the list of animations to start
  85814. * @param from defines the initial value
  85815. * @param to defines the final value
  85816. * @param loop defines if you want animation to loop (off by default)
  85817. * @param speedRatio defines the speed ratio to apply to all animations
  85818. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85819. * @param onAnimationLoop defines the callback to call when an animation loops
  85820. * @returns the list of created animatables
  85821. */
  85822. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  85823. /**
  85824. * Begin a new animation on a given node and its hierarchy
  85825. * @param target defines the root node where the animation will take place
  85826. * @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.
  85827. * @param animations defines the list of animations to start
  85828. * @param from defines the initial value
  85829. * @param to defines the final value
  85830. * @param loop defines if you want animation to loop (off by default)
  85831. * @param speedRatio defines the speed ratio to apply to all animations
  85832. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85833. * @param onAnimationLoop defines the callback to call when an animation loops
  85834. * @returns the list of animatables created for all nodes
  85835. */
  85836. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  85837. /**
  85838. * Gets the animatable associated with a specific target
  85839. * @param target defines the target of the animatable
  85840. * @returns the required animatable if found
  85841. */
  85842. getAnimatableByTarget(target: any): Nullable<Animatable>;
  85843. /**
  85844. * Gets all animatables associated with a given target
  85845. * @param target defines the target to look animatables for
  85846. * @returns an array of Animatables
  85847. */
  85848. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  85849. /**
  85850. * Stops and removes all animations that have been applied to the scene
  85851. */
  85852. stopAllAnimations(): void;
  85853. /**
  85854. * Gets the current delta time used by animation engine
  85855. */
  85856. deltaTime: number;
  85857. }
  85858. interface Bone {
  85859. /**
  85860. * Copy an animation range from another bone
  85861. * @param source defines the source bone
  85862. * @param rangeName defines the range name to copy
  85863. * @param frameOffset defines the frame offset
  85864. * @param rescaleAsRequired defines if rescaling must be applied if required
  85865. * @param skelDimensionsRatio defines the scaling ratio
  85866. * @returns true if operation was successful
  85867. */
  85868. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  85869. }
  85870. }
  85871. declare module BABYLON {
  85872. /**
  85873. * Class used to override all child animations of a given target
  85874. */
  85875. export class AnimationPropertiesOverride {
  85876. /**
  85877. * Gets or sets a value indicating if animation blending must be used
  85878. */
  85879. enableBlending: boolean;
  85880. /**
  85881. * Gets or sets the blending speed to use when enableBlending is true
  85882. */
  85883. blendingSpeed: number;
  85884. /**
  85885. * Gets or sets the default loop mode to use
  85886. */
  85887. loopMode: number;
  85888. }
  85889. }
  85890. declare module BABYLON {
  85891. /**
  85892. * Class used to handle skinning animations
  85893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  85894. */
  85895. export class Skeleton implements IAnimatable {
  85896. /** defines the skeleton name */
  85897. name: string;
  85898. /** defines the skeleton Id */
  85899. id: string;
  85900. /**
  85901. * Defines the list of child bones
  85902. */
  85903. bones: Bone[];
  85904. /**
  85905. * Defines an estimate of the dimension of the skeleton at rest
  85906. */
  85907. dimensionsAtRest: Vector3;
  85908. /**
  85909. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  85910. */
  85911. needInitialSkinMatrix: boolean;
  85912. /**
  85913. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  85914. */
  85915. overrideMesh: Nullable<AbstractMesh>;
  85916. /**
  85917. * Gets the list of animations attached to this skeleton
  85918. */
  85919. animations: Array<Animation>;
  85920. private _scene;
  85921. private _isDirty;
  85922. private _transformMatrices;
  85923. private _transformMatrixTexture;
  85924. private _meshesWithPoseMatrix;
  85925. private _animatables;
  85926. private _identity;
  85927. private _synchronizedWithMesh;
  85928. private _ranges;
  85929. private _lastAbsoluteTransformsUpdateId;
  85930. private _canUseTextureForBones;
  85931. private _uniqueId;
  85932. /** @hidden */
  85933. _numBonesWithLinkedTransformNode: number;
  85934. /** @hidden */
  85935. _hasWaitingData: Nullable<boolean>;
  85936. /**
  85937. * Specifies if the skeleton should be serialized
  85938. */
  85939. doNotSerialize: boolean;
  85940. private _useTextureToStoreBoneMatrices;
  85941. /**
  85942. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  85943. * Please note that this option is not available if the hardware does not support it
  85944. */
  85945. get useTextureToStoreBoneMatrices(): boolean;
  85946. set useTextureToStoreBoneMatrices(value: boolean);
  85947. private _animationPropertiesOverride;
  85948. /**
  85949. * Gets or sets the animation properties override
  85950. */
  85951. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  85952. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  85953. /**
  85954. * List of inspectable custom properties (used by the Inspector)
  85955. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85956. */
  85957. inspectableCustomProperties: IInspectable[];
  85958. /**
  85959. * An observable triggered before computing the skeleton's matrices
  85960. */
  85961. onBeforeComputeObservable: Observable<Skeleton>;
  85962. /**
  85963. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  85964. */
  85965. get isUsingTextureForMatrices(): boolean;
  85966. /**
  85967. * Gets the unique ID of this skeleton
  85968. */
  85969. get uniqueId(): number;
  85970. /**
  85971. * Creates a new skeleton
  85972. * @param name defines the skeleton name
  85973. * @param id defines the skeleton Id
  85974. * @param scene defines the hosting scene
  85975. */
  85976. constructor(
  85977. /** defines the skeleton name */
  85978. name: string,
  85979. /** defines the skeleton Id */
  85980. id: string, scene: Scene);
  85981. /**
  85982. * Gets the current object class name.
  85983. * @return the class name
  85984. */
  85985. getClassName(): string;
  85986. /**
  85987. * Returns an array containing the root bones
  85988. * @returns an array containing the root bones
  85989. */
  85990. getChildren(): Array<Bone>;
  85991. /**
  85992. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  85993. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  85994. * @returns a Float32Array containing matrices data
  85995. */
  85996. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  85997. /**
  85998. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  85999. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86000. * @returns a raw texture containing the data
  86001. */
  86002. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  86003. /**
  86004. * Gets the current hosting scene
  86005. * @returns a scene object
  86006. */
  86007. getScene(): Scene;
  86008. /**
  86009. * Gets a string representing the current skeleton data
  86010. * @param fullDetails defines a boolean indicating if we want a verbose version
  86011. * @returns a string representing the current skeleton data
  86012. */
  86013. toString(fullDetails?: boolean): string;
  86014. /**
  86015. * Get bone's index searching by name
  86016. * @param name defines bone's name to search for
  86017. * @return the indice of the bone. Returns -1 if not found
  86018. */
  86019. getBoneIndexByName(name: string): number;
  86020. /**
  86021. * Creater a new animation range
  86022. * @param name defines the name of the range
  86023. * @param from defines the start key
  86024. * @param to defines the end key
  86025. */
  86026. createAnimationRange(name: string, from: number, to: number): void;
  86027. /**
  86028. * Delete a specific animation range
  86029. * @param name defines the name of the range
  86030. * @param deleteFrames defines if frames must be removed as well
  86031. */
  86032. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  86033. /**
  86034. * Gets a specific animation range
  86035. * @param name defines the name of the range to look for
  86036. * @returns the requested animation range or null if not found
  86037. */
  86038. getAnimationRange(name: string): Nullable<AnimationRange>;
  86039. /**
  86040. * Gets the list of all animation ranges defined on this skeleton
  86041. * @returns an array
  86042. */
  86043. getAnimationRanges(): Nullable<AnimationRange>[];
  86044. /**
  86045. * Copy animation range from a source skeleton.
  86046. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  86047. * @param source defines the source skeleton
  86048. * @param name defines the name of the range to copy
  86049. * @param rescaleAsRequired defines if rescaling must be applied if required
  86050. * @returns true if operation was successful
  86051. */
  86052. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  86053. /**
  86054. * Forces the skeleton to go to rest pose
  86055. */
  86056. returnToRest(): void;
  86057. private _getHighestAnimationFrame;
  86058. /**
  86059. * Begin a specific animation range
  86060. * @param name defines the name of the range to start
  86061. * @param loop defines if looping must be turned on (false by default)
  86062. * @param speedRatio defines the speed ratio to apply (1 by default)
  86063. * @param onAnimationEnd defines a callback which will be called when animation will end
  86064. * @returns a new animatable
  86065. */
  86066. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  86067. /** @hidden */
  86068. _markAsDirty(): void;
  86069. /** @hidden */
  86070. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86071. /** @hidden */
  86072. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86073. private _computeTransformMatrices;
  86074. /**
  86075. * Build all resources required to render a skeleton
  86076. */
  86077. prepare(): void;
  86078. /**
  86079. * Gets the list of animatables currently running for this skeleton
  86080. * @returns an array of animatables
  86081. */
  86082. getAnimatables(): IAnimatable[];
  86083. /**
  86084. * Clone the current skeleton
  86085. * @param name defines the name of the new skeleton
  86086. * @param id defines the id of the new skeleton
  86087. * @returns the new skeleton
  86088. */
  86089. clone(name: string, id?: string): Skeleton;
  86090. /**
  86091. * Enable animation blending for this skeleton
  86092. * @param blendingSpeed defines the blending speed to apply
  86093. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86094. */
  86095. enableBlending(blendingSpeed?: number): void;
  86096. /**
  86097. * Releases all resources associated with the current skeleton
  86098. */
  86099. dispose(): void;
  86100. /**
  86101. * Serialize the skeleton in a JSON object
  86102. * @returns a JSON object
  86103. */
  86104. serialize(): any;
  86105. /**
  86106. * Creates a new skeleton from serialized data
  86107. * @param parsedSkeleton defines the serialized data
  86108. * @param scene defines the hosting scene
  86109. * @returns a new skeleton
  86110. */
  86111. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  86112. /**
  86113. * Compute all node absolute transforms
  86114. * @param forceUpdate defines if computation must be done even if cache is up to date
  86115. */
  86116. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  86117. /**
  86118. * Gets the root pose matrix
  86119. * @returns a matrix
  86120. */
  86121. getPoseMatrix(): Nullable<Matrix>;
  86122. /**
  86123. * Sorts bones per internal index
  86124. */
  86125. sortBones(): void;
  86126. private _sortBones;
  86127. }
  86128. }
  86129. declare module BABYLON {
  86130. /**
  86131. * Class used to store bone information
  86132. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86133. */
  86134. export class Bone extends Node {
  86135. /**
  86136. * defines the bone name
  86137. */
  86138. name: string;
  86139. private static _tmpVecs;
  86140. private static _tmpQuat;
  86141. private static _tmpMats;
  86142. /**
  86143. * Gets the list of child bones
  86144. */
  86145. children: Bone[];
  86146. /** Gets the animations associated with this bone */
  86147. animations: Animation[];
  86148. /**
  86149. * Gets or sets bone length
  86150. */
  86151. length: number;
  86152. /**
  86153. * @hidden Internal only
  86154. * Set this value to map this bone to a different index in the transform matrices
  86155. * Set this value to -1 to exclude the bone from the transform matrices
  86156. */
  86157. _index: Nullable<number>;
  86158. private _skeleton;
  86159. private _localMatrix;
  86160. private _restPose;
  86161. private _baseMatrix;
  86162. private _absoluteTransform;
  86163. private _invertedAbsoluteTransform;
  86164. private _parent;
  86165. private _scalingDeterminant;
  86166. private _worldTransform;
  86167. private _localScaling;
  86168. private _localRotation;
  86169. private _localPosition;
  86170. private _needToDecompose;
  86171. private _needToCompose;
  86172. /** @hidden */
  86173. _linkedTransformNode: Nullable<TransformNode>;
  86174. /** @hidden */
  86175. _waitingTransformNodeId: Nullable<string>;
  86176. /** @hidden */
  86177. get _matrix(): Matrix;
  86178. /** @hidden */
  86179. set _matrix(value: Matrix);
  86180. /**
  86181. * Create a new bone
  86182. * @param name defines the bone name
  86183. * @param skeleton defines the parent skeleton
  86184. * @param parentBone defines the parent (can be null if the bone is the root)
  86185. * @param localMatrix defines the local matrix
  86186. * @param restPose defines the rest pose matrix
  86187. * @param baseMatrix defines the base matrix
  86188. * @param index defines index of the bone in the hiearchy
  86189. */
  86190. constructor(
  86191. /**
  86192. * defines the bone name
  86193. */
  86194. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  86195. /**
  86196. * Gets the current object class name.
  86197. * @return the class name
  86198. */
  86199. getClassName(): string;
  86200. /**
  86201. * Gets the parent skeleton
  86202. * @returns a skeleton
  86203. */
  86204. getSkeleton(): Skeleton;
  86205. /**
  86206. * Gets parent bone
  86207. * @returns a bone or null if the bone is the root of the bone hierarchy
  86208. */
  86209. getParent(): Nullable<Bone>;
  86210. /**
  86211. * Returns an array containing the root bones
  86212. * @returns an array containing the root bones
  86213. */
  86214. getChildren(): Array<Bone>;
  86215. /**
  86216. * Gets the node index in matrix array generated for rendering
  86217. * @returns the node index
  86218. */
  86219. getIndex(): number;
  86220. /**
  86221. * Sets the parent bone
  86222. * @param parent defines the parent (can be null if the bone is the root)
  86223. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86224. */
  86225. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  86226. /**
  86227. * Gets the local matrix
  86228. * @returns a matrix
  86229. */
  86230. getLocalMatrix(): Matrix;
  86231. /**
  86232. * Gets the base matrix (initial matrix which remains unchanged)
  86233. * @returns a matrix
  86234. */
  86235. getBaseMatrix(): Matrix;
  86236. /**
  86237. * Gets the rest pose matrix
  86238. * @returns a matrix
  86239. */
  86240. getRestPose(): Matrix;
  86241. /**
  86242. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  86243. */
  86244. getWorldMatrix(): Matrix;
  86245. /**
  86246. * Sets the local matrix to rest pose matrix
  86247. */
  86248. returnToRest(): void;
  86249. /**
  86250. * Gets the inverse of the absolute transform matrix.
  86251. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  86252. * @returns a matrix
  86253. */
  86254. getInvertedAbsoluteTransform(): Matrix;
  86255. /**
  86256. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  86257. * @returns a matrix
  86258. */
  86259. getAbsoluteTransform(): Matrix;
  86260. /**
  86261. * Links with the given transform node.
  86262. * The local matrix of this bone is copied from the transform node every frame.
  86263. * @param transformNode defines the transform node to link to
  86264. */
  86265. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  86266. /**
  86267. * Gets the node used to drive the bone's transformation
  86268. * @returns a transform node or null
  86269. */
  86270. getTransformNode(): Nullable<TransformNode>;
  86271. /** Gets or sets current position (in local space) */
  86272. get position(): Vector3;
  86273. set position(newPosition: Vector3);
  86274. /** Gets or sets current rotation (in local space) */
  86275. get rotation(): Vector3;
  86276. set rotation(newRotation: Vector3);
  86277. /** Gets or sets current rotation quaternion (in local space) */
  86278. get rotationQuaternion(): Quaternion;
  86279. set rotationQuaternion(newRotation: Quaternion);
  86280. /** Gets or sets current scaling (in local space) */
  86281. get scaling(): Vector3;
  86282. set scaling(newScaling: Vector3);
  86283. /**
  86284. * Gets the animation properties override
  86285. */
  86286. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86287. private _decompose;
  86288. private _compose;
  86289. /**
  86290. * Update the base and local matrices
  86291. * @param matrix defines the new base or local matrix
  86292. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86293. * @param updateLocalMatrix defines if the local matrix should be updated
  86294. */
  86295. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  86296. /** @hidden */
  86297. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  86298. /**
  86299. * Flag the bone as dirty (Forcing it to update everything)
  86300. */
  86301. markAsDirty(): void;
  86302. /** @hidden */
  86303. _markAsDirtyAndCompose(): void;
  86304. private _markAsDirtyAndDecompose;
  86305. /**
  86306. * Translate the bone in local or world space
  86307. * @param vec The amount to translate the bone
  86308. * @param space The space that the translation is in
  86309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86310. */
  86311. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86312. /**
  86313. * Set the postion of the bone in local or world space
  86314. * @param position The position to set the bone
  86315. * @param space The space that the position is in
  86316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86317. */
  86318. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86319. /**
  86320. * Set the absolute position of the bone (world space)
  86321. * @param position The position to set the bone
  86322. * @param mesh The mesh that this bone is attached to
  86323. */
  86324. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  86325. /**
  86326. * Scale the bone on the x, y and z axes (in local space)
  86327. * @param x The amount to scale the bone on the x axis
  86328. * @param y The amount to scale the bone on the y axis
  86329. * @param z The amount to scale the bone on the z axis
  86330. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  86331. */
  86332. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  86333. /**
  86334. * Set the bone scaling in local space
  86335. * @param scale defines the scaling vector
  86336. */
  86337. setScale(scale: Vector3): void;
  86338. /**
  86339. * Gets the current scaling in local space
  86340. * @returns the current scaling vector
  86341. */
  86342. getScale(): Vector3;
  86343. /**
  86344. * Gets the current scaling in local space and stores it in a target vector
  86345. * @param result defines the target vector
  86346. */
  86347. getScaleToRef(result: Vector3): void;
  86348. /**
  86349. * Set the yaw, pitch, and roll of the bone in local or world space
  86350. * @param yaw The rotation of the bone on the y axis
  86351. * @param pitch The rotation of the bone on the x axis
  86352. * @param roll The rotation of the bone on the z axis
  86353. * @param space The space that the axes of rotation are in
  86354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86355. */
  86356. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  86357. /**
  86358. * Add a rotation to the bone on an axis in local or world space
  86359. * @param axis The axis to rotate the bone on
  86360. * @param amount The amount to rotate the bone
  86361. * @param space The space that the axis is in
  86362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86363. */
  86364. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  86365. /**
  86366. * Set the rotation of the bone to a particular axis angle in local or world space
  86367. * @param axis The axis to rotate the bone on
  86368. * @param angle The angle that the bone should be rotated to
  86369. * @param space The space that the axis is in
  86370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86371. */
  86372. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  86373. /**
  86374. * Set the euler rotation of the bone in local of world space
  86375. * @param rotation The euler rotation that the bone should be set to
  86376. * @param space The space that the rotation is in
  86377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86378. */
  86379. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86380. /**
  86381. * Set the quaternion rotation of the bone in local of world space
  86382. * @param quat The quaternion rotation that the bone should be set to
  86383. * @param space The space that the rotation is in
  86384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86385. */
  86386. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  86387. /**
  86388. * Set the rotation matrix of the bone in local of world space
  86389. * @param rotMat The rotation matrix that the bone should be set to
  86390. * @param space The space that the rotation is in
  86391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86392. */
  86393. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  86394. private _rotateWithMatrix;
  86395. private _getNegativeRotationToRef;
  86396. /**
  86397. * Get the position of the bone in local or world space
  86398. * @param space The space that the returned position is in
  86399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86400. * @returns The position of the bone
  86401. */
  86402. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86403. /**
  86404. * Copy the position of the bone to a vector3 in local or world space
  86405. * @param space The space that the returned position is in
  86406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86407. * @param result The vector3 to copy the position to
  86408. */
  86409. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  86410. /**
  86411. * Get the absolute position of the bone (world space)
  86412. * @param mesh The mesh that this bone is attached to
  86413. * @returns The absolute position of the bone
  86414. */
  86415. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  86416. /**
  86417. * Copy the absolute position of the bone (world space) to the result param
  86418. * @param mesh The mesh that this bone is attached to
  86419. * @param result The vector3 to copy the absolute position to
  86420. */
  86421. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  86422. /**
  86423. * Compute the absolute transforms of this bone and its children
  86424. */
  86425. computeAbsoluteTransforms(): void;
  86426. /**
  86427. * Get the world direction from an axis that is in the local space of the bone
  86428. * @param localAxis The local direction that is used to compute the world direction
  86429. * @param mesh The mesh that this bone is attached to
  86430. * @returns The world direction
  86431. */
  86432. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86433. /**
  86434. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  86435. * @param localAxis The local direction that is used to compute the world direction
  86436. * @param mesh The mesh that this bone is attached to
  86437. * @param result The vector3 that the world direction will be copied to
  86438. */
  86439. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86440. /**
  86441. * Get the euler rotation of the bone in local or world space
  86442. * @param space The space that the rotation should be in
  86443. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86444. * @returns The euler rotation
  86445. */
  86446. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86447. /**
  86448. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  86449. * @param space The space that the rotation should be in
  86450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86451. * @param result The vector3 that the rotation should be copied to
  86452. */
  86453. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86454. /**
  86455. * Get the quaternion rotation of the bone in either local or world space
  86456. * @param space The space that the rotation should be in
  86457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86458. * @returns The quaternion rotation
  86459. */
  86460. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  86461. /**
  86462. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  86463. * @param space The space that the rotation should be in
  86464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86465. * @param result The quaternion that the rotation should be copied to
  86466. */
  86467. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  86468. /**
  86469. * Get the rotation matrix of the bone in local or world space
  86470. * @param space The space that the rotation should be in
  86471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86472. * @returns The rotation matrix
  86473. */
  86474. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  86475. /**
  86476. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  86477. * @param space The space that the rotation should be in
  86478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86479. * @param result The quaternion that the rotation should be copied to
  86480. */
  86481. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  86482. /**
  86483. * Get the world position of a point that is in the local space of the bone
  86484. * @param position The local position
  86485. * @param mesh The mesh that this bone is attached to
  86486. * @returns The world position
  86487. */
  86488. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86489. /**
  86490. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  86491. * @param position The local position
  86492. * @param mesh The mesh that this bone is attached to
  86493. * @param result The vector3 that the world position should be copied to
  86494. */
  86495. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86496. /**
  86497. * Get the local position of a point that is in world space
  86498. * @param position The world position
  86499. * @param mesh The mesh that this bone is attached to
  86500. * @returns The local position
  86501. */
  86502. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86503. /**
  86504. * Get the local position of a point that is in world space and copy it to the result param
  86505. * @param position The world position
  86506. * @param mesh The mesh that this bone is attached to
  86507. * @param result The vector3 that the local position should be copied to
  86508. */
  86509. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86510. }
  86511. }
  86512. declare module BABYLON {
  86513. /**
  86514. * 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.
  86515. * @see https://doc.babylonjs.com/how_to/transformnode
  86516. */
  86517. export class TransformNode extends Node {
  86518. /**
  86519. * Object will not rotate to face the camera
  86520. */
  86521. static BILLBOARDMODE_NONE: number;
  86522. /**
  86523. * Object will rotate to face the camera but only on the x axis
  86524. */
  86525. static BILLBOARDMODE_X: number;
  86526. /**
  86527. * Object will rotate to face the camera but only on the y axis
  86528. */
  86529. static BILLBOARDMODE_Y: number;
  86530. /**
  86531. * Object will rotate to face the camera but only on the z axis
  86532. */
  86533. static BILLBOARDMODE_Z: number;
  86534. /**
  86535. * Object will rotate to face the camera
  86536. */
  86537. static BILLBOARDMODE_ALL: number;
  86538. /**
  86539. * Object will rotate to face the camera's position instead of orientation
  86540. */
  86541. static BILLBOARDMODE_USE_POSITION: number;
  86542. private _forward;
  86543. private _forwardInverted;
  86544. private _up;
  86545. private _right;
  86546. private _rightInverted;
  86547. private _position;
  86548. private _rotation;
  86549. private _rotationQuaternion;
  86550. protected _scaling: Vector3;
  86551. protected _isDirty: boolean;
  86552. private _transformToBoneReferal;
  86553. private _isAbsoluteSynced;
  86554. private _billboardMode;
  86555. /**
  86556. * Gets or sets the billboard mode. Default is 0.
  86557. *
  86558. * | Value | Type | Description |
  86559. * | --- | --- | --- |
  86560. * | 0 | BILLBOARDMODE_NONE | |
  86561. * | 1 | BILLBOARDMODE_X | |
  86562. * | 2 | BILLBOARDMODE_Y | |
  86563. * | 4 | BILLBOARDMODE_Z | |
  86564. * | 7 | BILLBOARDMODE_ALL | |
  86565. *
  86566. */
  86567. get billboardMode(): number;
  86568. set billboardMode(value: number);
  86569. private _preserveParentRotationForBillboard;
  86570. /**
  86571. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86572. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86573. */
  86574. get preserveParentRotationForBillboard(): boolean;
  86575. set preserveParentRotationForBillboard(value: boolean);
  86576. /**
  86577. * 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
  86578. */
  86579. scalingDeterminant: number;
  86580. private _infiniteDistance;
  86581. /**
  86582. * Gets or sets the distance of the object to max, often used by skybox
  86583. */
  86584. get infiniteDistance(): boolean;
  86585. set infiniteDistance(value: boolean);
  86586. /**
  86587. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86588. * By default the system will update normals to compensate
  86589. */
  86590. ignoreNonUniformScaling: boolean;
  86591. /**
  86592. * 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
  86593. */
  86594. reIntegrateRotationIntoRotationQuaternion: boolean;
  86595. /** @hidden */
  86596. _poseMatrix: Nullable<Matrix>;
  86597. /** @hidden */
  86598. _localMatrix: Matrix;
  86599. private _usePivotMatrix;
  86600. private _absolutePosition;
  86601. private _absoluteScaling;
  86602. private _absoluteRotationQuaternion;
  86603. private _pivotMatrix;
  86604. private _pivotMatrixInverse;
  86605. protected _postMultiplyPivotMatrix: boolean;
  86606. protected _isWorldMatrixFrozen: boolean;
  86607. /** @hidden */
  86608. _indexInSceneTransformNodesArray: number;
  86609. /**
  86610. * An event triggered after the world matrix is updated
  86611. */
  86612. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86613. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86614. /**
  86615. * Gets a string identifying the name of the class
  86616. * @returns "TransformNode" string
  86617. */
  86618. getClassName(): string;
  86619. /**
  86620. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86621. */
  86622. get position(): Vector3;
  86623. set position(newPosition: Vector3);
  86624. /**
  86625. * 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)).
  86626. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86627. */
  86628. get rotation(): Vector3;
  86629. set rotation(newRotation: Vector3);
  86630. /**
  86631. * 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)).
  86632. */
  86633. get scaling(): Vector3;
  86634. set scaling(newScaling: Vector3);
  86635. /**
  86636. * 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).
  86637. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86638. */
  86639. get rotationQuaternion(): Nullable<Quaternion>;
  86640. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86641. /**
  86642. * The forward direction of that transform in world space.
  86643. */
  86644. get forward(): Vector3;
  86645. /**
  86646. * The up direction of that transform in world space.
  86647. */
  86648. get up(): Vector3;
  86649. /**
  86650. * The right direction of that transform in world space.
  86651. */
  86652. get right(): Vector3;
  86653. /**
  86654. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86655. * @param matrix the matrix to copy the pose from
  86656. * @returns this TransformNode.
  86657. */
  86658. updatePoseMatrix(matrix: Matrix): TransformNode;
  86659. /**
  86660. * Returns the mesh Pose matrix.
  86661. * @returns the pose matrix
  86662. */
  86663. getPoseMatrix(): Matrix;
  86664. /** @hidden */
  86665. _isSynchronized(): boolean;
  86666. /** @hidden */
  86667. _initCache(): void;
  86668. /**
  86669. * Flag the transform node as dirty (Forcing it to update everything)
  86670. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86671. * @returns this transform node
  86672. */
  86673. markAsDirty(property: string): TransformNode;
  86674. /**
  86675. * Returns the current mesh absolute position.
  86676. * Returns a Vector3.
  86677. */
  86678. get absolutePosition(): Vector3;
  86679. /**
  86680. * Returns the current mesh absolute scaling.
  86681. * Returns a Vector3.
  86682. */
  86683. get absoluteScaling(): Vector3;
  86684. /**
  86685. * Returns the current mesh absolute rotation.
  86686. * Returns a Quaternion.
  86687. */
  86688. get absoluteRotationQuaternion(): Quaternion;
  86689. /**
  86690. * Sets a new matrix to apply before all other transformation
  86691. * @param matrix defines the transform matrix
  86692. * @returns the current TransformNode
  86693. */
  86694. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86695. /**
  86696. * Sets a new pivot matrix to the current node
  86697. * @param matrix defines the new pivot matrix to use
  86698. * @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
  86699. * @returns the current TransformNode
  86700. */
  86701. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86702. /**
  86703. * Returns the mesh pivot matrix.
  86704. * Default : Identity.
  86705. * @returns the matrix
  86706. */
  86707. getPivotMatrix(): Matrix;
  86708. /**
  86709. * Instantiate (when possible) or clone that node with its hierarchy
  86710. * @param newParent defines the new parent to use for the instance (or clone)
  86711. * @param options defines options to configure how copy is done
  86712. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86713. * @returns an instance (or a clone) of the current node with its hiearchy
  86714. */
  86715. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86716. doNotInstantiate: boolean;
  86717. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86718. /**
  86719. * Prevents the World matrix to be computed any longer
  86720. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86721. * @returns the TransformNode.
  86722. */
  86723. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86724. /**
  86725. * Allows back the World matrix computation.
  86726. * @returns the TransformNode.
  86727. */
  86728. unfreezeWorldMatrix(): this;
  86729. /**
  86730. * True if the World matrix has been frozen.
  86731. */
  86732. get isWorldMatrixFrozen(): boolean;
  86733. /**
  86734. * Retuns the mesh absolute position in the World.
  86735. * @returns a Vector3.
  86736. */
  86737. getAbsolutePosition(): Vector3;
  86738. /**
  86739. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86740. * @param absolutePosition the absolute position to set
  86741. * @returns the TransformNode.
  86742. */
  86743. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86744. /**
  86745. * Sets the mesh position in its local space.
  86746. * @param vector3 the position to set in localspace
  86747. * @returns the TransformNode.
  86748. */
  86749. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86750. /**
  86751. * Returns the mesh position in the local space from the current World matrix values.
  86752. * @returns a new Vector3.
  86753. */
  86754. getPositionExpressedInLocalSpace(): Vector3;
  86755. /**
  86756. * Translates the mesh along the passed Vector3 in its local space.
  86757. * @param vector3 the distance to translate in localspace
  86758. * @returns the TransformNode.
  86759. */
  86760. locallyTranslate(vector3: Vector3): TransformNode;
  86761. private static _lookAtVectorCache;
  86762. /**
  86763. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86764. * @param targetPoint the position (must be in same space as current mesh) to look at
  86765. * @param yawCor optional yaw (y-axis) correction in radians
  86766. * @param pitchCor optional pitch (x-axis) correction in radians
  86767. * @param rollCor optional roll (z-axis) correction in radians
  86768. * @param space the choosen space of the target
  86769. * @returns the TransformNode.
  86770. */
  86771. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86772. /**
  86773. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86774. * This Vector3 is expressed in the World space.
  86775. * @param localAxis axis to rotate
  86776. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86777. */
  86778. getDirection(localAxis: Vector3): Vector3;
  86779. /**
  86780. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86781. * localAxis is expressed in the mesh local space.
  86782. * result is computed in the Wordl space from the mesh World matrix.
  86783. * @param localAxis axis to rotate
  86784. * @param result the resulting transformnode
  86785. * @returns this TransformNode.
  86786. */
  86787. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86788. /**
  86789. * Sets this transform node rotation to the given local axis.
  86790. * @param localAxis the axis in local space
  86791. * @param yawCor optional yaw (y-axis) correction in radians
  86792. * @param pitchCor optional pitch (x-axis) correction in radians
  86793. * @param rollCor optional roll (z-axis) correction in radians
  86794. * @returns this TransformNode
  86795. */
  86796. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86797. /**
  86798. * Sets a new pivot point to the current node
  86799. * @param point defines the new pivot point to use
  86800. * @param space defines if the point is in world or local space (local by default)
  86801. * @returns the current TransformNode
  86802. */
  86803. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  86804. /**
  86805. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  86806. * @returns the pivot point
  86807. */
  86808. getPivotPoint(): Vector3;
  86809. /**
  86810. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  86811. * @param result the vector3 to store the result
  86812. * @returns this TransformNode.
  86813. */
  86814. getPivotPointToRef(result: Vector3): TransformNode;
  86815. /**
  86816. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  86817. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  86818. */
  86819. getAbsolutePivotPoint(): Vector3;
  86820. /**
  86821. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  86822. * @param result vector3 to store the result
  86823. * @returns this TransformNode.
  86824. */
  86825. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  86826. /**
  86827. * Defines the passed node as the parent of the current node.
  86828. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  86829. * @see https://doc.babylonjs.com/how_to/parenting
  86830. * @param node the node ot set as the parent
  86831. * @returns this TransformNode.
  86832. */
  86833. setParent(node: Nullable<Node>): TransformNode;
  86834. private _nonUniformScaling;
  86835. /**
  86836. * True if the scaling property of this object is non uniform eg. (1,2,1)
  86837. */
  86838. get nonUniformScaling(): boolean;
  86839. /** @hidden */
  86840. _updateNonUniformScalingState(value: boolean): boolean;
  86841. /**
  86842. * Attach the current TransformNode to another TransformNode associated with a bone
  86843. * @param bone Bone affecting the TransformNode
  86844. * @param affectedTransformNode TransformNode associated with the bone
  86845. * @returns this object
  86846. */
  86847. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  86848. /**
  86849. * Detach the transform node if its associated with a bone
  86850. * @returns this object
  86851. */
  86852. detachFromBone(): TransformNode;
  86853. private static _rotationAxisCache;
  86854. /**
  86855. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  86856. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  86857. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  86858. * The passed axis is also normalized.
  86859. * @param axis the axis to rotate around
  86860. * @param amount the amount to rotate in radians
  86861. * @param space Space to rotate in (Default: local)
  86862. * @returns the TransformNode.
  86863. */
  86864. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86865. /**
  86866. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  86867. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  86868. * The passed axis is also normalized. .
  86869. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  86870. * @param point the point to rotate around
  86871. * @param axis the axis to rotate around
  86872. * @param amount the amount to rotate in radians
  86873. * @returns the TransformNode
  86874. */
  86875. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  86876. /**
  86877. * Translates the mesh along the axis vector for the passed distance in the given space.
  86878. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  86879. * @param axis the axis to translate in
  86880. * @param distance the distance to translate
  86881. * @param space Space to rotate in (Default: local)
  86882. * @returns the TransformNode.
  86883. */
  86884. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86885. /**
  86886. * Adds a rotation step to the mesh current rotation.
  86887. * x, y, z are Euler angles expressed in radians.
  86888. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  86889. * This means this rotation is made in the mesh local space only.
  86890. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  86891. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  86892. * ```javascript
  86893. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  86894. * ```
  86895. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  86896. * 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.
  86897. * @param x Rotation to add
  86898. * @param y Rotation to add
  86899. * @param z Rotation to add
  86900. * @returns the TransformNode.
  86901. */
  86902. addRotation(x: number, y: number, z: number): TransformNode;
  86903. /**
  86904. * @hidden
  86905. */
  86906. protected _getEffectiveParent(): Nullable<Node>;
  86907. /**
  86908. * Computes the world matrix of the node
  86909. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86910. * @returns the world matrix
  86911. */
  86912. computeWorldMatrix(force?: boolean): Matrix;
  86913. protected _afterComputeWorldMatrix(): void;
  86914. /**
  86915. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  86916. * @param func callback function to add
  86917. *
  86918. * @returns the TransformNode.
  86919. */
  86920. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  86921. /**
  86922. * Removes a registered callback function.
  86923. * @param func callback function to remove
  86924. * @returns the TransformNode.
  86925. */
  86926. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  86927. /**
  86928. * Gets the position of the current mesh in camera space
  86929. * @param camera defines the camera to use
  86930. * @returns a position
  86931. */
  86932. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  86933. /**
  86934. * Returns the distance from the mesh to the active camera
  86935. * @param camera defines the camera to use
  86936. * @returns the distance
  86937. */
  86938. getDistanceToCamera(camera?: Nullable<Camera>): number;
  86939. /**
  86940. * Clone the current transform node
  86941. * @param name Name of the new clone
  86942. * @param newParent New parent for the clone
  86943. * @param doNotCloneChildren Do not clone children hierarchy
  86944. * @returns the new transform node
  86945. */
  86946. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  86947. /**
  86948. * Serializes the objects information.
  86949. * @param currentSerializationObject defines the object to serialize in
  86950. * @returns the serialized object
  86951. */
  86952. serialize(currentSerializationObject?: any): any;
  86953. /**
  86954. * Returns a new TransformNode object parsed from the source provided.
  86955. * @param parsedTransformNode is the source.
  86956. * @param scene the scne the object belongs to
  86957. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  86958. * @returns a new TransformNode object parsed from the source provided.
  86959. */
  86960. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  86961. /**
  86962. * Get all child-transformNodes of this node
  86963. * @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
  86964. * @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
  86965. * @returns an array of TransformNode
  86966. */
  86967. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  86968. /**
  86969. * Releases resources associated with this transform node.
  86970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86972. */
  86973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86974. /**
  86975. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  86976. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  86977. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  86978. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  86979. * @returns the current mesh
  86980. */
  86981. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  86982. private _syncAbsoluteScalingAndRotation;
  86983. }
  86984. }
  86985. declare module BABYLON {
  86986. /**
  86987. * Defines the types of pose enabled controllers that are supported
  86988. */
  86989. export enum PoseEnabledControllerType {
  86990. /**
  86991. * HTC Vive
  86992. */
  86993. VIVE = 0,
  86994. /**
  86995. * Oculus Rift
  86996. */
  86997. OCULUS = 1,
  86998. /**
  86999. * Windows mixed reality
  87000. */
  87001. WINDOWS = 2,
  87002. /**
  87003. * Samsung gear VR
  87004. */
  87005. GEAR_VR = 3,
  87006. /**
  87007. * Google Daydream
  87008. */
  87009. DAYDREAM = 4,
  87010. /**
  87011. * Generic
  87012. */
  87013. GENERIC = 5
  87014. }
  87015. /**
  87016. * Defines the MutableGamepadButton interface for the state of a gamepad button
  87017. */
  87018. export interface MutableGamepadButton {
  87019. /**
  87020. * Value of the button/trigger
  87021. */
  87022. value: number;
  87023. /**
  87024. * If the button/trigger is currently touched
  87025. */
  87026. touched: boolean;
  87027. /**
  87028. * If the button/trigger is currently pressed
  87029. */
  87030. pressed: boolean;
  87031. }
  87032. /**
  87033. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  87034. * @hidden
  87035. */
  87036. export interface ExtendedGamepadButton extends GamepadButton {
  87037. /**
  87038. * If the button/trigger is currently pressed
  87039. */
  87040. readonly pressed: boolean;
  87041. /**
  87042. * If the button/trigger is currently touched
  87043. */
  87044. readonly touched: boolean;
  87045. /**
  87046. * Value of the button/trigger
  87047. */
  87048. readonly value: number;
  87049. }
  87050. /** @hidden */
  87051. export interface _GamePadFactory {
  87052. /**
  87053. * Returns wether or not the current gamepad can be created for this type of controller.
  87054. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  87055. * @returns true if it can be created, otherwise false
  87056. */
  87057. canCreate(gamepadInfo: any): boolean;
  87058. /**
  87059. * Creates a new instance of the Gamepad.
  87060. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  87061. * @returns the new gamepad instance
  87062. */
  87063. create(gamepadInfo: any): Gamepad;
  87064. }
  87065. /**
  87066. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87067. */
  87068. export class PoseEnabledControllerHelper {
  87069. /** @hidden */
  87070. static _ControllerFactories: _GamePadFactory[];
  87071. /** @hidden */
  87072. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  87073. /**
  87074. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87075. * @param vrGamepad the gamepad to initialized
  87076. * @returns a vr controller of the type the gamepad identified as
  87077. */
  87078. static InitiateController(vrGamepad: any): Gamepad;
  87079. }
  87080. /**
  87081. * Defines the PoseEnabledController object that contains state of a vr capable controller
  87082. */
  87083. export class PoseEnabledController extends Gamepad implements PoseControlled {
  87084. /**
  87085. * If the controller is used in a webXR session
  87086. */
  87087. isXR: boolean;
  87088. private _deviceRoomPosition;
  87089. private _deviceRoomRotationQuaternion;
  87090. /**
  87091. * The device position in babylon space
  87092. */
  87093. devicePosition: Vector3;
  87094. /**
  87095. * The device rotation in babylon space
  87096. */
  87097. deviceRotationQuaternion: Quaternion;
  87098. /**
  87099. * The scale factor of the device in babylon space
  87100. */
  87101. deviceScaleFactor: number;
  87102. /**
  87103. * (Likely devicePosition should be used instead) The device position in its room space
  87104. */
  87105. position: Vector3;
  87106. /**
  87107. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  87108. */
  87109. rotationQuaternion: Quaternion;
  87110. /**
  87111. * The type of controller (Eg. Windows mixed reality)
  87112. */
  87113. controllerType: PoseEnabledControllerType;
  87114. protected _calculatedPosition: Vector3;
  87115. private _calculatedRotation;
  87116. /**
  87117. * The raw pose from the device
  87118. */
  87119. rawPose: DevicePose;
  87120. private _trackPosition;
  87121. private _maxRotationDistFromHeadset;
  87122. private _draggedRoomRotation;
  87123. /**
  87124. * @hidden
  87125. */
  87126. _disableTrackPosition(fixedPosition: Vector3): void;
  87127. /**
  87128. * Internal, the mesh attached to the controller
  87129. * @hidden
  87130. */
  87131. _mesh: Nullable<AbstractMesh>;
  87132. private _poseControlledCamera;
  87133. private _leftHandSystemQuaternion;
  87134. /**
  87135. * Internal, matrix used to convert room space to babylon space
  87136. * @hidden
  87137. */
  87138. _deviceToWorld: Matrix;
  87139. /**
  87140. * Node to be used when casting a ray from the controller
  87141. * @hidden
  87142. */
  87143. _pointingPoseNode: Nullable<TransformNode>;
  87144. /**
  87145. * Name of the child mesh that can be used to cast a ray from the controller
  87146. */
  87147. static readonly POINTING_POSE: string;
  87148. /**
  87149. * Creates a new PoseEnabledController from a gamepad
  87150. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  87151. */
  87152. constructor(browserGamepad: any);
  87153. private _workingMatrix;
  87154. /**
  87155. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  87156. */
  87157. update(): void;
  87158. /**
  87159. * Updates only the pose device and mesh without doing any button event checking
  87160. */
  87161. protected _updatePoseAndMesh(): void;
  87162. /**
  87163. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  87164. * @param poseData raw pose fromthe device
  87165. */
  87166. updateFromDevice(poseData: DevicePose): void;
  87167. /**
  87168. * @hidden
  87169. */
  87170. _meshAttachedObservable: Observable<AbstractMesh>;
  87171. /**
  87172. * Attaches a mesh to the controller
  87173. * @param mesh the mesh to be attached
  87174. */
  87175. attachToMesh(mesh: AbstractMesh): void;
  87176. /**
  87177. * Attaches the controllers mesh to a camera
  87178. * @param camera the camera the mesh should be attached to
  87179. */
  87180. attachToPoseControlledCamera(camera: TargetCamera): void;
  87181. /**
  87182. * Disposes of the controller
  87183. */
  87184. dispose(): void;
  87185. /**
  87186. * The mesh that is attached to the controller
  87187. */
  87188. get mesh(): Nullable<AbstractMesh>;
  87189. /**
  87190. * Gets the ray of the controller in the direction the controller is pointing
  87191. * @param length the length the resulting ray should be
  87192. * @returns a ray in the direction the controller is pointing
  87193. */
  87194. getForwardRay(length?: number): Ray;
  87195. }
  87196. }
  87197. declare module BABYLON {
  87198. /**
  87199. * Defines the WebVRController object that represents controllers tracked in 3D space
  87200. */
  87201. export abstract class WebVRController extends PoseEnabledController {
  87202. /**
  87203. * Internal, the default controller model for the controller
  87204. */
  87205. protected _defaultModel: Nullable<AbstractMesh>;
  87206. /**
  87207. * Fired when the trigger state has changed
  87208. */
  87209. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  87210. /**
  87211. * Fired when the main button state has changed
  87212. */
  87213. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87214. /**
  87215. * Fired when the secondary button state has changed
  87216. */
  87217. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87218. /**
  87219. * Fired when the pad state has changed
  87220. */
  87221. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  87222. /**
  87223. * Fired when controllers stick values have changed
  87224. */
  87225. onPadValuesChangedObservable: Observable<StickValues>;
  87226. /**
  87227. * Array of button availible on the controller
  87228. */
  87229. protected _buttons: Array<MutableGamepadButton>;
  87230. private _onButtonStateChange;
  87231. /**
  87232. * Fired when a controller button's state has changed
  87233. * @param callback the callback containing the button that was modified
  87234. */
  87235. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  87236. /**
  87237. * X and Y axis corresponding to the controllers joystick
  87238. */
  87239. pad: StickValues;
  87240. /**
  87241. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  87242. */
  87243. hand: string;
  87244. /**
  87245. * The default controller model for the controller
  87246. */
  87247. get defaultModel(): Nullable<AbstractMesh>;
  87248. /**
  87249. * Creates a new WebVRController from a gamepad
  87250. * @param vrGamepad the gamepad that the WebVRController should be created from
  87251. */
  87252. constructor(vrGamepad: any);
  87253. /**
  87254. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  87255. */
  87256. update(): void;
  87257. /**
  87258. * Function to be called when a button is modified
  87259. */
  87260. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  87261. /**
  87262. * Loads a mesh and attaches it to the controller
  87263. * @param scene the scene the mesh should be added to
  87264. * @param meshLoaded callback for when the mesh has been loaded
  87265. */
  87266. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  87267. private _setButtonValue;
  87268. private _changes;
  87269. private _checkChanges;
  87270. /**
  87271. * Disposes of th webVRCOntroller
  87272. */
  87273. dispose(): void;
  87274. }
  87275. }
  87276. declare module BABYLON {
  87277. /**
  87278. * The HemisphericLight simulates the ambient environment light,
  87279. * so the passed direction is the light reflection direction, not the incoming direction.
  87280. */
  87281. export class HemisphericLight extends Light {
  87282. /**
  87283. * The groundColor is the light in the opposite direction to the one specified during creation.
  87284. * 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.
  87285. */
  87286. groundColor: Color3;
  87287. /**
  87288. * The light reflection direction, not the incoming direction.
  87289. */
  87290. direction: Vector3;
  87291. /**
  87292. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  87293. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  87294. * The HemisphericLight can't cast shadows.
  87295. * Documentation : https://doc.babylonjs.com/babylon101/lights
  87296. * @param name The friendly name of the light
  87297. * @param direction The direction of the light reflection
  87298. * @param scene The scene the light belongs to
  87299. */
  87300. constructor(name: string, direction: Vector3, scene: Scene);
  87301. protected _buildUniformLayout(): void;
  87302. /**
  87303. * Returns the string "HemisphericLight".
  87304. * @return The class name
  87305. */
  87306. getClassName(): string;
  87307. /**
  87308. * Sets the HemisphericLight direction towards the passed target (Vector3).
  87309. * Returns the updated direction.
  87310. * @param target The target the direction should point to
  87311. * @return The computed direction
  87312. */
  87313. setDirectionToTarget(target: Vector3): Vector3;
  87314. /**
  87315. * Returns the shadow generator associated to the light.
  87316. * @returns Always null for hemispheric lights because it does not support shadows.
  87317. */
  87318. getShadowGenerator(): Nullable<IShadowGenerator>;
  87319. /**
  87320. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  87321. * @param effect The effect to update
  87322. * @param lightIndex The index of the light in the effect to update
  87323. * @returns The hemispheric light
  87324. */
  87325. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  87326. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  87327. /**
  87328. * Computes the world matrix of the node
  87329. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87330. * @param useWasUpdatedFlag defines a reserved property
  87331. * @returns the world matrix
  87332. */
  87333. computeWorldMatrix(): Matrix;
  87334. /**
  87335. * Returns the integer 3.
  87336. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  87337. */
  87338. getTypeID(): number;
  87339. /**
  87340. * Prepares the list of defines specific to the light type.
  87341. * @param defines the list of defines
  87342. * @param lightIndex defines the index of the light for the effect
  87343. */
  87344. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  87345. }
  87346. }
  87347. declare module BABYLON {
  87348. /** @hidden */
  87349. export var vrMultiviewToSingleviewPixelShader: {
  87350. name: string;
  87351. shader: string;
  87352. };
  87353. }
  87354. declare module BABYLON {
  87355. /**
  87356. * Renders to multiple views with a single draw call
  87357. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  87358. */
  87359. export class MultiviewRenderTarget extends RenderTargetTexture {
  87360. /**
  87361. * Creates a multiview render target
  87362. * @param scene scene used with the render target
  87363. * @param size the size of the render target (used for each view)
  87364. */
  87365. constructor(scene: Scene, size?: number | {
  87366. width: number;
  87367. height: number;
  87368. } | {
  87369. ratio: number;
  87370. });
  87371. /**
  87372. * @hidden
  87373. * @param faceIndex the face index, if its a cube texture
  87374. */
  87375. _bindFrameBuffer(faceIndex?: number): void;
  87376. /**
  87377. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87378. * @returns the view count
  87379. */
  87380. getViewCount(): number;
  87381. }
  87382. }
  87383. declare module BABYLON {
  87384. /**
  87385. * Represents a camera frustum
  87386. */
  87387. export class Frustum {
  87388. /**
  87389. * Gets the planes representing the frustum
  87390. * @param transform matrix to be applied to the returned planes
  87391. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87392. */
  87393. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87394. /**
  87395. * Gets the near frustum plane transformed by the transform matrix
  87396. * @param transform transformation matrix to be applied to the resulting frustum plane
  87397. * @param frustumPlane the resuling frustum plane
  87398. */
  87399. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87400. /**
  87401. * Gets the far frustum plane transformed by the transform matrix
  87402. * @param transform transformation matrix to be applied to the resulting frustum plane
  87403. * @param frustumPlane the resuling frustum plane
  87404. */
  87405. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87406. /**
  87407. * Gets the left frustum plane transformed by the transform matrix
  87408. * @param transform transformation matrix to be applied to the resulting frustum plane
  87409. * @param frustumPlane the resuling frustum plane
  87410. */
  87411. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87412. /**
  87413. * Gets the right frustum plane transformed by the transform matrix
  87414. * @param transform transformation matrix to be applied to the resulting frustum plane
  87415. * @param frustumPlane the resuling frustum plane
  87416. */
  87417. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87418. /**
  87419. * Gets the top frustum plane transformed by the transform matrix
  87420. * @param transform transformation matrix to be applied to the resulting frustum plane
  87421. * @param frustumPlane the resuling frustum plane
  87422. */
  87423. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87424. /**
  87425. * Gets the bottom frustum plane transformed by the transform matrix
  87426. * @param transform transformation matrix to be applied to the resulting frustum plane
  87427. * @param frustumPlane the resuling frustum plane
  87428. */
  87429. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87430. /**
  87431. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87432. * @param transform transformation matrix to be applied to the resulting frustum planes
  87433. * @param frustumPlanes the resuling frustum planes
  87434. */
  87435. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87436. }
  87437. }
  87438. declare module BABYLON {
  87439. interface Engine {
  87440. /**
  87441. * Creates a new multiview render target
  87442. * @param width defines the width of the texture
  87443. * @param height defines the height of the texture
  87444. * @returns the created multiview texture
  87445. */
  87446. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  87447. /**
  87448. * Binds a multiview framebuffer to be drawn to
  87449. * @param multiviewTexture texture to bind
  87450. */
  87451. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  87452. }
  87453. interface Camera {
  87454. /**
  87455. * @hidden
  87456. * 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)
  87457. */
  87458. _useMultiviewToSingleView: boolean;
  87459. /**
  87460. * @hidden
  87461. * 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)
  87462. */
  87463. _multiviewTexture: Nullable<RenderTargetTexture>;
  87464. /**
  87465. * @hidden
  87466. * ensures the multiview texture of the camera exists and has the specified width/height
  87467. * @param width height to set on the multiview texture
  87468. * @param height width to set on the multiview texture
  87469. */
  87470. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  87471. }
  87472. interface Scene {
  87473. /** @hidden */
  87474. _transformMatrixR: Matrix;
  87475. /** @hidden */
  87476. _multiviewSceneUbo: Nullable<UniformBuffer>;
  87477. /** @hidden */
  87478. _createMultiviewUbo(): void;
  87479. /** @hidden */
  87480. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  87481. /** @hidden */
  87482. _renderMultiviewToSingleView(camera: Camera): void;
  87483. }
  87484. }
  87485. declare module BABYLON {
  87486. /**
  87487. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  87488. * This will not be used for webXR as it supports displaying texture arrays directly
  87489. */
  87490. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  87491. /**
  87492. * Initializes a VRMultiviewToSingleview
  87493. * @param name name of the post process
  87494. * @param camera camera to be applied to
  87495. * @param scaleFactor scaling factor to the size of the output texture
  87496. */
  87497. constructor(name: string, camera: Camera, scaleFactor: number);
  87498. }
  87499. }
  87500. declare module BABYLON {
  87501. /**
  87502. * Interface used to define additional presentation attributes
  87503. */
  87504. export interface IVRPresentationAttributes {
  87505. /**
  87506. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  87507. */
  87508. highRefreshRate: boolean;
  87509. /**
  87510. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  87511. */
  87512. foveationLevel: number;
  87513. }
  87514. interface Engine {
  87515. /** @hidden */
  87516. _vrDisplay: any;
  87517. /** @hidden */
  87518. _vrSupported: boolean;
  87519. /** @hidden */
  87520. _oldSize: Size;
  87521. /** @hidden */
  87522. _oldHardwareScaleFactor: number;
  87523. /** @hidden */
  87524. _vrExclusivePointerMode: boolean;
  87525. /** @hidden */
  87526. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  87527. /** @hidden */
  87528. _onVRDisplayPointerRestricted: () => void;
  87529. /** @hidden */
  87530. _onVRDisplayPointerUnrestricted: () => void;
  87531. /** @hidden */
  87532. _onVrDisplayConnect: Nullable<(display: any) => void>;
  87533. /** @hidden */
  87534. _onVrDisplayDisconnect: Nullable<() => void>;
  87535. /** @hidden */
  87536. _onVrDisplayPresentChange: Nullable<() => void>;
  87537. /**
  87538. * Observable signaled when VR display mode changes
  87539. */
  87540. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  87541. /**
  87542. * Observable signaled when VR request present is complete
  87543. */
  87544. onVRRequestPresentComplete: Observable<boolean>;
  87545. /**
  87546. * Observable signaled when VR request present starts
  87547. */
  87548. onVRRequestPresentStart: Observable<Engine>;
  87549. /**
  87550. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  87551. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  87552. */
  87553. isInVRExclusivePointerMode: boolean;
  87554. /**
  87555. * Gets a boolean indicating if a webVR device was detected
  87556. * @returns true if a webVR device was detected
  87557. */
  87558. isVRDevicePresent(): boolean;
  87559. /**
  87560. * Gets the current webVR device
  87561. * @returns the current webVR device (or null)
  87562. */
  87563. getVRDevice(): any;
  87564. /**
  87565. * Initializes a webVR display and starts listening to display change events
  87566. * The onVRDisplayChangedObservable will be notified upon these changes
  87567. * @returns A promise containing a VRDisplay and if vr is supported
  87568. */
  87569. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87570. /** @hidden */
  87571. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  87572. /**
  87573. * Gets or sets the presentation attributes used to configure VR rendering
  87574. */
  87575. vrPresentationAttributes?: IVRPresentationAttributes;
  87576. /**
  87577. * Call this function to switch to webVR mode
  87578. * Will do nothing if webVR is not supported or if there is no webVR device
  87579. * @param options the webvr options provided to the camera. mainly used for multiview
  87580. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87581. */
  87582. enableVR(options: WebVROptions): void;
  87583. /** @hidden */
  87584. _onVRFullScreenTriggered(): void;
  87585. }
  87586. }
  87587. declare module BABYLON {
  87588. /**
  87589. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  87590. * IMPORTANT!! The data is right-hand data.
  87591. * @export
  87592. * @interface DevicePose
  87593. */
  87594. export interface DevicePose {
  87595. /**
  87596. * The position of the device, values in array are [x,y,z].
  87597. */
  87598. readonly position: Nullable<Float32Array>;
  87599. /**
  87600. * The linearVelocity of the device, values in array are [x,y,z].
  87601. */
  87602. readonly linearVelocity: Nullable<Float32Array>;
  87603. /**
  87604. * The linearAcceleration of the device, values in array are [x,y,z].
  87605. */
  87606. readonly linearAcceleration: Nullable<Float32Array>;
  87607. /**
  87608. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  87609. */
  87610. readonly orientation: Nullable<Float32Array>;
  87611. /**
  87612. * The angularVelocity of the device, values in array are [x,y,z].
  87613. */
  87614. readonly angularVelocity: Nullable<Float32Array>;
  87615. /**
  87616. * The angularAcceleration of the device, values in array are [x,y,z].
  87617. */
  87618. readonly angularAcceleration: Nullable<Float32Array>;
  87619. }
  87620. /**
  87621. * Interface representing a pose controlled object in Babylon.
  87622. * A pose controlled object has both regular pose values as well as pose values
  87623. * from an external device such as a VR head mounted display
  87624. */
  87625. export interface PoseControlled {
  87626. /**
  87627. * The position of the object in babylon space.
  87628. */
  87629. position: Vector3;
  87630. /**
  87631. * The rotation quaternion of the object in babylon space.
  87632. */
  87633. rotationQuaternion: Quaternion;
  87634. /**
  87635. * The position of the device in babylon space.
  87636. */
  87637. devicePosition?: Vector3;
  87638. /**
  87639. * The rotation quaternion of the device in babylon space.
  87640. */
  87641. deviceRotationQuaternion: Quaternion;
  87642. /**
  87643. * The raw pose coming from the device.
  87644. */
  87645. rawPose: Nullable<DevicePose>;
  87646. /**
  87647. * The scale of the device to be used when translating from device space to babylon space.
  87648. */
  87649. deviceScaleFactor: number;
  87650. /**
  87651. * Updates the poseControlled values based on the input device pose.
  87652. * @param poseData the pose data to update the object with
  87653. */
  87654. updateFromDevice(poseData: DevicePose): void;
  87655. }
  87656. /**
  87657. * Set of options to customize the webVRCamera
  87658. */
  87659. export interface WebVROptions {
  87660. /**
  87661. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  87662. */
  87663. trackPosition?: boolean;
  87664. /**
  87665. * Sets the scale of the vrDevice in babylon space. (default: 1)
  87666. */
  87667. positionScale?: number;
  87668. /**
  87669. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  87670. */
  87671. displayName?: string;
  87672. /**
  87673. * Should the native controller meshes be initialized. (default: true)
  87674. */
  87675. controllerMeshes?: boolean;
  87676. /**
  87677. * Creating a default HemiLight only on controllers. (default: true)
  87678. */
  87679. defaultLightingOnControllers?: boolean;
  87680. /**
  87681. * If you don't want to use the default VR button of the helper. (default: false)
  87682. */
  87683. useCustomVRButton?: boolean;
  87684. /**
  87685. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  87686. */
  87687. customVRButton?: HTMLButtonElement;
  87688. /**
  87689. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  87690. */
  87691. rayLength?: number;
  87692. /**
  87693. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  87694. */
  87695. defaultHeight?: number;
  87696. /**
  87697. * If multiview should be used if availible (default: false)
  87698. */
  87699. useMultiview?: boolean;
  87700. }
  87701. /**
  87702. * This represents a WebVR camera.
  87703. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  87704. * @example http://doc.babylonjs.com/how_to/webvr_camera
  87705. */
  87706. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  87707. private webVROptions;
  87708. /**
  87709. * @hidden
  87710. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  87711. */
  87712. _vrDevice: any;
  87713. /**
  87714. * The rawPose of the vrDevice.
  87715. */
  87716. rawPose: Nullable<DevicePose>;
  87717. private _onVREnabled;
  87718. private _specsVersion;
  87719. private _attached;
  87720. private _frameData;
  87721. protected _descendants: Array<Node>;
  87722. private _deviceRoomPosition;
  87723. /** @hidden */
  87724. _deviceRoomRotationQuaternion: Quaternion;
  87725. private _standingMatrix;
  87726. /**
  87727. * Represents device position in babylon space.
  87728. */
  87729. devicePosition: Vector3;
  87730. /**
  87731. * Represents device rotation in babylon space.
  87732. */
  87733. deviceRotationQuaternion: Quaternion;
  87734. /**
  87735. * The scale of the device to be used when translating from device space to babylon space.
  87736. */
  87737. deviceScaleFactor: number;
  87738. private _deviceToWorld;
  87739. private _worldToDevice;
  87740. /**
  87741. * References to the webVR controllers for the vrDevice.
  87742. */
  87743. controllers: Array<WebVRController>;
  87744. /**
  87745. * Emits an event when a controller is attached.
  87746. */
  87747. onControllersAttachedObservable: Observable<WebVRController[]>;
  87748. /**
  87749. * Emits an event when a controller's mesh has been loaded;
  87750. */
  87751. onControllerMeshLoadedObservable: Observable<WebVRController>;
  87752. /**
  87753. * Emits an event when the HMD's pose has been updated.
  87754. */
  87755. onPoseUpdatedFromDeviceObservable: Observable<any>;
  87756. private _poseSet;
  87757. /**
  87758. * If the rig cameras be used as parent instead of this camera.
  87759. */
  87760. rigParenting: boolean;
  87761. private _lightOnControllers;
  87762. private _defaultHeight?;
  87763. /**
  87764. * Instantiates a WebVRFreeCamera.
  87765. * @param name The name of the WebVRFreeCamera
  87766. * @param position The starting anchor position for the camera
  87767. * @param scene The scene the camera belongs to
  87768. * @param webVROptions a set of customizable options for the webVRCamera
  87769. */
  87770. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  87771. /**
  87772. * Gets the device distance from the ground in meters.
  87773. * @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.
  87774. */
  87775. deviceDistanceToRoomGround(): number;
  87776. /**
  87777. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  87778. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  87779. */
  87780. useStandingMatrix(callback?: (bool: boolean) => void): void;
  87781. /**
  87782. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  87783. * @returns A promise with a boolean set to if the standing matrix is supported.
  87784. */
  87785. useStandingMatrixAsync(): Promise<boolean>;
  87786. /**
  87787. * Disposes the camera
  87788. */
  87789. dispose(): void;
  87790. /**
  87791. * Gets a vrController by name.
  87792. * @param name The name of the controller to retreive
  87793. * @returns the controller matching the name specified or null if not found
  87794. */
  87795. getControllerByName(name: string): Nullable<WebVRController>;
  87796. private _leftController;
  87797. /**
  87798. * The controller corresponding to the users left hand.
  87799. */
  87800. get leftController(): Nullable<WebVRController>;
  87801. private _rightController;
  87802. /**
  87803. * The controller corresponding to the users right hand.
  87804. */
  87805. get rightController(): Nullable<WebVRController>;
  87806. /**
  87807. * Casts a ray forward from the vrCamera's gaze.
  87808. * @param length Length of the ray (default: 100)
  87809. * @returns the ray corresponding to the gaze
  87810. */
  87811. getForwardRay(length?: number): Ray;
  87812. /**
  87813. * @hidden
  87814. * Updates the camera based on device's frame data
  87815. */
  87816. _checkInputs(): void;
  87817. /**
  87818. * Updates the poseControlled values based on the input device pose.
  87819. * @param poseData Pose coming from the device
  87820. */
  87821. updateFromDevice(poseData: DevicePose): void;
  87822. private _htmlElementAttached;
  87823. private _detachIfAttached;
  87824. /**
  87825. * WebVR's attach control will start broadcasting frames to the device.
  87826. * Note that in certain browsers (chrome for example) this function must be called
  87827. * within a user-interaction callback. Example:
  87828. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  87829. *
  87830. * @param element html element to attach the vrDevice to
  87831. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  87832. */
  87833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87834. /**
  87835. * Detaches the camera from the html element and disables VR
  87836. *
  87837. * @param element html element to detach from
  87838. */
  87839. detachControl(element: HTMLElement): void;
  87840. /**
  87841. * @returns the name of this class
  87842. */
  87843. getClassName(): string;
  87844. /**
  87845. * Calls resetPose on the vrDisplay
  87846. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  87847. */
  87848. resetToCurrentRotation(): void;
  87849. /**
  87850. * @hidden
  87851. * Updates the rig cameras (left and right eye)
  87852. */
  87853. _updateRigCameras(): void;
  87854. private _workingVector;
  87855. private _oneVector;
  87856. private _workingMatrix;
  87857. private updateCacheCalled;
  87858. private _correctPositionIfNotTrackPosition;
  87859. /**
  87860. * @hidden
  87861. * Updates the cached values of the camera
  87862. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  87863. */
  87864. _updateCache(ignoreParentClass?: boolean): void;
  87865. /**
  87866. * @hidden
  87867. * Get current device position in babylon world
  87868. */
  87869. _computeDevicePosition(): void;
  87870. /**
  87871. * Updates the current device position and rotation in the babylon world
  87872. */
  87873. update(): void;
  87874. /**
  87875. * @hidden
  87876. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  87877. * @returns an identity matrix
  87878. */
  87879. _getViewMatrix(): Matrix;
  87880. private _tmpMatrix;
  87881. /**
  87882. * This function is called by the two RIG cameras.
  87883. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  87884. * @hidden
  87885. */
  87886. _getWebVRViewMatrix(): Matrix;
  87887. /** @hidden */
  87888. _getWebVRProjectionMatrix(): Matrix;
  87889. private _onGamepadConnectedObserver;
  87890. private _onGamepadDisconnectedObserver;
  87891. private _updateCacheWhenTrackingDisabledObserver;
  87892. /**
  87893. * Initializes the controllers and their meshes
  87894. */
  87895. initControllers(): void;
  87896. }
  87897. }
  87898. declare module BABYLON {
  87899. /**
  87900. * Size options for a post process
  87901. */
  87902. export type PostProcessOptions = {
  87903. width: number;
  87904. height: number;
  87905. };
  87906. /**
  87907. * PostProcess can be used to apply a shader to a texture after it has been rendered
  87908. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  87909. */
  87910. export class PostProcess {
  87911. /** Name of the PostProcess. */
  87912. name: string;
  87913. /**
  87914. * Gets or sets the unique id of the post process
  87915. */
  87916. uniqueId: number;
  87917. /**
  87918. * Width of the texture to apply the post process on
  87919. */
  87920. width: number;
  87921. /**
  87922. * Height of the texture to apply the post process on
  87923. */
  87924. height: number;
  87925. /**
  87926. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  87927. * @hidden
  87928. */
  87929. _outputTexture: Nullable<InternalTexture>;
  87930. /**
  87931. * Sampling mode used by the shader
  87932. * See https://doc.babylonjs.com/classes/3.1/texture
  87933. */
  87934. renderTargetSamplingMode: number;
  87935. /**
  87936. * Clear color to use when screen clearing
  87937. */
  87938. clearColor: Color4;
  87939. /**
  87940. * If the buffer needs to be cleared before applying the post process. (default: true)
  87941. * Should be set to false if shader will overwrite all previous pixels.
  87942. */
  87943. autoClear: boolean;
  87944. /**
  87945. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  87946. */
  87947. alphaMode: number;
  87948. /**
  87949. * Sets the setAlphaBlendConstants of the babylon engine
  87950. */
  87951. alphaConstants: Color4;
  87952. /**
  87953. * Animations to be used for the post processing
  87954. */
  87955. animations: Animation[];
  87956. /**
  87957. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  87958. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  87959. */
  87960. enablePixelPerfectMode: boolean;
  87961. /**
  87962. * Force the postprocess to be applied without taking in account viewport
  87963. */
  87964. forceFullscreenViewport: boolean;
  87965. /**
  87966. * List of inspectable custom properties (used by the Inspector)
  87967. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87968. */
  87969. inspectableCustomProperties: IInspectable[];
  87970. /**
  87971. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  87972. *
  87973. * | Value | Type | Description |
  87974. * | ----- | ----------------------------------- | ----------- |
  87975. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  87976. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  87977. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  87978. *
  87979. */
  87980. scaleMode: number;
  87981. /**
  87982. * Force textures to be a power of two (default: false)
  87983. */
  87984. alwaysForcePOT: boolean;
  87985. private _samples;
  87986. /**
  87987. * Number of sample textures (default: 1)
  87988. */
  87989. get samples(): number;
  87990. set samples(n: number);
  87991. /**
  87992. * Modify the scale of the post process to be the same as the viewport (default: false)
  87993. */
  87994. adaptScaleToCurrentViewport: boolean;
  87995. private _camera;
  87996. private _scene;
  87997. private _engine;
  87998. private _options;
  87999. private _reusable;
  88000. private _textureType;
  88001. private _textureFormat;
  88002. /**
  88003. * Smart array of input and output textures for the post process.
  88004. * @hidden
  88005. */
  88006. _textures: SmartArray<InternalTexture>;
  88007. /**
  88008. * The index in _textures that corresponds to the output texture.
  88009. * @hidden
  88010. */
  88011. _currentRenderTextureInd: number;
  88012. private _effect;
  88013. private _samplers;
  88014. private _fragmentUrl;
  88015. private _vertexUrl;
  88016. private _parameters;
  88017. private _scaleRatio;
  88018. protected _indexParameters: any;
  88019. private _shareOutputWithPostProcess;
  88020. private _texelSize;
  88021. private _forcedOutputTexture;
  88022. /**
  88023. * Returns the fragment url or shader name used in the post process.
  88024. * @returns the fragment url or name in the shader store.
  88025. */
  88026. getEffectName(): string;
  88027. /**
  88028. * An event triggered when the postprocess is activated.
  88029. */
  88030. onActivateObservable: Observable<Camera>;
  88031. private _onActivateObserver;
  88032. /**
  88033. * A function that is added to the onActivateObservable
  88034. */
  88035. set onActivate(callback: Nullable<(camera: Camera) => void>);
  88036. /**
  88037. * An event triggered when the postprocess changes its size.
  88038. */
  88039. onSizeChangedObservable: Observable<PostProcess>;
  88040. private _onSizeChangedObserver;
  88041. /**
  88042. * A function that is added to the onSizeChangedObservable
  88043. */
  88044. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  88045. /**
  88046. * An event triggered when the postprocess applies its effect.
  88047. */
  88048. onApplyObservable: Observable<Effect>;
  88049. private _onApplyObserver;
  88050. /**
  88051. * A function that is added to the onApplyObservable
  88052. */
  88053. set onApply(callback: (effect: Effect) => void);
  88054. /**
  88055. * An event triggered before rendering the postprocess
  88056. */
  88057. onBeforeRenderObservable: Observable<Effect>;
  88058. private _onBeforeRenderObserver;
  88059. /**
  88060. * A function that is added to the onBeforeRenderObservable
  88061. */
  88062. set onBeforeRender(callback: (effect: Effect) => void);
  88063. /**
  88064. * An event triggered after rendering the postprocess
  88065. */
  88066. onAfterRenderObservable: Observable<Effect>;
  88067. private _onAfterRenderObserver;
  88068. /**
  88069. * A function that is added to the onAfterRenderObservable
  88070. */
  88071. set onAfterRender(callback: (efect: Effect) => void);
  88072. /**
  88073. * 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
  88074. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  88075. */
  88076. get inputTexture(): InternalTexture;
  88077. set inputTexture(value: InternalTexture);
  88078. /**
  88079. * Gets the camera which post process is applied to.
  88080. * @returns The camera the post process is applied to.
  88081. */
  88082. getCamera(): Camera;
  88083. /**
  88084. * Gets the texel size of the postprocess.
  88085. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  88086. */
  88087. get texelSize(): Vector2;
  88088. /**
  88089. * Creates a new instance PostProcess
  88090. * @param name The name of the PostProcess.
  88091. * @param fragmentUrl The url of the fragment shader to be used.
  88092. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  88093. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  88094. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88095. * @param camera The camera to apply the render pass to.
  88096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88097. * @param engine The engine which the post process will be applied. (default: current engine)
  88098. * @param reusable If the post process can be reused on the same frame. (default: false)
  88099. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  88100. * @param textureType Type of textures used when performing the post process. (default: 0)
  88101. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  88102. * @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
  88103. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  88104. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  88105. */
  88106. constructor(
  88107. /** Name of the PostProcess. */
  88108. 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);
  88109. /**
  88110. * Gets a string idenfifying the name of the class
  88111. * @returns "PostProcess" string
  88112. */
  88113. getClassName(): string;
  88114. /**
  88115. * Gets the engine which this post process belongs to.
  88116. * @returns The engine the post process was enabled with.
  88117. */
  88118. getEngine(): Engine;
  88119. /**
  88120. * The effect that is created when initializing the post process.
  88121. * @returns The created effect corresponding the the postprocess.
  88122. */
  88123. getEffect(): Effect;
  88124. /**
  88125. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  88126. * @param postProcess The post process to share the output with.
  88127. * @returns This post process.
  88128. */
  88129. shareOutputWith(postProcess: PostProcess): PostProcess;
  88130. /**
  88131. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  88132. * This should be called if the post process that shares output with this post process is disabled/disposed.
  88133. */
  88134. useOwnOutput(): void;
  88135. /**
  88136. * Updates the effect with the current post process compile time values and recompiles the shader.
  88137. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88138. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88139. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88140. * @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
  88141. * @param onCompiled Called when the shader has been compiled.
  88142. * @param onError Called if there is an error when compiling a shader.
  88143. */
  88144. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88145. /**
  88146. * The post process is reusable if it can be used multiple times within one frame.
  88147. * @returns If the post process is reusable
  88148. */
  88149. isReusable(): boolean;
  88150. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  88151. markTextureDirty(): void;
  88152. /**
  88153. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  88154. * 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.
  88155. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  88156. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  88157. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  88158. * @returns The target texture that was bound to be written to.
  88159. */
  88160. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  88161. /**
  88162. * If the post process is supported.
  88163. */
  88164. get isSupported(): boolean;
  88165. /**
  88166. * The aspect ratio of the output texture.
  88167. */
  88168. get aspectRatio(): number;
  88169. /**
  88170. * Get a value indicating if the post-process is ready to be used
  88171. * @returns true if the post-process is ready (shader is compiled)
  88172. */
  88173. isReady(): boolean;
  88174. /**
  88175. * Binds all textures and uniforms to the shader, this will be run on every pass.
  88176. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  88177. */
  88178. apply(): Nullable<Effect>;
  88179. private _disposeTextures;
  88180. /**
  88181. * Disposes the post process.
  88182. * @param camera The camera to dispose the post process on.
  88183. */
  88184. dispose(camera?: Camera): void;
  88185. }
  88186. }
  88187. declare module BABYLON {
  88188. /** @hidden */
  88189. export var kernelBlurVaryingDeclaration: {
  88190. name: string;
  88191. shader: string;
  88192. };
  88193. }
  88194. declare module BABYLON {
  88195. /** @hidden */
  88196. export var kernelBlurFragment: {
  88197. name: string;
  88198. shader: string;
  88199. };
  88200. }
  88201. declare module BABYLON {
  88202. /** @hidden */
  88203. export var kernelBlurFragment2: {
  88204. name: string;
  88205. shader: string;
  88206. };
  88207. }
  88208. declare module BABYLON {
  88209. /** @hidden */
  88210. export var kernelBlurPixelShader: {
  88211. name: string;
  88212. shader: string;
  88213. };
  88214. }
  88215. declare module BABYLON {
  88216. /** @hidden */
  88217. export var kernelBlurVertex: {
  88218. name: string;
  88219. shader: string;
  88220. };
  88221. }
  88222. declare module BABYLON {
  88223. /** @hidden */
  88224. export var kernelBlurVertexShader: {
  88225. name: string;
  88226. shader: string;
  88227. };
  88228. }
  88229. declare module BABYLON {
  88230. /**
  88231. * The Blur Post Process which blurs an image based on a kernel and direction.
  88232. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  88233. */
  88234. export class BlurPostProcess extends PostProcess {
  88235. /** The direction in which to blur the image. */
  88236. direction: Vector2;
  88237. private blockCompilation;
  88238. protected _kernel: number;
  88239. protected _idealKernel: number;
  88240. protected _packedFloat: boolean;
  88241. private _staticDefines;
  88242. /**
  88243. * Sets the length in pixels of the blur sample region
  88244. */
  88245. set kernel(v: number);
  88246. /**
  88247. * Gets the length in pixels of the blur sample region
  88248. */
  88249. get kernel(): number;
  88250. /**
  88251. * Sets wether or not the blur needs to unpack/repack floats
  88252. */
  88253. set packedFloat(v: boolean);
  88254. /**
  88255. * Gets wether or not the blur is unpacking/repacking floats
  88256. */
  88257. get packedFloat(): boolean;
  88258. /**
  88259. * Creates a new instance BlurPostProcess
  88260. * @param name The name of the effect.
  88261. * @param direction The direction in which to blur the image.
  88262. * @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.
  88263. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88264. * @param camera The camera to apply the render pass to.
  88265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88266. * @param engine The engine which the post process will be applied. (default: current engine)
  88267. * @param reusable If the post process can be reused on the same frame. (default: false)
  88268. * @param textureType Type of textures used when performing the post process. (default: 0)
  88269. * @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)
  88270. */
  88271. constructor(name: string,
  88272. /** The direction in which to blur the image. */
  88273. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  88274. /**
  88275. * Updates the effect with the current post process compile time values and recompiles the shader.
  88276. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88277. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88278. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88279. * @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
  88280. * @param onCompiled Called when the shader has been compiled.
  88281. * @param onError Called if there is an error when compiling a shader.
  88282. */
  88283. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88284. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88285. /**
  88286. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  88287. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  88288. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  88289. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  88290. * The gaps between physical kernels are compensated for in the weighting of the samples
  88291. * @param idealKernel Ideal blur kernel.
  88292. * @return Nearest best kernel.
  88293. */
  88294. protected _nearestBestKernel(idealKernel: number): number;
  88295. /**
  88296. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  88297. * @param x The point on the Gaussian distribution to sample.
  88298. * @return the value of the Gaussian function at x.
  88299. */
  88300. protected _gaussianWeight(x: number): number;
  88301. /**
  88302. * Generates a string that can be used as a floating point number in GLSL.
  88303. * @param x Value to print.
  88304. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  88305. * @return GLSL float string.
  88306. */
  88307. protected _glslFloat(x: number, decimalFigures?: number): string;
  88308. }
  88309. }
  88310. declare module BABYLON {
  88311. /**
  88312. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88313. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88314. * You can then easily use it as a reflectionTexture on a flat surface.
  88315. * In case the surface is not a plane, please consider relying on reflection probes.
  88316. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88317. */
  88318. export class MirrorTexture extends RenderTargetTexture {
  88319. private scene;
  88320. /**
  88321. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  88322. * 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.
  88323. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88324. */
  88325. mirrorPlane: Plane;
  88326. /**
  88327. * Define the blur ratio used to blur the reflection if needed.
  88328. */
  88329. set blurRatio(value: number);
  88330. get blurRatio(): number;
  88331. /**
  88332. * Define the adaptive blur kernel used to blur the reflection if needed.
  88333. * This will autocompute the closest best match for the `blurKernel`
  88334. */
  88335. set adaptiveBlurKernel(value: number);
  88336. /**
  88337. * Define the blur kernel used to blur the reflection if needed.
  88338. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88339. */
  88340. set blurKernel(value: number);
  88341. /**
  88342. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  88343. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88344. */
  88345. set blurKernelX(value: number);
  88346. get blurKernelX(): number;
  88347. /**
  88348. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  88349. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88350. */
  88351. set blurKernelY(value: number);
  88352. get blurKernelY(): number;
  88353. private _autoComputeBlurKernel;
  88354. protected _onRatioRescale(): void;
  88355. private _updateGammaSpace;
  88356. private _imageProcessingConfigChangeObserver;
  88357. private _transformMatrix;
  88358. private _mirrorMatrix;
  88359. private _savedViewMatrix;
  88360. private _blurX;
  88361. private _blurY;
  88362. private _adaptiveBlurKernel;
  88363. private _blurKernelX;
  88364. private _blurKernelY;
  88365. private _blurRatio;
  88366. /**
  88367. * Instantiates a Mirror Texture.
  88368. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88369. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88370. * You can then easily use it as a reflectionTexture on a flat surface.
  88371. * In case the surface is not a plane, please consider relying on reflection probes.
  88372. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88373. * @param name
  88374. * @param size
  88375. * @param scene
  88376. * @param generateMipMaps
  88377. * @param type
  88378. * @param samplingMode
  88379. * @param generateDepthBuffer
  88380. */
  88381. constructor(name: string, size: number | {
  88382. width: number;
  88383. height: number;
  88384. } | {
  88385. ratio: number;
  88386. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  88387. private _preparePostProcesses;
  88388. /**
  88389. * Clone the mirror texture.
  88390. * @returns the cloned texture
  88391. */
  88392. clone(): MirrorTexture;
  88393. /**
  88394. * Serialize the texture to a JSON representation you could use in Parse later on
  88395. * @returns the serialized JSON representation
  88396. */
  88397. serialize(): any;
  88398. /**
  88399. * Dispose the texture and release its associated resources.
  88400. */
  88401. dispose(): void;
  88402. }
  88403. }
  88404. declare module BABYLON {
  88405. /**
  88406. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88407. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88408. */
  88409. export class Texture extends BaseTexture {
  88410. /**
  88411. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  88412. */
  88413. static SerializeBuffers: boolean;
  88414. /** @hidden */
  88415. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  88416. /** @hidden */
  88417. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  88418. /** @hidden */
  88419. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  88420. /** nearest is mag = nearest and min = nearest and mip = linear */
  88421. static readonly NEAREST_SAMPLINGMODE: number;
  88422. /** nearest is mag = nearest and min = nearest and mip = linear */
  88423. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  88424. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88425. static readonly BILINEAR_SAMPLINGMODE: number;
  88426. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88427. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  88428. /** Trilinear is mag = linear and min = linear and mip = linear */
  88429. static readonly TRILINEAR_SAMPLINGMODE: number;
  88430. /** Trilinear is mag = linear and min = linear and mip = linear */
  88431. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  88432. /** mag = nearest and min = nearest and mip = nearest */
  88433. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  88434. /** mag = nearest and min = linear and mip = nearest */
  88435. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  88436. /** mag = nearest and min = linear and mip = linear */
  88437. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  88438. /** mag = nearest and min = linear and mip = none */
  88439. static readonly NEAREST_LINEAR: number;
  88440. /** mag = nearest and min = nearest and mip = none */
  88441. static readonly NEAREST_NEAREST: number;
  88442. /** mag = linear and min = nearest and mip = nearest */
  88443. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  88444. /** mag = linear and min = nearest and mip = linear */
  88445. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  88446. /** mag = linear and min = linear and mip = none */
  88447. static readonly LINEAR_LINEAR: number;
  88448. /** mag = linear and min = nearest and mip = none */
  88449. static readonly LINEAR_NEAREST: number;
  88450. /** Explicit coordinates mode */
  88451. static readonly EXPLICIT_MODE: number;
  88452. /** Spherical coordinates mode */
  88453. static readonly SPHERICAL_MODE: number;
  88454. /** Planar coordinates mode */
  88455. static readonly PLANAR_MODE: number;
  88456. /** Cubic coordinates mode */
  88457. static readonly CUBIC_MODE: number;
  88458. /** Projection coordinates mode */
  88459. static readonly PROJECTION_MODE: number;
  88460. /** Inverse Cubic coordinates mode */
  88461. static readonly SKYBOX_MODE: number;
  88462. /** Inverse Cubic coordinates mode */
  88463. static readonly INVCUBIC_MODE: number;
  88464. /** Equirectangular coordinates mode */
  88465. static readonly EQUIRECTANGULAR_MODE: number;
  88466. /** Equirectangular Fixed coordinates mode */
  88467. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  88468. /** Equirectangular Fixed Mirrored coordinates mode */
  88469. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  88470. /** Texture is not repeating outside of 0..1 UVs */
  88471. static readonly CLAMP_ADDRESSMODE: number;
  88472. /** Texture is repeating outside of 0..1 UVs */
  88473. static readonly WRAP_ADDRESSMODE: number;
  88474. /** Texture is repeating and mirrored */
  88475. static readonly MIRROR_ADDRESSMODE: number;
  88476. /**
  88477. * 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
  88478. */
  88479. static UseSerializedUrlIfAny: boolean;
  88480. /**
  88481. * Define the url of the texture.
  88482. */
  88483. url: Nullable<string>;
  88484. /**
  88485. * Define an offset on the texture to offset the u coordinates of the UVs
  88486. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88487. */
  88488. uOffset: number;
  88489. /**
  88490. * Define an offset on the texture to offset the v coordinates of the UVs
  88491. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88492. */
  88493. vOffset: number;
  88494. /**
  88495. * Define an offset on the texture to scale the u coordinates of the UVs
  88496. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88497. */
  88498. uScale: number;
  88499. /**
  88500. * Define an offset on the texture to scale the v coordinates of the UVs
  88501. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88502. */
  88503. vScale: number;
  88504. /**
  88505. * Define an offset on the texture to rotate around the u coordinates of the UVs
  88506. * @see http://doc.babylonjs.com/how_to/more_materials
  88507. */
  88508. uAng: number;
  88509. /**
  88510. * Define an offset on the texture to rotate around the v coordinates of the UVs
  88511. * @see http://doc.babylonjs.com/how_to/more_materials
  88512. */
  88513. vAng: number;
  88514. /**
  88515. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  88516. * @see http://doc.babylonjs.com/how_to/more_materials
  88517. */
  88518. wAng: number;
  88519. /**
  88520. * Defines the center of rotation (U)
  88521. */
  88522. uRotationCenter: number;
  88523. /**
  88524. * Defines the center of rotation (V)
  88525. */
  88526. vRotationCenter: number;
  88527. /**
  88528. * Defines the center of rotation (W)
  88529. */
  88530. wRotationCenter: number;
  88531. /**
  88532. * Are mip maps generated for this texture or not.
  88533. */
  88534. get noMipmap(): boolean;
  88535. /**
  88536. * List of inspectable custom properties (used by the Inspector)
  88537. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88538. */
  88539. inspectableCustomProperties: Nullable<IInspectable[]>;
  88540. private _noMipmap;
  88541. /** @hidden */
  88542. _invertY: boolean;
  88543. private _rowGenerationMatrix;
  88544. private _cachedTextureMatrix;
  88545. private _projectionModeMatrix;
  88546. private _t0;
  88547. private _t1;
  88548. private _t2;
  88549. private _cachedUOffset;
  88550. private _cachedVOffset;
  88551. private _cachedUScale;
  88552. private _cachedVScale;
  88553. private _cachedUAng;
  88554. private _cachedVAng;
  88555. private _cachedWAng;
  88556. private _cachedProjectionMatrixId;
  88557. private _cachedCoordinatesMode;
  88558. /** @hidden */
  88559. protected _initialSamplingMode: number;
  88560. /** @hidden */
  88561. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  88562. private _deleteBuffer;
  88563. protected _format: Nullable<number>;
  88564. private _delayedOnLoad;
  88565. private _delayedOnError;
  88566. private _mimeType?;
  88567. /**
  88568. * Observable triggered once the texture has been loaded.
  88569. */
  88570. onLoadObservable: Observable<Texture>;
  88571. protected _isBlocking: boolean;
  88572. /**
  88573. * Is the texture preventing material to render while loading.
  88574. * If false, a default texture will be used instead of the loading one during the preparation step.
  88575. */
  88576. set isBlocking(value: boolean);
  88577. get isBlocking(): boolean;
  88578. /**
  88579. * Get the current sampling mode associated with the texture.
  88580. */
  88581. get samplingMode(): number;
  88582. /**
  88583. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  88584. */
  88585. get invertY(): boolean;
  88586. /**
  88587. * Instantiates a new texture.
  88588. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88589. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88590. * @param url defines the url of the picture to load as a texture
  88591. * @param scene defines the scene or engine the texture will belong to
  88592. * @param noMipmap defines if the texture will require mip maps or not
  88593. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  88594. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88595. * @param onLoad defines a callback triggered when the texture has been loaded
  88596. * @param onError defines a callback triggered when an error occurred during the loading session
  88597. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  88598. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  88599. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88600. * @param mimeType defines an optional mime type information
  88601. */
  88602. 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);
  88603. /**
  88604. * Update the url (and optional buffer) of this texture if url was null during construction.
  88605. * @param url the url of the texture
  88606. * @param buffer the buffer of the texture (defaults to null)
  88607. * @param onLoad callback called when the texture is loaded (defaults to null)
  88608. */
  88609. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  88610. /**
  88611. * Finish the loading sequence of a texture flagged as delayed load.
  88612. * @hidden
  88613. */
  88614. delayLoad(): void;
  88615. private _prepareRowForTextureGeneration;
  88616. /**
  88617. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  88618. * @returns the transform matrix of the texture.
  88619. */
  88620. getTextureMatrix(uBase?: number): Matrix;
  88621. /**
  88622. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  88623. * @returns The reflection texture transform
  88624. */
  88625. getReflectionTextureMatrix(): Matrix;
  88626. /**
  88627. * Clones the texture.
  88628. * @returns the cloned texture
  88629. */
  88630. clone(): Texture;
  88631. /**
  88632. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88633. * @returns The JSON representation of the texture
  88634. */
  88635. serialize(): any;
  88636. /**
  88637. * Get the current class name of the texture useful for serialization or dynamic coding.
  88638. * @returns "Texture"
  88639. */
  88640. getClassName(): string;
  88641. /**
  88642. * Dispose the texture and release its associated resources.
  88643. */
  88644. dispose(): void;
  88645. /**
  88646. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  88647. * @param parsedTexture Define the JSON representation of the texture
  88648. * @param scene Define the scene the parsed texture should be instantiated in
  88649. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  88650. * @returns The parsed texture if successful
  88651. */
  88652. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  88653. /**
  88654. * Creates a texture from its base 64 representation.
  88655. * @param data Define the base64 payload without the data: prefix
  88656. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  88657. * @param scene Define the scene the texture should belong to
  88658. * @param noMipmap Forces the texture to not create mip map information if true
  88659. * @param invertY define if the texture needs to be inverted on the y axis during loading
  88660. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88661. * @param onLoad define a callback triggered when the texture has been loaded
  88662. * @param onError define a callback triggered when an error occurred during the loading session
  88663. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88664. * @returns the created texture
  88665. */
  88666. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  88667. /**
  88668. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  88669. * @param data Define the base64 payload without the data: prefix
  88670. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  88671. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  88672. * @param scene Define the scene the texture should belong to
  88673. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  88674. * @param noMipmap Forces the texture to not create mip map information if true
  88675. * @param invertY define if the texture needs to be inverted on the y axis during loading
  88676. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88677. * @param onLoad define a callback triggered when the texture has been loaded
  88678. * @param onError define a callback triggered when an error occurred during the loading session
  88679. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88680. * @returns the created texture
  88681. */
  88682. 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;
  88683. }
  88684. }
  88685. declare module BABYLON {
  88686. /**
  88687. * PostProcessManager is used to manage one or more post processes or post process pipelines
  88688. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  88689. */
  88690. export class PostProcessManager {
  88691. private _scene;
  88692. private _indexBuffer;
  88693. private _vertexBuffers;
  88694. /**
  88695. * Creates a new instance PostProcess
  88696. * @param scene The scene that the post process is associated with.
  88697. */
  88698. constructor(scene: Scene);
  88699. private _prepareBuffers;
  88700. private _buildIndexBuffer;
  88701. /**
  88702. * Rebuilds the vertex buffers of the manager.
  88703. * @hidden
  88704. */
  88705. _rebuild(): void;
  88706. /**
  88707. * Prepares a frame to be run through a post process.
  88708. * @param sourceTexture The input texture to the post procesess. (default: null)
  88709. * @param postProcesses An array of post processes to be run. (default: null)
  88710. * @returns True if the post processes were able to be run.
  88711. * @hidden
  88712. */
  88713. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  88714. /**
  88715. * Manually render a set of post processes to a texture.
  88716. * @param postProcesses An array of post processes to be run.
  88717. * @param targetTexture The target texture to render to.
  88718. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  88719. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  88720. * @param lodLevel defines which lod of the texture to render to
  88721. */
  88722. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  88723. /**
  88724. * Finalize the result of the output of the postprocesses.
  88725. * @param doNotPresent If true the result will not be displayed to the screen.
  88726. * @param targetTexture The target texture to render to.
  88727. * @param faceIndex The index of the face to bind the target texture to.
  88728. * @param postProcesses The array of post processes to render.
  88729. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  88730. * @hidden
  88731. */
  88732. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  88733. /**
  88734. * Disposes of the post process manager.
  88735. */
  88736. dispose(): void;
  88737. }
  88738. }
  88739. declare module BABYLON {
  88740. /** Interface used by value gradients (color, factor, ...) */
  88741. export interface IValueGradient {
  88742. /**
  88743. * Gets or sets the gradient value (between 0 and 1)
  88744. */
  88745. gradient: number;
  88746. }
  88747. /** Class used to store color4 gradient */
  88748. export class ColorGradient implements IValueGradient {
  88749. /**
  88750. * Gets or sets the gradient value (between 0 and 1)
  88751. */
  88752. gradient: number;
  88753. /**
  88754. * Gets or sets first associated color
  88755. */
  88756. color1: Color4;
  88757. /**
  88758. * Gets or sets second associated color
  88759. */
  88760. color2?: Color4;
  88761. /**
  88762. * Will get a color picked randomly between color1 and color2.
  88763. * If color2 is undefined then color1 will be used
  88764. * @param result defines the target Color4 to store the result in
  88765. */
  88766. getColorToRef(result: Color4): void;
  88767. }
  88768. /** Class used to store color 3 gradient */
  88769. export class Color3Gradient implements IValueGradient {
  88770. /**
  88771. * Gets or sets the gradient value (between 0 and 1)
  88772. */
  88773. gradient: number;
  88774. /**
  88775. * Gets or sets the associated color
  88776. */
  88777. color: Color3;
  88778. }
  88779. /** Class used to store factor gradient */
  88780. export class FactorGradient implements IValueGradient {
  88781. /**
  88782. * Gets or sets the gradient value (between 0 and 1)
  88783. */
  88784. gradient: number;
  88785. /**
  88786. * Gets or sets first associated factor
  88787. */
  88788. factor1: number;
  88789. /**
  88790. * Gets or sets second associated factor
  88791. */
  88792. factor2?: number;
  88793. /**
  88794. * Will get a number picked randomly between factor1 and factor2.
  88795. * If factor2 is undefined then factor1 will be used
  88796. * @returns the picked number
  88797. */
  88798. getFactor(): number;
  88799. }
  88800. /**
  88801. * Helper used to simplify some generic gradient tasks
  88802. */
  88803. export class GradientHelper {
  88804. /**
  88805. * Gets the current gradient from an array of IValueGradient
  88806. * @param ratio defines the current ratio to get
  88807. * @param gradients defines the array of IValueGradient
  88808. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88809. */
  88810. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88811. }
  88812. }
  88813. declare module BABYLON {
  88814. interface ThinEngine {
  88815. /**
  88816. * Creates a dynamic texture
  88817. * @param width defines the width of the texture
  88818. * @param height defines the height of the texture
  88819. * @param generateMipMaps defines if the engine should generate the mip levels
  88820. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88821. * @returns the dynamic texture inside an InternalTexture
  88822. */
  88823. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88824. /**
  88825. * Update the content of a dynamic texture
  88826. * @param texture defines the texture to update
  88827. * @param canvas defines the canvas containing the source
  88828. * @param invertY defines if data must be stored with Y axis inverted
  88829. * @param premulAlpha defines if alpha is stored as premultiplied
  88830. * @param format defines the format of the data
  88831. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88832. */
  88833. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88834. }
  88835. }
  88836. declare module BABYLON {
  88837. /**
  88838. * Helper class used to generate a canvas to manipulate images
  88839. */
  88840. export class CanvasGenerator {
  88841. /**
  88842. * Create a new canvas (or offscreen canvas depending on the context)
  88843. * @param width defines the expected width
  88844. * @param height defines the expected height
  88845. * @return a new canvas or offscreen canvas
  88846. */
  88847. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88848. }
  88849. }
  88850. declare module BABYLON {
  88851. /**
  88852. * A class extending Texture allowing drawing on a texture
  88853. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88854. */
  88855. export class DynamicTexture extends Texture {
  88856. private _generateMipMaps;
  88857. private _canvas;
  88858. private _context;
  88859. private _engine;
  88860. /**
  88861. * Creates a DynamicTexture
  88862. * @param name defines the name of the texture
  88863. * @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
  88864. * @param scene defines the scene where you want the texture
  88865. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88866. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88867. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88868. */
  88869. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88870. /**
  88871. * Get the current class name of the texture useful for serialization or dynamic coding.
  88872. * @returns "DynamicTexture"
  88873. */
  88874. getClassName(): string;
  88875. /**
  88876. * Gets the current state of canRescale
  88877. */
  88878. get canRescale(): boolean;
  88879. private _recreate;
  88880. /**
  88881. * Scales the texture
  88882. * @param ratio the scale factor to apply to both width and height
  88883. */
  88884. scale(ratio: number): void;
  88885. /**
  88886. * Resizes the texture
  88887. * @param width the new width
  88888. * @param height the new height
  88889. */
  88890. scaleTo(width: number, height: number): void;
  88891. /**
  88892. * Gets the context of the canvas used by the texture
  88893. * @returns the canvas context of the dynamic texture
  88894. */
  88895. getContext(): CanvasRenderingContext2D;
  88896. /**
  88897. * Clears the texture
  88898. */
  88899. clear(): void;
  88900. /**
  88901. * Updates the texture
  88902. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88903. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88904. */
  88905. update(invertY?: boolean, premulAlpha?: boolean): void;
  88906. /**
  88907. * Draws text onto the texture
  88908. * @param text defines the text to be drawn
  88909. * @param x defines the placement of the text from the left
  88910. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88911. * @param font defines the font to be used with font-style, font-size, font-name
  88912. * @param color defines the color used for the text
  88913. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88914. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88915. * @param update defines whether texture is immediately update (default is true)
  88916. */
  88917. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  88918. /**
  88919. * Clones the texture
  88920. * @returns the clone of the texture.
  88921. */
  88922. clone(): DynamicTexture;
  88923. /**
  88924. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88925. * @returns a serialized dynamic texture object
  88926. */
  88927. serialize(): any;
  88928. /** @hidden */
  88929. _rebuild(): void;
  88930. }
  88931. }
  88932. declare module BABYLON {
  88933. interface AbstractScene {
  88934. /**
  88935. * The list of procedural textures added to the scene
  88936. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88937. */
  88938. proceduralTextures: Array<ProceduralTexture>;
  88939. }
  88940. /**
  88941. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  88942. * in a given scene.
  88943. */
  88944. export class ProceduralTextureSceneComponent implements ISceneComponent {
  88945. /**
  88946. * The component name helpfull to identify the component in the list of scene components.
  88947. */
  88948. readonly name: string;
  88949. /**
  88950. * The scene the component belongs to.
  88951. */
  88952. scene: Scene;
  88953. /**
  88954. * Creates a new instance of the component for the given scene
  88955. * @param scene Defines the scene to register the component in
  88956. */
  88957. constructor(scene: Scene);
  88958. /**
  88959. * Registers the component in a given scene
  88960. */
  88961. register(): void;
  88962. /**
  88963. * Rebuilds the elements related to this component in case of
  88964. * context lost for instance.
  88965. */
  88966. rebuild(): void;
  88967. /**
  88968. * Disposes the component and the associated ressources.
  88969. */
  88970. dispose(): void;
  88971. private _beforeClear;
  88972. }
  88973. }
  88974. declare module BABYLON {
  88975. interface ThinEngine {
  88976. /**
  88977. * Creates a new render target cube texture
  88978. * @param size defines the size of the texture
  88979. * @param options defines the options used to create the texture
  88980. * @returns a new render target cube texture stored in an InternalTexture
  88981. */
  88982. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  88983. }
  88984. }
  88985. declare module BABYLON {
  88986. /** @hidden */
  88987. export var proceduralVertexShader: {
  88988. name: string;
  88989. shader: string;
  88990. };
  88991. }
  88992. declare module BABYLON {
  88993. /**
  88994. * 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.
  88995. * This is the base class of any Procedural texture and contains most of the shareable code.
  88996. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88997. */
  88998. export class ProceduralTexture extends Texture {
  88999. isCube: boolean;
  89000. /**
  89001. * Define if the texture is enabled or not (disabled texture will not render)
  89002. */
  89003. isEnabled: boolean;
  89004. /**
  89005. * Define if the texture must be cleared before rendering (default is true)
  89006. */
  89007. autoClear: boolean;
  89008. /**
  89009. * Callback called when the texture is generated
  89010. */
  89011. onGenerated: () => void;
  89012. /**
  89013. * Event raised when the texture is generated
  89014. */
  89015. onGeneratedObservable: Observable<ProceduralTexture>;
  89016. /** @hidden */
  89017. _generateMipMaps: boolean;
  89018. /** @hidden **/
  89019. _effect: Effect;
  89020. /** @hidden */
  89021. _textures: {
  89022. [key: string]: Texture;
  89023. };
  89024. private _size;
  89025. private _currentRefreshId;
  89026. private _frameId;
  89027. private _refreshRate;
  89028. private _vertexBuffers;
  89029. private _indexBuffer;
  89030. private _uniforms;
  89031. private _samplers;
  89032. private _fragment;
  89033. private _floats;
  89034. private _ints;
  89035. private _floatsArrays;
  89036. private _colors3;
  89037. private _colors4;
  89038. private _vectors2;
  89039. private _vectors3;
  89040. private _matrices;
  89041. private _fallbackTexture;
  89042. private _fallbackTextureUsed;
  89043. private _engine;
  89044. private _cachedDefines;
  89045. private _contentUpdateId;
  89046. private _contentData;
  89047. /**
  89048. * Instantiates a new procedural texture.
  89049. * 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.
  89050. * This is the base class of any Procedural texture and contains most of the shareable code.
  89051. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89052. * @param name Define the name of the texture
  89053. * @param size Define the size of the texture to create
  89054. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89055. * @param scene Define the scene the texture belongs to
  89056. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89057. * @param generateMipMaps Define if the texture should creates mip maps or not
  89058. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89059. */
  89060. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89061. /**
  89062. * The effect that is created when initializing the post process.
  89063. * @returns The created effect corresponding the the postprocess.
  89064. */
  89065. getEffect(): Effect;
  89066. /**
  89067. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89068. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89069. */
  89070. getContent(): Nullable<ArrayBufferView>;
  89071. private _createIndexBuffer;
  89072. /** @hidden */
  89073. _rebuild(): void;
  89074. /**
  89075. * Resets the texture in order to recreate its associated resources.
  89076. * This can be called in case of context loss
  89077. */
  89078. reset(): void;
  89079. protected _getDefines(): string;
  89080. /**
  89081. * Is the texture ready to be used ? (rendered at least once)
  89082. * @returns true if ready, otherwise, false.
  89083. */
  89084. isReady(): boolean;
  89085. /**
  89086. * Resets the refresh counter of the texture and start bak from scratch.
  89087. * Could be useful to regenerate the texture if it is setup to render only once.
  89088. */
  89089. resetRefreshCounter(): void;
  89090. /**
  89091. * Set the fragment shader to use in order to render the texture.
  89092. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89093. */
  89094. setFragment(fragment: any): void;
  89095. /**
  89096. * Define the refresh rate of the texture or the rendering frequency.
  89097. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89098. */
  89099. get refreshRate(): number;
  89100. set refreshRate(value: number);
  89101. /** @hidden */
  89102. _shouldRender(): boolean;
  89103. /**
  89104. * Get the size the texture is rendering at.
  89105. * @returns the size (texture is always squared)
  89106. */
  89107. getRenderSize(): number;
  89108. /**
  89109. * Resize the texture to new value.
  89110. * @param size Define the new size the texture should have
  89111. * @param generateMipMaps Define whether the new texture should create mip maps
  89112. */
  89113. resize(size: number, generateMipMaps: boolean): void;
  89114. private _checkUniform;
  89115. /**
  89116. * Set a texture in the shader program used to render.
  89117. * @param name Define the name of the uniform samplers as defined in the shader
  89118. * @param texture Define the texture to bind to this sampler
  89119. * @return the texture itself allowing "fluent" like uniform updates
  89120. */
  89121. setTexture(name: string, texture: Texture): ProceduralTexture;
  89122. /**
  89123. * Set a float in the shader.
  89124. * @param name Define the name of the uniform as defined in the shader
  89125. * @param value Define the value to give to the uniform
  89126. * @return the texture itself allowing "fluent" like uniform updates
  89127. */
  89128. setFloat(name: string, value: number): ProceduralTexture;
  89129. /**
  89130. * Set a int in the shader.
  89131. * @param name Define the name of the uniform as defined in the shader
  89132. * @param value Define the value to give to the uniform
  89133. * @return the texture itself allowing "fluent" like uniform updates
  89134. */
  89135. setInt(name: string, value: number): ProceduralTexture;
  89136. /**
  89137. * Set an array of floats in the shader.
  89138. * @param name Define the name of the uniform as defined in the shader
  89139. * @param value Define the value to give to the uniform
  89140. * @return the texture itself allowing "fluent" like uniform updates
  89141. */
  89142. setFloats(name: string, value: number[]): ProceduralTexture;
  89143. /**
  89144. * Set a vec3 in the shader from a Color3.
  89145. * @param name Define the name of the uniform as defined in the shader
  89146. * @param value Define the value to give to the uniform
  89147. * @return the texture itself allowing "fluent" like uniform updates
  89148. */
  89149. setColor3(name: string, value: Color3): ProceduralTexture;
  89150. /**
  89151. * Set a vec4 in the shader from a Color4.
  89152. * @param name Define the name of the uniform as defined in the shader
  89153. * @param value Define the value to give to the uniform
  89154. * @return the texture itself allowing "fluent" like uniform updates
  89155. */
  89156. setColor4(name: string, value: Color4): ProceduralTexture;
  89157. /**
  89158. * Set a vec2 in the shader from a Vector2.
  89159. * @param name Define the name of the uniform as defined in the shader
  89160. * @param value Define the value to give to the uniform
  89161. * @return the texture itself allowing "fluent" like uniform updates
  89162. */
  89163. setVector2(name: string, value: Vector2): ProceduralTexture;
  89164. /**
  89165. * Set a vec3 in the shader from a Vector3.
  89166. * @param name Define the name of the uniform as defined in the shader
  89167. * @param value Define the value to give to the uniform
  89168. * @return the texture itself allowing "fluent" like uniform updates
  89169. */
  89170. setVector3(name: string, value: Vector3): ProceduralTexture;
  89171. /**
  89172. * Set a mat4 in the shader from a MAtrix.
  89173. * @param name Define the name of the uniform as defined in the shader
  89174. * @param value Define the value to give to the uniform
  89175. * @return the texture itself allowing "fluent" like uniform updates
  89176. */
  89177. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89178. /**
  89179. * Render the texture to its associated render target.
  89180. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89181. */
  89182. render(useCameraPostProcess?: boolean): void;
  89183. /**
  89184. * Clone the texture.
  89185. * @returns the cloned texture
  89186. */
  89187. clone(): ProceduralTexture;
  89188. /**
  89189. * Dispose the texture and release its asoociated resources.
  89190. */
  89191. dispose(): void;
  89192. }
  89193. }
  89194. declare module BABYLON {
  89195. /**
  89196. * This represents the base class for particle system in Babylon.
  89197. * 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.
  89198. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89199. * @example https://doc.babylonjs.com/babylon101/particles
  89200. */
  89201. export class BaseParticleSystem {
  89202. /**
  89203. * Source color is added to the destination color without alpha affecting the result
  89204. */
  89205. static BLENDMODE_ONEONE: number;
  89206. /**
  89207. * Blend current color and particle color using particle’s alpha
  89208. */
  89209. static BLENDMODE_STANDARD: number;
  89210. /**
  89211. * Add current color and particle color multiplied by particle’s alpha
  89212. */
  89213. static BLENDMODE_ADD: number;
  89214. /**
  89215. * Multiply current color with particle color
  89216. */
  89217. static BLENDMODE_MULTIPLY: number;
  89218. /**
  89219. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89220. */
  89221. static BLENDMODE_MULTIPLYADD: number;
  89222. /**
  89223. * List of animations used by the particle system.
  89224. */
  89225. animations: Animation[];
  89226. /**
  89227. * The id of the Particle system.
  89228. */
  89229. id: string;
  89230. /**
  89231. * The friendly name of the Particle system.
  89232. */
  89233. name: string;
  89234. /**
  89235. * The rendering group used by the Particle system to chose when to render.
  89236. */
  89237. renderingGroupId: number;
  89238. /**
  89239. * The emitter represents the Mesh or position we are attaching the particle system to.
  89240. */
  89241. emitter: Nullable<AbstractMesh | Vector3>;
  89242. /**
  89243. * The maximum number of particles to emit per frame
  89244. */
  89245. emitRate: number;
  89246. /**
  89247. * If you want to launch only a few particles at once, that can be done, as well.
  89248. */
  89249. manualEmitCount: number;
  89250. /**
  89251. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89252. */
  89253. updateSpeed: number;
  89254. /**
  89255. * The amount of time the particle system is running (depends of the overall update speed).
  89256. */
  89257. targetStopDuration: number;
  89258. /**
  89259. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89260. */
  89261. disposeOnStop: boolean;
  89262. /**
  89263. * Minimum power of emitting particles.
  89264. */
  89265. minEmitPower: number;
  89266. /**
  89267. * Maximum power of emitting particles.
  89268. */
  89269. maxEmitPower: number;
  89270. /**
  89271. * Minimum life time of emitting particles.
  89272. */
  89273. minLifeTime: number;
  89274. /**
  89275. * Maximum life time of emitting particles.
  89276. */
  89277. maxLifeTime: number;
  89278. /**
  89279. * Minimum Size of emitting particles.
  89280. */
  89281. minSize: number;
  89282. /**
  89283. * Maximum Size of emitting particles.
  89284. */
  89285. maxSize: number;
  89286. /**
  89287. * Minimum scale of emitting particles on X axis.
  89288. */
  89289. minScaleX: number;
  89290. /**
  89291. * Maximum scale of emitting particles on X axis.
  89292. */
  89293. maxScaleX: number;
  89294. /**
  89295. * Minimum scale of emitting particles on Y axis.
  89296. */
  89297. minScaleY: number;
  89298. /**
  89299. * Maximum scale of emitting particles on Y axis.
  89300. */
  89301. maxScaleY: number;
  89302. /**
  89303. * Gets or sets the minimal initial rotation in radians.
  89304. */
  89305. minInitialRotation: number;
  89306. /**
  89307. * Gets or sets the maximal initial rotation in radians.
  89308. */
  89309. maxInitialRotation: number;
  89310. /**
  89311. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89312. */
  89313. minAngularSpeed: number;
  89314. /**
  89315. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89316. */
  89317. maxAngularSpeed: number;
  89318. /**
  89319. * The texture used to render each particle. (this can be a spritesheet)
  89320. */
  89321. particleTexture: Nullable<Texture>;
  89322. /**
  89323. * The layer mask we are rendering the particles through.
  89324. */
  89325. layerMask: number;
  89326. /**
  89327. * This can help using your own shader to render the particle system.
  89328. * The according effect will be created
  89329. */
  89330. customShader: any;
  89331. /**
  89332. * By default particle system starts as soon as they are created. This prevents the
  89333. * automatic start to happen and let you decide when to start emitting particles.
  89334. */
  89335. preventAutoStart: boolean;
  89336. private _noiseTexture;
  89337. /**
  89338. * Gets or sets a texture used to add random noise to particle positions
  89339. */
  89340. get noiseTexture(): Nullable<ProceduralTexture>;
  89341. set noiseTexture(value: Nullable<ProceduralTexture>);
  89342. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89343. noiseStrength: Vector3;
  89344. /**
  89345. * Callback triggered when the particle animation is ending.
  89346. */
  89347. onAnimationEnd: Nullable<() => void>;
  89348. /**
  89349. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89350. */
  89351. blendMode: number;
  89352. /**
  89353. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89354. * to override the particles.
  89355. */
  89356. forceDepthWrite: boolean;
  89357. /** 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 */
  89358. preWarmCycles: number;
  89359. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89360. preWarmStepOffset: number;
  89361. /**
  89362. * 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)
  89363. */
  89364. spriteCellChangeSpeed: number;
  89365. /**
  89366. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89367. */
  89368. startSpriteCellID: number;
  89369. /**
  89370. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89371. */
  89372. endSpriteCellID: number;
  89373. /**
  89374. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89375. */
  89376. spriteCellWidth: number;
  89377. /**
  89378. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89379. */
  89380. spriteCellHeight: number;
  89381. /**
  89382. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89383. */
  89384. spriteRandomStartCell: boolean;
  89385. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89386. translationPivot: Vector2;
  89387. /** @hidden */
  89388. protected _isAnimationSheetEnabled: boolean;
  89389. /**
  89390. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89391. */
  89392. beginAnimationOnStart: boolean;
  89393. /**
  89394. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89395. */
  89396. beginAnimationFrom: number;
  89397. /**
  89398. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89399. */
  89400. beginAnimationTo: number;
  89401. /**
  89402. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89403. */
  89404. beginAnimationLoop: boolean;
  89405. /**
  89406. * Gets or sets a world offset applied to all particles
  89407. */
  89408. worldOffset: Vector3;
  89409. /**
  89410. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89411. */
  89412. get isAnimationSheetEnabled(): boolean;
  89413. set isAnimationSheetEnabled(value: boolean);
  89414. /**
  89415. * Get hosting scene
  89416. * @returns the scene
  89417. */
  89418. getScene(): Scene;
  89419. /**
  89420. * You can use gravity if you want to give an orientation to your particles.
  89421. */
  89422. gravity: Vector3;
  89423. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89424. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89425. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89426. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89427. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89428. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89429. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89430. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89431. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89432. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89433. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89434. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89435. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89436. /**
  89437. * Defines the delay in milliseconds before starting the system (0 by default)
  89438. */
  89439. startDelay: number;
  89440. /**
  89441. * Gets the current list of drag gradients.
  89442. * You must use addDragGradient and removeDragGradient to udpate this list
  89443. * @returns the list of drag gradients
  89444. */
  89445. getDragGradients(): Nullable<Array<FactorGradient>>;
  89446. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89447. limitVelocityDamping: number;
  89448. /**
  89449. * Gets the current list of limit velocity gradients.
  89450. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89451. * @returns the list of limit velocity gradients
  89452. */
  89453. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89454. /**
  89455. * Gets the current list of color gradients.
  89456. * You must use addColorGradient and removeColorGradient to udpate this list
  89457. * @returns the list of color gradients
  89458. */
  89459. getColorGradients(): Nullable<Array<ColorGradient>>;
  89460. /**
  89461. * Gets the current list of size gradients.
  89462. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89463. * @returns the list of size gradients
  89464. */
  89465. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89466. /**
  89467. * Gets the current list of color remap gradients.
  89468. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89469. * @returns the list of color remap gradients
  89470. */
  89471. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89472. /**
  89473. * Gets the current list of alpha remap gradients.
  89474. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89475. * @returns the list of alpha remap gradients
  89476. */
  89477. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89478. /**
  89479. * Gets the current list of life time gradients.
  89480. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89481. * @returns the list of life time gradients
  89482. */
  89483. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89484. /**
  89485. * Gets the current list of angular speed gradients.
  89486. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89487. * @returns the list of angular speed gradients
  89488. */
  89489. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89490. /**
  89491. * Gets the current list of velocity gradients.
  89492. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89493. * @returns the list of velocity gradients
  89494. */
  89495. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89496. /**
  89497. * Gets the current list of start size gradients.
  89498. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89499. * @returns the list of start size gradients
  89500. */
  89501. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89502. /**
  89503. * Gets the current list of emit rate gradients.
  89504. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89505. * @returns the list of emit rate gradients
  89506. */
  89507. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89508. /**
  89509. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89510. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89511. */
  89512. get direction1(): Vector3;
  89513. set direction1(value: Vector3);
  89514. /**
  89515. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89516. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89517. */
  89518. get direction2(): Vector3;
  89519. set direction2(value: Vector3);
  89520. /**
  89521. * 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.
  89522. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89523. */
  89524. get minEmitBox(): Vector3;
  89525. set minEmitBox(value: Vector3);
  89526. /**
  89527. * 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.
  89528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89529. */
  89530. get maxEmitBox(): Vector3;
  89531. set maxEmitBox(value: Vector3);
  89532. /**
  89533. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89534. */
  89535. color1: Color4;
  89536. /**
  89537. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89538. */
  89539. color2: Color4;
  89540. /**
  89541. * Color the particle will have at the end of its lifetime
  89542. */
  89543. colorDead: Color4;
  89544. /**
  89545. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89546. */
  89547. textureMask: Color4;
  89548. /**
  89549. * The particle emitter type defines the emitter used by the particle system.
  89550. * It can be for example box, sphere, or cone...
  89551. */
  89552. particleEmitterType: IParticleEmitterType;
  89553. /** @hidden */
  89554. _isSubEmitter: boolean;
  89555. /**
  89556. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89557. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89558. */
  89559. billboardMode: number;
  89560. protected _isBillboardBased: boolean;
  89561. /**
  89562. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89563. */
  89564. get isBillboardBased(): boolean;
  89565. set isBillboardBased(value: boolean);
  89566. /**
  89567. * The scene the particle system belongs to.
  89568. */
  89569. protected _scene: Scene;
  89570. /**
  89571. * Local cache of defines for image processing.
  89572. */
  89573. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89574. /**
  89575. * Default configuration related to image processing available in the standard Material.
  89576. */
  89577. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89578. /**
  89579. * Gets the image processing configuration used either in this material.
  89580. */
  89581. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89582. /**
  89583. * Sets the Default image processing configuration used either in the this material.
  89584. *
  89585. * If sets to null, the scene one is in use.
  89586. */
  89587. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89588. /**
  89589. * Attaches a new image processing configuration to the Standard Material.
  89590. * @param configuration
  89591. */
  89592. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89593. /** @hidden */
  89594. protected _reset(): void;
  89595. /** @hidden */
  89596. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89597. /**
  89598. * Instantiates a particle system.
  89599. * 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.
  89600. * @param name The name of the particle system
  89601. */
  89602. constructor(name: string);
  89603. /**
  89604. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89607. * @returns the emitter
  89608. */
  89609. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89610. /**
  89611. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89612. * @param radius The radius of the hemisphere to emit from
  89613. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89614. * @returns the emitter
  89615. */
  89616. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89617. /**
  89618. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89619. * @param radius The radius of the sphere to emit from
  89620. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89621. * @returns the emitter
  89622. */
  89623. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89624. /**
  89625. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89626. * @param radius The radius of the sphere to emit from
  89627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89629. * @returns the emitter
  89630. */
  89631. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89632. /**
  89633. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89634. * @param radius The radius of the emission cylinder
  89635. * @param height The height of the emission cylinder
  89636. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89637. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89638. * @returns the emitter
  89639. */
  89640. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89641. /**
  89642. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89643. * @param radius The radius of the cylinder to emit from
  89644. * @param height The height of the emission cylinder
  89645. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89648. * @returns the emitter
  89649. */
  89650. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89651. /**
  89652. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89653. * @param radius The radius of the cone to emit from
  89654. * @param angle The base angle of the cone
  89655. * @returns the emitter
  89656. */
  89657. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89658. /**
  89659. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89662. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89663. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89664. * @returns the emitter
  89665. */
  89666. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89667. }
  89668. }
  89669. declare module BABYLON {
  89670. /**
  89671. * Type of sub emitter
  89672. */
  89673. export enum SubEmitterType {
  89674. /**
  89675. * Attached to the particle over it's lifetime
  89676. */
  89677. ATTACHED = 0,
  89678. /**
  89679. * Created when the particle dies
  89680. */
  89681. END = 1
  89682. }
  89683. /**
  89684. * Sub emitter class used to emit particles from an existing particle
  89685. */
  89686. export class SubEmitter {
  89687. /**
  89688. * the particle system to be used by the sub emitter
  89689. */
  89690. particleSystem: ParticleSystem;
  89691. /**
  89692. * Type of the submitter (Default: END)
  89693. */
  89694. type: SubEmitterType;
  89695. /**
  89696. * 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)
  89697. * Note: This only is supported when using an emitter of type Mesh
  89698. */
  89699. inheritDirection: boolean;
  89700. /**
  89701. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89702. */
  89703. inheritedVelocityAmount: number;
  89704. /**
  89705. * Creates a sub emitter
  89706. * @param particleSystem the particle system to be used by the sub emitter
  89707. */
  89708. constructor(
  89709. /**
  89710. * the particle system to be used by the sub emitter
  89711. */
  89712. particleSystem: ParticleSystem);
  89713. /**
  89714. * Clones the sub emitter
  89715. * @returns the cloned sub emitter
  89716. */
  89717. clone(): SubEmitter;
  89718. /**
  89719. * Serialize current object to a JSON object
  89720. * @returns the serialized object
  89721. */
  89722. serialize(): any;
  89723. /** @hidden */
  89724. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89725. /**
  89726. * Creates a new SubEmitter from a serialized JSON version
  89727. * @param serializationObject defines the JSON object to read from
  89728. * @param scene defines the hosting scene
  89729. * @param rootUrl defines the rootUrl for data loading
  89730. * @returns a new SubEmitter
  89731. */
  89732. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89733. /** Release associated resources */
  89734. dispose(): void;
  89735. }
  89736. }
  89737. declare module BABYLON {
  89738. /** @hidden */
  89739. export var clipPlaneFragmentDeclaration: {
  89740. name: string;
  89741. shader: string;
  89742. };
  89743. }
  89744. declare module BABYLON {
  89745. /** @hidden */
  89746. export var imageProcessingDeclaration: {
  89747. name: string;
  89748. shader: string;
  89749. };
  89750. }
  89751. declare module BABYLON {
  89752. /** @hidden */
  89753. export var imageProcessingFunctions: {
  89754. name: string;
  89755. shader: string;
  89756. };
  89757. }
  89758. declare module BABYLON {
  89759. /** @hidden */
  89760. export var clipPlaneFragment: {
  89761. name: string;
  89762. shader: string;
  89763. };
  89764. }
  89765. declare module BABYLON {
  89766. /** @hidden */
  89767. export var particlesPixelShader: {
  89768. name: string;
  89769. shader: string;
  89770. };
  89771. }
  89772. declare module BABYLON {
  89773. /** @hidden */
  89774. export var clipPlaneVertexDeclaration: {
  89775. name: string;
  89776. shader: string;
  89777. };
  89778. }
  89779. declare module BABYLON {
  89780. /** @hidden */
  89781. export var clipPlaneVertex: {
  89782. name: string;
  89783. shader: string;
  89784. };
  89785. }
  89786. declare module BABYLON {
  89787. /** @hidden */
  89788. export var particlesVertexShader: {
  89789. name: string;
  89790. shader: string;
  89791. };
  89792. }
  89793. declare module BABYLON {
  89794. /**
  89795. * This represents a particle system in Babylon.
  89796. * 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.
  89797. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89798. * @example https://doc.babylonjs.com/babylon101/particles
  89799. */
  89800. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89801. /**
  89802. * Billboard mode will only apply to Y axis
  89803. */
  89804. static readonly BILLBOARDMODE_Y: number;
  89805. /**
  89806. * Billboard mode will apply to all axes
  89807. */
  89808. static readonly BILLBOARDMODE_ALL: number;
  89809. /**
  89810. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89811. */
  89812. static readonly BILLBOARDMODE_STRETCHED: number;
  89813. /**
  89814. * This function can be defined to provide custom update for active particles.
  89815. * This function will be called instead of regular update (age, position, color, etc.).
  89816. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89817. */
  89818. updateFunction: (particles: Particle[]) => void;
  89819. private _emitterWorldMatrix;
  89820. /**
  89821. * This function can be defined to specify initial direction for every new particle.
  89822. * It by default use the emitterType defined function
  89823. */
  89824. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  89825. /**
  89826. * This function can be defined to specify initial position for every new particle.
  89827. * It by default use the emitterType defined function
  89828. */
  89829. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  89830. /**
  89831. * @hidden
  89832. */
  89833. _inheritedVelocityOffset: Vector3;
  89834. /**
  89835. * An event triggered when the system is disposed
  89836. */
  89837. onDisposeObservable: Observable<ParticleSystem>;
  89838. private _onDisposeObserver;
  89839. /**
  89840. * Sets a callback that will be triggered when the system is disposed
  89841. */
  89842. set onDispose(callback: () => void);
  89843. private _particles;
  89844. private _epsilon;
  89845. private _capacity;
  89846. private _stockParticles;
  89847. private _newPartsExcess;
  89848. private _vertexData;
  89849. private _vertexBuffer;
  89850. private _vertexBuffers;
  89851. private _spriteBuffer;
  89852. private _indexBuffer;
  89853. private _effect;
  89854. private _customEffect;
  89855. private _cachedDefines;
  89856. private _scaledColorStep;
  89857. private _colorDiff;
  89858. private _scaledDirection;
  89859. private _scaledGravity;
  89860. private _currentRenderId;
  89861. private _alive;
  89862. private _useInstancing;
  89863. private _started;
  89864. private _stopped;
  89865. private _actualFrame;
  89866. private _scaledUpdateSpeed;
  89867. private _vertexBufferSize;
  89868. /** @hidden */
  89869. _currentEmitRateGradient: Nullable<FactorGradient>;
  89870. /** @hidden */
  89871. _currentEmitRate1: number;
  89872. /** @hidden */
  89873. _currentEmitRate2: number;
  89874. /** @hidden */
  89875. _currentStartSizeGradient: Nullable<FactorGradient>;
  89876. /** @hidden */
  89877. _currentStartSize1: number;
  89878. /** @hidden */
  89879. _currentStartSize2: number;
  89880. private readonly _rawTextureWidth;
  89881. private _rampGradientsTexture;
  89882. private _useRampGradients;
  89883. /** Gets or sets a boolean indicating that ramp gradients must be used
  89884. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89885. */
  89886. get useRampGradients(): boolean;
  89887. set useRampGradients(value: boolean);
  89888. /**
  89889. * 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.
  89890. * 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: [])
  89891. */
  89892. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89893. private _subEmitters;
  89894. /**
  89895. * @hidden
  89896. * If the particle systems emitter should be disposed when the particle system is disposed
  89897. */
  89898. _disposeEmitterOnDispose: boolean;
  89899. /**
  89900. * The current active Sub-systems, this property is used by the root particle system only.
  89901. */
  89902. activeSubSystems: Array<ParticleSystem>;
  89903. private _rootParticleSystem;
  89904. /**
  89905. * Gets the current list of active particles
  89906. */
  89907. get particles(): Particle[];
  89908. /**
  89909. * Returns the string "ParticleSystem"
  89910. * @returns a string containing the class name
  89911. */
  89912. getClassName(): string;
  89913. /**
  89914. * Instantiates a particle system.
  89915. * 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.
  89916. * @param name The name of the particle system
  89917. * @param capacity The max number of particles alive at the same time
  89918. * @param scene The scene the particle system belongs to
  89919. * @param customEffect a custom effect used to change the way particles are rendered by default
  89920. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89921. * @param epsilon Offset used to render the particles
  89922. */
  89923. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89924. private _addFactorGradient;
  89925. private _removeFactorGradient;
  89926. /**
  89927. * Adds a new life time gradient
  89928. * @param gradient defines the gradient to use (between 0 and 1)
  89929. * @param factor defines the life time factor to affect to the specified gradient
  89930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89931. * @returns the current particle system
  89932. */
  89933. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89934. /**
  89935. * Remove a specific life time gradient
  89936. * @param gradient defines the gradient to remove
  89937. * @returns the current particle system
  89938. */
  89939. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89940. /**
  89941. * Adds a new size gradient
  89942. * @param gradient defines the gradient to use (between 0 and 1)
  89943. * @param factor defines the size factor to affect to the specified gradient
  89944. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89945. * @returns the current particle system
  89946. */
  89947. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89948. /**
  89949. * Remove a specific size gradient
  89950. * @param gradient defines the gradient to remove
  89951. * @returns the current particle system
  89952. */
  89953. removeSizeGradient(gradient: number): IParticleSystem;
  89954. /**
  89955. * Adds a new color remap gradient
  89956. * @param gradient defines the gradient to use (between 0 and 1)
  89957. * @param min defines the color remap minimal range
  89958. * @param max defines the color remap maximal range
  89959. * @returns the current particle system
  89960. */
  89961. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89962. /**
  89963. * Remove a specific color remap gradient
  89964. * @param gradient defines the gradient to remove
  89965. * @returns the current particle system
  89966. */
  89967. removeColorRemapGradient(gradient: number): IParticleSystem;
  89968. /**
  89969. * Adds a new alpha remap gradient
  89970. * @param gradient defines the gradient to use (between 0 and 1)
  89971. * @param min defines the alpha remap minimal range
  89972. * @param max defines the alpha remap maximal range
  89973. * @returns the current particle system
  89974. */
  89975. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89976. /**
  89977. * Remove a specific alpha remap gradient
  89978. * @param gradient defines the gradient to remove
  89979. * @returns the current particle system
  89980. */
  89981. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  89982. /**
  89983. * Adds a new angular speed gradient
  89984. * @param gradient defines the gradient to use (between 0 and 1)
  89985. * @param factor defines the angular speed to affect to the specified gradient
  89986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89987. * @returns the current particle system
  89988. */
  89989. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89990. /**
  89991. * Remove a specific angular speed gradient
  89992. * @param gradient defines the gradient to remove
  89993. * @returns the current particle system
  89994. */
  89995. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89996. /**
  89997. * Adds a new velocity gradient
  89998. * @param gradient defines the gradient to use (between 0 and 1)
  89999. * @param factor defines the velocity to affect to the specified gradient
  90000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90001. * @returns the current particle system
  90002. */
  90003. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90004. /**
  90005. * Remove a specific velocity gradient
  90006. * @param gradient defines the gradient to remove
  90007. * @returns the current particle system
  90008. */
  90009. removeVelocityGradient(gradient: number): IParticleSystem;
  90010. /**
  90011. * Adds a new limit velocity gradient
  90012. * @param gradient defines the gradient to use (between 0 and 1)
  90013. * @param factor defines the limit velocity value to affect to the specified gradient
  90014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90015. * @returns the current particle system
  90016. */
  90017. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90018. /**
  90019. * Remove a specific limit velocity gradient
  90020. * @param gradient defines the gradient to remove
  90021. * @returns the current particle system
  90022. */
  90023. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90024. /**
  90025. * Adds a new drag gradient
  90026. * @param gradient defines the gradient to use (between 0 and 1)
  90027. * @param factor defines the drag value to affect to the specified gradient
  90028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90029. * @returns the current particle system
  90030. */
  90031. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90032. /**
  90033. * Remove a specific drag gradient
  90034. * @param gradient defines the gradient to remove
  90035. * @returns the current particle system
  90036. */
  90037. removeDragGradient(gradient: number): IParticleSystem;
  90038. /**
  90039. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90040. * @param gradient defines the gradient to use (between 0 and 1)
  90041. * @param factor defines the emit rate value to affect to the specified gradient
  90042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90043. * @returns the current particle system
  90044. */
  90045. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90046. /**
  90047. * Remove a specific emit rate gradient
  90048. * @param gradient defines the gradient to remove
  90049. * @returns the current particle system
  90050. */
  90051. removeEmitRateGradient(gradient: number): IParticleSystem;
  90052. /**
  90053. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90054. * @param gradient defines the gradient to use (between 0 and 1)
  90055. * @param factor defines the start size value to affect to the specified gradient
  90056. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90057. * @returns the current particle system
  90058. */
  90059. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90060. /**
  90061. * Remove a specific start size gradient
  90062. * @param gradient defines the gradient to remove
  90063. * @returns the current particle system
  90064. */
  90065. removeStartSizeGradient(gradient: number): IParticleSystem;
  90066. private _createRampGradientTexture;
  90067. /**
  90068. * Gets the current list of ramp gradients.
  90069. * You must use addRampGradient and removeRampGradient to udpate this list
  90070. * @returns the list of ramp gradients
  90071. */
  90072. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90073. /**
  90074. * Adds a new ramp gradient used to remap particle colors
  90075. * @param gradient defines the gradient to use (between 0 and 1)
  90076. * @param color defines the color to affect to the specified gradient
  90077. * @returns the current particle system
  90078. */
  90079. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90080. /**
  90081. * Remove a specific ramp gradient
  90082. * @param gradient defines the gradient to remove
  90083. * @returns the current particle system
  90084. */
  90085. removeRampGradient(gradient: number): ParticleSystem;
  90086. /**
  90087. * Adds a new color gradient
  90088. * @param gradient defines the gradient to use (between 0 and 1)
  90089. * @param color1 defines the color to affect to the specified gradient
  90090. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90091. * @returns this particle system
  90092. */
  90093. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90094. /**
  90095. * Remove a specific color gradient
  90096. * @param gradient defines the gradient to remove
  90097. * @returns this particle system
  90098. */
  90099. removeColorGradient(gradient: number): IParticleSystem;
  90100. private _fetchR;
  90101. protected _reset(): void;
  90102. private _resetEffect;
  90103. private _createVertexBuffers;
  90104. private _createIndexBuffer;
  90105. /**
  90106. * Gets the maximum number of particles active at the same time.
  90107. * @returns The max number of active particles.
  90108. */
  90109. getCapacity(): number;
  90110. /**
  90111. * Gets whether there are still active particles in the system.
  90112. * @returns True if it is alive, otherwise false.
  90113. */
  90114. isAlive(): boolean;
  90115. /**
  90116. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90117. * @returns True if it has been started, otherwise false.
  90118. */
  90119. isStarted(): boolean;
  90120. private _prepareSubEmitterInternalArray;
  90121. /**
  90122. * Starts the particle system and begins to emit
  90123. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90124. */
  90125. start(delay?: number): void;
  90126. /**
  90127. * Stops the particle system.
  90128. * @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.
  90129. */
  90130. stop(stopSubEmitters?: boolean): void;
  90131. /**
  90132. * Remove all active particles
  90133. */
  90134. reset(): void;
  90135. /**
  90136. * @hidden (for internal use only)
  90137. */
  90138. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90139. /**
  90140. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90141. * Its lifetime will start back at 0.
  90142. */
  90143. recycleParticle: (particle: Particle) => void;
  90144. private _stopSubEmitters;
  90145. private _createParticle;
  90146. private _removeFromRoot;
  90147. private _emitFromParticle;
  90148. private _update;
  90149. /** @hidden */
  90150. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90151. /** @hidden */
  90152. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90153. /** @hidden */
  90154. private _getEffect;
  90155. /**
  90156. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90157. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90158. */
  90159. animate(preWarmOnly?: boolean): void;
  90160. private _appendParticleVertices;
  90161. /**
  90162. * Rebuilds the particle system.
  90163. */
  90164. rebuild(): void;
  90165. /**
  90166. * Is this system ready to be used/rendered
  90167. * @return true if the system is ready
  90168. */
  90169. isReady(): boolean;
  90170. private _render;
  90171. /**
  90172. * Renders the particle system in its current state.
  90173. * @returns the current number of particles
  90174. */
  90175. render(): number;
  90176. /**
  90177. * Disposes the particle system and free the associated resources
  90178. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90179. */
  90180. dispose(disposeTexture?: boolean): void;
  90181. /**
  90182. * Clones the particle system.
  90183. * @param name The name of the cloned object
  90184. * @param newEmitter The new emitter to use
  90185. * @returns the cloned particle system
  90186. */
  90187. clone(name: string, newEmitter: any): ParticleSystem;
  90188. /**
  90189. * Serializes the particle system to a JSON object.
  90190. * @returns the JSON object
  90191. */
  90192. serialize(): any;
  90193. /** @hidden */
  90194. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  90195. /** @hidden */
  90196. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90197. /**
  90198. * Parses a JSON object to create a particle system.
  90199. * @param parsedParticleSystem The JSON object to parse
  90200. * @param scene The scene to create the particle system in
  90201. * @param rootUrl The root url to use to load external dependencies like texture
  90202. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90203. * @returns the Parsed particle system
  90204. */
  90205. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90206. }
  90207. }
  90208. declare module BABYLON {
  90209. /**
  90210. * A particle represents one of the element emitted by a particle system.
  90211. * This is mainly define by its coordinates, direction, velocity and age.
  90212. */
  90213. export class Particle {
  90214. /**
  90215. * The particle system the particle belongs to.
  90216. */
  90217. particleSystem: ParticleSystem;
  90218. private static _Count;
  90219. /**
  90220. * Unique ID of the particle
  90221. */
  90222. id: number;
  90223. /**
  90224. * The world position of the particle in the scene.
  90225. */
  90226. position: Vector3;
  90227. /**
  90228. * The world direction of the particle in the scene.
  90229. */
  90230. direction: Vector3;
  90231. /**
  90232. * The color of the particle.
  90233. */
  90234. color: Color4;
  90235. /**
  90236. * The color change of the particle per step.
  90237. */
  90238. colorStep: Color4;
  90239. /**
  90240. * Defines how long will the life of the particle be.
  90241. */
  90242. lifeTime: number;
  90243. /**
  90244. * The current age of the particle.
  90245. */
  90246. age: number;
  90247. /**
  90248. * The current size of the particle.
  90249. */
  90250. size: number;
  90251. /**
  90252. * The current scale of the particle.
  90253. */
  90254. scale: Vector2;
  90255. /**
  90256. * The current angle of the particle.
  90257. */
  90258. angle: number;
  90259. /**
  90260. * Defines how fast is the angle changing.
  90261. */
  90262. angularSpeed: number;
  90263. /**
  90264. * Defines the cell index used by the particle to be rendered from a sprite.
  90265. */
  90266. cellIndex: number;
  90267. /**
  90268. * The information required to support color remapping
  90269. */
  90270. remapData: Vector4;
  90271. /** @hidden */
  90272. _randomCellOffset?: number;
  90273. /** @hidden */
  90274. _initialDirection: Nullable<Vector3>;
  90275. /** @hidden */
  90276. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90277. /** @hidden */
  90278. _initialStartSpriteCellID: number;
  90279. /** @hidden */
  90280. _initialEndSpriteCellID: number;
  90281. /** @hidden */
  90282. _currentColorGradient: Nullable<ColorGradient>;
  90283. /** @hidden */
  90284. _currentColor1: Color4;
  90285. /** @hidden */
  90286. _currentColor2: Color4;
  90287. /** @hidden */
  90288. _currentSizeGradient: Nullable<FactorGradient>;
  90289. /** @hidden */
  90290. _currentSize1: number;
  90291. /** @hidden */
  90292. _currentSize2: number;
  90293. /** @hidden */
  90294. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90295. /** @hidden */
  90296. _currentAngularSpeed1: number;
  90297. /** @hidden */
  90298. _currentAngularSpeed2: number;
  90299. /** @hidden */
  90300. _currentVelocityGradient: Nullable<FactorGradient>;
  90301. /** @hidden */
  90302. _currentVelocity1: number;
  90303. /** @hidden */
  90304. _currentVelocity2: number;
  90305. /** @hidden */
  90306. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90307. /** @hidden */
  90308. _currentLimitVelocity1: number;
  90309. /** @hidden */
  90310. _currentLimitVelocity2: number;
  90311. /** @hidden */
  90312. _currentDragGradient: Nullable<FactorGradient>;
  90313. /** @hidden */
  90314. _currentDrag1: number;
  90315. /** @hidden */
  90316. _currentDrag2: number;
  90317. /** @hidden */
  90318. _randomNoiseCoordinates1: Vector3;
  90319. /** @hidden */
  90320. _randomNoiseCoordinates2: Vector3;
  90321. /**
  90322. * Creates a new instance Particle
  90323. * @param particleSystem the particle system the particle belongs to
  90324. */
  90325. constructor(
  90326. /**
  90327. * The particle system the particle belongs to.
  90328. */
  90329. particleSystem: ParticleSystem);
  90330. private updateCellInfoFromSystem;
  90331. /**
  90332. * Defines how the sprite cell index is updated for the particle
  90333. */
  90334. updateCellIndex(): void;
  90335. /** @hidden */
  90336. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90337. /** @hidden */
  90338. _inheritParticleInfoToSubEmitters(): void;
  90339. /** @hidden */
  90340. _reset(): void;
  90341. /**
  90342. * Copy the properties of particle to another one.
  90343. * @param other the particle to copy the information to.
  90344. */
  90345. copyTo(other: Particle): void;
  90346. }
  90347. }
  90348. declare module BABYLON {
  90349. /**
  90350. * Particle emitter represents a volume emitting particles.
  90351. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90352. */
  90353. export interface IParticleEmitterType {
  90354. /**
  90355. * Called by the particle System when the direction is computed for the created particle.
  90356. * @param worldMatrix is the world matrix of the particle system
  90357. * @param directionToUpdate is the direction vector to update with the result
  90358. * @param particle is the particle we are computed the direction for
  90359. */
  90360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90361. /**
  90362. * Called by the particle System when the position is computed for the created particle.
  90363. * @param worldMatrix is the world matrix of the particle system
  90364. * @param positionToUpdate is the position vector to update with the result
  90365. * @param particle is the particle we are computed the position for
  90366. */
  90367. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90368. /**
  90369. * Clones the current emitter and returns a copy of it
  90370. * @returns the new emitter
  90371. */
  90372. clone(): IParticleEmitterType;
  90373. /**
  90374. * Called by the GPUParticleSystem to setup the update shader
  90375. * @param effect defines the update shader
  90376. */
  90377. applyToShader(effect: Effect): void;
  90378. /**
  90379. * Returns a string to use to update the GPU particles update shader
  90380. * @returns the effect defines string
  90381. */
  90382. getEffectDefines(): string;
  90383. /**
  90384. * Returns a string representing the class name
  90385. * @returns a string containing the class name
  90386. */
  90387. getClassName(): string;
  90388. /**
  90389. * Serializes the particle system to a JSON object.
  90390. * @returns the JSON object
  90391. */
  90392. serialize(): any;
  90393. /**
  90394. * Parse properties from a JSON object
  90395. * @param serializationObject defines the JSON object
  90396. */
  90397. parse(serializationObject: any): void;
  90398. }
  90399. }
  90400. declare module BABYLON {
  90401. /**
  90402. * Particle emitter emitting particles from the inside of a box.
  90403. * It emits the particles randomly between 2 given directions.
  90404. */
  90405. export class BoxParticleEmitter implements IParticleEmitterType {
  90406. /**
  90407. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90408. */
  90409. direction1: Vector3;
  90410. /**
  90411. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90412. */
  90413. direction2: Vector3;
  90414. /**
  90415. * 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.
  90416. */
  90417. minEmitBox: Vector3;
  90418. /**
  90419. * 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.
  90420. */
  90421. maxEmitBox: Vector3;
  90422. /**
  90423. * Creates a new instance BoxParticleEmitter
  90424. */
  90425. constructor();
  90426. /**
  90427. * Called by the particle System when the direction is computed for the created particle.
  90428. * @param worldMatrix is the world matrix of the particle system
  90429. * @param directionToUpdate is the direction vector to update with the result
  90430. * @param particle is the particle we are computed the direction for
  90431. */
  90432. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90433. /**
  90434. * Called by the particle System when the position is computed for the created particle.
  90435. * @param worldMatrix is the world matrix of the particle system
  90436. * @param positionToUpdate is the position vector to update with the result
  90437. * @param particle is the particle we are computed the position for
  90438. */
  90439. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90440. /**
  90441. * Clones the current emitter and returns a copy of it
  90442. * @returns the new emitter
  90443. */
  90444. clone(): BoxParticleEmitter;
  90445. /**
  90446. * Called by the GPUParticleSystem to setup the update shader
  90447. * @param effect defines the update shader
  90448. */
  90449. applyToShader(effect: Effect): void;
  90450. /**
  90451. * Returns a string to use to update the GPU particles update shader
  90452. * @returns a string containng the defines string
  90453. */
  90454. getEffectDefines(): string;
  90455. /**
  90456. * Returns the string "BoxParticleEmitter"
  90457. * @returns a string containing the class name
  90458. */
  90459. getClassName(): string;
  90460. /**
  90461. * Serializes the particle system to a JSON object.
  90462. * @returns the JSON object
  90463. */
  90464. serialize(): any;
  90465. /**
  90466. * Parse properties from a JSON object
  90467. * @param serializationObject defines the JSON object
  90468. */
  90469. parse(serializationObject: any): void;
  90470. }
  90471. }
  90472. declare module BABYLON {
  90473. /**
  90474. * Particle emitter emitting particles from the inside of a cone.
  90475. * It emits the particles alongside the cone volume from the base to the particle.
  90476. * The emission direction might be randomized.
  90477. */
  90478. export class ConeParticleEmitter implements IParticleEmitterType {
  90479. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90480. directionRandomizer: number;
  90481. private _radius;
  90482. private _angle;
  90483. private _height;
  90484. /**
  90485. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90486. */
  90487. radiusRange: number;
  90488. /**
  90489. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90490. */
  90491. heightRange: number;
  90492. /**
  90493. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90494. */
  90495. emitFromSpawnPointOnly: boolean;
  90496. /**
  90497. * Gets or sets the radius of the emission cone
  90498. */
  90499. get radius(): number;
  90500. set radius(value: number);
  90501. /**
  90502. * Gets or sets the angle of the emission cone
  90503. */
  90504. get angle(): number;
  90505. set angle(value: number);
  90506. private _buildHeight;
  90507. /**
  90508. * Creates a new instance ConeParticleEmitter
  90509. * @param radius the radius of the emission cone (1 by default)
  90510. * @param angle the cone base angle (PI by default)
  90511. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90512. */
  90513. constructor(radius?: number, angle?: number,
  90514. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90515. directionRandomizer?: number);
  90516. /**
  90517. * Called by the particle System when the direction is computed for the created particle.
  90518. * @param worldMatrix is the world matrix of the particle system
  90519. * @param directionToUpdate is the direction vector to update with the result
  90520. * @param particle is the particle we are computed the direction for
  90521. */
  90522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90523. /**
  90524. * Called by the particle System when the position is computed for the created particle.
  90525. * @param worldMatrix is the world matrix of the particle system
  90526. * @param positionToUpdate is the position vector to update with the result
  90527. * @param particle is the particle we are computed the position for
  90528. */
  90529. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90530. /**
  90531. * Clones the current emitter and returns a copy of it
  90532. * @returns the new emitter
  90533. */
  90534. clone(): ConeParticleEmitter;
  90535. /**
  90536. * Called by the GPUParticleSystem to setup the update shader
  90537. * @param effect defines the update shader
  90538. */
  90539. applyToShader(effect: Effect): void;
  90540. /**
  90541. * Returns a string to use to update the GPU particles update shader
  90542. * @returns a string containng the defines string
  90543. */
  90544. getEffectDefines(): string;
  90545. /**
  90546. * Returns the string "ConeParticleEmitter"
  90547. * @returns a string containing the class name
  90548. */
  90549. getClassName(): string;
  90550. /**
  90551. * Serializes the particle system to a JSON object.
  90552. * @returns the JSON object
  90553. */
  90554. serialize(): any;
  90555. /**
  90556. * Parse properties from a JSON object
  90557. * @param serializationObject defines the JSON object
  90558. */
  90559. parse(serializationObject: any): void;
  90560. }
  90561. }
  90562. declare module BABYLON {
  90563. /**
  90564. * Particle emitter emitting particles from the inside of a cylinder.
  90565. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90566. */
  90567. export class CylinderParticleEmitter implements IParticleEmitterType {
  90568. /**
  90569. * The radius of the emission cylinder.
  90570. */
  90571. radius: number;
  90572. /**
  90573. * The height of the emission cylinder.
  90574. */
  90575. height: number;
  90576. /**
  90577. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90578. */
  90579. radiusRange: number;
  90580. /**
  90581. * How much to randomize the particle direction [0-1].
  90582. */
  90583. directionRandomizer: number;
  90584. /**
  90585. * Creates a new instance CylinderParticleEmitter
  90586. * @param radius the radius of the emission cylinder (1 by default)
  90587. * @param height the height of the emission cylinder (1 by default)
  90588. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90589. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90590. */
  90591. constructor(
  90592. /**
  90593. * The radius of the emission cylinder.
  90594. */
  90595. radius?: number,
  90596. /**
  90597. * The height of the emission cylinder.
  90598. */
  90599. height?: number,
  90600. /**
  90601. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90602. */
  90603. radiusRange?: number,
  90604. /**
  90605. * How much to randomize the particle direction [0-1].
  90606. */
  90607. directionRandomizer?: number);
  90608. /**
  90609. * Called by the particle System when the direction is computed for the created particle.
  90610. * @param worldMatrix is the world matrix of the particle system
  90611. * @param directionToUpdate is the direction vector to update with the result
  90612. * @param particle is the particle we are computed the direction for
  90613. */
  90614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90615. /**
  90616. * Called by the particle System when the position is computed for the created particle.
  90617. * @param worldMatrix is the world matrix of the particle system
  90618. * @param positionToUpdate is the position vector to update with the result
  90619. * @param particle is the particle we are computed the position for
  90620. */
  90621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90622. /**
  90623. * Clones the current emitter and returns a copy of it
  90624. * @returns the new emitter
  90625. */
  90626. clone(): CylinderParticleEmitter;
  90627. /**
  90628. * Called by the GPUParticleSystem to setup the update shader
  90629. * @param effect defines the update shader
  90630. */
  90631. applyToShader(effect: Effect): void;
  90632. /**
  90633. * Returns a string to use to update the GPU particles update shader
  90634. * @returns a string containng the defines string
  90635. */
  90636. getEffectDefines(): string;
  90637. /**
  90638. * Returns the string "CylinderParticleEmitter"
  90639. * @returns a string containing the class name
  90640. */
  90641. getClassName(): string;
  90642. /**
  90643. * Serializes the particle system to a JSON object.
  90644. * @returns the JSON object
  90645. */
  90646. serialize(): any;
  90647. /**
  90648. * Parse properties from a JSON object
  90649. * @param serializationObject defines the JSON object
  90650. */
  90651. parse(serializationObject: any): void;
  90652. }
  90653. /**
  90654. * Particle emitter emitting particles from the inside of a cylinder.
  90655. * It emits the particles randomly between two vectors.
  90656. */
  90657. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90658. /**
  90659. * The min limit of the emission direction.
  90660. */
  90661. direction1: Vector3;
  90662. /**
  90663. * The max limit of the emission direction.
  90664. */
  90665. direction2: Vector3;
  90666. /**
  90667. * Creates a new instance CylinderDirectedParticleEmitter
  90668. * @param radius the radius of the emission cylinder (1 by default)
  90669. * @param height the height of the emission cylinder (1 by default)
  90670. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90671. * @param direction1 the min limit of the emission direction (up vector by default)
  90672. * @param direction2 the max limit of the emission direction (up vector by default)
  90673. */
  90674. constructor(radius?: number, height?: number, radiusRange?: number,
  90675. /**
  90676. * The min limit of the emission direction.
  90677. */
  90678. direction1?: Vector3,
  90679. /**
  90680. * The max limit of the emission direction.
  90681. */
  90682. direction2?: Vector3);
  90683. /**
  90684. * Called by the particle System when the direction is computed for the created particle.
  90685. * @param worldMatrix is the world matrix of the particle system
  90686. * @param directionToUpdate is the direction vector to update with the result
  90687. * @param particle is the particle we are computed the direction for
  90688. */
  90689. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90690. /**
  90691. * Clones the current emitter and returns a copy of it
  90692. * @returns the new emitter
  90693. */
  90694. clone(): CylinderDirectedParticleEmitter;
  90695. /**
  90696. * Called by the GPUParticleSystem to setup the update shader
  90697. * @param effect defines the update shader
  90698. */
  90699. applyToShader(effect: Effect): void;
  90700. /**
  90701. * Returns a string to use to update the GPU particles update shader
  90702. * @returns a string containng the defines string
  90703. */
  90704. getEffectDefines(): string;
  90705. /**
  90706. * Returns the string "CylinderDirectedParticleEmitter"
  90707. * @returns a string containing the class name
  90708. */
  90709. getClassName(): string;
  90710. /**
  90711. * Serializes the particle system to a JSON object.
  90712. * @returns the JSON object
  90713. */
  90714. serialize(): any;
  90715. /**
  90716. * Parse properties from a JSON object
  90717. * @param serializationObject defines the JSON object
  90718. */
  90719. parse(serializationObject: any): void;
  90720. }
  90721. }
  90722. declare module BABYLON {
  90723. /**
  90724. * Particle emitter emitting particles from the inside of a hemisphere.
  90725. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90726. */
  90727. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90728. /**
  90729. * The radius of the emission hemisphere.
  90730. */
  90731. radius: number;
  90732. /**
  90733. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90734. */
  90735. radiusRange: number;
  90736. /**
  90737. * How much to randomize the particle direction [0-1].
  90738. */
  90739. directionRandomizer: number;
  90740. /**
  90741. * Creates a new instance HemisphericParticleEmitter
  90742. * @param radius the radius of the emission hemisphere (1 by default)
  90743. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90744. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90745. */
  90746. constructor(
  90747. /**
  90748. * The radius of the emission hemisphere.
  90749. */
  90750. radius?: number,
  90751. /**
  90752. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90753. */
  90754. radiusRange?: number,
  90755. /**
  90756. * How much to randomize the particle direction [0-1].
  90757. */
  90758. directionRandomizer?: number);
  90759. /**
  90760. * Called by the particle System when the direction is computed for the created particle.
  90761. * @param worldMatrix is the world matrix of the particle system
  90762. * @param directionToUpdate is the direction vector to update with the result
  90763. * @param particle is the particle we are computed the direction for
  90764. */
  90765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90766. /**
  90767. * Called by the particle System when the position is computed for the created particle.
  90768. * @param worldMatrix is the world matrix of the particle system
  90769. * @param positionToUpdate is the position vector to update with the result
  90770. * @param particle is the particle we are computed the position for
  90771. */
  90772. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90773. /**
  90774. * Clones the current emitter and returns a copy of it
  90775. * @returns the new emitter
  90776. */
  90777. clone(): HemisphericParticleEmitter;
  90778. /**
  90779. * Called by the GPUParticleSystem to setup the update shader
  90780. * @param effect defines the update shader
  90781. */
  90782. applyToShader(effect: Effect): void;
  90783. /**
  90784. * Returns a string to use to update the GPU particles update shader
  90785. * @returns a string containng the defines string
  90786. */
  90787. getEffectDefines(): string;
  90788. /**
  90789. * Returns the string "HemisphericParticleEmitter"
  90790. * @returns a string containing the class name
  90791. */
  90792. getClassName(): string;
  90793. /**
  90794. * Serializes the particle system to a JSON object.
  90795. * @returns the JSON object
  90796. */
  90797. serialize(): any;
  90798. /**
  90799. * Parse properties from a JSON object
  90800. * @param serializationObject defines the JSON object
  90801. */
  90802. parse(serializationObject: any): void;
  90803. }
  90804. }
  90805. declare module BABYLON {
  90806. /**
  90807. * Particle emitter emitting particles from a point.
  90808. * It emits the particles randomly between 2 given directions.
  90809. */
  90810. export class PointParticleEmitter implements IParticleEmitterType {
  90811. /**
  90812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90813. */
  90814. direction1: Vector3;
  90815. /**
  90816. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90817. */
  90818. direction2: Vector3;
  90819. /**
  90820. * Creates a new instance PointParticleEmitter
  90821. */
  90822. constructor();
  90823. /**
  90824. * Called by the particle System when the direction is computed for the created particle.
  90825. * @param worldMatrix is the world matrix of the particle system
  90826. * @param directionToUpdate is the direction vector to update with the result
  90827. * @param particle is the particle we are computed the direction for
  90828. */
  90829. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90830. /**
  90831. * Called by the particle System when the position is computed for the created particle.
  90832. * @param worldMatrix is the world matrix of the particle system
  90833. * @param positionToUpdate is the position vector to update with the result
  90834. * @param particle is the particle we are computed the position for
  90835. */
  90836. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90837. /**
  90838. * Clones the current emitter and returns a copy of it
  90839. * @returns the new emitter
  90840. */
  90841. clone(): PointParticleEmitter;
  90842. /**
  90843. * Called by the GPUParticleSystem to setup the update shader
  90844. * @param effect defines the update shader
  90845. */
  90846. applyToShader(effect: Effect): void;
  90847. /**
  90848. * Returns a string to use to update the GPU particles update shader
  90849. * @returns a string containng the defines string
  90850. */
  90851. getEffectDefines(): string;
  90852. /**
  90853. * Returns the string "PointParticleEmitter"
  90854. * @returns a string containing the class name
  90855. */
  90856. getClassName(): string;
  90857. /**
  90858. * Serializes the particle system to a JSON object.
  90859. * @returns the JSON object
  90860. */
  90861. serialize(): any;
  90862. /**
  90863. * Parse properties from a JSON object
  90864. * @param serializationObject defines the JSON object
  90865. */
  90866. parse(serializationObject: any): void;
  90867. }
  90868. }
  90869. declare module BABYLON {
  90870. /**
  90871. * Particle emitter emitting particles from the inside of a sphere.
  90872. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90873. */
  90874. export class SphereParticleEmitter implements IParticleEmitterType {
  90875. /**
  90876. * The radius of the emission sphere.
  90877. */
  90878. radius: number;
  90879. /**
  90880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90881. */
  90882. radiusRange: number;
  90883. /**
  90884. * How much to randomize the particle direction [0-1].
  90885. */
  90886. directionRandomizer: number;
  90887. /**
  90888. * Creates a new instance SphereParticleEmitter
  90889. * @param radius the radius of the emission sphere (1 by default)
  90890. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90891. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90892. */
  90893. constructor(
  90894. /**
  90895. * The radius of the emission sphere.
  90896. */
  90897. radius?: number,
  90898. /**
  90899. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90900. */
  90901. radiusRange?: number,
  90902. /**
  90903. * How much to randomize the particle direction [0-1].
  90904. */
  90905. directionRandomizer?: number);
  90906. /**
  90907. * Called by the particle System when the direction is computed for the created particle.
  90908. * @param worldMatrix is the world matrix of the particle system
  90909. * @param directionToUpdate is the direction vector to update with the result
  90910. * @param particle is the particle we are computed the direction for
  90911. */
  90912. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90913. /**
  90914. * Called by the particle System when the position is computed for the created particle.
  90915. * @param worldMatrix is the world matrix of the particle system
  90916. * @param positionToUpdate is the position vector to update with the result
  90917. * @param particle is the particle we are computed the position for
  90918. */
  90919. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90920. /**
  90921. * Clones the current emitter and returns a copy of it
  90922. * @returns the new emitter
  90923. */
  90924. clone(): SphereParticleEmitter;
  90925. /**
  90926. * Called by the GPUParticleSystem to setup the update shader
  90927. * @param effect defines the update shader
  90928. */
  90929. applyToShader(effect: Effect): void;
  90930. /**
  90931. * Returns a string to use to update the GPU particles update shader
  90932. * @returns a string containng the defines string
  90933. */
  90934. getEffectDefines(): string;
  90935. /**
  90936. * Returns the string "SphereParticleEmitter"
  90937. * @returns a string containing the class name
  90938. */
  90939. getClassName(): string;
  90940. /**
  90941. * Serializes the particle system to a JSON object.
  90942. * @returns the JSON object
  90943. */
  90944. serialize(): any;
  90945. /**
  90946. * Parse properties from a JSON object
  90947. * @param serializationObject defines the JSON object
  90948. */
  90949. parse(serializationObject: any): void;
  90950. }
  90951. /**
  90952. * Particle emitter emitting particles from the inside of a sphere.
  90953. * It emits the particles randomly between two vectors.
  90954. */
  90955. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  90956. /**
  90957. * The min limit of the emission direction.
  90958. */
  90959. direction1: Vector3;
  90960. /**
  90961. * The max limit of the emission direction.
  90962. */
  90963. direction2: Vector3;
  90964. /**
  90965. * Creates a new instance SphereDirectedParticleEmitter
  90966. * @param radius the radius of the emission sphere (1 by default)
  90967. * @param direction1 the min limit of the emission direction (up vector by default)
  90968. * @param direction2 the max limit of the emission direction (up vector by default)
  90969. */
  90970. constructor(radius?: number,
  90971. /**
  90972. * The min limit of the emission direction.
  90973. */
  90974. direction1?: Vector3,
  90975. /**
  90976. * The max limit of the emission direction.
  90977. */
  90978. direction2?: Vector3);
  90979. /**
  90980. * Called by the particle System when the direction is computed for the created particle.
  90981. * @param worldMatrix is the world matrix of the particle system
  90982. * @param directionToUpdate is the direction vector to update with the result
  90983. * @param particle is the particle we are computed the direction for
  90984. */
  90985. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90986. /**
  90987. * Clones the current emitter and returns a copy of it
  90988. * @returns the new emitter
  90989. */
  90990. clone(): SphereDirectedParticleEmitter;
  90991. /**
  90992. * Called by the GPUParticleSystem to setup the update shader
  90993. * @param effect defines the update shader
  90994. */
  90995. applyToShader(effect: Effect): void;
  90996. /**
  90997. * Returns a string to use to update the GPU particles update shader
  90998. * @returns a string containng the defines string
  90999. */
  91000. getEffectDefines(): string;
  91001. /**
  91002. * Returns the string "SphereDirectedParticleEmitter"
  91003. * @returns a string containing the class name
  91004. */
  91005. getClassName(): string;
  91006. /**
  91007. * Serializes the particle system to a JSON object.
  91008. * @returns the JSON object
  91009. */
  91010. serialize(): any;
  91011. /**
  91012. * Parse properties from a JSON object
  91013. * @param serializationObject defines the JSON object
  91014. */
  91015. parse(serializationObject: any): void;
  91016. }
  91017. }
  91018. declare module BABYLON {
  91019. /**
  91020. * Particle emitter emitting particles from a custom list of positions.
  91021. */
  91022. export class CustomParticleEmitter implements IParticleEmitterType {
  91023. /**
  91024. * Gets or sets the position generator that will create the inital position of each particle.
  91025. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91026. */
  91027. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91028. /**
  91029. * Gets or sets the destination generator that will create the final destination of each particle.
  91030. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91031. */
  91032. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91033. /**
  91034. * Creates a new instance CustomParticleEmitter
  91035. */
  91036. constructor();
  91037. /**
  91038. * Called by the particle System when the direction is computed for the created particle.
  91039. * @param worldMatrix is the world matrix of the particle system
  91040. * @param directionToUpdate is the direction vector to update with the result
  91041. * @param particle is the particle we are computed the direction for
  91042. */
  91043. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91044. /**
  91045. * Called by the particle System when the position is computed for the created particle.
  91046. * @param worldMatrix is the world matrix of the particle system
  91047. * @param positionToUpdate is the position vector to update with the result
  91048. * @param particle is the particle we are computed the position for
  91049. */
  91050. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91051. /**
  91052. * Clones the current emitter and returns a copy of it
  91053. * @returns the new emitter
  91054. */
  91055. clone(): CustomParticleEmitter;
  91056. /**
  91057. * Called by the GPUParticleSystem to setup the update shader
  91058. * @param effect defines the update shader
  91059. */
  91060. applyToShader(effect: Effect): void;
  91061. /**
  91062. * Returns a string to use to update the GPU particles update shader
  91063. * @returns a string containng the defines string
  91064. */
  91065. getEffectDefines(): string;
  91066. /**
  91067. * Returns the string "PointParticleEmitter"
  91068. * @returns a string containing the class name
  91069. */
  91070. getClassName(): string;
  91071. /**
  91072. * Serializes the particle system to a JSON object.
  91073. * @returns the JSON object
  91074. */
  91075. serialize(): any;
  91076. /**
  91077. * Parse properties from a JSON object
  91078. * @param serializationObject defines the JSON object
  91079. */
  91080. parse(serializationObject: any): void;
  91081. }
  91082. }
  91083. declare module BABYLON {
  91084. /**
  91085. * Interface representing a particle system in Babylon.js.
  91086. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91087. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91088. */
  91089. export interface IParticleSystem {
  91090. /**
  91091. * List of animations used by the particle system.
  91092. */
  91093. animations: Animation[];
  91094. /**
  91095. * The id of the Particle system.
  91096. */
  91097. id: string;
  91098. /**
  91099. * The name of the Particle system.
  91100. */
  91101. name: string;
  91102. /**
  91103. * The emitter represents the Mesh or position we are attaching the particle system to.
  91104. */
  91105. emitter: Nullable<AbstractMesh | Vector3>;
  91106. /**
  91107. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91108. */
  91109. isBillboardBased: boolean;
  91110. /**
  91111. * The rendering group used by the Particle system to chose when to render.
  91112. */
  91113. renderingGroupId: number;
  91114. /**
  91115. * The layer mask we are rendering the particles through.
  91116. */
  91117. layerMask: number;
  91118. /**
  91119. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91120. */
  91121. updateSpeed: number;
  91122. /**
  91123. * The amount of time the particle system is running (depends of the overall update speed).
  91124. */
  91125. targetStopDuration: number;
  91126. /**
  91127. * The texture used to render each particle. (this can be a spritesheet)
  91128. */
  91129. particleTexture: Nullable<Texture>;
  91130. /**
  91131. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91132. */
  91133. blendMode: number;
  91134. /**
  91135. * Minimum life time of emitting particles.
  91136. */
  91137. minLifeTime: number;
  91138. /**
  91139. * Maximum life time of emitting particles.
  91140. */
  91141. maxLifeTime: number;
  91142. /**
  91143. * Minimum Size of emitting particles.
  91144. */
  91145. minSize: number;
  91146. /**
  91147. * Maximum Size of emitting particles.
  91148. */
  91149. maxSize: number;
  91150. /**
  91151. * Minimum scale of emitting particles on X axis.
  91152. */
  91153. minScaleX: number;
  91154. /**
  91155. * Maximum scale of emitting particles on X axis.
  91156. */
  91157. maxScaleX: number;
  91158. /**
  91159. * Minimum scale of emitting particles on Y axis.
  91160. */
  91161. minScaleY: number;
  91162. /**
  91163. * Maximum scale of emitting particles on Y axis.
  91164. */
  91165. maxScaleY: number;
  91166. /**
  91167. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91168. */
  91169. color1: Color4;
  91170. /**
  91171. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91172. */
  91173. color2: Color4;
  91174. /**
  91175. * Color the particle will have at the end of its lifetime.
  91176. */
  91177. colorDead: Color4;
  91178. /**
  91179. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91180. */
  91181. emitRate: number;
  91182. /**
  91183. * You can use gravity if you want to give an orientation to your particles.
  91184. */
  91185. gravity: Vector3;
  91186. /**
  91187. * Minimum power of emitting particles.
  91188. */
  91189. minEmitPower: number;
  91190. /**
  91191. * Maximum power of emitting particles.
  91192. */
  91193. maxEmitPower: number;
  91194. /**
  91195. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91196. */
  91197. minAngularSpeed: number;
  91198. /**
  91199. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91200. */
  91201. maxAngularSpeed: number;
  91202. /**
  91203. * Gets or sets the minimal initial rotation in radians.
  91204. */
  91205. minInitialRotation: number;
  91206. /**
  91207. * Gets or sets the maximal initial rotation in radians.
  91208. */
  91209. maxInitialRotation: number;
  91210. /**
  91211. * The particle emitter type defines the emitter used by the particle system.
  91212. * It can be for example box, sphere, or cone...
  91213. */
  91214. particleEmitterType: Nullable<IParticleEmitterType>;
  91215. /**
  91216. * Defines the delay in milliseconds before starting the system (0 by default)
  91217. */
  91218. startDelay: number;
  91219. /**
  91220. * 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
  91221. */
  91222. preWarmCycles: number;
  91223. /**
  91224. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91225. */
  91226. preWarmStepOffset: number;
  91227. /**
  91228. * 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)
  91229. */
  91230. spriteCellChangeSpeed: number;
  91231. /**
  91232. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91233. */
  91234. startSpriteCellID: number;
  91235. /**
  91236. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91237. */
  91238. endSpriteCellID: number;
  91239. /**
  91240. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91241. */
  91242. spriteCellWidth: number;
  91243. /**
  91244. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91245. */
  91246. spriteCellHeight: number;
  91247. /**
  91248. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91249. */
  91250. spriteRandomStartCell: boolean;
  91251. /**
  91252. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91253. */
  91254. isAnimationSheetEnabled: boolean;
  91255. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91256. translationPivot: Vector2;
  91257. /**
  91258. * Gets or sets a texture used to add random noise to particle positions
  91259. */
  91260. noiseTexture: Nullable<BaseTexture>;
  91261. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91262. noiseStrength: Vector3;
  91263. /**
  91264. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91265. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91266. */
  91267. billboardMode: number;
  91268. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91269. limitVelocityDamping: number;
  91270. /**
  91271. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91272. */
  91273. beginAnimationOnStart: boolean;
  91274. /**
  91275. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91276. */
  91277. beginAnimationFrom: number;
  91278. /**
  91279. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91280. */
  91281. beginAnimationTo: number;
  91282. /**
  91283. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91284. */
  91285. beginAnimationLoop: boolean;
  91286. /**
  91287. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91288. */
  91289. disposeOnStop: boolean;
  91290. /**
  91291. * Gets the maximum number of particles active at the same time.
  91292. * @returns The max number of active particles.
  91293. */
  91294. getCapacity(): number;
  91295. /**
  91296. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91297. * @returns True if it has been started, otherwise false.
  91298. */
  91299. isStarted(): boolean;
  91300. /**
  91301. * Animates the particle system for this frame.
  91302. */
  91303. animate(): void;
  91304. /**
  91305. * Renders the particle system in its current state.
  91306. * @returns the current number of particles
  91307. */
  91308. render(): number;
  91309. /**
  91310. * Dispose the particle system and frees its associated resources.
  91311. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91312. */
  91313. dispose(disposeTexture?: boolean): void;
  91314. /**
  91315. * Clones the particle system.
  91316. * @param name The name of the cloned object
  91317. * @param newEmitter The new emitter to use
  91318. * @returns the cloned particle system
  91319. */
  91320. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91321. /**
  91322. * Serializes the particle system to a JSON object.
  91323. * @returns the JSON object
  91324. */
  91325. serialize(): any;
  91326. /**
  91327. * Rebuild the particle system
  91328. */
  91329. rebuild(): void;
  91330. /**
  91331. * Starts the particle system and begins to emit
  91332. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91333. */
  91334. start(delay?: number): void;
  91335. /**
  91336. * Stops the particle system.
  91337. */
  91338. stop(): void;
  91339. /**
  91340. * Remove all active particles
  91341. */
  91342. reset(): void;
  91343. /**
  91344. * Is this system ready to be used/rendered
  91345. * @return true if the system is ready
  91346. */
  91347. isReady(): boolean;
  91348. /**
  91349. * Adds a new color gradient
  91350. * @param gradient defines the gradient to use (between 0 and 1)
  91351. * @param color1 defines the color to affect to the specified gradient
  91352. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91353. * @returns the current particle system
  91354. */
  91355. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91356. /**
  91357. * Remove a specific color gradient
  91358. * @param gradient defines the gradient to remove
  91359. * @returns the current particle system
  91360. */
  91361. removeColorGradient(gradient: number): IParticleSystem;
  91362. /**
  91363. * Adds a new size gradient
  91364. * @param gradient defines the gradient to use (between 0 and 1)
  91365. * @param factor defines the size factor to affect to the specified gradient
  91366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91367. * @returns the current particle system
  91368. */
  91369. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91370. /**
  91371. * Remove a specific size gradient
  91372. * @param gradient defines the gradient to remove
  91373. * @returns the current particle system
  91374. */
  91375. removeSizeGradient(gradient: number): IParticleSystem;
  91376. /**
  91377. * Gets the current list of color gradients.
  91378. * You must use addColorGradient and removeColorGradient to udpate this list
  91379. * @returns the list of color gradients
  91380. */
  91381. getColorGradients(): Nullable<Array<ColorGradient>>;
  91382. /**
  91383. * Gets the current list of size gradients.
  91384. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91385. * @returns the list of size gradients
  91386. */
  91387. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91388. /**
  91389. * Gets the current list of angular speed gradients.
  91390. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91391. * @returns the list of angular speed gradients
  91392. */
  91393. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91394. /**
  91395. * Adds a new angular speed gradient
  91396. * @param gradient defines the gradient to use (between 0 and 1)
  91397. * @param factor defines the angular speed to affect to the specified gradient
  91398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91399. * @returns the current particle system
  91400. */
  91401. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91402. /**
  91403. * Remove a specific angular speed gradient
  91404. * @param gradient defines the gradient to remove
  91405. * @returns the current particle system
  91406. */
  91407. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91408. /**
  91409. * Gets the current list of velocity gradients.
  91410. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91411. * @returns the list of velocity gradients
  91412. */
  91413. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91414. /**
  91415. * Adds a new velocity gradient
  91416. * @param gradient defines the gradient to use (between 0 and 1)
  91417. * @param factor defines the velocity to affect to the specified gradient
  91418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91419. * @returns the current particle system
  91420. */
  91421. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91422. /**
  91423. * Remove a specific velocity gradient
  91424. * @param gradient defines the gradient to remove
  91425. * @returns the current particle system
  91426. */
  91427. removeVelocityGradient(gradient: number): IParticleSystem;
  91428. /**
  91429. * Gets the current list of limit velocity gradients.
  91430. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91431. * @returns the list of limit velocity gradients
  91432. */
  91433. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91434. /**
  91435. * Adds a new limit velocity gradient
  91436. * @param gradient defines the gradient to use (between 0 and 1)
  91437. * @param factor defines the limit velocity to affect to the specified gradient
  91438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91439. * @returns the current particle system
  91440. */
  91441. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91442. /**
  91443. * Remove a specific limit velocity gradient
  91444. * @param gradient defines the gradient to remove
  91445. * @returns the current particle system
  91446. */
  91447. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91448. /**
  91449. * Adds a new drag gradient
  91450. * @param gradient defines the gradient to use (between 0 and 1)
  91451. * @param factor defines the drag to affect to the specified gradient
  91452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91453. * @returns the current particle system
  91454. */
  91455. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91456. /**
  91457. * Remove a specific drag gradient
  91458. * @param gradient defines the gradient to remove
  91459. * @returns the current particle system
  91460. */
  91461. removeDragGradient(gradient: number): IParticleSystem;
  91462. /**
  91463. * Gets the current list of drag gradients.
  91464. * You must use addDragGradient and removeDragGradient to udpate this list
  91465. * @returns the list of drag gradients
  91466. */
  91467. getDragGradients(): Nullable<Array<FactorGradient>>;
  91468. /**
  91469. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91470. * @param gradient defines the gradient to use (between 0 and 1)
  91471. * @param factor defines the emit rate to affect to the specified gradient
  91472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91473. * @returns the current particle system
  91474. */
  91475. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91476. /**
  91477. * Remove a specific emit rate gradient
  91478. * @param gradient defines the gradient to remove
  91479. * @returns the current particle system
  91480. */
  91481. removeEmitRateGradient(gradient: number): IParticleSystem;
  91482. /**
  91483. * Gets the current list of emit rate gradients.
  91484. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91485. * @returns the list of emit rate gradients
  91486. */
  91487. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91488. /**
  91489. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91490. * @param gradient defines the gradient to use (between 0 and 1)
  91491. * @param factor defines the start size to affect to the specified gradient
  91492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91493. * @returns the current particle system
  91494. */
  91495. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91496. /**
  91497. * Remove a specific start size gradient
  91498. * @param gradient defines the gradient to remove
  91499. * @returns the current particle system
  91500. */
  91501. removeStartSizeGradient(gradient: number): IParticleSystem;
  91502. /**
  91503. * Gets the current list of start size gradients.
  91504. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91505. * @returns the list of start size gradients
  91506. */
  91507. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91508. /**
  91509. * Adds a new life time gradient
  91510. * @param gradient defines the gradient to use (between 0 and 1)
  91511. * @param factor defines the life time factor to affect to the specified gradient
  91512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91513. * @returns the current particle system
  91514. */
  91515. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91516. /**
  91517. * Remove a specific life time gradient
  91518. * @param gradient defines the gradient to remove
  91519. * @returns the current particle system
  91520. */
  91521. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91522. /**
  91523. * Gets the current list of life time gradients.
  91524. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91525. * @returns the list of life time gradients
  91526. */
  91527. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91528. /**
  91529. * Gets the current list of color gradients.
  91530. * You must use addColorGradient and removeColorGradient to udpate this list
  91531. * @returns the list of color gradients
  91532. */
  91533. getColorGradients(): Nullable<Array<ColorGradient>>;
  91534. /**
  91535. * Adds a new ramp gradient used to remap particle colors
  91536. * @param gradient defines the gradient to use (between 0 and 1)
  91537. * @param color defines the color to affect to the specified gradient
  91538. * @returns the current particle system
  91539. */
  91540. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91541. /**
  91542. * Gets the current list of ramp gradients.
  91543. * You must use addRampGradient and removeRampGradient to udpate this list
  91544. * @returns the list of ramp gradients
  91545. */
  91546. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91547. /** Gets or sets a boolean indicating that ramp gradients must be used
  91548. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91549. */
  91550. useRampGradients: boolean;
  91551. /**
  91552. * Adds a new color remap gradient
  91553. * @param gradient defines the gradient to use (between 0 and 1)
  91554. * @param min defines the color remap minimal range
  91555. * @param max defines the color remap maximal range
  91556. * @returns the current particle system
  91557. */
  91558. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91559. /**
  91560. * Gets the current list of color remap gradients.
  91561. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91562. * @returns the list of color remap gradients
  91563. */
  91564. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91565. /**
  91566. * Adds a new alpha remap gradient
  91567. * @param gradient defines the gradient to use (between 0 and 1)
  91568. * @param min defines the alpha remap minimal range
  91569. * @param max defines the alpha remap maximal range
  91570. * @returns the current particle system
  91571. */
  91572. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91573. /**
  91574. * Gets the current list of alpha remap gradients.
  91575. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91576. * @returns the list of alpha remap gradients
  91577. */
  91578. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91579. /**
  91580. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91581. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91582. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91583. * @returns the emitter
  91584. */
  91585. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91586. /**
  91587. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91588. * @param radius The radius of the hemisphere to emit from
  91589. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91590. * @returns the emitter
  91591. */
  91592. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91593. /**
  91594. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91595. * @param radius The radius of the sphere to emit from
  91596. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91597. * @returns the emitter
  91598. */
  91599. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91600. /**
  91601. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91602. * @param radius The radius of the sphere to emit from
  91603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91605. * @returns the emitter
  91606. */
  91607. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91608. /**
  91609. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91610. * @param radius The radius of the emission cylinder
  91611. * @param height The height of the emission cylinder
  91612. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91613. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91614. * @returns the emitter
  91615. */
  91616. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91617. /**
  91618. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91619. * @param radius The radius of the cylinder to emit from
  91620. * @param height The height of the emission cylinder
  91621. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91624. * @returns the emitter
  91625. */
  91626. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91627. /**
  91628. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91629. * @param radius The radius of the cone to emit from
  91630. * @param angle The base angle of the cone
  91631. * @returns the emitter
  91632. */
  91633. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91634. /**
  91635. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91636. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91637. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91638. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91639. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91640. * @returns the emitter
  91641. */
  91642. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91643. /**
  91644. * Get hosting scene
  91645. * @returns the scene
  91646. */
  91647. getScene(): Scene;
  91648. }
  91649. }
  91650. declare module BABYLON {
  91651. /**
  91652. * Creates an instance based on a source mesh.
  91653. */
  91654. export class InstancedMesh extends AbstractMesh {
  91655. private _sourceMesh;
  91656. private _currentLOD;
  91657. /** @hidden */
  91658. _indexInSourceMeshInstanceArray: number;
  91659. constructor(name: string, source: Mesh);
  91660. /**
  91661. * Returns the string "InstancedMesh".
  91662. */
  91663. getClassName(): string;
  91664. /** Gets the list of lights affecting that mesh */
  91665. get lightSources(): Light[];
  91666. _resyncLightSources(): void;
  91667. _resyncLightSource(light: Light): void;
  91668. _removeLightSource(light: Light, dispose: boolean): void;
  91669. /**
  91670. * If the source mesh receives shadows
  91671. */
  91672. get receiveShadows(): boolean;
  91673. /**
  91674. * The material of the source mesh
  91675. */
  91676. get material(): Nullable<Material>;
  91677. /**
  91678. * Visibility of the source mesh
  91679. */
  91680. get visibility(): number;
  91681. /**
  91682. * Skeleton of the source mesh
  91683. */
  91684. get skeleton(): Nullable<Skeleton>;
  91685. /**
  91686. * Rendering ground id of the source mesh
  91687. */
  91688. get renderingGroupId(): number;
  91689. set renderingGroupId(value: number);
  91690. /**
  91691. * Returns the total number of vertices (integer).
  91692. */
  91693. getTotalVertices(): number;
  91694. /**
  91695. * Returns a positive integer : the total number of indices in this mesh geometry.
  91696. * @returns the numner of indices or zero if the mesh has no geometry.
  91697. */
  91698. getTotalIndices(): number;
  91699. /**
  91700. * The source mesh of the instance
  91701. */
  91702. get sourceMesh(): Mesh;
  91703. /**
  91704. * Is this node ready to be used/rendered
  91705. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91706. * @return {boolean} is it ready
  91707. */
  91708. isReady(completeCheck?: boolean): boolean;
  91709. /**
  91710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91711. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91712. * @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.
  91713. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91714. */
  91715. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91716. /**
  91717. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91718. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91719. * The `data` are either a numeric array either a Float32Array.
  91720. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91721. * 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).
  91722. * Note that a new underlying VertexBuffer object is created each call.
  91723. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91724. *
  91725. * Possible `kind` values :
  91726. * - VertexBuffer.PositionKind
  91727. * - VertexBuffer.UVKind
  91728. * - VertexBuffer.UV2Kind
  91729. * - VertexBuffer.UV3Kind
  91730. * - VertexBuffer.UV4Kind
  91731. * - VertexBuffer.UV5Kind
  91732. * - VertexBuffer.UV6Kind
  91733. * - VertexBuffer.ColorKind
  91734. * - VertexBuffer.MatricesIndicesKind
  91735. * - VertexBuffer.MatricesIndicesExtraKind
  91736. * - VertexBuffer.MatricesWeightsKind
  91737. * - VertexBuffer.MatricesWeightsExtraKind
  91738. *
  91739. * Returns the Mesh.
  91740. */
  91741. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91742. /**
  91743. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91744. * If the mesh has no geometry, it is simply returned as it is.
  91745. * The `data` are either a numeric array either a Float32Array.
  91746. * No new underlying VertexBuffer object is created.
  91747. * 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.
  91748. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91749. *
  91750. * Possible `kind` values :
  91751. * - VertexBuffer.PositionKind
  91752. * - VertexBuffer.UVKind
  91753. * - VertexBuffer.UV2Kind
  91754. * - VertexBuffer.UV3Kind
  91755. * - VertexBuffer.UV4Kind
  91756. * - VertexBuffer.UV5Kind
  91757. * - VertexBuffer.UV6Kind
  91758. * - VertexBuffer.ColorKind
  91759. * - VertexBuffer.MatricesIndicesKind
  91760. * - VertexBuffer.MatricesIndicesExtraKind
  91761. * - VertexBuffer.MatricesWeightsKind
  91762. * - VertexBuffer.MatricesWeightsExtraKind
  91763. *
  91764. * Returns the Mesh.
  91765. */
  91766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91767. /**
  91768. * Sets the mesh indices.
  91769. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91770. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91771. * This method creates a new index buffer each call.
  91772. * Returns the Mesh.
  91773. */
  91774. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91775. /**
  91776. * Boolean : True if the mesh owns the requested kind of data.
  91777. */
  91778. isVerticesDataPresent(kind: string): boolean;
  91779. /**
  91780. * Returns an array of indices (IndicesArray).
  91781. */
  91782. getIndices(): Nullable<IndicesArray>;
  91783. get _positions(): Nullable<Vector3[]>;
  91784. /**
  91785. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91786. * This means the mesh underlying bounding box and sphere are recomputed.
  91787. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91788. * @returns the current mesh
  91789. */
  91790. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91791. /** @hidden */
  91792. _preActivate(): InstancedMesh;
  91793. /** @hidden */
  91794. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91795. /** @hidden */
  91796. _postActivate(): void;
  91797. getWorldMatrix(): Matrix;
  91798. get isAnInstance(): boolean;
  91799. /**
  91800. * Returns the current associated LOD AbstractMesh.
  91801. */
  91802. getLOD(camera: Camera): AbstractMesh;
  91803. /** @hidden */
  91804. _syncSubMeshes(): InstancedMesh;
  91805. /** @hidden */
  91806. _generatePointsArray(): boolean;
  91807. /**
  91808. * Creates a new InstancedMesh from the current mesh.
  91809. * - name (string) : the cloned mesh name
  91810. * - newParent (optional Node) : the optional Node to parent the clone to.
  91811. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91812. *
  91813. * Returns the clone.
  91814. */
  91815. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91816. /**
  91817. * Disposes the InstancedMesh.
  91818. * Returns nothing.
  91819. */
  91820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91821. }
  91822. interface Mesh {
  91823. /**
  91824. * Register a custom buffer that will be instanced
  91825. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91826. * @param kind defines the buffer kind
  91827. * @param stride defines the stride in floats
  91828. */
  91829. registerInstancedBuffer(kind: string, stride: number): void;
  91830. /** @hidden */
  91831. _userInstancedBuffersStorage: {
  91832. data: {
  91833. [key: string]: Float32Array;
  91834. };
  91835. sizes: {
  91836. [key: string]: number;
  91837. };
  91838. vertexBuffers: {
  91839. [key: string]: Nullable<VertexBuffer>;
  91840. };
  91841. strides: {
  91842. [key: string]: number;
  91843. };
  91844. };
  91845. }
  91846. interface AbstractMesh {
  91847. /**
  91848. * Object used to store instanced buffers defined by user
  91849. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91850. */
  91851. instancedBuffers: {
  91852. [key: string]: any;
  91853. };
  91854. }
  91855. }
  91856. declare module BABYLON {
  91857. /**
  91858. * Defines the options associated with the creation of a shader material.
  91859. */
  91860. export interface IShaderMaterialOptions {
  91861. /**
  91862. * Does the material work in alpha blend mode
  91863. */
  91864. needAlphaBlending: boolean;
  91865. /**
  91866. * Does the material work in alpha test mode
  91867. */
  91868. needAlphaTesting: boolean;
  91869. /**
  91870. * The list of attribute names used in the shader
  91871. */
  91872. attributes: string[];
  91873. /**
  91874. * The list of unifrom names used in the shader
  91875. */
  91876. uniforms: string[];
  91877. /**
  91878. * The list of UBO names used in the shader
  91879. */
  91880. uniformBuffers: string[];
  91881. /**
  91882. * The list of sampler names used in the shader
  91883. */
  91884. samplers: string[];
  91885. /**
  91886. * The list of defines used in the shader
  91887. */
  91888. defines: string[];
  91889. }
  91890. /**
  91891. * 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.
  91892. *
  91893. * This returned material effects how the mesh will look based on the code in the shaders.
  91894. *
  91895. * @see http://doc.babylonjs.com/how_to/shader_material
  91896. */
  91897. export class ShaderMaterial extends Material {
  91898. private _shaderPath;
  91899. private _options;
  91900. private _textures;
  91901. private _textureArrays;
  91902. private _floats;
  91903. private _ints;
  91904. private _floatsArrays;
  91905. private _colors3;
  91906. private _colors3Arrays;
  91907. private _colors4;
  91908. private _colors4Arrays;
  91909. private _vectors2;
  91910. private _vectors3;
  91911. private _vectors4;
  91912. private _matrices;
  91913. private _matrixArrays;
  91914. private _matrices3x3;
  91915. private _matrices2x2;
  91916. private _vectors2Arrays;
  91917. private _vectors3Arrays;
  91918. private _vectors4Arrays;
  91919. private _cachedWorldViewMatrix;
  91920. private _cachedWorldViewProjectionMatrix;
  91921. private _renderId;
  91922. private _multiview;
  91923. /**
  91924. * Instantiate a new shader material.
  91925. * 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.
  91926. * This returned material effects how the mesh will look based on the code in the shaders.
  91927. * @see http://doc.babylonjs.com/how_to/shader_material
  91928. * @param name Define the name of the material in the scene
  91929. * @param scene Define the scene the material belongs to
  91930. * @param shaderPath Defines the route to the shader code in one of three ways:
  91931. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91932. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91933. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91934. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  91935. * @param options Define the options used to create the shader
  91936. */
  91937. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  91938. /**
  91939. * Gets the shader path used to define the shader code
  91940. * It can be modified to trigger a new compilation
  91941. */
  91942. get shaderPath(): any;
  91943. /**
  91944. * Sets the shader path used to define the shader code
  91945. * It can be modified to trigger a new compilation
  91946. */
  91947. set shaderPath(shaderPath: any);
  91948. /**
  91949. * Gets the options used to compile the shader.
  91950. * They can be modified to trigger a new compilation
  91951. */
  91952. get options(): IShaderMaterialOptions;
  91953. /**
  91954. * Gets the current class name of the material e.g. "ShaderMaterial"
  91955. * Mainly use in serialization.
  91956. * @returns the class name
  91957. */
  91958. getClassName(): string;
  91959. /**
  91960. * Specifies if the material will require alpha blending
  91961. * @returns a boolean specifying if alpha blending is needed
  91962. */
  91963. needAlphaBlending(): boolean;
  91964. /**
  91965. * Specifies if this material should be rendered in alpha test mode
  91966. * @returns a boolean specifying if an alpha test is needed.
  91967. */
  91968. needAlphaTesting(): boolean;
  91969. private _checkUniform;
  91970. /**
  91971. * Set a texture in the shader.
  91972. * @param name Define the name of the uniform samplers as defined in the shader
  91973. * @param texture Define the texture to bind to this sampler
  91974. * @return the material itself allowing "fluent" like uniform updates
  91975. */
  91976. setTexture(name: string, texture: Texture): ShaderMaterial;
  91977. /**
  91978. * Set a texture array in the shader.
  91979. * @param name Define the name of the uniform sampler array as defined in the shader
  91980. * @param textures Define the list of textures to bind to this sampler
  91981. * @return the material itself allowing "fluent" like uniform updates
  91982. */
  91983. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  91984. /**
  91985. * Set a float in the shader.
  91986. * @param name Define the name of the uniform as defined in the shader
  91987. * @param value Define the value to give to the uniform
  91988. * @return the material itself allowing "fluent" like uniform updates
  91989. */
  91990. setFloat(name: string, value: number): ShaderMaterial;
  91991. /**
  91992. * Set a int in the shader.
  91993. * @param name Define the name of the uniform as defined in the shader
  91994. * @param value Define the value to give to the uniform
  91995. * @return the material itself allowing "fluent" like uniform updates
  91996. */
  91997. setInt(name: string, value: number): ShaderMaterial;
  91998. /**
  91999. * Set an array of floats in the shader.
  92000. * @param name Define the name of the uniform as defined in the shader
  92001. * @param value Define the value to give to the uniform
  92002. * @return the material itself allowing "fluent" like uniform updates
  92003. */
  92004. setFloats(name: string, value: number[]): ShaderMaterial;
  92005. /**
  92006. * Set a vec3 in the shader from a Color3.
  92007. * @param name Define the name of the uniform as defined in the shader
  92008. * @param value Define the value to give to the uniform
  92009. * @return the material itself allowing "fluent" like uniform updates
  92010. */
  92011. setColor3(name: string, value: Color3): ShaderMaterial;
  92012. /**
  92013. * Set a vec3 array in the shader from a Color3 array.
  92014. * @param name Define the name of the uniform as defined in the shader
  92015. * @param value Define the value to give to the uniform
  92016. * @return the material itself allowing "fluent" like uniform updates
  92017. */
  92018. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  92019. /**
  92020. * Set a vec4 in the shader from a Color4.
  92021. * @param name Define the name of the uniform as defined in the shader
  92022. * @param value Define the value to give to the uniform
  92023. * @return the material itself allowing "fluent" like uniform updates
  92024. */
  92025. setColor4(name: string, value: Color4): ShaderMaterial;
  92026. /**
  92027. * Set a vec4 array in the shader from a Color4 array.
  92028. * @param name Define the name of the uniform as defined in the shader
  92029. * @param value Define the value to give to the uniform
  92030. * @return the material itself allowing "fluent" like uniform updates
  92031. */
  92032. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  92033. /**
  92034. * Set a vec2 in the shader from a Vector2.
  92035. * @param name Define the name of the uniform as defined in the shader
  92036. * @param value Define the value to give to the uniform
  92037. * @return the material itself allowing "fluent" like uniform updates
  92038. */
  92039. setVector2(name: string, value: Vector2): ShaderMaterial;
  92040. /**
  92041. * Set a vec3 in the shader from a Vector3.
  92042. * @param name Define the name of the uniform as defined in the shader
  92043. * @param value Define the value to give to the uniform
  92044. * @return the material itself allowing "fluent" like uniform updates
  92045. */
  92046. setVector3(name: string, value: Vector3): ShaderMaterial;
  92047. /**
  92048. * Set a vec4 in the shader from a Vector4.
  92049. * @param name Define the name of the uniform as defined in the shader
  92050. * @param value Define the value to give to the uniform
  92051. * @return the material itself allowing "fluent" like uniform updates
  92052. */
  92053. setVector4(name: string, value: Vector4): ShaderMaterial;
  92054. /**
  92055. * Set a mat4 in the shader from a Matrix.
  92056. * @param name Define the name of the uniform as defined in the shader
  92057. * @param value Define the value to give to the uniform
  92058. * @return the material itself allowing "fluent" like uniform updates
  92059. */
  92060. setMatrix(name: string, value: Matrix): ShaderMaterial;
  92061. /**
  92062. * Set a float32Array in the shader from a matrix array.
  92063. * @param name Define the name of the uniform as defined in the shader
  92064. * @param value Define the value to give to the uniform
  92065. * @return the material itself allowing "fluent" like uniform updates
  92066. */
  92067. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  92068. /**
  92069. * Set a mat3 in the shader from a Float32Array.
  92070. * @param name Define the name of the uniform as defined in the shader
  92071. * @param value Define the value to give to the uniform
  92072. * @return the material itself allowing "fluent" like uniform updates
  92073. */
  92074. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  92075. /**
  92076. * Set a mat2 in the shader from a Float32Array.
  92077. * @param name Define the name of the uniform as defined in the shader
  92078. * @param value Define the value to give to the uniform
  92079. * @return the material itself allowing "fluent" like uniform updates
  92080. */
  92081. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  92082. /**
  92083. * Set a vec2 array in the shader from a number array.
  92084. * @param name Define the name of the uniform as defined in the shader
  92085. * @param value Define the value to give to the uniform
  92086. * @return the material itself allowing "fluent" like uniform updates
  92087. */
  92088. setArray2(name: string, value: number[]): ShaderMaterial;
  92089. /**
  92090. * Set a vec3 array in the shader from a number array.
  92091. * @param name Define the name of the uniform as defined in the shader
  92092. * @param value Define the value to give to the uniform
  92093. * @return the material itself allowing "fluent" like uniform updates
  92094. */
  92095. setArray3(name: string, value: number[]): ShaderMaterial;
  92096. /**
  92097. * Set a vec4 array in the shader from a number array.
  92098. * @param name Define the name of the uniform as defined in the shader
  92099. * @param value Define the value to give to the uniform
  92100. * @return the material itself allowing "fluent" like uniform updates
  92101. */
  92102. setArray4(name: string, value: number[]): ShaderMaterial;
  92103. private _checkCache;
  92104. /**
  92105. * Specifies that the submesh is ready to be used
  92106. * @param mesh defines the mesh to check
  92107. * @param subMesh defines which submesh to check
  92108. * @param useInstances specifies that instances should be used
  92109. * @returns a boolean indicating that the submesh is ready or not
  92110. */
  92111. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92112. /**
  92113. * Checks if the material is ready to render the requested mesh
  92114. * @param mesh Define the mesh to render
  92115. * @param useInstances Define whether or not the material is used with instances
  92116. * @returns true if ready, otherwise false
  92117. */
  92118. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92119. /**
  92120. * Binds the world matrix to the material
  92121. * @param world defines the world transformation matrix
  92122. */
  92123. bindOnlyWorldMatrix(world: Matrix): void;
  92124. /**
  92125. * Binds the material to the mesh
  92126. * @param world defines the world transformation matrix
  92127. * @param mesh defines the mesh to bind the material to
  92128. */
  92129. bind(world: Matrix, mesh?: Mesh): void;
  92130. /**
  92131. * Gets the active textures from the material
  92132. * @returns an array of textures
  92133. */
  92134. getActiveTextures(): BaseTexture[];
  92135. /**
  92136. * Specifies if the material uses a texture
  92137. * @param texture defines the texture to check against the material
  92138. * @returns a boolean specifying if the material uses the texture
  92139. */
  92140. hasTexture(texture: BaseTexture): boolean;
  92141. /**
  92142. * Makes a duplicate of the material, and gives it a new name
  92143. * @param name defines the new name for the duplicated material
  92144. * @returns the cloned material
  92145. */
  92146. clone(name: string): ShaderMaterial;
  92147. /**
  92148. * Disposes the material
  92149. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92150. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92151. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92152. */
  92153. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92154. /**
  92155. * Serializes this material in a JSON representation
  92156. * @returns the serialized material object
  92157. */
  92158. serialize(): any;
  92159. /**
  92160. * Creates a shader material from parsed shader material data
  92161. * @param source defines the JSON represnetation of the material
  92162. * @param scene defines the hosting scene
  92163. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92164. * @returns a new material
  92165. */
  92166. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  92167. }
  92168. }
  92169. declare module BABYLON {
  92170. /** @hidden */
  92171. export var colorPixelShader: {
  92172. name: string;
  92173. shader: string;
  92174. };
  92175. }
  92176. declare module BABYLON {
  92177. /** @hidden */
  92178. export var colorVertexShader: {
  92179. name: string;
  92180. shader: string;
  92181. };
  92182. }
  92183. declare module BABYLON {
  92184. /**
  92185. * Line mesh
  92186. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  92187. */
  92188. export class LinesMesh extends Mesh {
  92189. /**
  92190. * If vertex color should be applied to the mesh
  92191. */
  92192. readonly useVertexColor?: boolean | undefined;
  92193. /**
  92194. * If vertex alpha should be applied to the mesh
  92195. */
  92196. readonly useVertexAlpha?: boolean | undefined;
  92197. /**
  92198. * Color of the line (Default: White)
  92199. */
  92200. color: Color3;
  92201. /**
  92202. * Alpha of the line (Default: 1)
  92203. */
  92204. alpha: number;
  92205. /**
  92206. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92207. * This margin is expressed in world space coordinates, so its value may vary.
  92208. * Default value is 0.1
  92209. */
  92210. intersectionThreshold: number;
  92211. private _colorShader;
  92212. private color4;
  92213. /**
  92214. * Creates a new LinesMesh
  92215. * @param name defines the name
  92216. * @param scene defines the hosting scene
  92217. * @param parent defines the parent mesh if any
  92218. * @param source defines the optional source LinesMesh used to clone data from
  92219. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92220. * When false, achieved by calling a clone(), also passing False.
  92221. * This will make creation of children, recursive.
  92222. * @param useVertexColor defines if this LinesMesh supports vertex color
  92223. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  92224. */
  92225. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  92226. /**
  92227. * If vertex color should be applied to the mesh
  92228. */
  92229. useVertexColor?: boolean | undefined,
  92230. /**
  92231. * If vertex alpha should be applied to the mesh
  92232. */
  92233. useVertexAlpha?: boolean | undefined);
  92234. private _addClipPlaneDefine;
  92235. private _removeClipPlaneDefine;
  92236. isReady(): boolean;
  92237. /**
  92238. * Returns the string "LineMesh"
  92239. */
  92240. getClassName(): string;
  92241. /**
  92242. * @hidden
  92243. */
  92244. get material(): Material;
  92245. /**
  92246. * @hidden
  92247. */
  92248. set material(value: Material);
  92249. /**
  92250. * @hidden
  92251. */
  92252. get checkCollisions(): boolean;
  92253. /** @hidden */
  92254. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92255. /** @hidden */
  92256. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92257. /**
  92258. * Disposes of the line mesh
  92259. * @param doNotRecurse If children should be disposed
  92260. */
  92261. dispose(doNotRecurse?: boolean): void;
  92262. /**
  92263. * Returns a new LineMesh object cloned from the current one.
  92264. */
  92265. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  92266. /**
  92267. * Creates a new InstancedLinesMesh object from the mesh model.
  92268. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92269. * @param name defines the name of the new instance
  92270. * @returns a new InstancedLinesMesh
  92271. */
  92272. createInstance(name: string): InstancedLinesMesh;
  92273. }
  92274. /**
  92275. * Creates an instance based on a source LinesMesh
  92276. */
  92277. export class InstancedLinesMesh extends InstancedMesh {
  92278. /**
  92279. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92280. * This margin is expressed in world space coordinates, so its value may vary.
  92281. * Initilized with the intersectionThreshold value of the source LinesMesh
  92282. */
  92283. intersectionThreshold: number;
  92284. constructor(name: string, source: LinesMesh);
  92285. /**
  92286. * Returns the string "InstancedLinesMesh".
  92287. */
  92288. getClassName(): string;
  92289. }
  92290. }
  92291. declare module BABYLON {
  92292. /** @hidden */
  92293. export var linePixelShader: {
  92294. name: string;
  92295. shader: string;
  92296. };
  92297. }
  92298. declare module BABYLON {
  92299. /** @hidden */
  92300. export var lineVertexShader: {
  92301. name: string;
  92302. shader: string;
  92303. };
  92304. }
  92305. declare module BABYLON {
  92306. interface AbstractMesh {
  92307. /**
  92308. * Gets the edgesRenderer associated with the mesh
  92309. */
  92310. edgesRenderer: Nullable<EdgesRenderer>;
  92311. }
  92312. interface LinesMesh {
  92313. /**
  92314. * Enables the edge rendering mode on the mesh.
  92315. * This mode makes the mesh edges visible
  92316. * @param epsilon defines the maximal distance between two angles to detect a face
  92317. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92318. * @returns the currentAbstractMesh
  92319. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92320. */
  92321. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92322. }
  92323. interface InstancedLinesMesh {
  92324. /**
  92325. * Enables the edge rendering mode on the mesh.
  92326. * This mode makes the mesh edges visible
  92327. * @param epsilon defines the maximal distance between two angles to detect a face
  92328. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92329. * @returns the current InstancedLinesMesh
  92330. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92331. */
  92332. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  92333. }
  92334. /**
  92335. * Defines the minimum contract an Edges renderer should follow.
  92336. */
  92337. export interface IEdgesRenderer extends IDisposable {
  92338. /**
  92339. * Gets or sets a boolean indicating if the edgesRenderer is active
  92340. */
  92341. isEnabled: boolean;
  92342. /**
  92343. * Renders the edges of the attached mesh,
  92344. */
  92345. render(): void;
  92346. /**
  92347. * Checks wether or not the edges renderer is ready to render.
  92348. * @return true if ready, otherwise false.
  92349. */
  92350. isReady(): boolean;
  92351. }
  92352. /**
  92353. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  92354. */
  92355. export class EdgesRenderer implements IEdgesRenderer {
  92356. /**
  92357. * Define the size of the edges with an orthographic camera
  92358. */
  92359. edgesWidthScalerForOrthographic: number;
  92360. /**
  92361. * Define the size of the edges with a perspective camera
  92362. */
  92363. edgesWidthScalerForPerspective: number;
  92364. protected _source: AbstractMesh;
  92365. protected _linesPositions: number[];
  92366. protected _linesNormals: number[];
  92367. protected _linesIndices: number[];
  92368. protected _epsilon: number;
  92369. protected _indicesCount: number;
  92370. protected _lineShader: ShaderMaterial;
  92371. protected _ib: DataBuffer;
  92372. protected _buffers: {
  92373. [key: string]: Nullable<VertexBuffer>;
  92374. };
  92375. protected _checkVerticesInsteadOfIndices: boolean;
  92376. private _meshRebuildObserver;
  92377. private _meshDisposeObserver;
  92378. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  92379. isEnabled: boolean;
  92380. /**
  92381. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  92382. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  92383. * @param source Mesh used to create edges
  92384. * @param epsilon sum of angles in adjacency to check for edge
  92385. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  92386. * @param generateEdgesLines - should generate Lines or only prepare resources.
  92387. */
  92388. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  92389. protected _prepareRessources(): void;
  92390. /** @hidden */
  92391. _rebuild(): void;
  92392. /**
  92393. * Releases the required resources for the edges renderer
  92394. */
  92395. dispose(): void;
  92396. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92397. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92398. /**
  92399. * Checks if the pair of p0 and p1 is en edge
  92400. * @param faceIndex
  92401. * @param edge
  92402. * @param faceNormals
  92403. * @param p0
  92404. * @param p1
  92405. * @private
  92406. */
  92407. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92408. /**
  92409. * push line into the position, normal and index buffer
  92410. * @protected
  92411. */
  92412. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92413. /**
  92414. * Generates lines edges from adjacencjes
  92415. * @private
  92416. */
  92417. _generateEdgesLines(): void;
  92418. /**
  92419. * Checks wether or not the edges renderer is ready to render.
  92420. * @return true if ready, otherwise false.
  92421. */
  92422. isReady(): boolean;
  92423. /**
  92424. * Renders the edges of the attached mesh,
  92425. */
  92426. render(): void;
  92427. }
  92428. /**
  92429. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92430. */
  92431. export class LineEdgesRenderer extends EdgesRenderer {
  92432. /**
  92433. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92434. * @param source LineMesh used to generate edges
  92435. * @param epsilon not important (specified angle for edge detection)
  92436. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92437. */
  92438. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92439. /**
  92440. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92441. */
  92442. _generateEdgesLines(): void;
  92443. }
  92444. }
  92445. declare module BABYLON {
  92446. /**
  92447. * This represents the object necessary to create a rendering group.
  92448. * This is exclusively used and created by the rendering manager.
  92449. * To modify the behavior, you use the available helpers in your scene or meshes.
  92450. * @hidden
  92451. */
  92452. export class RenderingGroup {
  92453. index: number;
  92454. private static _zeroVector;
  92455. private _scene;
  92456. private _opaqueSubMeshes;
  92457. private _transparentSubMeshes;
  92458. private _alphaTestSubMeshes;
  92459. private _depthOnlySubMeshes;
  92460. private _particleSystems;
  92461. private _spriteManagers;
  92462. private _opaqueSortCompareFn;
  92463. private _alphaTestSortCompareFn;
  92464. private _transparentSortCompareFn;
  92465. private _renderOpaque;
  92466. private _renderAlphaTest;
  92467. private _renderTransparent;
  92468. /** @hidden */
  92469. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92470. onBeforeTransparentRendering: () => void;
  92471. /**
  92472. * Set the opaque sort comparison function.
  92473. * If null the sub meshes will be render in the order they were created
  92474. */
  92475. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92476. /**
  92477. * Set the alpha test sort comparison function.
  92478. * If null the sub meshes will be render in the order they were created
  92479. */
  92480. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92481. /**
  92482. * Set the transparent sort comparison function.
  92483. * If null the sub meshes will be render in the order they were created
  92484. */
  92485. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92486. /**
  92487. * Creates a new rendering group.
  92488. * @param index The rendering group index
  92489. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92490. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92491. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92492. */
  92493. 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>);
  92494. /**
  92495. * Render all the sub meshes contained in the group.
  92496. * @param customRenderFunction Used to override the default render behaviour of the group.
  92497. * @returns true if rendered some submeshes.
  92498. */
  92499. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92500. /**
  92501. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92502. * @param subMeshes The submeshes to render
  92503. */
  92504. private renderOpaqueSorted;
  92505. /**
  92506. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92507. * @param subMeshes The submeshes to render
  92508. */
  92509. private renderAlphaTestSorted;
  92510. /**
  92511. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92512. * @param subMeshes The submeshes to render
  92513. */
  92514. private renderTransparentSorted;
  92515. /**
  92516. * Renders the submeshes in a specified order.
  92517. * @param subMeshes The submeshes to sort before render
  92518. * @param sortCompareFn The comparison function use to sort
  92519. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92520. * @param transparent Specifies to activate blending if true
  92521. */
  92522. private static renderSorted;
  92523. /**
  92524. * Renders the submeshes in the order they were dispatched (no sort applied).
  92525. * @param subMeshes The submeshes to render
  92526. */
  92527. private static renderUnsorted;
  92528. /**
  92529. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92530. * are rendered back to front if in the same alpha index.
  92531. *
  92532. * @param a The first submesh
  92533. * @param b The second submesh
  92534. * @returns The result of the comparison
  92535. */
  92536. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92537. /**
  92538. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92539. * are rendered back to front.
  92540. *
  92541. * @param a The first submesh
  92542. * @param b The second submesh
  92543. * @returns The result of the comparison
  92544. */
  92545. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92546. /**
  92547. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92548. * are rendered front to back (prevent overdraw).
  92549. *
  92550. * @param a The first submesh
  92551. * @param b The second submesh
  92552. * @returns The result of the comparison
  92553. */
  92554. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  92555. /**
  92556. * Resets the different lists of submeshes to prepare a new frame.
  92557. */
  92558. prepare(): void;
  92559. dispose(): void;
  92560. /**
  92561. * Inserts the submesh in its correct queue depending on its material.
  92562. * @param subMesh The submesh to dispatch
  92563. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92564. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92565. */
  92566. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92567. dispatchSprites(spriteManager: ISpriteManager): void;
  92568. dispatchParticles(particleSystem: IParticleSystem): void;
  92569. private _renderParticles;
  92570. private _renderSprites;
  92571. }
  92572. }
  92573. declare module BABYLON {
  92574. /**
  92575. * Interface describing the different options available in the rendering manager
  92576. * regarding Auto Clear between groups.
  92577. */
  92578. export interface IRenderingManagerAutoClearSetup {
  92579. /**
  92580. * Defines whether or not autoclear is enable.
  92581. */
  92582. autoClear: boolean;
  92583. /**
  92584. * Defines whether or not to autoclear the depth buffer.
  92585. */
  92586. depth: boolean;
  92587. /**
  92588. * Defines whether or not to autoclear the stencil buffer.
  92589. */
  92590. stencil: boolean;
  92591. }
  92592. /**
  92593. * This class is used by the onRenderingGroupObservable
  92594. */
  92595. export class RenderingGroupInfo {
  92596. /**
  92597. * The Scene that being rendered
  92598. */
  92599. scene: Scene;
  92600. /**
  92601. * The camera currently used for the rendering pass
  92602. */
  92603. camera: Nullable<Camera>;
  92604. /**
  92605. * The ID of the renderingGroup being processed
  92606. */
  92607. renderingGroupId: number;
  92608. }
  92609. /**
  92610. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92611. * It is enable to manage the different groups as well as the different necessary sort functions.
  92612. * This should not be used directly aside of the few static configurations
  92613. */
  92614. export class RenderingManager {
  92615. /**
  92616. * The max id used for rendering groups (not included)
  92617. */
  92618. static MAX_RENDERINGGROUPS: number;
  92619. /**
  92620. * The min id used for rendering groups (included)
  92621. */
  92622. static MIN_RENDERINGGROUPS: number;
  92623. /**
  92624. * Used to globally prevent autoclearing scenes.
  92625. */
  92626. static AUTOCLEAR: boolean;
  92627. /**
  92628. * @hidden
  92629. */
  92630. _useSceneAutoClearSetup: boolean;
  92631. private _scene;
  92632. private _renderingGroups;
  92633. private _depthStencilBufferAlreadyCleaned;
  92634. private _autoClearDepthStencil;
  92635. private _customOpaqueSortCompareFn;
  92636. private _customAlphaTestSortCompareFn;
  92637. private _customTransparentSortCompareFn;
  92638. private _renderingGroupInfo;
  92639. /**
  92640. * Instantiates a new rendering group for a particular scene
  92641. * @param scene Defines the scene the groups belongs to
  92642. */
  92643. constructor(scene: Scene);
  92644. private _clearDepthStencilBuffer;
  92645. /**
  92646. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92647. * @hidden
  92648. */
  92649. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92650. /**
  92651. * Resets the different information of the group to prepare a new frame
  92652. * @hidden
  92653. */
  92654. reset(): void;
  92655. /**
  92656. * Dispose and release the group and its associated resources.
  92657. * @hidden
  92658. */
  92659. dispose(): void;
  92660. /**
  92661. * Clear the info related to rendering groups preventing retention points during dispose.
  92662. */
  92663. freeRenderingGroups(): void;
  92664. private _prepareRenderingGroup;
  92665. /**
  92666. * Add a sprite manager to the rendering manager in order to render it this frame.
  92667. * @param spriteManager Define the sprite manager to render
  92668. */
  92669. dispatchSprites(spriteManager: ISpriteManager): void;
  92670. /**
  92671. * Add a particle system to the rendering manager in order to render it this frame.
  92672. * @param particleSystem Define the particle system to render
  92673. */
  92674. dispatchParticles(particleSystem: IParticleSystem): void;
  92675. /**
  92676. * Add a submesh to the manager in order to render it this frame
  92677. * @param subMesh The submesh to dispatch
  92678. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92679. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92680. */
  92681. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92682. /**
  92683. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92684. * This allowed control for front to back rendering or reversly depending of the special needs.
  92685. *
  92686. * @param renderingGroupId The rendering group id corresponding to its index
  92687. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92688. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92689. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92690. */
  92691. 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;
  92692. /**
  92693. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92694. *
  92695. * @param renderingGroupId The rendering group id corresponding to its index
  92696. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92697. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92698. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92699. */
  92700. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92701. /**
  92702. * Gets the current auto clear configuration for one rendering group of the rendering
  92703. * manager.
  92704. * @param index the rendering group index to get the information for
  92705. * @returns The auto clear setup for the requested rendering group
  92706. */
  92707. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92708. }
  92709. }
  92710. declare module BABYLON {
  92711. /**
  92712. * This Helps creating a texture that will be created from a camera in your scene.
  92713. * It is basically a dynamic texture that could be used to create special effects for instance.
  92714. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  92715. */
  92716. export class RenderTargetTexture extends Texture {
  92717. isCube: boolean;
  92718. /**
  92719. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  92720. */
  92721. static readonly REFRESHRATE_RENDER_ONCE: number;
  92722. /**
  92723. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  92724. */
  92725. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  92726. /**
  92727. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  92728. * the central point of your effect and can save a lot of performances.
  92729. */
  92730. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  92731. /**
  92732. * Use this predicate to dynamically define the list of mesh you want to render.
  92733. * If set, the renderList property will be overwritten.
  92734. */
  92735. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  92736. private _renderList;
  92737. /**
  92738. * Use this list to define the list of mesh you want to render.
  92739. */
  92740. get renderList(): Nullable<Array<AbstractMesh>>;
  92741. set renderList(value: Nullable<Array<AbstractMesh>>);
  92742. private _hookArray;
  92743. /**
  92744. * Define if particles should be rendered in your texture.
  92745. */
  92746. renderParticles: boolean;
  92747. /**
  92748. * Define if sprites should be rendered in your texture.
  92749. */
  92750. renderSprites: boolean;
  92751. /**
  92752. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  92753. */
  92754. coordinatesMode: number;
  92755. /**
  92756. * Define the camera used to render the texture.
  92757. */
  92758. activeCamera: Nullable<Camera>;
  92759. /**
  92760. * Override the render function of the texture with your own one.
  92761. */
  92762. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  92763. /**
  92764. * Define if camera post processes should be use while rendering the texture.
  92765. */
  92766. useCameraPostProcesses: boolean;
  92767. /**
  92768. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  92769. */
  92770. ignoreCameraViewport: boolean;
  92771. private _postProcessManager;
  92772. private _postProcesses;
  92773. private _resizeObserver;
  92774. /**
  92775. * An event triggered when the texture is unbind.
  92776. */
  92777. onBeforeBindObservable: Observable<RenderTargetTexture>;
  92778. /**
  92779. * An event triggered when the texture is unbind.
  92780. */
  92781. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  92782. private _onAfterUnbindObserver;
  92783. /**
  92784. * Set a after unbind callback in the texture.
  92785. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  92786. */
  92787. set onAfterUnbind(callback: () => void);
  92788. /**
  92789. * An event triggered before rendering the texture
  92790. */
  92791. onBeforeRenderObservable: Observable<number>;
  92792. private _onBeforeRenderObserver;
  92793. /**
  92794. * Set a before render callback in the texture.
  92795. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  92796. */
  92797. set onBeforeRender(callback: (faceIndex: number) => void);
  92798. /**
  92799. * An event triggered after rendering the texture
  92800. */
  92801. onAfterRenderObservable: Observable<number>;
  92802. private _onAfterRenderObserver;
  92803. /**
  92804. * Set a after render callback in the texture.
  92805. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  92806. */
  92807. set onAfterRender(callback: (faceIndex: number) => void);
  92808. /**
  92809. * An event triggered after the texture clear
  92810. */
  92811. onClearObservable: Observable<Engine>;
  92812. private _onClearObserver;
  92813. /**
  92814. * Set a clear callback in the texture.
  92815. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  92816. */
  92817. set onClear(callback: (Engine: Engine) => void);
  92818. /**
  92819. * An event triggered when the texture is resized.
  92820. */
  92821. onResizeObservable: Observable<RenderTargetTexture>;
  92822. /**
  92823. * Define the clear color of the Render Target if it should be different from the scene.
  92824. */
  92825. clearColor: Color4;
  92826. protected _size: number | {
  92827. width: number;
  92828. height: number;
  92829. layers?: number;
  92830. };
  92831. protected _initialSizeParameter: number | {
  92832. width: number;
  92833. height: number;
  92834. } | {
  92835. ratio: number;
  92836. };
  92837. protected _sizeRatio: Nullable<number>;
  92838. /** @hidden */
  92839. _generateMipMaps: boolean;
  92840. protected _renderingManager: RenderingManager;
  92841. /** @hidden */
  92842. _waitingRenderList: string[];
  92843. protected _doNotChangeAspectRatio: boolean;
  92844. protected _currentRefreshId: number;
  92845. protected _refreshRate: number;
  92846. protected _textureMatrix: Matrix;
  92847. protected _samples: number;
  92848. protected _renderTargetOptions: RenderTargetCreationOptions;
  92849. /**
  92850. * Gets render target creation options that were used.
  92851. */
  92852. get renderTargetOptions(): RenderTargetCreationOptions;
  92853. protected _engine: Engine;
  92854. protected _onRatioRescale(): void;
  92855. /**
  92856. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  92857. * It must define where the camera used to render the texture is set
  92858. */
  92859. boundingBoxPosition: Vector3;
  92860. private _boundingBoxSize;
  92861. /**
  92862. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  92863. * When defined, the cubemap will switch to local mode
  92864. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92865. * @example https://www.babylonjs-playground.com/#RNASML
  92866. */
  92867. set boundingBoxSize(value: Vector3);
  92868. get boundingBoxSize(): Vector3;
  92869. /**
  92870. * In case the RTT has been created with a depth texture, get the associated
  92871. * depth texture.
  92872. * Otherwise, return null.
  92873. */
  92874. get depthStencilTexture(): Nullable<InternalTexture>;
  92875. /**
  92876. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  92877. * or used a shadow, depth texture...
  92878. * @param name The friendly name of the texture
  92879. * @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)
  92880. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  92881. * @param generateMipMaps True if mip maps need to be generated after render.
  92882. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  92883. * @param type The type of the buffer in the RTT (int, half float, float...)
  92884. * @param isCube True if a cube texture needs to be created
  92885. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  92886. * @param generateDepthBuffer True to generate a depth buffer
  92887. * @param generateStencilBuffer True to generate a stencil buffer
  92888. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  92889. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  92890. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92891. */
  92892. constructor(name: string, size: number | {
  92893. width: number;
  92894. height: number;
  92895. layers?: number;
  92896. } | {
  92897. ratio: number;
  92898. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  92899. /**
  92900. * Creates a depth stencil texture.
  92901. * This is only available in WebGL 2 or with the depth texture extension available.
  92902. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  92903. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  92904. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  92905. */
  92906. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  92907. private _processSizeParameter;
  92908. /**
  92909. * Define the number of samples to use in case of MSAA.
  92910. * It defaults to one meaning no MSAA has been enabled.
  92911. */
  92912. get samples(): number;
  92913. set samples(value: number);
  92914. /**
  92915. * Resets the refresh counter of the texture and start bak from scratch.
  92916. * Could be useful to regenerate the texture if it is setup to render only once.
  92917. */
  92918. resetRefreshCounter(): void;
  92919. /**
  92920. * Define the refresh rate of the texture or the rendering frequency.
  92921. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92922. */
  92923. get refreshRate(): number;
  92924. set refreshRate(value: number);
  92925. /**
  92926. * Adds a post process to the render target rendering passes.
  92927. * @param postProcess define the post process to add
  92928. */
  92929. addPostProcess(postProcess: PostProcess): void;
  92930. /**
  92931. * Clear all the post processes attached to the render target
  92932. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  92933. */
  92934. clearPostProcesses(dispose?: boolean): void;
  92935. /**
  92936. * Remove one of the post process from the list of attached post processes to the texture
  92937. * @param postProcess define the post process to remove from the list
  92938. */
  92939. removePostProcess(postProcess: PostProcess): void;
  92940. /** @hidden */
  92941. _shouldRender(): boolean;
  92942. /**
  92943. * Gets the actual render size of the texture.
  92944. * @returns the width of the render size
  92945. */
  92946. getRenderSize(): number;
  92947. /**
  92948. * Gets the actual render width of the texture.
  92949. * @returns the width of the render size
  92950. */
  92951. getRenderWidth(): number;
  92952. /**
  92953. * Gets the actual render height of the texture.
  92954. * @returns the height of the render size
  92955. */
  92956. getRenderHeight(): number;
  92957. /**
  92958. * Gets the actual number of layers of the texture.
  92959. * @returns the number of layers
  92960. */
  92961. getRenderLayers(): number;
  92962. /**
  92963. * Get if the texture can be rescaled or not.
  92964. */
  92965. get canRescale(): boolean;
  92966. /**
  92967. * Resize the texture using a ratio.
  92968. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  92969. */
  92970. scale(ratio: number): void;
  92971. /**
  92972. * Get the texture reflection matrix used to rotate/transform the reflection.
  92973. * @returns the reflection matrix
  92974. */
  92975. getReflectionTextureMatrix(): Matrix;
  92976. /**
  92977. * Resize the texture to a new desired size.
  92978. * Be carrefull as it will recreate all the data in the new texture.
  92979. * @param size Define the new size. It can be:
  92980. * - a number for squared texture,
  92981. * - an object containing { width: number, height: number }
  92982. * - or an object containing a ratio { ratio: number }
  92983. */
  92984. resize(size: number | {
  92985. width: number;
  92986. height: number;
  92987. } | {
  92988. ratio: number;
  92989. }): void;
  92990. /**
  92991. * Renders all the objects from the render list into the texture.
  92992. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  92993. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  92994. */
  92995. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  92996. private _bestReflectionRenderTargetDimension;
  92997. /**
  92998. * @hidden
  92999. * @param faceIndex face index to bind to if this is a cubetexture
  93000. * @param layer defines the index of the texture to bind in the array
  93001. */
  93002. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93003. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93004. private renderToTarget;
  93005. /**
  93006. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93007. * This allowed control for front to back rendering or reversly depending of the special needs.
  93008. *
  93009. * @param renderingGroupId The rendering group id corresponding to its index
  93010. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93011. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93012. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93013. */
  93014. 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;
  93015. /**
  93016. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93017. *
  93018. * @param renderingGroupId The rendering group id corresponding to its index
  93019. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93020. */
  93021. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93022. /**
  93023. * Clones the texture.
  93024. * @returns the cloned texture
  93025. */
  93026. clone(): RenderTargetTexture;
  93027. /**
  93028. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93029. * @returns The JSON representation of the texture
  93030. */
  93031. serialize(): any;
  93032. /**
  93033. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93034. */
  93035. disposeFramebufferObjects(): void;
  93036. /**
  93037. * Dispose the texture and release its associated resources.
  93038. */
  93039. dispose(): void;
  93040. /** @hidden */
  93041. _rebuild(): void;
  93042. /**
  93043. * Clear the info related to rendering groups preventing retention point in material dispose.
  93044. */
  93045. freeRenderingGroups(): void;
  93046. /**
  93047. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93048. * @returns the view count
  93049. */
  93050. getViewCount(): number;
  93051. }
  93052. }
  93053. declare module BABYLON {
  93054. /**
  93055. * Options for compiling materials.
  93056. */
  93057. export interface IMaterialCompilationOptions {
  93058. /**
  93059. * Defines whether clip planes are enabled.
  93060. */
  93061. clipPlane: boolean;
  93062. /**
  93063. * Defines whether instances are enabled.
  93064. */
  93065. useInstances: boolean;
  93066. }
  93067. /**
  93068. * Base class for the main features of a material in Babylon.js
  93069. */
  93070. export class Material implements IAnimatable {
  93071. /**
  93072. * Returns the triangle fill mode
  93073. */
  93074. static readonly TriangleFillMode: number;
  93075. /**
  93076. * Returns the wireframe mode
  93077. */
  93078. static readonly WireFrameFillMode: number;
  93079. /**
  93080. * Returns the point fill mode
  93081. */
  93082. static readonly PointFillMode: number;
  93083. /**
  93084. * Returns the point list draw mode
  93085. */
  93086. static readonly PointListDrawMode: number;
  93087. /**
  93088. * Returns the line list draw mode
  93089. */
  93090. static readonly LineListDrawMode: number;
  93091. /**
  93092. * Returns the line loop draw mode
  93093. */
  93094. static readonly LineLoopDrawMode: number;
  93095. /**
  93096. * Returns the line strip draw mode
  93097. */
  93098. static readonly LineStripDrawMode: number;
  93099. /**
  93100. * Returns the triangle strip draw mode
  93101. */
  93102. static readonly TriangleStripDrawMode: number;
  93103. /**
  93104. * Returns the triangle fan draw mode
  93105. */
  93106. static readonly TriangleFanDrawMode: number;
  93107. /**
  93108. * Stores the clock-wise side orientation
  93109. */
  93110. static readonly ClockWiseSideOrientation: number;
  93111. /**
  93112. * Stores the counter clock-wise side orientation
  93113. */
  93114. static readonly CounterClockWiseSideOrientation: number;
  93115. /**
  93116. * The dirty texture flag value
  93117. */
  93118. static readonly TextureDirtyFlag: number;
  93119. /**
  93120. * The dirty light flag value
  93121. */
  93122. static readonly LightDirtyFlag: number;
  93123. /**
  93124. * The dirty fresnel flag value
  93125. */
  93126. static readonly FresnelDirtyFlag: number;
  93127. /**
  93128. * The dirty attribute flag value
  93129. */
  93130. static readonly AttributesDirtyFlag: number;
  93131. /**
  93132. * The dirty misc flag value
  93133. */
  93134. static readonly MiscDirtyFlag: number;
  93135. /**
  93136. * The all dirty flag value
  93137. */
  93138. static readonly AllDirtyFlag: number;
  93139. /**
  93140. * The ID of the material
  93141. */
  93142. id: string;
  93143. /**
  93144. * Gets or sets the unique id of the material
  93145. */
  93146. uniqueId: number;
  93147. /**
  93148. * The name of the material
  93149. */
  93150. name: string;
  93151. /**
  93152. * Gets or sets user defined metadata
  93153. */
  93154. metadata: any;
  93155. /**
  93156. * For internal use only. Please do not use.
  93157. */
  93158. reservedDataStore: any;
  93159. /**
  93160. * Specifies if the ready state should be checked on each call
  93161. */
  93162. checkReadyOnEveryCall: boolean;
  93163. /**
  93164. * Specifies if the ready state should be checked once
  93165. */
  93166. checkReadyOnlyOnce: boolean;
  93167. /**
  93168. * The state of the material
  93169. */
  93170. state: string;
  93171. /**
  93172. * The alpha value of the material
  93173. */
  93174. protected _alpha: number;
  93175. /**
  93176. * List of inspectable custom properties (used by the Inspector)
  93177. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93178. */
  93179. inspectableCustomProperties: IInspectable[];
  93180. /**
  93181. * Sets the alpha value of the material
  93182. */
  93183. set alpha(value: number);
  93184. /**
  93185. * Gets the alpha value of the material
  93186. */
  93187. get alpha(): number;
  93188. /**
  93189. * Specifies if back face culling is enabled
  93190. */
  93191. protected _backFaceCulling: boolean;
  93192. /**
  93193. * Sets the back-face culling state
  93194. */
  93195. set backFaceCulling(value: boolean);
  93196. /**
  93197. * Gets the back-face culling state
  93198. */
  93199. get backFaceCulling(): boolean;
  93200. /**
  93201. * Stores the value for side orientation
  93202. */
  93203. sideOrientation: number;
  93204. /**
  93205. * Callback triggered when the material is compiled
  93206. */
  93207. onCompiled: Nullable<(effect: Effect) => void>;
  93208. /**
  93209. * Callback triggered when an error occurs
  93210. */
  93211. onError: Nullable<(effect: Effect, errors: string) => void>;
  93212. /**
  93213. * Callback triggered to get the render target textures
  93214. */
  93215. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  93216. /**
  93217. * Gets a boolean indicating that current material needs to register RTT
  93218. */
  93219. get hasRenderTargetTextures(): boolean;
  93220. /**
  93221. * Specifies if the material should be serialized
  93222. */
  93223. doNotSerialize: boolean;
  93224. /**
  93225. * @hidden
  93226. */
  93227. _storeEffectOnSubMeshes: boolean;
  93228. /**
  93229. * Stores the animations for the material
  93230. */
  93231. animations: Nullable<Array<Animation>>;
  93232. /**
  93233. * An event triggered when the material is disposed
  93234. */
  93235. onDisposeObservable: Observable<Material>;
  93236. /**
  93237. * An observer which watches for dispose events
  93238. */
  93239. private _onDisposeObserver;
  93240. private _onUnBindObservable;
  93241. /**
  93242. * Called during a dispose event
  93243. */
  93244. set onDispose(callback: () => void);
  93245. private _onBindObservable;
  93246. /**
  93247. * An event triggered when the material is bound
  93248. */
  93249. get onBindObservable(): Observable<AbstractMesh>;
  93250. /**
  93251. * An observer which watches for bind events
  93252. */
  93253. private _onBindObserver;
  93254. /**
  93255. * Called during a bind event
  93256. */
  93257. set onBind(callback: (Mesh: AbstractMesh) => void);
  93258. /**
  93259. * An event triggered when the material is unbound
  93260. */
  93261. get onUnBindObservable(): Observable<Material>;
  93262. /**
  93263. * Stores the value of the alpha mode
  93264. */
  93265. private _alphaMode;
  93266. /**
  93267. * Sets the value of the alpha mode.
  93268. *
  93269. * | Value | Type | Description |
  93270. * | --- | --- | --- |
  93271. * | 0 | ALPHA_DISABLE | |
  93272. * | 1 | ALPHA_ADD | |
  93273. * | 2 | ALPHA_COMBINE | |
  93274. * | 3 | ALPHA_SUBTRACT | |
  93275. * | 4 | ALPHA_MULTIPLY | |
  93276. * | 5 | ALPHA_MAXIMIZED | |
  93277. * | 6 | ALPHA_ONEONE | |
  93278. * | 7 | ALPHA_PREMULTIPLIED | |
  93279. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  93280. * | 9 | ALPHA_INTERPOLATE | |
  93281. * | 10 | ALPHA_SCREENMODE | |
  93282. *
  93283. */
  93284. set alphaMode(value: number);
  93285. /**
  93286. * Gets the value of the alpha mode
  93287. */
  93288. get alphaMode(): number;
  93289. /**
  93290. * Stores the state of the need depth pre-pass value
  93291. */
  93292. private _needDepthPrePass;
  93293. /**
  93294. * Sets the need depth pre-pass value
  93295. */
  93296. set needDepthPrePass(value: boolean);
  93297. /**
  93298. * Gets the depth pre-pass value
  93299. */
  93300. get needDepthPrePass(): boolean;
  93301. /**
  93302. * Specifies if depth writing should be disabled
  93303. */
  93304. disableDepthWrite: boolean;
  93305. /**
  93306. * Specifies if depth writing should be forced
  93307. */
  93308. forceDepthWrite: boolean;
  93309. /**
  93310. * Specifies the depth function that should be used. 0 means the default engine function
  93311. */
  93312. depthFunction: number;
  93313. /**
  93314. * Specifies if there should be a separate pass for culling
  93315. */
  93316. separateCullingPass: boolean;
  93317. /**
  93318. * Stores the state specifing if fog should be enabled
  93319. */
  93320. private _fogEnabled;
  93321. /**
  93322. * Sets the state for enabling fog
  93323. */
  93324. set fogEnabled(value: boolean);
  93325. /**
  93326. * Gets the value of the fog enabled state
  93327. */
  93328. get fogEnabled(): boolean;
  93329. /**
  93330. * Stores the size of points
  93331. */
  93332. pointSize: number;
  93333. /**
  93334. * Stores the z offset value
  93335. */
  93336. zOffset: number;
  93337. /**
  93338. * Gets a value specifying if wireframe mode is enabled
  93339. */
  93340. get wireframe(): boolean;
  93341. /**
  93342. * Sets the state of wireframe mode
  93343. */
  93344. set wireframe(value: boolean);
  93345. /**
  93346. * Gets the value specifying if point clouds are enabled
  93347. */
  93348. get pointsCloud(): boolean;
  93349. /**
  93350. * Sets the state of point cloud mode
  93351. */
  93352. set pointsCloud(value: boolean);
  93353. /**
  93354. * Gets the material fill mode
  93355. */
  93356. get fillMode(): number;
  93357. /**
  93358. * Sets the material fill mode
  93359. */
  93360. set fillMode(value: number);
  93361. /**
  93362. * @hidden
  93363. * Stores the effects for the material
  93364. */
  93365. _effect: Nullable<Effect>;
  93366. /**
  93367. * Specifies if uniform buffers should be used
  93368. */
  93369. private _useUBO;
  93370. /**
  93371. * Stores a reference to the scene
  93372. */
  93373. private _scene;
  93374. /**
  93375. * Stores the fill mode state
  93376. */
  93377. private _fillMode;
  93378. /**
  93379. * Specifies if the depth write state should be cached
  93380. */
  93381. private _cachedDepthWriteState;
  93382. /**
  93383. * Specifies if the depth function state should be cached
  93384. */
  93385. private _cachedDepthFunctionState;
  93386. /**
  93387. * Stores the uniform buffer
  93388. */
  93389. protected _uniformBuffer: UniformBuffer;
  93390. /** @hidden */
  93391. _indexInSceneMaterialArray: number;
  93392. /** @hidden */
  93393. meshMap: Nullable<{
  93394. [id: string]: AbstractMesh | undefined;
  93395. }>;
  93396. /**
  93397. * Creates a material instance
  93398. * @param name defines the name of the material
  93399. * @param scene defines the scene to reference
  93400. * @param doNotAdd specifies if the material should be added to the scene
  93401. */
  93402. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  93403. /**
  93404. * Returns a string representation of the current material
  93405. * @param fullDetails defines a boolean indicating which levels of logging is desired
  93406. * @returns a string with material information
  93407. */
  93408. toString(fullDetails?: boolean): string;
  93409. /**
  93410. * Gets the class name of the material
  93411. * @returns a string with the class name of the material
  93412. */
  93413. getClassName(): string;
  93414. /**
  93415. * Specifies if updates for the material been locked
  93416. */
  93417. get isFrozen(): boolean;
  93418. /**
  93419. * Locks updates for the material
  93420. */
  93421. freeze(): void;
  93422. /**
  93423. * Unlocks updates for the material
  93424. */
  93425. unfreeze(): void;
  93426. /**
  93427. * Specifies if the material is ready to be used
  93428. * @param mesh defines the mesh to check
  93429. * @param useInstances specifies if instances should be used
  93430. * @returns a boolean indicating if the material is ready to be used
  93431. */
  93432. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93433. /**
  93434. * Specifies that the submesh is ready to be used
  93435. * @param mesh defines the mesh to check
  93436. * @param subMesh defines which submesh to check
  93437. * @param useInstances specifies that instances should be used
  93438. * @returns a boolean indicating that the submesh is ready or not
  93439. */
  93440. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93441. /**
  93442. * Returns the material effect
  93443. * @returns the effect associated with the material
  93444. */
  93445. getEffect(): Nullable<Effect>;
  93446. /**
  93447. * Returns the current scene
  93448. * @returns a Scene
  93449. */
  93450. getScene(): Scene;
  93451. /**
  93452. * Specifies if the material will require alpha blending
  93453. * @returns a boolean specifying if alpha blending is needed
  93454. */
  93455. needAlphaBlending(): boolean;
  93456. /**
  93457. * Specifies if the mesh will require alpha blending
  93458. * @param mesh defines the mesh to check
  93459. * @returns a boolean specifying if alpha blending is needed for the mesh
  93460. */
  93461. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  93462. /**
  93463. * Specifies if this material should be rendered in alpha test mode
  93464. * @returns a boolean specifying if an alpha test is needed.
  93465. */
  93466. needAlphaTesting(): boolean;
  93467. /**
  93468. * Gets the texture used for the alpha test
  93469. * @returns the texture to use for alpha testing
  93470. */
  93471. getAlphaTestTexture(): Nullable<BaseTexture>;
  93472. /**
  93473. * Marks the material to indicate that it needs to be re-calculated
  93474. */
  93475. markDirty(): void;
  93476. /** @hidden */
  93477. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  93478. /**
  93479. * Binds the material to the mesh
  93480. * @param world defines the world transformation matrix
  93481. * @param mesh defines the mesh to bind the material to
  93482. */
  93483. bind(world: Matrix, mesh?: Mesh): void;
  93484. /**
  93485. * Binds the submesh to the material
  93486. * @param world defines the world transformation matrix
  93487. * @param mesh defines the mesh containing the submesh
  93488. * @param subMesh defines the submesh to bind the material to
  93489. */
  93490. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93491. /**
  93492. * Binds the world matrix to the material
  93493. * @param world defines the world transformation matrix
  93494. */
  93495. bindOnlyWorldMatrix(world: Matrix): void;
  93496. /**
  93497. * Binds the scene's uniform buffer to the effect.
  93498. * @param effect defines the effect to bind to the scene uniform buffer
  93499. * @param sceneUbo defines the uniform buffer storing scene data
  93500. */
  93501. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  93502. /**
  93503. * Binds the view matrix to the effect
  93504. * @param effect defines the effect to bind the view matrix to
  93505. */
  93506. bindView(effect: Effect): void;
  93507. /**
  93508. * Binds the view projection matrix to the effect
  93509. * @param effect defines the effect to bind the view projection matrix to
  93510. */
  93511. bindViewProjection(effect: Effect): void;
  93512. /**
  93513. * Specifies if material alpha testing should be turned on for the mesh
  93514. * @param mesh defines the mesh to check
  93515. */
  93516. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  93517. /**
  93518. * Processes to execute after binding the material to a mesh
  93519. * @param mesh defines the rendered mesh
  93520. */
  93521. protected _afterBind(mesh?: Mesh): void;
  93522. /**
  93523. * Unbinds the material from the mesh
  93524. */
  93525. unbind(): void;
  93526. /**
  93527. * Gets the active textures from the material
  93528. * @returns an array of textures
  93529. */
  93530. getActiveTextures(): BaseTexture[];
  93531. /**
  93532. * Specifies if the material uses a texture
  93533. * @param texture defines the texture to check against the material
  93534. * @returns a boolean specifying if the material uses the texture
  93535. */
  93536. hasTexture(texture: BaseTexture): boolean;
  93537. /**
  93538. * Makes a duplicate of the material, and gives it a new name
  93539. * @param name defines the new name for the duplicated material
  93540. * @returns the cloned material
  93541. */
  93542. clone(name: string): Nullable<Material>;
  93543. /**
  93544. * Gets the meshes bound to the material
  93545. * @returns an array of meshes bound to the material
  93546. */
  93547. getBindedMeshes(): AbstractMesh[];
  93548. /**
  93549. * Force shader compilation
  93550. * @param mesh defines the mesh associated with this material
  93551. * @param onCompiled defines a function to execute once the material is compiled
  93552. * @param options defines the options to configure the compilation
  93553. * @param onError defines a function to execute if the material fails compiling
  93554. */
  93555. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  93556. /**
  93557. * Force shader compilation
  93558. * @param mesh defines the mesh that will use this material
  93559. * @param options defines additional options for compiling the shaders
  93560. * @returns a promise that resolves when the compilation completes
  93561. */
  93562. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  93563. private static readonly _AllDirtyCallBack;
  93564. private static readonly _ImageProcessingDirtyCallBack;
  93565. private static readonly _TextureDirtyCallBack;
  93566. private static readonly _FresnelDirtyCallBack;
  93567. private static readonly _MiscDirtyCallBack;
  93568. private static readonly _LightsDirtyCallBack;
  93569. private static readonly _AttributeDirtyCallBack;
  93570. private static _FresnelAndMiscDirtyCallBack;
  93571. private static _TextureAndMiscDirtyCallBack;
  93572. private static readonly _DirtyCallbackArray;
  93573. private static readonly _RunDirtyCallBacks;
  93574. /**
  93575. * Marks a define in the material to indicate that it needs to be re-computed
  93576. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  93577. */
  93578. markAsDirty(flag: number): void;
  93579. /**
  93580. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  93581. * @param func defines a function which checks material defines against the submeshes
  93582. */
  93583. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  93584. /**
  93585. * Indicates that we need to re-calculated for all submeshes
  93586. */
  93587. protected _markAllSubMeshesAsAllDirty(): void;
  93588. /**
  93589. * Indicates that image processing needs to be re-calculated for all submeshes
  93590. */
  93591. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  93592. /**
  93593. * Indicates that textures need to be re-calculated for all submeshes
  93594. */
  93595. protected _markAllSubMeshesAsTexturesDirty(): void;
  93596. /**
  93597. * Indicates that fresnel needs to be re-calculated for all submeshes
  93598. */
  93599. protected _markAllSubMeshesAsFresnelDirty(): void;
  93600. /**
  93601. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  93602. */
  93603. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  93604. /**
  93605. * Indicates that lights need to be re-calculated for all submeshes
  93606. */
  93607. protected _markAllSubMeshesAsLightsDirty(): void;
  93608. /**
  93609. * Indicates that attributes need to be re-calculated for all submeshes
  93610. */
  93611. protected _markAllSubMeshesAsAttributesDirty(): void;
  93612. /**
  93613. * Indicates that misc needs to be re-calculated for all submeshes
  93614. */
  93615. protected _markAllSubMeshesAsMiscDirty(): void;
  93616. /**
  93617. * Indicates that textures and misc need to be re-calculated for all submeshes
  93618. */
  93619. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  93620. /**
  93621. * Disposes the material
  93622. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93623. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93624. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93625. */
  93626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93627. /** @hidden */
  93628. private releaseVertexArrayObject;
  93629. /**
  93630. * Serializes this material
  93631. * @returns the serialized material object
  93632. */
  93633. serialize(): any;
  93634. /**
  93635. * Creates a material from parsed material data
  93636. * @param parsedMaterial defines parsed material data
  93637. * @param scene defines the hosting scene
  93638. * @param rootUrl defines the root URL to use to load textures
  93639. * @returns a new material
  93640. */
  93641. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  93642. }
  93643. }
  93644. declare module BABYLON {
  93645. /**
  93646. * A multi-material is used to apply different materials to different parts of the same object without the need of
  93647. * separate meshes. This can be use to improve performances.
  93648. * @see http://doc.babylonjs.com/how_to/multi_materials
  93649. */
  93650. export class MultiMaterial extends Material {
  93651. private _subMaterials;
  93652. /**
  93653. * Gets or Sets the list of Materials used within the multi material.
  93654. * They need to be ordered according to the submeshes order in the associated mesh
  93655. */
  93656. get subMaterials(): Nullable<Material>[];
  93657. set subMaterials(value: Nullable<Material>[]);
  93658. /**
  93659. * Function used to align with Node.getChildren()
  93660. * @returns the list of Materials used within the multi material
  93661. */
  93662. getChildren(): Nullable<Material>[];
  93663. /**
  93664. * Instantiates a new Multi Material
  93665. * A multi-material is used to apply different materials to different parts of the same object without the need of
  93666. * separate meshes. This can be use to improve performances.
  93667. * @see http://doc.babylonjs.com/how_to/multi_materials
  93668. * @param name Define the name in the scene
  93669. * @param scene Define the scene the material belongs to
  93670. */
  93671. constructor(name: string, scene: Scene);
  93672. private _hookArray;
  93673. /**
  93674. * Get one of the submaterial by its index in the submaterials array
  93675. * @param index The index to look the sub material at
  93676. * @returns The Material if the index has been defined
  93677. */
  93678. getSubMaterial(index: number): Nullable<Material>;
  93679. /**
  93680. * Get the list of active textures for the whole sub materials list.
  93681. * @returns All the textures that will be used during the rendering
  93682. */
  93683. getActiveTextures(): BaseTexture[];
  93684. /**
  93685. * Gets the current class name of the material e.g. "MultiMaterial"
  93686. * Mainly use in serialization.
  93687. * @returns the class name
  93688. */
  93689. getClassName(): string;
  93690. /**
  93691. * Checks if the material is ready to render the requested sub mesh
  93692. * @param mesh Define the mesh the submesh belongs to
  93693. * @param subMesh Define the sub mesh to look readyness for
  93694. * @param useInstances Define whether or not the material is used with instances
  93695. * @returns true if ready, otherwise false
  93696. */
  93697. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93698. /**
  93699. * Clones the current material and its related sub materials
  93700. * @param name Define the name of the newly cloned material
  93701. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  93702. * @returns the cloned material
  93703. */
  93704. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  93705. /**
  93706. * Serializes the materials into a JSON representation.
  93707. * @returns the JSON representation
  93708. */
  93709. serialize(): any;
  93710. /**
  93711. * Dispose the material and release its associated resources
  93712. * @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)
  93713. * @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)
  93714. * @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)
  93715. */
  93716. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  93717. /**
  93718. * Creates a MultiMaterial from parsed MultiMaterial data.
  93719. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  93720. * @param scene defines the hosting scene
  93721. * @returns a new MultiMaterial
  93722. */
  93723. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  93724. }
  93725. }
  93726. declare module BABYLON {
  93727. /**
  93728. * Base class for submeshes
  93729. */
  93730. export class BaseSubMesh {
  93731. /** @hidden */
  93732. _materialDefines: Nullable<MaterialDefines>;
  93733. /** @hidden */
  93734. _materialEffect: Nullable<Effect>;
  93735. /**
  93736. * Gets material defines used by the effect associated to the sub mesh
  93737. */
  93738. get materialDefines(): Nullable<MaterialDefines>;
  93739. /**
  93740. * Sets material defines used by the effect associated to the sub mesh
  93741. */
  93742. set materialDefines(defines: Nullable<MaterialDefines>);
  93743. /**
  93744. * Gets associated effect
  93745. */
  93746. get effect(): Nullable<Effect>;
  93747. /**
  93748. * Sets associated effect (effect used to render this submesh)
  93749. * @param effect defines the effect to associate with
  93750. * @param defines defines the set of defines used to compile this effect
  93751. */
  93752. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  93753. }
  93754. /**
  93755. * Defines a subdivision inside a mesh
  93756. */
  93757. export class SubMesh extends BaseSubMesh implements ICullable {
  93758. /** the material index to use */
  93759. materialIndex: number;
  93760. /** vertex index start */
  93761. verticesStart: number;
  93762. /** vertices count */
  93763. verticesCount: number;
  93764. /** index start */
  93765. indexStart: number;
  93766. /** indices count */
  93767. indexCount: number;
  93768. /** @hidden */
  93769. _linesIndexCount: number;
  93770. private _mesh;
  93771. private _renderingMesh;
  93772. private _boundingInfo;
  93773. private _linesIndexBuffer;
  93774. /** @hidden */
  93775. _lastColliderWorldVertices: Nullable<Vector3[]>;
  93776. /** @hidden */
  93777. _trianglePlanes: Plane[];
  93778. /** @hidden */
  93779. _lastColliderTransformMatrix: Nullable<Matrix>;
  93780. /** @hidden */
  93781. _renderId: number;
  93782. /** @hidden */
  93783. _alphaIndex: number;
  93784. /** @hidden */
  93785. _distanceToCamera: number;
  93786. /** @hidden */
  93787. _id: number;
  93788. private _currentMaterial;
  93789. /**
  93790. * Add a new submesh to a mesh
  93791. * @param materialIndex defines the material index to use
  93792. * @param verticesStart defines vertex index start
  93793. * @param verticesCount defines vertices count
  93794. * @param indexStart defines index start
  93795. * @param indexCount defines indices count
  93796. * @param mesh defines the parent mesh
  93797. * @param renderingMesh defines an optional rendering mesh
  93798. * @param createBoundingBox defines if bounding box should be created for this submesh
  93799. * @returns the new submesh
  93800. */
  93801. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  93802. /**
  93803. * Creates a new submesh
  93804. * @param materialIndex defines the material index to use
  93805. * @param verticesStart defines vertex index start
  93806. * @param verticesCount defines vertices count
  93807. * @param indexStart defines index start
  93808. * @param indexCount defines indices count
  93809. * @param mesh defines the parent mesh
  93810. * @param renderingMesh defines an optional rendering mesh
  93811. * @param createBoundingBox defines if bounding box should be created for this submesh
  93812. */
  93813. constructor(
  93814. /** the material index to use */
  93815. materialIndex: number,
  93816. /** vertex index start */
  93817. verticesStart: number,
  93818. /** vertices count */
  93819. verticesCount: number,
  93820. /** index start */
  93821. indexStart: number,
  93822. /** indices count */
  93823. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  93824. /**
  93825. * Returns true if this submesh covers the entire parent mesh
  93826. * @ignorenaming
  93827. */
  93828. get IsGlobal(): boolean;
  93829. /**
  93830. * Returns the submesh BoudingInfo object
  93831. * @returns current bounding info (or mesh's one if the submesh is global)
  93832. */
  93833. getBoundingInfo(): BoundingInfo;
  93834. /**
  93835. * Sets the submesh BoundingInfo
  93836. * @param boundingInfo defines the new bounding info to use
  93837. * @returns the SubMesh
  93838. */
  93839. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  93840. /**
  93841. * Returns the mesh of the current submesh
  93842. * @return the parent mesh
  93843. */
  93844. getMesh(): AbstractMesh;
  93845. /**
  93846. * Returns the rendering mesh of the submesh
  93847. * @returns the rendering mesh (could be different from parent mesh)
  93848. */
  93849. getRenderingMesh(): Mesh;
  93850. /**
  93851. * Returns the submesh material
  93852. * @returns null or the current material
  93853. */
  93854. getMaterial(): Nullable<Material>;
  93855. /**
  93856. * Sets a new updated BoundingInfo object to the submesh
  93857. * @param data defines an optional position array to use to determine the bounding info
  93858. * @returns the SubMesh
  93859. */
  93860. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  93861. /** @hidden */
  93862. _checkCollision(collider: Collider): boolean;
  93863. /**
  93864. * Updates the submesh BoundingInfo
  93865. * @param world defines the world matrix to use to update the bounding info
  93866. * @returns the submesh
  93867. */
  93868. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  93869. /**
  93870. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  93871. * @param frustumPlanes defines the frustum planes
  93872. * @returns true if the submesh is intersecting with the frustum
  93873. */
  93874. isInFrustum(frustumPlanes: Plane[]): boolean;
  93875. /**
  93876. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  93877. * @param frustumPlanes defines the frustum planes
  93878. * @returns true if the submesh is inside the frustum
  93879. */
  93880. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93881. /**
  93882. * Renders the submesh
  93883. * @param enableAlphaMode defines if alpha needs to be used
  93884. * @returns the submesh
  93885. */
  93886. render(enableAlphaMode: boolean): SubMesh;
  93887. /**
  93888. * @hidden
  93889. */
  93890. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  93891. /**
  93892. * Checks if the submesh intersects with a ray
  93893. * @param ray defines the ray to test
  93894. * @returns true is the passed ray intersects the submesh bounding box
  93895. */
  93896. canIntersects(ray: Ray): boolean;
  93897. /**
  93898. * Intersects current submesh with a ray
  93899. * @param ray defines the ray to test
  93900. * @param positions defines mesh's positions array
  93901. * @param indices defines mesh's indices array
  93902. * @param fastCheck defines if only bounding info should be used
  93903. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93904. * @returns intersection info or null if no intersection
  93905. */
  93906. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  93907. /** @hidden */
  93908. private _intersectLines;
  93909. /** @hidden */
  93910. private _intersectUnIndexedLines;
  93911. /** @hidden */
  93912. private _intersectTriangles;
  93913. /** @hidden */
  93914. private _intersectUnIndexedTriangles;
  93915. /** @hidden */
  93916. _rebuild(): void;
  93917. /**
  93918. * Creates a new submesh from the passed mesh
  93919. * @param newMesh defines the new hosting mesh
  93920. * @param newRenderingMesh defines an optional rendering mesh
  93921. * @returns the new submesh
  93922. */
  93923. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  93924. /**
  93925. * Release associated resources
  93926. */
  93927. dispose(): void;
  93928. /**
  93929. * Gets the class name
  93930. * @returns the string "SubMesh".
  93931. */
  93932. getClassName(): string;
  93933. /**
  93934. * Creates a new submesh from indices data
  93935. * @param materialIndex the index of the main mesh material
  93936. * @param startIndex the index where to start the copy in the mesh indices array
  93937. * @param indexCount the number of indices to copy then from the startIndex
  93938. * @param mesh the main mesh to create the submesh from
  93939. * @param renderingMesh the optional rendering mesh
  93940. * @returns a new submesh
  93941. */
  93942. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  93943. }
  93944. }
  93945. declare module BABYLON {
  93946. /**
  93947. * Class used to represent data loading progression
  93948. */
  93949. export class SceneLoaderFlags {
  93950. private static _ForceFullSceneLoadingForIncremental;
  93951. private static _ShowLoadingScreen;
  93952. private static _CleanBoneMatrixWeights;
  93953. private static _loggingLevel;
  93954. /**
  93955. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  93956. */
  93957. static get ForceFullSceneLoadingForIncremental(): boolean;
  93958. static set ForceFullSceneLoadingForIncremental(value: boolean);
  93959. /**
  93960. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  93961. */
  93962. static get ShowLoadingScreen(): boolean;
  93963. static set ShowLoadingScreen(value: boolean);
  93964. /**
  93965. * Defines the current logging level (while loading the scene)
  93966. * @ignorenaming
  93967. */
  93968. static get loggingLevel(): number;
  93969. static set loggingLevel(value: number);
  93970. /**
  93971. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  93972. */
  93973. static get CleanBoneMatrixWeights(): boolean;
  93974. static set CleanBoneMatrixWeights(value: boolean);
  93975. }
  93976. }
  93977. declare module BABYLON {
  93978. /**
  93979. * Class used to store geometry data (vertex buffers + index buffer)
  93980. */
  93981. export class Geometry implements IGetSetVerticesData {
  93982. /**
  93983. * Gets or sets the ID of the geometry
  93984. */
  93985. id: string;
  93986. /**
  93987. * Gets or sets the unique ID of the geometry
  93988. */
  93989. uniqueId: number;
  93990. /**
  93991. * Gets the delay loading state of the geometry (none by default which means not delayed)
  93992. */
  93993. delayLoadState: number;
  93994. /**
  93995. * Gets the file containing the data to load when running in delay load state
  93996. */
  93997. delayLoadingFile: Nullable<string>;
  93998. /**
  93999. * Callback called when the geometry is updated
  94000. */
  94001. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94002. private _scene;
  94003. private _engine;
  94004. private _meshes;
  94005. private _totalVertices;
  94006. /** @hidden */
  94007. _indices: IndicesArray;
  94008. /** @hidden */
  94009. _vertexBuffers: {
  94010. [key: string]: VertexBuffer;
  94011. };
  94012. private _isDisposed;
  94013. private _extend;
  94014. private _boundingBias;
  94015. /** @hidden */
  94016. _delayInfo: Array<string>;
  94017. private _indexBuffer;
  94018. private _indexBufferIsUpdatable;
  94019. /** @hidden */
  94020. _boundingInfo: Nullable<BoundingInfo>;
  94021. /** @hidden */
  94022. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94023. /** @hidden */
  94024. _softwareSkinningFrameId: number;
  94025. private _vertexArrayObjects;
  94026. private _updatable;
  94027. /** @hidden */
  94028. _positions: Nullable<Vector3[]>;
  94029. /**
  94030. * 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
  94031. */
  94032. get boundingBias(): Vector2;
  94033. /**
  94034. * 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
  94035. */
  94036. set boundingBias(value: Vector2);
  94037. /**
  94038. * Static function used to attach a new empty geometry to a mesh
  94039. * @param mesh defines the mesh to attach the geometry to
  94040. * @returns the new Geometry
  94041. */
  94042. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94043. /**
  94044. * Creates a new geometry
  94045. * @param id defines the unique ID
  94046. * @param scene defines the hosting scene
  94047. * @param vertexData defines the VertexData used to get geometry data
  94048. * @param updatable defines if geometry must be updatable (false by default)
  94049. * @param mesh defines the mesh that will be associated with the geometry
  94050. */
  94051. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94052. /**
  94053. * Gets the current extend of the geometry
  94054. */
  94055. get extend(): {
  94056. minimum: Vector3;
  94057. maximum: Vector3;
  94058. };
  94059. /**
  94060. * Gets the hosting scene
  94061. * @returns the hosting Scene
  94062. */
  94063. getScene(): Scene;
  94064. /**
  94065. * Gets the hosting engine
  94066. * @returns the hosting Engine
  94067. */
  94068. getEngine(): Engine;
  94069. /**
  94070. * Defines if the geometry is ready to use
  94071. * @returns true if the geometry is ready to be used
  94072. */
  94073. isReady(): boolean;
  94074. /**
  94075. * Gets a value indicating that the geometry should not be serialized
  94076. */
  94077. get doNotSerialize(): boolean;
  94078. /** @hidden */
  94079. _rebuild(): void;
  94080. /**
  94081. * Affects all geometry data in one call
  94082. * @param vertexData defines the geometry data
  94083. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94084. */
  94085. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94086. /**
  94087. * Set specific vertex data
  94088. * @param kind defines the data kind (Position, normal, etc...)
  94089. * @param data defines the vertex data to use
  94090. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94091. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94092. */
  94093. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94094. /**
  94095. * Removes a specific vertex data
  94096. * @param kind defines the data kind (Position, normal, etc...)
  94097. */
  94098. removeVerticesData(kind: string): void;
  94099. /**
  94100. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  94101. * @param buffer defines the vertex buffer to use
  94102. * @param totalVertices defines the total number of vertices for position kind (could be null)
  94103. */
  94104. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  94105. /**
  94106. * Update a specific vertex buffer
  94107. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  94108. * It will do nothing if the buffer is not updatable
  94109. * @param kind defines the data kind (Position, normal, etc...)
  94110. * @param data defines the data to use
  94111. * @param offset defines the offset in the target buffer where to store the data
  94112. * @param useBytes set to true if the offset is in bytes
  94113. */
  94114. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  94115. /**
  94116. * Update a specific vertex buffer
  94117. * This function will create a new buffer if the current one is not updatable
  94118. * @param kind defines the data kind (Position, normal, etc...)
  94119. * @param data defines the data to use
  94120. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  94121. */
  94122. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  94123. private _updateBoundingInfo;
  94124. /** @hidden */
  94125. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  94126. /**
  94127. * Gets total number of vertices
  94128. * @returns the total number of vertices
  94129. */
  94130. getTotalVertices(): number;
  94131. /**
  94132. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94133. * @param kind defines the data kind (Position, normal, etc...)
  94134. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94135. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94136. * @returns a float array containing vertex data
  94137. */
  94138. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94139. /**
  94140. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  94141. * @param kind defines the data kind (Position, normal, etc...)
  94142. * @returns true if the vertex buffer with the specified kind is updatable
  94143. */
  94144. isVertexBufferUpdatable(kind: string): boolean;
  94145. /**
  94146. * Gets a specific vertex buffer
  94147. * @param kind defines the data kind (Position, normal, etc...)
  94148. * @returns a VertexBuffer
  94149. */
  94150. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94151. /**
  94152. * Returns all vertex buffers
  94153. * @return an object holding all vertex buffers indexed by kind
  94154. */
  94155. getVertexBuffers(): Nullable<{
  94156. [key: string]: VertexBuffer;
  94157. }>;
  94158. /**
  94159. * Gets a boolean indicating if specific vertex buffer is present
  94160. * @param kind defines the data kind (Position, normal, etc...)
  94161. * @returns true if data is present
  94162. */
  94163. isVerticesDataPresent(kind: string): boolean;
  94164. /**
  94165. * Gets a list of all attached data kinds (Position, normal, etc...)
  94166. * @returns a list of string containing all kinds
  94167. */
  94168. getVerticesDataKinds(): string[];
  94169. /**
  94170. * Update index buffer
  94171. * @param indices defines the indices to store in the index buffer
  94172. * @param offset defines the offset in the target buffer where to store the data
  94173. * @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)
  94174. */
  94175. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  94176. /**
  94177. * Creates a new index buffer
  94178. * @param indices defines the indices to store in the index buffer
  94179. * @param totalVertices defines the total number of vertices (could be null)
  94180. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94181. */
  94182. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  94183. /**
  94184. * Return the total number of indices
  94185. * @returns the total number of indices
  94186. */
  94187. getTotalIndices(): number;
  94188. /**
  94189. * Gets the index buffer array
  94190. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94191. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94192. * @returns the index buffer array
  94193. */
  94194. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94195. /**
  94196. * Gets the index buffer
  94197. * @return the index buffer
  94198. */
  94199. getIndexBuffer(): Nullable<DataBuffer>;
  94200. /** @hidden */
  94201. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  94202. /**
  94203. * Release the associated resources for a specific mesh
  94204. * @param mesh defines the source mesh
  94205. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  94206. */
  94207. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  94208. /**
  94209. * Apply current geometry to a given mesh
  94210. * @param mesh defines the mesh to apply geometry to
  94211. */
  94212. applyToMesh(mesh: Mesh): void;
  94213. private _updateExtend;
  94214. private _applyToMesh;
  94215. private notifyUpdate;
  94216. /**
  94217. * Load the geometry if it was flagged as delay loaded
  94218. * @param scene defines the hosting scene
  94219. * @param onLoaded defines a callback called when the geometry is loaded
  94220. */
  94221. load(scene: Scene, onLoaded?: () => void): void;
  94222. private _queueLoad;
  94223. /**
  94224. * Invert the geometry to move from a right handed system to a left handed one.
  94225. */
  94226. toLeftHanded(): void;
  94227. /** @hidden */
  94228. _resetPointsArrayCache(): void;
  94229. /** @hidden */
  94230. _generatePointsArray(): boolean;
  94231. /**
  94232. * Gets a value indicating if the geometry is disposed
  94233. * @returns true if the geometry was disposed
  94234. */
  94235. isDisposed(): boolean;
  94236. private _disposeVertexArrayObjects;
  94237. /**
  94238. * Free all associated resources
  94239. */
  94240. dispose(): void;
  94241. /**
  94242. * Clone the current geometry into a new geometry
  94243. * @param id defines the unique ID of the new geometry
  94244. * @returns a new geometry object
  94245. */
  94246. copy(id: string): Geometry;
  94247. /**
  94248. * Serialize the current geometry info (and not the vertices data) into a JSON object
  94249. * @return a JSON representation of the current geometry data (without the vertices data)
  94250. */
  94251. serialize(): any;
  94252. private toNumberArray;
  94253. /**
  94254. * Serialize all vertices data into a JSON oject
  94255. * @returns a JSON representation of the current geometry data
  94256. */
  94257. serializeVerticeData(): any;
  94258. /**
  94259. * Extracts a clone of a mesh geometry
  94260. * @param mesh defines the source mesh
  94261. * @param id defines the unique ID of the new geometry object
  94262. * @returns the new geometry object
  94263. */
  94264. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  94265. /**
  94266. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  94267. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94268. * Be aware Math.random() could cause collisions, but:
  94269. * "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"
  94270. * @returns a string containing a new GUID
  94271. */
  94272. static RandomId(): string;
  94273. /** @hidden */
  94274. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  94275. private static _CleanMatricesWeights;
  94276. /**
  94277. * Create a new geometry from persisted data (Using .babylon file format)
  94278. * @param parsedVertexData defines the persisted data
  94279. * @param scene defines the hosting scene
  94280. * @param rootUrl defines the root url to use to load assets (like delayed data)
  94281. * @returns the new geometry object
  94282. */
  94283. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  94284. }
  94285. }
  94286. declare module BABYLON {
  94287. /**
  94288. * Define an interface for all classes that will get and set the data on vertices
  94289. */
  94290. export interface IGetSetVerticesData {
  94291. /**
  94292. * Gets a boolean indicating if specific vertex data is present
  94293. * @param kind defines the vertex data kind to use
  94294. * @returns true is data kind is present
  94295. */
  94296. isVerticesDataPresent(kind: string): boolean;
  94297. /**
  94298. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94299. * @param kind defines the data kind (Position, normal, etc...)
  94300. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94302. * @returns a float array containing vertex data
  94303. */
  94304. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94305. /**
  94306. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94307. * @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.
  94308. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94309. * @returns the indices array or an empty array if the mesh has no geometry
  94310. */
  94311. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94312. /**
  94313. * Set specific vertex data
  94314. * @param kind defines the data kind (Position, normal, etc...)
  94315. * @param data defines the vertex data to use
  94316. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94317. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94318. */
  94319. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  94320. /**
  94321. * Update a specific associated vertex buffer
  94322. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94323. * - VertexBuffer.PositionKind
  94324. * - VertexBuffer.UVKind
  94325. * - VertexBuffer.UV2Kind
  94326. * - VertexBuffer.UV3Kind
  94327. * - VertexBuffer.UV4Kind
  94328. * - VertexBuffer.UV5Kind
  94329. * - VertexBuffer.UV6Kind
  94330. * - VertexBuffer.ColorKind
  94331. * - VertexBuffer.MatricesIndicesKind
  94332. * - VertexBuffer.MatricesIndicesExtraKind
  94333. * - VertexBuffer.MatricesWeightsKind
  94334. * - VertexBuffer.MatricesWeightsExtraKind
  94335. * @param data defines the data source
  94336. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  94337. * @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)
  94338. */
  94339. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  94340. /**
  94341. * Creates a new index buffer
  94342. * @param indices defines the indices to store in the index buffer
  94343. * @param totalVertices defines the total number of vertices (could be null)
  94344. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94345. */
  94346. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  94347. }
  94348. /**
  94349. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  94350. */
  94351. export class VertexData {
  94352. /**
  94353. * Mesh side orientation : usually the external or front surface
  94354. */
  94355. static readonly FRONTSIDE: number;
  94356. /**
  94357. * Mesh side orientation : usually the internal or back surface
  94358. */
  94359. static readonly BACKSIDE: number;
  94360. /**
  94361. * Mesh side orientation : both internal and external or front and back surfaces
  94362. */
  94363. static readonly DOUBLESIDE: number;
  94364. /**
  94365. * Mesh side orientation : by default, `FRONTSIDE`
  94366. */
  94367. static readonly DEFAULTSIDE: number;
  94368. /**
  94369. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  94370. */
  94371. positions: Nullable<FloatArray>;
  94372. /**
  94373. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  94374. */
  94375. normals: Nullable<FloatArray>;
  94376. /**
  94377. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  94378. */
  94379. tangents: Nullable<FloatArray>;
  94380. /**
  94381. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94382. */
  94383. uvs: Nullable<FloatArray>;
  94384. /**
  94385. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94386. */
  94387. uvs2: Nullable<FloatArray>;
  94388. /**
  94389. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94390. */
  94391. uvs3: Nullable<FloatArray>;
  94392. /**
  94393. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94394. */
  94395. uvs4: Nullable<FloatArray>;
  94396. /**
  94397. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94398. */
  94399. uvs5: Nullable<FloatArray>;
  94400. /**
  94401. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94402. */
  94403. uvs6: Nullable<FloatArray>;
  94404. /**
  94405. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  94406. */
  94407. colors: Nullable<FloatArray>;
  94408. /**
  94409. * 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).
  94410. */
  94411. matricesIndices: Nullable<FloatArray>;
  94412. /**
  94413. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  94414. */
  94415. matricesWeights: Nullable<FloatArray>;
  94416. /**
  94417. * An array extending the number of possible indices
  94418. */
  94419. matricesIndicesExtra: Nullable<FloatArray>;
  94420. /**
  94421. * An array extending the number of possible weights when the number of indices is extended
  94422. */
  94423. matricesWeightsExtra: Nullable<FloatArray>;
  94424. /**
  94425. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  94426. */
  94427. indices: Nullable<IndicesArray>;
  94428. /**
  94429. * Uses the passed data array to set the set the values for the specified kind of data
  94430. * @param data a linear array of floating numbers
  94431. * @param kind the type of data that is being set, eg positions, colors etc
  94432. */
  94433. set(data: FloatArray, kind: string): void;
  94434. /**
  94435. * Associates the vertexData to the passed Mesh.
  94436. * Sets it as updatable or not (default `false`)
  94437. * @param mesh the mesh the vertexData is applied to
  94438. * @param updatable when used and having the value true allows new data to update the vertexData
  94439. * @returns the VertexData
  94440. */
  94441. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  94442. /**
  94443. * Associates the vertexData to the passed Geometry.
  94444. * Sets it as updatable or not (default `false`)
  94445. * @param geometry the geometry the vertexData is applied to
  94446. * @param updatable when used and having the value true allows new data to update the vertexData
  94447. * @returns VertexData
  94448. */
  94449. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  94450. /**
  94451. * Updates the associated mesh
  94452. * @param mesh the mesh to be updated
  94453. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94454. * @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
  94455. * @returns VertexData
  94456. */
  94457. updateMesh(mesh: Mesh): VertexData;
  94458. /**
  94459. * Updates the associated geometry
  94460. * @param geometry the geometry to be updated
  94461. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94462. * @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
  94463. * @returns VertexData.
  94464. */
  94465. updateGeometry(geometry: Geometry): VertexData;
  94466. private _applyTo;
  94467. private _update;
  94468. /**
  94469. * Transforms each position and each normal of the vertexData according to the passed Matrix
  94470. * @param matrix the transforming matrix
  94471. * @returns the VertexData
  94472. */
  94473. transform(matrix: Matrix): VertexData;
  94474. /**
  94475. * Merges the passed VertexData into the current one
  94476. * @param other the VertexData to be merged into the current one
  94477. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  94478. * @returns the modified VertexData
  94479. */
  94480. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  94481. private _mergeElement;
  94482. private _validate;
  94483. /**
  94484. * Serializes the VertexData
  94485. * @returns a serialized object
  94486. */
  94487. serialize(): any;
  94488. /**
  94489. * Extracts the vertexData from a mesh
  94490. * @param mesh the mesh from which to extract the VertexData
  94491. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  94492. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94493. * @returns the object VertexData associated to the passed mesh
  94494. */
  94495. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94496. /**
  94497. * Extracts the vertexData from the geometry
  94498. * @param geometry the geometry from which to extract the VertexData
  94499. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  94500. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94501. * @returns the object VertexData associated to the passed mesh
  94502. */
  94503. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94504. private static _ExtractFrom;
  94505. /**
  94506. * Creates the VertexData for a Ribbon
  94507. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  94508. * * pathArray array of paths, each of which an array of successive Vector3
  94509. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  94510. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  94511. * * 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
  94512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94513. * * 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)
  94514. * * 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)
  94515. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  94516. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  94517. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  94518. * @returns the VertexData of the ribbon
  94519. */
  94520. static CreateRibbon(options: {
  94521. pathArray: Vector3[][];
  94522. closeArray?: boolean;
  94523. closePath?: boolean;
  94524. offset?: number;
  94525. sideOrientation?: number;
  94526. frontUVs?: Vector4;
  94527. backUVs?: Vector4;
  94528. invertUV?: boolean;
  94529. uvs?: Vector2[];
  94530. colors?: Color4[];
  94531. }): VertexData;
  94532. /**
  94533. * Creates the VertexData for a box
  94534. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94535. * * size sets the width, height and depth of the box to the value of size, optional default 1
  94536. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  94537. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  94538. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  94539. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94540. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94542. * * 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)
  94543. * * 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)
  94544. * @returns the VertexData of the box
  94545. */
  94546. static CreateBox(options: {
  94547. size?: number;
  94548. width?: number;
  94549. height?: number;
  94550. depth?: number;
  94551. faceUV?: Vector4[];
  94552. faceColors?: Color4[];
  94553. sideOrientation?: number;
  94554. frontUVs?: Vector4;
  94555. backUVs?: Vector4;
  94556. }): VertexData;
  94557. /**
  94558. * Creates the VertexData for a tiled box
  94559. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94560. * * faceTiles sets the pattern, tile size and number of tiles for a face
  94561. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94562. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94564. * @returns the VertexData of the box
  94565. */
  94566. static CreateTiledBox(options: {
  94567. pattern?: number;
  94568. width?: number;
  94569. height?: number;
  94570. depth?: number;
  94571. tileSize?: number;
  94572. tileWidth?: number;
  94573. tileHeight?: number;
  94574. alignHorizontal?: number;
  94575. alignVertical?: number;
  94576. faceUV?: Vector4[];
  94577. faceColors?: Color4[];
  94578. sideOrientation?: number;
  94579. }): VertexData;
  94580. /**
  94581. * Creates the VertexData for a tiled plane
  94582. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94583. * * pattern a limited pattern arrangement depending on the number
  94584. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  94585. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  94586. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  94587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94588. * * 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)
  94589. * * 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)
  94590. * @returns the VertexData of the tiled plane
  94591. */
  94592. static CreateTiledPlane(options: {
  94593. pattern?: number;
  94594. tileSize?: number;
  94595. tileWidth?: number;
  94596. tileHeight?: number;
  94597. size?: number;
  94598. width?: number;
  94599. height?: number;
  94600. alignHorizontal?: number;
  94601. alignVertical?: number;
  94602. sideOrientation?: number;
  94603. frontUVs?: Vector4;
  94604. backUVs?: Vector4;
  94605. }): VertexData;
  94606. /**
  94607. * Creates the VertexData for an ellipsoid, defaults to a sphere
  94608. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94609. * * segments sets the number of horizontal strips optional, default 32
  94610. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  94611. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  94612. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  94613. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  94614. * * 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
  94615. * * 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
  94616. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94617. * * 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)
  94618. * * 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)
  94619. * @returns the VertexData of the ellipsoid
  94620. */
  94621. static CreateSphere(options: {
  94622. segments?: number;
  94623. diameter?: number;
  94624. diameterX?: number;
  94625. diameterY?: number;
  94626. diameterZ?: number;
  94627. arc?: number;
  94628. slice?: number;
  94629. sideOrientation?: number;
  94630. frontUVs?: Vector4;
  94631. backUVs?: Vector4;
  94632. }): VertexData;
  94633. /**
  94634. * Creates the VertexData for a cylinder, cone or prism
  94635. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94636. * * height sets the height (y direction) of the cylinder, optional, default 2
  94637. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  94638. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  94639. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  94640. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  94641. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  94642. * * 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
  94643. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94644. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94645. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  94646. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  94647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94648. * * 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)
  94649. * * 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)
  94650. * @returns the VertexData of the cylinder, cone or prism
  94651. */
  94652. static CreateCylinder(options: {
  94653. height?: number;
  94654. diameterTop?: number;
  94655. diameterBottom?: number;
  94656. diameter?: number;
  94657. tessellation?: number;
  94658. subdivisions?: number;
  94659. arc?: number;
  94660. faceColors?: Color4[];
  94661. faceUV?: Vector4[];
  94662. hasRings?: boolean;
  94663. enclose?: boolean;
  94664. sideOrientation?: number;
  94665. frontUVs?: Vector4;
  94666. backUVs?: Vector4;
  94667. }): VertexData;
  94668. /**
  94669. * Creates the VertexData for a torus
  94670. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94671. * * diameter the diameter of the torus, optional default 1
  94672. * * thickness the diameter of the tube forming the torus, optional default 0.5
  94673. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  94674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94675. * * 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)
  94676. * * 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)
  94677. * @returns the VertexData of the torus
  94678. */
  94679. static CreateTorus(options: {
  94680. diameter?: number;
  94681. thickness?: number;
  94682. tessellation?: number;
  94683. sideOrientation?: number;
  94684. frontUVs?: Vector4;
  94685. backUVs?: Vector4;
  94686. }): VertexData;
  94687. /**
  94688. * Creates the VertexData of the LineSystem
  94689. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  94690. * - lines an array of lines, each line being an array of successive Vector3
  94691. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  94692. * @returns the VertexData of the LineSystem
  94693. */
  94694. static CreateLineSystem(options: {
  94695. lines: Vector3[][];
  94696. colors?: Nullable<Color4[][]>;
  94697. }): VertexData;
  94698. /**
  94699. * Create the VertexData for a DashedLines
  94700. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  94701. * - points an array successive Vector3
  94702. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  94703. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  94704. * - dashNb the intended total number of dashes, optional, default 200
  94705. * @returns the VertexData for the DashedLines
  94706. */
  94707. static CreateDashedLines(options: {
  94708. points: Vector3[];
  94709. dashSize?: number;
  94710. gapSize?: number;
  94711. dashNb?: number;
  94712. }): VertexData;
  94713. /**
  94714. * Creates the VertexData for a Ground
  94715. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  94716. * - width the width (x direction) of the ground, optional, default 1
  94717. * - height the height (z direction) of the ground, optional, default 1
  94718. * - subdivisions the number of subdivisions per side, optional, default 1
  94719. * @returns the VertexData of the Ground
  94720. */
  94721. static CreateGround(options: {
  94722. width?: number;
  94723. height?: number;
  94724. subdivisions?: number;
  94725. subdivisionsX?: number;
  94726. subdivisionsY?: number;
  94727. }): VertexData;
  94728. /**
  94729. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  94730. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  94731. * * xmin the ground minimum X coordinate, optional, default -1
  94732. * * zmin the ground minimum Z coordinate, optional, default -1
  94733. * * xmax the ground maximum X coordinate, optional, default 1
  94734. * * zmax the ground maximum Z coordinate, optional, default 1
  94735. * * 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}
  94736. * * 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}
  94737. * @returns the VertexData of the TiledGround
  94738. */
  94739. static CreateTiledGround(options: {
  94740. xmin: number;
  94741. zmin: number;
  94742. xmax: number;
  94743. zmax: number;
  94744. subdivisions?: {
  94745. w: number;
  94746. h: number;
  94747. };
  94748. precision?: {
  94749. w: number;
  94750. h: number;
  94751. };
  94752. }): VertexData;
  94753. /**
  94754. * Creates the VertexData of the Ground designed from a heightmap
  94755. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  94756. * * width the width (x direction) of the ground
  94757. * * height the height (z direction) of the ground
  94758. * * subdivisions the number of subdivisions per side
  94759. * * minHeight the minimum altitude on the ground, optional, default 0
  94760. * * maxHeight the maximum altitude on the ground, optional default 1
  94761. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  94762. * * buffer the array holding the image color data
  94763. * * bufferWidth the width of image
  94764. * * bufferHeight the height of image
  94765. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  94766. * @returns the VertexData of the Ground designed from a heightmap
  94767. */
  94768. static CreateGroundFromHeightMap(options: {
  94769. width: number;
  94770. height: number;
  94771. subdivisions: number;
  94772. minHeight: number;
  94773. maxHeight: number;
  94774. colorFilter: Color3;
  94775. buffer: Uint8Array;
  94776. bufferWidth: number;
  94777. bufferHeight: number;
  94778. alphaFilter: number;
  94779. }): VertexData;
  94780. /**
  94781. * Creates the VertexData for a Plane
  94782. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  94783. * * size sets the width and height of the plane to the value of size, optional default 1
  94784. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  94785. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  94786. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94787. * * 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)
  94788. * * 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)
  94789. * @returns the VertexData of the box
  94790. */
  94791. static CreatePlane(options: {
  94792. size?: number;
  94793. width?: number;
  94794. height?: number;
  94795. sideOrientation?: number;
  94796. frontUVs?: Vector4;
  94797. backUVs?: Vector4;
  94798. }): VertexData;
  94799. /**
  94800. * Creates the VertexData of the Disc or regular Polygon
  94801. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  94802. * * radius the radius of the disc, optional default 0.5
  94803. * * tessellation the number of polygon sides, optional, default 64
  94804. * * 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
  94805. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94806. * * 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)
  94807. * * 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)
  94808. * @returns the VertexData of the box
  94809. */
  94810. static CreateDisc(options: {
  94811. radius?: number;
  94812. tessellation?: number;
  94813. arc?: number;
  94814. sideOrientation?: number;
  94815. frontUVs?: Vector4;
  94816. backUVs?: Vector4;
  94817. }): VertexData;
  94818. /**
  94819. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  94820. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  94821. * @param polygon a mesh built from polygonTriangulation.build()
  94822. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94823. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94824. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94825. * @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)
  94826. * @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)
  94827. * @returns the VertexData of the Polygon
  94828. */
  94829. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  94830. /**
  94831. * Creates the VertexData of the IcoSphere
  94832. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  94833. * * radius the radius of the IcoSphere, optional default 1
  94834. * * radiusX allows stretching in the x direction, optional, default radius
  94835. * * radiusY allows stretching in the y direction, optional, default radius
  94836. * * radiusZ allows stretching in the z direction, optional, default radius
  94837. * * flat when true creates a flat shaded mesh, optional, default true
  94838. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  94839. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94840. * * 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)
  94841. * * 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)
  94842. * @returns the VertexData of the IcoSphere
  94843. */
  94844. static CreateIcoSphere(options: {
  94845. radius?: number;
  94846. radiusX?: number;
  94847. radiusY?: number;
  94848. radiusZ?: number;
  94849. flat?: boolean;
  94850. subdivisions?: number;
  94851. sideOrientation?: number;
  94852. frontUVs?: Vector4;
  94853. backUVs?: Vector4;
  94854. }): VertexData;
  94855. /**
  94856. * Creates the VertexData for a Polyhedron
  94857. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  94858. * * type provided types are:
  94859. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  94860. * * 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)
  94861. * * size the size of the IcoSphere, optional default 1
  94862. * * sizeX allows stretching in the x direction, optional, default size
  94863. * * sizeY allows stretching in the y direction, optional, default size
  94864. * * sizeZ allows stretching in the z direction, optional, default size
  94865. * * 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
  94866. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94867. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94868. * * flat when true creates a flat shaded mesh, optional, default true
  94869. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  94870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94871. * * 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)
  94872. * * 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)
  94873. * @returns the VertexData of the Polyhedron
  94874. */
  94875. static CreatePolyhedron(options: {
  94876. type?: number;
  94877. size?: number;
  94878. sizeX?: number;
  94879. sizeY?: number;
  94880. sizeZ?: number;
  94881. custom?: any;
  94882. faceUV?: Vector4[];
  94883. faceColors?: Color4[];
  94884. flat?: boolean;
  94885. sideOrientation?: number;
  94886. frontUVs?: Vector4;
  94887. backUVs?: Vector4;
  94888. }): VertexData;
  94889. /**
  94890. * Creates the VertexData for a TorusKnot
  94891. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  94892. * * radius the radius of the torus knot, optional, default 2
  94893. * * tube the thickness of the tube, optional, default 0.5
  94894. * * radialSegments the number of sides on each tube segments, optional, default 32
  94895. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  94896. * * p the number of windings around the z axis, optional, default 2
  94897. * * q the number of windings around the x axis, optional, default 3
  94898. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94899. * * 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)
  94900. * * 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)
  94901. * @returns the VertexData of the Torus Knot
  94902. */
  94903. static CreateTorusKnot(options: {
  94904. radius?: number;
  94905. tube?: number;
  94906. radialSegments?: number;
  94907. tubularSegments?: number;
  94908. p?: number;
  94909. q?: number;
  94910. sideOrientation?: number;
  94911. frontUVs?: Vector4;
  94912. backUVs?: Vector4;
  94913. }): VertexData;
  94914. /**
  94915. * Compute normals for given positions and indices
  94916. * @param positions an array of vertex positions, [...., x, y, z, ......]
  94917. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  94918. * @param normals an array of vertex normals, [...., x, y, z, ......]
  94919. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  94920. * * facetNormals : optional array of facet normals (vector3)
  94921. * * facetPositions : optional array of facet positions (vector3)
  94922. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  94923. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  94924. * * bInfo : optional bounding info, required for facetPartitioning computation
  94925. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  94926. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  94927. * * useRightHandedSystem: optional boolean to for right handed system computation
  94928. * * depthSort : optional boolean to enable the facet depth sort computation
  94929. * * distanceTo : optional Vector3 to compute the facet depth from this location
  94930. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  94931. */
  94932. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  94933. facetNormals?: any;
  94934. facetPositions?: any;
  94935. facetPartitioning?: any;
  94936. ratio?: number;
  94937. bInfo?: any;
  94938. bbSize?: Vector3;
  94939. subDiv?: any;
  94940. useRightHandedSystem?: boolean;
  94941. depthSort?: boolean;
  94942. distanceTo?: Vector3;
  94943. depthSortedFacets?: any;
  94944. }): void;
  94945. /** @hidden */
  94946. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  94947. /**
  94948. * Applies VertexData created from the imported parameters to the geometry
  94949. * @param parsedVertexData the parsed data from an imported file
  94950. * @param geometry the geometry to apply the VertexData to
  94951. */
  94952. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  94953. }
  94954. }
  94955. declare module BABYLON {
  94956. /**
  94957. * Defines a target to use with MorphTargetManager
  94958. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94959. */
  94960. export class MorphTarget implements IAnimatable {
  94961. /** defines the name of the target */
  94962. name: string;
  94963. /**
  94964. * Gets or sets the list of animations
  94965. */
  94966. animations: Animation[];
  94967. private _scene;
  94968. private _positions;
  94969. private _normals;
  94970. private _tangents;
  94971. private _uvs;
  94972. private _influence;
  94973. private _uniqueId;
  94974. /**
  94975. * Observable raised when the influence changes
  94976. */
  94977. onInfluenceChanged: Observable<boolean>;
  94978. /** @hidden */
  94979. _onDataLayoutChanged: Observable<void>;
  94980. /**
  94981. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  94982. */
  94983. get influence(): number;
  94984. set influence(influence: number);
  94985. /**
  94986. * Gets or sets the id of the morph Target
  94987. */
  94988. id: string;
  94989. private _animationPropertiesOverride;
  94990. /**
  94991. * Gets or sets the animation properties override
  94992. */
  94993. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94994. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94995. /**
  94996. * Creates a new MorphTarget
  94997. * @param name defines the name of the target
  94998. * @param influence defines the influence to use
  94999. * @param scene defines the scene the morphtarget belongs to
  95000. */
  95001. constructor(
  95002. /** defines the name of the target */
  95003. name: string, influence?: number, scene?: Nullable<Scene>);
  95004. /**
  95005. * Gets the unique ID of this manager
  95006. */
  95007. get uniqueId(): number;
  95008. /**
  95009. * Gets a boolean defining if the target contains position data
  95010. */
  95011. get hasPositions(): boolean;
  95012. /**
  95013. * Gets a boolean defining if the target contains normal data
  95014. */
  95015. get hasNormals(): boolean;
  95016. /**
  95017. * Gets a boolean defining if the target contains tangent data
  95018. */
  95019. get hasTangents(): boolean;
  95020. /**
  95021. * Gets a boolean defining if the target contains texture coordinates data
  95022. */
  95023. get hasUVs(): boolean;
  95024. /**
  95025. * Affects position data to this target
  95026. * @param data defines the position data to use
  95027. */
  95028. setPositions(data: Nullable<FloatArray>): void;
  95029. /**
  95030. * Gets the position data stored in this target
  95031. * @returns a FloatArray containing the position data (or null if not present)
  95032. */
  95033. getPositions(): Nullable<FloatArray>;
  95034. /**
  95035. * Affects normal data to this target
  95036. * @param data defines the normal data to use
  95037. */
  95038. setNormals(data: Nullable<FloatArray>): void;
  95039. /**
  95040. * Gets the normal data stored in this target
  95041. * @returns a FloatArray containing the normal data (or null if not present)
  95042. */
  95043. getNormals(): Nullable<FloatArray>;
  95044. /**
  95045. * Affects tangent data to this target
  95046. * @param data defines the tangent data to use
  95047. */
  95048. setTangents(data: Nullable<FloatArray>): void;
  95049. /**
  95050. * Gets the tangent data stored in this target
  95051. * @returns a FloatArray containing the tangent data (or null if not present)
  95052. */
  95053. getTangents(): Nullable<FloatArray>;
  95054. /**
  95055. * Affects texture coordinates data to this target
  95056. * @param data defines the texture coordinates data to use
  95057. */
  95058. setUVs(data: Nullable<FloatArray>): void;
  95059. /**
  95060. * Gets the texture coordinates data stored in this target
  95061. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95062. */
  95063. getUVs(): Nullable<FloatArray>;
  95064. /**
  95065. * Clone the current target
  95066. * @returns a new MorphTarget
  95067. */
  95068. clone(): MorphTarget;
  95069. /**
  95070. * Serializes the current target into a Serialization object
  95071. * @returns the serialized object
  95072. */
  95073. serialize(): any;
  95074. /**
  95075. * Returns the string "MorphTarget"
  95076. * @returns "MorphTarget"
  95077. */
  95078. getClassName(): string;
  95079. /**
  95080. * Creates a new target from serialized data
  95081. * @param serializationObject defines the serialized data to use
  95082. * @returns a new MorphTarget
  95083. */
  95084. static Parse(serializationObject: any): MorphTarget;
  95085. /**
  95086. * Creates a MorphTarget from mesh data
  95087. * @param mesh defines the source mesh
  95088. * @param name defines the name to use for the new target
  95089. * @param influence defines the influence to attach to the target
  95090. * @returns a new MorphTarget
  95091. */
  95092. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95093. }
  95094. }
  95095. declare module BABYLON {
  95096. /**
  95097. * This class is used to deform meshes using morphing between different targets
  95098. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95099. */
  95100. export class MorphTargetManager {
  95101. private _targets;
  95102. private _targetInfluenceChangedObservers;
  95103. private _targetDataLayoutChangedObservers;
  95104. private _activeTargets;
  95105. private _scene;
  95106. private _influences;
  95107. private _supportsNormals;
  95108. private _supportsTangents;
  95109. private _supportsUVs;
  95110. private _vertexCount;
  95111. private _uniqueId;
  95112. private _tempInfluences;
  95113. /**
  95114. * Gets or sets a boolean indicating if normals must be morphed
  95115. */
  95116. enableNormalMorphing: boolean;
  95117. /**
  95118. * Gets or sets a boolean indicating if tangents must be morphed
  95119. */
  95120. enableTangentMorphing: boolean;
  95121. /**
  95122. * Gets or sets a boolean indicating if UV must be morphed
  95123. */
  95124. enableUVMorphing: boolean;
  95125. /**
  95126. * Creates a new MorphTargetManager
  95127. * @param scene defines the current scene
  95128. */
  95129. constructor(scene?: Nullable<Scene>);
  95130. /**
  95131. * Gets the unique ID of this manager
  95132. */
  95133. get uniqueId(): number;
  95134. /**
  95135. * Gets the number of vertices handled by this manager
  95136. */
  95137. get vertexCount(): number;
  95138. /**
  95139. * Gets a boolean indicating if this manager supports morphing of normals
  95140. */
  95141. get supportsNormals(): boolean;
  95142. /**
  95143. * Gets a boolean indicating if this manager supports morphing of tangents
  95144. */
  95145. get supportsTangents(): boolean;
  95146. /**
  95147. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  95148. */
  95149. get supportsUVs(): boolean;
  95150. /**
  95151. * Gets the number of targets stored in this manager
  95152. */
  95153. get numTargets(): number;
  95154. /**
  95155. * Gets the number of influencers (ie. the number of targets with influences > 0)
  95156. */
  95157. get numInfluencers(): number;
  95158. /**
  95159. * Gets the list of influences (one per target)
  95160. */
  95161. get influences(): Float32Array;
  95162. /**
  95163. * Gets the active target at specified index. An active target is a target with an influence > 0
  95164. * @param index defines the index to check
  95165. * @returns the requested target
  95166. */
  95167. getActiveTarget(index: number): MorphTarget;
  95168. /**
  95169. * Gets the target at specified index
  95170. * @param index defines the index to check
  95171. * @returns the requested target
  95172. */
  95173. getTarget(index: number): MorphTarget;
  95174. /**
  95175. * Add a new target to this manager
  95176. * @param target defines the target to add
  95177. */
  95178. addTarget(target: MorphTarget): void;
  95179. /**
  95180. * Removes a target from the manager
  95181. * @param target defines the target to remove
  95182. */
  95183. removeTarget(target: MorphTarget): void;
  95184. /**
  95185. * Clone the current manager
  95186. * @returns a new MorphTargetManager
  95187. */
  95188. clone(): MorphTargetManager;
  95189. /**
  95190. * Serializes the current manager into a Serialization object
  95191. * @returns the serialized object
  95192. */
  95193. serialize(): any;
  95194. private _syncActiveTargets;
  95195. /**
  95196. * Syncrhonize the targets with all the meshes using this morph target manager
  95197. */
  95198. synchronize(): void;
  95199. /**
  95200. * Creates a new MorphTargetManager from serialized data
  95201. * @param serializationObject defines the serialized data
  95202. * @param scene defines the hosting scene
  95203. * @returns the new MorphTargetManager
  95204. */
  95205. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  95206. }
  95207. }
  95208. declare module BABYLON {
  95209. /**
  95210. * Class used to represent a specific level of detail of a mesh
  95211. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95212. */
  95213. export class MeshLODLevel {
  95214. /** Defines the distance where this level should start being displayed */
  95215. distance: number;
  95216. /** Defines the mesh to use to render this level */
  95217. mesh: Nullable<Mesh>;
  95218. /**
  95219. * Creates a new LOD level
  95220. * @param distance defines the distance where this level should star being displayed
  95221. * @param mesh defines the mesh to use to render this level
  95222. */
  95223. constructor(
  95224. /** Defines the distance where this level should start being displayed */
  95225. distance: number,
  95226. /** Defines the mesh to use to render this level */
  95227. mesh: Nullable<Mesh>);
  95228. }
  95229. }
  95230. declare module BABYLON {
  95231. /**
  95232. * Mesh representing the gorund
  95233. */
  95234. export class GroundMesh extends Mesh {
  95235. /** If octree should be generated */
  95236. generateOctree: boolean;
  95237. private _heightQuads;
  95238. /** @hidden */
  95239. _subdivisionsX: number;
  95240. /** @hidden */
  95241. _subdivisionsY: number;
  95242. /** @hidden */
  95243. _width: number;
  95244. /** @hidden */
  95245. _height: number;
  95246. /** @hidden */
  95247. _minX: number;
  95248. /** @hidden */
  95249. _maxX: number;
  95250. /** @hidden */
  95251. _minZ: number;
  95252. /** @hidden */
  95253. _maxZ: number;
  95254. constructor(name: string, scene: Scene);
  95255. /**
  95256. * "GroundMesh"
  95257. * @returns "GroundMesh"
  95258. */
  95259. getClassName(): string;
  95260. /**
  95261. * The minimum of x and y subdivisions
  95262. */
  95263. get subdivisions(): number;
  95264. /**
  95265. * X subdivisions
  95266. */
  95267. get subdivisionsX(): number;
  95268. /**
  95269. * Y subdivisions
  95270. */
  95271. get subdivisionsY(): number;
  95272. /**
  95273. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  95274. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95275. * @param chunksCount the number of subdivisions for x and y
  95276. * @param octreeBlocksSize (Default: 32)
  95277. */
  95278. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  95279. /**
  95280. * Returns a height (y) value in the Worl system :
  95281. * the ground altitude at the coordinates (x, z) expressed in the World system.
  95282. * @param x x coordinate
  95283. * @param z z coordinate
  95284. * @returns the ground y position if (x, z) are outside the ground surface.
  95285. */
  95286. getHeightAtCoordinates(x: number, z: number): number;
  95287. /**
  95288. * Returns a normalized vector (Vector3) orthogonal to the ground
  95289. * at the ground coordinates (x, z) expressed in the World system.
  95290. * @param x x coordinate
  95291. * @param z z coordinate
  95292. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  95293. */
  95294. getNormalAtCoordinates(x: number, z: number): Vector3;
  95295. /**
  95296. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  95297. * at the ground coordinates (x, z) expressed in the World system.
  95298. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  95299. * @param x x coordinate
  95300. * @param z z coordinate
  95301. * @param ref vector to store the result
  95302. * @returns the GroundMesh.
  95303. */
  95304. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  95305. /**
  95306. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  95307. * if the ground has been updated.
  95308. * This can be used in the render loop.
  95309. * @returns the GroundMesh.
  95310. */
  95311. updateCoordinateHeights(): GroundMesh;
  95312. private _getFacetAt;
  95313. private _initHeightQuads;
  95314. private _computeHeightQuads;
  95315. /**
  95316. * Serializes this ground mesh
  95317. * @param serializationObject object to write serialization to
  95318. */
  95319. serialize(serializationObject: any): void;
  95320. /**
  95321. * Parses a serialized ground mesh
  95322. * @param parsedMesh the serialized mesh
  95323. * @param scene the scene to create the ground mesh in
  95324. * @returns the created ground mesh
  95325. */
  95326. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  95327. }
  95328. }
  95329. declare module BABYLON {
  95330. /**
  95331. * Interface for Physics-Joint data
  95332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95333. */
  95334. export interface PhysicsJointData {
  95335. /**
  95336. * The main pivot of the joint
  95337. */
  95338. mainPivot?: Vector3;
  95339. /**
  95340. * The connected pivot of the joint
  95341. */
  95342. connectedPivot?: Vector3;
  95343. /**
  95344. * The main axis of the joint
  95345. */
  95346. mainAxis?: Vector3;
  95347. /**
  95348. * The connected axis of the joint
  95349. */
  95350. connectedAxis?: Vector3;
  95351. /**
  95352. * The collision of the joint
  95353. */
  95354. collision?: boolean;
  95355. /**
  95356. * Native Oimo/Cannon/Energy data
  95357. */
  95358. nativeParams?: any;
  95359. }
  95360. /**
  95361. * This is a holder class for the physics joint created by the physics plugin
  95362. * It holds a set of functions to control the underlying joint
  95363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95364. */
  95365. export class PhysicsJoint {
  95366. /**
  95367. * The type of the physics joint
  95368. */
  95369. type: number;
  95370. /**
  95371. * The data for the physics joint
  95372. */
  95373. jointData: PhysicsJointData;
  95374. private _physicsJoint;
  95375. protected _physicsPlugin: IPhysicsEnginePlugin;
  95376. /**
  95377. * Initializes the physics joint
  95378. * @param type The type of the physics joint
  95379. * @param jointData The data for the physics joint
  95380. */
  95381. constructor(
  95382. /**
  95383. * The type of the physics joint
  95384. */
  95385. type: number,
  95386. /**
  95387. * The data for the physics joint
  95388. */
  95389. jointData: PhysicsJointData);
  95390. /**
  95391. * Gets the physics joint
  95392. */
  95393. get physicsJoint(): any;
  95394. /**
  95395. * Sets the physics joint
  95396. */
  95397. set physicsJoint(newJoint: any);
  95398. /**
  95399. * Sets the physics plugin
  95400. */
  95401. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  95402. /**
  95403. * Execute a function that is physics-plugin specific.
  95404. * @param {Function} func the function that will be executed.
  95405. * It accepts two parameters: the physics world and the physics joint
  95406. */
  95407. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  95408. /**
  95409. * Distance-Joint type
  95410. */
  95411. static DistanceJoint: number;
  95412. /**
  95413. * Hinge-Joint type
  95414. */
  95415. static HingeJoint: number;
  95416. /**
  95417. * Ball-and-Socket joint type
  95418. */
  95419. static BallAndSocketJoint: number;
  95420. /**
  95421. * Wheel-Joint type
  95422. */
  95423. static WheelJoint: number;
  95424. /**
  95425. * Slider-Joint type
  95426. */
  95427. static SliderJoint: number;
  95428. /**
  95429. * Prismatic-Joint type
  95430. */
  95431. static PrismaticJoint: number;
  95432. /**
  95433. * Universal-Joint type
  95434. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  95435. */
  95436. static UniversalJoint: number;
  95437. /**
  95438. * Hinge-Joint 2 type
  95439. */
  95440. static Hinge2Joint: number;
  95441. /**
  95442. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  95443. */
  95444. static PointToPointJoint: number;
  95445. /**
  95446. * Spring-Joint type
  95447. */
  95448. static SpringJoint: number;
  95449. /**
  95450. * Lock-Joint type
  95451. */
  95452. static LockJoint: number;
  95453. }
  95454. /**
  95455. * A class representing a physics distance joint
  95456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95457. */
  95458. export class DistanceJoint extends PhysicsJoint {
  95459. /**
  95460. *
  95461. * @param jointData The data for the Distance-Joint
  95462. */
  95463. constructor(jointData: DistanceJointData);
  95464. /**
  95465. * Update the predefined distance.
  95466. * @param maxDistance The maximum preferred distance
  95467. * @param minDistance The minimum preferred distance
  95468. */
  95469. updateDistance(maxDistance: number, minDistance?: number): void;
  95470. }
  95471. /**
  95472. * Represents a Motor-Enabled Joint
  95473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95474. */
  95475. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  95476. /**
  95477. * Initializes the Motor-Enabled Joint
  95478. * @param type The type of the joint
  95479. * @param jointData The physica joint data for the joint
  95480. */
  95481. constructor(type: number, jointData: PhysicsJointData);
  95482. /**
  95483. * Set the motor values.
  95484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95485. * @param force the force to apply
  95486. * @param maxForce max force for this motor.
  95487. */
  95488. setMotor(force?: number, maxForce?: number): void;
  95489. /**
  95490. * Set the motor's limits.
  95491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95492. * @param upperLimit The upper limit of the motor
  95493. * @param lowerLimit The lower limit of the motor
  95494. */
  95495. setLimit(upperLimit: number, lowerLimit?: number): void;
  95496. }
  95497. /**
  95498. * This class represents a single physics Hinge-Joint
  95499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95500. */
  95501. export class HingeJoint extends MotorEnabledJoint {
  95502. /**
  95503. * Initializes the Hinge-Joint
  95504. * @param jointData The joint data for the Hinge-Joint
  95505. */
  95506. constructor(jointData: PhysicsJointData);
  95507. /**
  95508. * Set the motor values.
  95509. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95510. * @param {number} force the force to apply
  95511. * @param {number} maxForce max force for this motor.
  95512. */
  95513. setMotor(force?: number, maxForce?: number): void;
  95514. /**
  95515. * Set the motor's limits.
  95516. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95517. * @param upperLimit The upper limit of the motor
  95518. * @param lowerLimit The lower limit of the motor
  95519. */
  95520. setLimit(upperLimit: number, lowerLimit?: number): void;
  95521. }
  95522. /**
  95523. * This class represents a dual hinge physics joint (same as wheel joint)
  95524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95525. */
  95526. export class Hinge2Joint extends MotorEnabledJoint {
  95527. /**
  95528. * Initializes the Hinge2-Joint
  95529. * @param jointData The joint data for the Hinge2-Joint
  95530. */
  95531. constructor(jointData: PhysicsJointData);
  95532. /**
  95533. * Set the motor values.
  95534. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95535. * @param {number} targetSpeed the speed the motor is to reach
  95536. * @param {number} maxForce max force for this motor.
  95537. * @param {motorIndex} the motor's index, 0 or 1.
  95538. */
  95539. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  95540. /**
  95541. * Set the motor limits.
  95542. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95543. * @param {number} upperLimit the upper limit
  95544. * @param {number} lowerLimit lower limit
  95545. * @param {motorIndex} the motor's index, 0 or 1.
  95546. */
  95547. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95548. }
  95549. /**
  95550. * Interface for a motor enabled joint
  95551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95552. */
  95553. export interface IMotorEnabledJoint {
  95554. /**
  95555. * Physics joint
  95556. */
  95557. physicsJoint: any;
  95558. /**
  95559. * Sets the motor of the motor-enabled joint
  95560. * @param force The force of the motor
  95561. * @param maxForce The maximum force of the motor
  95562. * @param motorIndex The index of the motor
  95563. */
  95564. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  95565. /**
  95566. * Sets the limit of the motor
  95567. * @param upperLimit The upper limit of the motor
  95568. * @param lowerLimit The lower limit of the motor
  95569. * @param motorIndex The index of the motor
  95570. */
  95571. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95572. }
  95573. /**
  95574. * Joint data for a Distance-Joint
  95575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95576. */
  95577. export interface DistanceJointData extends PhysicsJointData {
  95578. /**
  95579. * Max distance the 2 joint objects can be apart
  95580. */
  95581. maxDistance: number;
  95582. }
  95583. /**
  95584. * Joint data from a spring joint
  95585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95586. */
  95587. export interface SpringJointData extends PhysicsJointData {
  95588. /**
  95589. * Length of the spring
  95590. */
  95591. length: number;
  95592. /**
  95593. * Stiffness of the spring
  95594. */
  95595. stiffness: number;
  95596. /**
  95597. * Damping of the spring
  95598. */
  95599. damping: number;
  95600. /** this callback will be called when applying the force to the impostors. */
  95601. forceApplicationCallback: () => void;
  95602. }
  95603. }
  95604. declare module BABYLON {
  95605. /**
  95606. * Holds the data for the raycast result
  95607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95608. */
  95609. export class PhysicsRaycastResult {
  95610. private _hasHit;
  95611. private _hitDistance;
  95612. private _hitNormalWorld;
  95613. private _hitPointWorld;
  95614. private _rayFromWorld;
  95615. private _rayToWorld;
  95616. /**
  95617. * Gets if there was a hit
  95618. */
  95619. get hasHit(): boolean;
  95620. /**
  95621. * Gets the distance from the hit
  95622. */
  95623. get hitDistance(): number;
  95624. /**
  95625. * Gets the hit normal/direction in the world
  95626. */
  95627. get hitNormalWorld(): Vector3;
  95628. /**
  95629. * Gets the hit point in the world
  95630. */
  95631. get hitPointWorld(): Vector3;
  95632. /**
  95633. * Gets the ray "start point" of the ray in the world
  95634. */
  95635. get rayFromWorld(): Vector3;
  95636. /**
  95637. * Gets the ray "end point" of the ray in the world
  95638. */
  95639. get rayToWorld(): Vector3;
  95640. /**
  95641. * Sets the hit data (normal & point in world space)
  95642. * @param hitNormalWorld defines the normal in world space
  95643. * @param hitPointWorld defines the point in world space
  95644. */
  95645. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  95646. /**
  95647. * Sets the distance from the start point to the hit point
  95648. * @param distance
  95649. */
  95650. setHitDistance(distance: number): void;
  95651. /**
  95652. * Calculates the distance manually
  95653. */
  95654. calculateHitDistance(): void;
  95655. /**
  95656. * Resets all the values to default
  95657. * @param from The from point on world space
  95658. * @param to The to point on world space
  95659. */
  95660. reset(from?: Vector3, to?: Vector3): void;
  95661. }
  95662. /**
  95663. * Interface for the size containing width and height
  95664. */
  95665. interface IXYZ {
  95666. /**
  95667. * X
  95668. */
  95669. x: number;
  95670. /**
  95671. * Y
  95672. */
  95673. y: number;
  95674. /**
  95675. * Z
  95676. */
  95677. z: number;
  95678. }
  95679. }
  95680. declare module BABYLON {
  95681. /**
  95682. * Interface used to describe a physics joint
  95683. */
  95684. export interface PhysicsImpostorJoint {
  95685. /** Defines the main impostor to which the joint is linked */
  95686. mainImpostor: PhysicsImpostor;
  95687. /** Defines the impostor that is connected to the main impostor using this joint */
  95688. connectedImpostor: PhysicsImpostor;
  95689. /** Defines the joint itself */
  95690. joint: PhysicsJoint;
  95691. }
  95692. /** @hidden */
  95693. export interface IPhysicsEnginePlugin {
  95694. world: any;
  95695. name: string;
  95696. setGravity(gravity: Vector3): void;
  95697. setTimeStep(timeStep: number): void;
  95698. getTimeStep(): number;
  95699. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  95700. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  95701. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  95702. generatePhysicsBody(impostor: PhysicsImpostor): void;
  95703. removePhysicsBody(impostor: PhysicsImpostor): void;
  95704. generateJoint(joint: PhysicsImpostorJoint): void;
  95705. removeJoint(joint: PhysicsImpostorJoint): void;
  95706. isSupported(): boolean;
  95707. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  95708. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  95709. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  95710. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  95711. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  95712. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  95713. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  95714. getBodyMass(impostor: PhysicsImpostor): number;
  95715. getBodyFriction(impostor: PhysicsImpostor): number;
  95716. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  95717. getBodyRestitution(impostor: PhysicsImpostor): number;
  95718. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  95719. getBodyPressure?(impostor: PhysicsImpostor): number;
  95720. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  95721. getBodyStiffness?(impostor: PhysicsImpostor): number;
  95722. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  95723. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  95724. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  95725. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  95726. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  95727. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  95728. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  95729. sleepBody(impostor: PhysicsImpostor): void;
  95730. wakeUpBody(impostor: PhysicsImpostor): void;
  95731. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  95732. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  95733. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  95734. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95735. getRadius(impostor: PhysicsImpostor): number;
  95736. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  95737. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  95738. dispose(): void;
  95739. }
  95740. /**
  95741. * Interface used to define a physics engine
  95742. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  95743. */
  95744. export interface IPhysicsEngine {
  95745. /**
  95746. * Gets the gravity vector used by the simulation
  95747. */
  95748. gravity: Vector3;
  95749. /**
  95750. * Sets the gravity vector used by the simulation
  95751. * @param gravity defines the gravity vector to use
  95752. */
  95753. setGravity(gravity: Vector3): void;
  95754. /**
  95755. * Set the time step of the physics engine.
  95756. * Default is 1/60.
  95757. * To slow it down, enter 1/600 for example.
  95758. * To speed it up, 1/30
  95759. * @param newTimeStep the new timestep to apply to this world.
  95760. */
  95761. setTimeStep(newTimeStep: number): void;
  95762. /**
  95763. * Get the time step of the physics engine.
  95764. * @returns the current time step
  95765. */
  95766. getTimeStep(): number;
  95767. /**
  95768. * Set the sub time step of the physics engine.
  95769. * Default is 0 meaning there is no sub steps
  95770. * To increase physics resolution precision, set a small value (like 1 ms)
  95771. * @param subTimeStep defines the new sub timestep used for physics resolution.
  95772. */
  95773. setSubTimeStep(subTimeStep: number): void;
  95774. /**
  95775. * Get the sub time step of the physics engine.
  95776. * @returns the current sub time step
  95777. */
  95778. getSubTimeStep(): number;
  95779. /**
  95780. * Release all resources
  95781. */
  95782. dispose(): void;
  95783. /**
  95784. * Gets the name of the current physics plugin
  95785. * @returns the name of the plugin
  95786. */
  95787. getPhysicsPluginName(): string;
  95788. /**
  95789. * Adding a new impostor for the impostor tracking.
  95790. * This will be done by the impostor itself.
  95791. * @param impostor the impostor to add
  95792. */
  95793. addImpostor(impostor: PhysicsImpostor): void;
  95794. /**
  95795. * Remove an impostor from the engine.
  95796. * This impostor and its mesh will not longer be updated by the physics engine.
  95797. * @param impostor the impostor to remove
  95798. */
  95799. removeImpostor(impostor: PhysicsImpostor): void;
  95800. /**
  95801. * Add a joint to the physics engine
  95802. * @param mainImpostor defines the main impostor to which the joint is added.
  95803. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  95804. * @param joint defines the joint that will connect both impostors.
  95805. */
  95806. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  95807. /**
  95808. * Removes a joint from the simulation
  95809. * @param mainImpostor defines the impostor used with the joint
  95810. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  95811. * @param joint defines the joint to remove
  95812. */
  95813. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  95814. /**
  95815. * Gets the current plugin used to run the simulation
  95816. * @returns current plugin
  95817. */
  95818. getPhysicsPlugin(): IPhysicsEnginePlugin;
  95819. /**
  95820. * Gets the list of physic impostors
  95821. * @returns an array of PhysicsImpostor
  95822. */
  95823. getImpostors(): Array<PhysicsImpostor>;
  95824. /**
  95825. * Gets the impostor for a physics enabled object
  95826. * @param object defines the object impersonated by the impostor
  95827. * @returns the PhysicsImpostor or null if not found
  95828. */
  95829. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  95830. /**
  95831. * Gets the impostor for a physics body object
  95832. * @param body defines physics body used by the impostor
  95833. * @returns the PhysicsImpostor or null if not found
  95834. */
  95835. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  95836. /**
  95837. * Does a raycast in the physics world
  95838. * @param from when should the ray start?
  95839. * @param to when should the ray end?
  95840. * @returns PhysicsRaycastResult
  95841. */
  95842. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  95843. /**
  95844. * Called by the scene. No need to call it.
  95845. * @param delta defines the timespam between frames
  95846. */
  95847. _step(delta: number): void;
  95848. }
  95849. }
  95850. declare module BABYLON {
  95851. /**
  95852. * The interface for the physics imposter parameters
  95853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95854. */
  95855. export interface PhysicsImpostorParameters {
  95856. /**
  95857. * The mass of the physics imposter
  95858. */
  95859. mass: number;
  95860. /**
  95861. * The friction of the physics imposter
  95862. */
  95863. friction?: number;
  95864. /**
  95865. * The coefficient of restitution of the physics imposter
  95866. */
  95867. restitution?: number;
  95868. /**
  95869. * The native options of the physics imposter
  95870. */
  95871. nativeOptions?: any;
  95872. /**
  95873. * Specifies if the parent should be ignored
  95874. */
  95875. ignoreParent?: boolean;
  95876. /**
  95877. * Specifies if bi-directional transformations should be disabled
  95878. */
  95879. disableBidirectionalTransformation?: boolean;
  95880. /**
  95881. * The pressure inside the physics imposter, soft object only
  95882. */
  95883. pressure?: number;
  95884. /**
  95885. * The stiffness the physics imposter, soft object only
  95886. */
  95887. stiffness?: number;
  95888. /**
  95889. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  95890. */
  95891. velocityIterations?: number;
  95892. /**
  95893. * The number of iterations used in maintaining consistent vertex positions, soft object only
  95894. */
  95895. positionIterations?: number;
  95896. /**
  95897. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  95898. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  95899. * Add to fix multiple points
  95900. */
  95901. fixedPoints?: number;
  95902. /**
  95903. * The collision margin around a soft object
  95904. */
  95905. margin?: number;
  95906. /**
  95907. * The collision margin around a soft object
  95908. */
  95909. damping?: number;
  95910. /**
  95911. * The path for a rope based on an extrusion
  95912. */
  95913. path?: any;
  95914. /**
  95915. * The shape of an extrusion used for a rope based on an extrusion
  95916. */
  95917. shape?: any;
  95918. }
  95919. /**
  95920. * Interface for a physics-enabled object
  95921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95922. */
  95923. export interface IPhysicsEnabledObject {
  95924. /**
  95925. * The position of the physics-enabled object
  95926. */
  95927. position: Vector3;
  95928. /**
  95929. * The rotation of the physics-enabled object
  95930. */
  95931. rotationQuaternion: Nullable<Quaternion>;
  95932. /**
  95933. * The scale of the physics-enabled object
  95934. */
  95935. scaling: Vector3;
  95936. /**
  95937. * The rotation of the physics-enabled object
  95938. */
  95939. rotation?: Vector3;
  95940. /**
  95941. * The parent of the physics-enabled object
  95942. */
  95943. parent?: any;
  95944. /**
  95945. * The bounding info of the physics-enabled object
  95946. * @returns The bounding info of the physics-enabled object
  95947. */
  95948. getBoundingInfo(): BoundingInfo;
  95949. /**
  95950. * Computes the world matrix
  95951. * @param force Specifies if the world matrix should be computed by force
  95952. * @returns A world matrix
  95953. */
  95954. computeWorldMatrix(force: boolean): Matrix;
  95955. /**
  95956. * Gets the world matrix
  95957. * @returns A world matrix
  95958. */
  95959. getWorldMatrix?(): Matrix;
  95960. /**
  95961. * Gets the child meshes
  95962. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  95963. * @returns An array of abstract meshes
  95964. */
  95965. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  95966. /**
  95967. * Gets the vertex data
  95968. * @param kind The type of vertex data
  95969. * @returns A nullable array of numbers, or a float32 array
  95970. */
  95971. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  95972. /**
  95973. * Gets the indices from the mesh
  95974. * @returns A nullable array of index arrays
  95975. */
  95976. getIndices?(): Nullable<IndicesArray>;
  95977. /**
  95978. * Gets the scene from the mesh
  95979. * @returns the indices array or null
  95980. */
  95981. getScene?(): Scene;
  95982. /**
  95983. * Gets the absolute position from the mesh
  95984. * @returns the absolute position
  95985. */
  95986. getAbsolutePosition(): Vector3;
  95987. /**
  95988. * Gets the absolute pivot point from the mesh
  95989. * @returns the absolute pivot point
  95990. */
  95991. getAbsolutePivotPoint(): Vector3;
  95992. /**
  95993. * Rotates the mesh
  95994. * @param axis The axis of rotation
  95995. * @param amount The amount of rotation
  95996. * @param space The space of the rotation
  95997. * @returns The rotation transform node
  95998. */
  95999. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96000. /**
  96001. * Translates the mesh
  96002. * @param axis The axis of translation
  96003. * @param distance The distance of translation
  96004. * @param space The space of the translation
  96005. * @returns The transform node
  96006. */
  96007. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96008. /**
  96009. * Sets the absolute position of the mesh
  96010. * @param absolutePosition The absolute position of the mesh
  96011. * @returns The transform node
  96012. */
  96013. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96014. /**
  96015. * Gets the class name of the mesh
  96016. * @returns The class name
  96017. */
  96018. getClassName(): string;
  96019. }
  96020. /**
  96021. * Represents a physics imposter
  96022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96023. */
  96024. export class PhysicsImpostor {
  96025. /**
  96026. * The physics-enabled object used as the physics imposter
  96027. */
  96028. object: IPhysicsEnabledObject;
  96029. /**
  96030. * The type of the physics imposter
  96031. */
  96032. type: number;
  96033. private _options;
  96034. private _scene?;
  96035. /**
  96036. * The default object size of the imposter
  96037. */
  96038. static DEFAULT_OBJECT_SIZE: Vector3;
  96039. /**
  96040. * The identity quaternion of the imposter
  96041. */
  96042. static IDENTITY_QUATERNION: Quaternion;
  96043. /** @hidden */
  96044. _pluginData: any;
  96045. private _physicsEngine;
  96046. private _physicsBody;
  96047. private _bodyUpdateRequired;
  96048. private _onBeforePhysicsStepCallbacks;
  96049. private _onAfterPhysicsStepCallbacks;
  96050. /** @hidden */
  96051. _onPhysicsCollideCallbacks: Array<{
  96052. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96053. otherImpostors: Array<PhysicsImpostor>;
  96054. }>;
  96055. private _deltaPosition;
  96056. private _deltaRotation;
  96057. private _deltaRotationConjugated;
  96058. /** @hidden */
  96059. _isFromLine: boolean;
  96060. private _parent;
  96061. private _isDisposed;
  96062. private static _tmpVecs;
  96063. private static _tmpQuat;
  96064. /**
  96065. * Specifies if the physics imposter is disposed
  96066. */
  96067. get isDisposed(): boolean;
  96068. /**
  96069. * Gets the mass of the physics imposter
  96070. */
  96071. get mass(): number;
  96072. set mass(value: number);
  96073. /**
  96074. * Gets the coefficient of friction
  96075. */
  96076. get friction(): number;
  96077. /**
  96078. * Sets the coefficient of friction
  96079. */
  96080. set friction(value: number);
  96081. /**
  96082. * Gets the coefficient of restitution
  96083. */
  96084. get restitution(): number;
  96085. /**
  96086. * Sets the coefficient of restitution
  96087. */
  96088. set restitution(value: number);
  96089. /**
  96090. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96091. */
  96092. get pressure(): number;
  96093. /**
  96094. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96095. */
  96096. set pressure(value: number);
  96097. /**
  96098. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96099. */
  96100. get stiffness(): number;
  96101. /**
  96102. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96103. */
  96104. set stiffness(value: number);
  96105. /**
  96106. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96107. */
  96108. get velocityIterations(): number;
  96109. /**
  96110. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96111. */
  96112. set velocityIterations(value: number);
  96113. /**
  96114. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96115. */
  96116. get positionIterations(): number;
  96117. /**
  96118. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96119. */
  96120. set positionIterations(value: number);
  96121. /**
  96122. * The unique id of the physics imposter
  96123. * set by the physics engine when adding this impostor to the array
  96124. */
  96125. uniqueId: number;
  96126. /**
  96127. * @hidden
  96128. */
  96129. soft: boolean;
  96130. /**
  96131. * @hidden
  96132. */
  96133. segments: number;
  96134. private _joints;
  96135. /**
  96136. * Initializes the physics imposter
  96137. * @param object The physics-enabled object used as the physics imposter
  96138. * @param type The type of the physics imposter
  96139. * @param _options The options for the physics imposter
  96140. * @param _scene The Babylon scene
  96141. */
  96142. constructor(
  96143. /**
  96144. * The physics-enabled object used as the physics imposter
  96145. */
  96146. object: IPhysicsEnabledObject,
  96147. /**
  96148. * The type of the physics imposter
  96149. */
  96150. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  96151. /**
  96152. * This function will completly initialize this impostor.
  96153. * It will create a new body - but only if this mesh has no parent.
  96154. * If it has, this impostor will not be used other than to define the impostor
  96155. * of the child mesh.
  96156. * @hidden
  96157. */
  96158. _init(): void;
  96159. private _getPhysicsParent;
  96160. /**
  96161. * Should a new body be generated.
  96162. * @returns boolean specifying if body initialization is required
  96163. */
  96164. isBodyInitRequired(): boolean;
  96165. /**
  96166. * Sets the updated scaling
  96167. * @param updated Specifies if the scaling is updated
  96168. */
  96169. setScalingUpdated(): void;
  96170. /**
  96171. * Force a regeneration of this or the parent's impostor's body.
  96172. * Use under cautious - This will remove all joints already implemented.
  96173. */
  96174. forceUpdate(): void;
  96175. /**
  96176. * Gets the body that holds this impostor. Either its own, or its parent.
  96177. */
  96178. get physicsBody(): any;
  96179. /**
  96180. * Get the parent of the physics imposter
  96181. * @returns Physics imposter or null
  96182. */
  96183. get parent(): Nullable<PhysicsImpostor>;
  96184. /**
  96185. * Sets the parent of the physics imposter
  96186. */
  96187. set parent(value: Nullable<PhysicsImpostor>);
  96188. /**
  96189. * Set the physics body. Used mainly by the physics engine/plugin
  96190. */
  96191. set physicsBody(physicsBody: any);
  96192. /**
  96193. * Resets the update flags
  96194. */
  96195. resetUpdateFlags(): void;
  96196. /**
  96197. * Gets the object extend size
  96198. * @returns the object extend size
  96199. */
  96200. getObjectExtendSize(): Vector3;
  96201. /**
  96202. * Gets the object center
  96203. * @returns The object center
  96204. */
  96205. getObjectCenter(): Vector3;
  96206. /**
  96207. * Get a specific parametes from the options parameter
  96208. * @param paramName The object parameter name
  96209. * @returns The object parameter
  96210. */
  96211. getParam(paramName: string): any;
  96212. /**
  96213. * Sets a specific parameter in the options given to the physics plugin
  96214. * @param paramName The parameter name
  96215. * @param value The value of the parameter
  96216. */
  96217. setParam(paramName: string, value: number): void;
  96218. /**
  96219. * Specifically change the body's mass option. Won't recreate the physics body object
  96220. * @param mass The mass of the physics imposter
  96221. */
  96222. setMass(mass: number): void;
  96223. /**
  96224. * Gets the linear velocity
  96225. * @returns linear velocity or null
  96226. */
  96227. getLinearVelocity(): Nullable<Vector3>;
  96228. /**
  96229. * Sets the linear velocity
  96230. * @param velocity linear velocity or null
  96231. */
  96232. setLinearVelocity(velocity: Nullable<Vector3>): void;
  96233. /**
  96234. * Gets the angular velocity
  96235. * @returns angular velocity or null
  96236. */
  96237. getAngularVelocity(): Nullable<Vector3>;
  96238. /**
  96239. * Sets the angular velocity
  96240. * @param velocity The velocity or null
  96241. */
  96242. setAngularVelocity(velocity: Nullable<Vector3>): void;
  96243. /**
  96244. * Execute a function with the physics plugin native code
  96245. * Provide a function the will have two variables - the world object and the physics body object
  96246. * @param func The function to execute with the physics plugin native code
  96247. */
  96248. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  96249. /**
  96250. * Register a function that will be executed before the physics world is stepping forward
  96251. * @param func The function to execute before the physics world is stepped forward
  96252. */
  96253. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96254. /**
  96255. * Unregister a function that will be executed before the physics world is stepping forward
  96256. * @param func The function to execute before the physics world is stepped forward
  96257. */
  96258. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96259. /**
  96260. * Register a function that will be executed after the physics step
  96261. * @param func The function to execute after physics step
  96262. */
  96263. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96264. /**
  96265. * Unregisters a function that will be executed after the physics step
  96266. * @param func The function to execute after physics step
  96267. */
  96268. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96269. /**
  96270. * register a function that will be executed when this impostor collides against a different body
  96271. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  96272. * @param func Callback that is executed on collision
  96273. */
  96274. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  96275. /**
  96276. * Unregisters the physics imposter on contact
  96277. * @param collideAgainst The physics object to collide against
  96278. * @param func Callback to execute on collision
  96279. */
  96280. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  96281. private _tmpQuat;
  96282. private _tmpQuat2;
  96283. /**
  96284. * Get the parent rotation
  96285. * @returns The parent rotation
  96286. */
  96287. getParentsRotation(): Quaternion;
  96288. /**
  96289. * this function is executed by the physics engine.
  96290. */
  96291. beforeStep: () => void;
  96292. /**
  96293. * this function is executed by the physics engine
  96294. */
  96295. afterStep: () => void;
  96296. /**
  96297. * Legacy collision detection event support
  96298. */
  96299. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  96300. /**
  96301. * event and body object due to cannon's event-based architecture.
  96302. */
  96303. onCollide: (e: {
  96304. body: any;
  96305. }) => void;
  96306. /**
  96307. * Apply a force
  96308. * @param force The force to apply
  96309. * @param contactPoint The contact point for the force
  96310. * @returns The physics imposter
  96311. */
  96312. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96313. /**
  96314. * Apply an impulse
  96315. * @param force The impulse force
  96316. * @param contactPoint The contact point for the impulse force
  96317. * @returns The physics imposter
  96318. */
  96319. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96320. /**
  96321. * A help function to create a joint
  96322. * @param otherImpostor A physics imposter used to create a joint
  96323. * @param jointType The type of joint
  96324. * @param jointData The data for the joint
  96325. * @returns The physics imposter
  96326. */
  96327. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  96328. /**
  96329. * Add a joint to this impostor with a different impostor
  96330. * @param otherImpostor A physics imposter used to add a joint
  96331. * @param joint The joint to add
  96332. * @returns The physics imposter
  96333. */
  96334. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  96335. /**
  96336. * Add an anchor to a cloth impostor
  96337. * @param otherImpostor rigid impostor to anchor to
  96338. * @param width ratio across width from 0 to 1
  96339. * @param height ratio up height from 0 to 1
  96340. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  96341. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  96342. * @returns impostor the soft imposter
  96343. */
  96344. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96345. /**
  96346. * Add a hook to a rope impostor
  96347. * @param otherImpostor rigid impostor to anchor to
  96348. * @param length ratio across rope from 0 to 1
  96349. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  96350. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  96351. * @returns impostor the rope imposter
  96352. */
  96353. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96354. /**
  96355. * Will keep this body still, in a sleep mode.
  96356. * @returns the physics imposter
  96357. */
  96358. sleep(): PhysicsImpostor;
  96359. /**
  96360. * Wake the body up.
  96361. * @returns The physics imposter
  96362. */
  96363. wakeUp(): PhysicsImpostor;
  96364. /**
  96365. * Clones the physics imposter
  96366. * @param newObject The physics imposter clones to this physics-enabled object
  96367. * @returns A nullable physics imposter
  96368. */
  96369. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96370. /**
  96371. * Disposes the physics imposter
  96372. */
  96373. dispose(): void;
  96374. /**
  96375. * Sets the delta position
  96376. * @param position The delta position amount
  96377. */
  96378. setDeltaPosition(position: Vector3): void;
  96379. /**
  96380. * Sets the delta rotation
  96381. * @param rotation The delta rotation amount
  96382. */
  96383. setDeltaRotation(rotation: Quaternion): void;
  96384. /**
  96385. * Gets the box size of the physics imposter and stores the result in the input parameter
  96386. * @param result Stores the box size
  96387. * @returns The physics imposter
  96388. */
  96389. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  96390. /**
  96391. * Gets the radius of the physics imposter
  96392. * @returns Radius of the physics imposter
  96393. */
  96394. getRadius(): number;
  96395. /**
  96396. * Sync a bone with this impostor
  96397. * @param bone The bone to sync to the impostor.
  96398. * @param boneMesh The mesh that the bone is influencing.
  96399. * @param jointPivot The pivot of the joint / bone in local space.
  96400. * @param distToJoint Optional distance from the impostor to the joint.
  96401. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96402. */
  96403. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  96404. /**
  96405. * Sync impostor to a bone
  96406. * @param bone The bone that the impostor will be synced to.
  96407. * @param boneMesh The mesh that the bone is influencing.
  96408. * @param jointPivot The pivot of the joint / bone in local space.
  96409. * @param distToJoint Optional distance from the impostor to the joint.
  96410. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96411. * @param boneAxis Optional vector3 axis the bone is aligned with
  96412. */
  96413. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  96414. /**
  96415. * No-Imposter type
  96416. */
  96417. static NoImpostor: number;
  96418. /**
  96419. * Sphere-Imposter type
  96420. */
  96421. static SphereImpostor: number;
  96422. /**
  96423. * Box-Imposter type
  96424. */
  96425. static BoxImpostor: number;
  96426. /**
  96427. * Plane-Imposter type
  96428. */
  96429. static PlaneImpostor: number;
  96430. /**
  96431. * Mesh-imposter type
  96432. */
  96433. static MeshImpostor: number;
  96434. /**
  96435. * Capsule-Impostor type (Ammo.js plugin only)
  96436. */
  96437. static CapsuleImpostor: number;
  96438. /**
  96439. * Cylinder-Imposter type
  96440. */
  96441. static CylinderImpostor: number;
  96442. /**
  96443. * Particle-Imposter type
  96444. */
  96445. static ParticleImpostor: number;
  96446. /**
  96447. * Heightmap-Imposter type
  96448. */
  96449. static HeightmapImpostor: number;
  96450. /**
  96451. * ConvexHull-Impostor type (Ammo.js plugin only)
  96452. */
  96453. static ConvexHullImpostor: number;
  96454. /**
  96455. * Custom-Imposter type (Ammo.js plugin only)
  96456. */
  96457. static CustomImpostor: number;
  96458. /**
  96459. * Rope-Imposter type
  96460. */
  96461. static RopeImpostor: number;
  96462. /**
  96463. * Cloth-Imposter type
  96464. */
  96465. static ClothImpostor: number;
  96466. /**
  96467. * Softbody-Imposter type
  96468. */
  96469. static SoftbodyImpostor: number;
  96470. }
  96471. }
  96472. declare module BABYLON {
  96473. /**
  96474. * @hidden
  96475. **/
  96476. export class _CreationDataStorage {
  96477. closePath?: boolean;
  96478. closeArray?: boolean;
  96479. idx: number[];
  96480. dashSize: number;
  96481. gapSize: number;
  96482. path3D: Path3D;
  96483. pathArray: Vector3[][];
  96484. arc: number;
  96485. radius: number;
  96486. cap: number;
  96487. tessellation: number;
  96488. }
  96489. /**
  96490. * @hidden
  96491. **/
  96492. class _InstanceDataStorage {
  96493. visibleInstances: any;
  96494. batchCache: _InstancesBatch;
  96495. instancesBufferSize: number;
  96496. instancesBuffer: Nullable<Buffer>;
  96497. instancesData: Float32Array;
  96498. overridenInstanceCount: number;
  96499. isFrozen: boolean;
  96500. previousBatch: Nullable<_InstancesBatch>;
  96501. hardwareInstancedRendering: boolean;
  96502. sideOrientation: number;
  96503. manualUpdate: boolean;
  96504. }
  96505. /**
  96506. * @hidden
  96507. **/
  96508. export class _InstancesBatch {
  96509. mustReturn: boolean;
  96510. visibleInstances: Nullable<InstancedMesh[]>[];
  96511. renderSelf: boolean[];
  96512. hardwareInstancedRendering: boolean[];
  96513. }
  96514. /**
  96515. * Class used to represent renderable models
  96516. */
  96517. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  96518. /**
  96519. * Mesh side orientation : usually the external or front surface
  96520. */
  96521. static readonly FRONTSIDE: number;
  96522. /**
  96523. * Mesh side orientation : usually the internal or back surface
  96524. */
  96525. static readonly BACKSIDE: number;
  96526. /**
  96527. * Mesh side orientation : both internal and external or front and back surfaces
  96528. */
  96529. static readonly DOUBLESIDE: number;
  96530. /**
  96531. * Mesh side orientation : by default, `FRONTSIDE`
  96532. */
  96533. static readonly DEFAULTSIDE: number;
  96534. /**
  96535. * Mesh cap setting : no cap
  96536. */
  96537. static readonly NO_CAP: number;
  96538. /**
  96539. * Mesh cap setting : one cap at the beginning of the mesh
  96540. */
  96541. static readonly CAP_START: number;
  96542. /**
  96543. * Mesh cap setting : one cap at the end of the mesh
  96544. */
  96545. static readonly CAP_END: number;
  96546. /**
  96547. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  96548. */
  96549. static readonly CAP_ALL: number;
  96550. /**
  96551. * Mesh pattern setting : no flip or rotate
  96552. */
  96553. static readonly NO_FLIP: number;
  96554. /**
  96555. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  96556. */
  96557. static readonly FLIP_TILE: number;
  96558. /**
  96559. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  96560. */
  96561. static readonly ROTATE_TILE: number;
  96562. /**
  96563. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  96564. */
  96565. static readonly FLIP_ROW: number;
  96566. /**
  96567. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  96568. */
  96569. static readonly ROTATE_ROW: number;
  96570. /**
  96571. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  96572. */
  96573. static readonly FLIP_N_ROTATE_TILE: number;
  96574. /**
  96575. * Mesh pattern setting : rotate pattern and rotate
  96576. */
  96577. static readonly FLIP_N_ROTATE_ROW: number;
  96578. /**
  96579. * Mesh tile positioning : part tiles same on left/right or top/bottom
  96580. */
  96581. static readonly CENTER: number;
  96582. /**
  96583. * Mesh tile positioning : part tiles on left
  96584. */
  96585. static readonly LEFT: number;
  96586. /**
  96587. * Mesh tile positioning : part tiles on right
  96588. */
  96589. static readonly RIGHT: number;
  96590. /**
  96591. * Mesh tile positioning : part tiles on top
  96592. */
  96593. static readonly TOP: number;
  96594. /**
  96595. * Mesh tile positioning : part tiles on bottom
  96596. */
  96597. static readonly BOTTOM: number;
  96598. /**
  96599. * Gets the default side orientation.
  96600. * @param orientation the orientation to value to attempt to get
  96601. * @returns the default orientation
  96602. * @hidden
  96603. */
  96604. static _GetDefaultSideOrientation(orientation?: number): number;
  96605. private _internalMeshDataInfo;
  96606. /**
  96607. * An event triggered before rendering the mesh
  96608. */
  96609. get onBeforeRenderObservable(): Observable<Mesh>;
  96610. /**
  96611. * An event triggered before binding the mesh
  96612. */
  96613. get onBeforeBindObservable(): Observable<Mesh>;
  96614. /**
  96615. * An event triggered after rendering the mesh
  96616. */
  96617. get onAfterRenderObservable(): Observable<Mesh>;
  96618. /**
  96619. * An event triggered before drawing the mesh
  96620. */
  96621. get onBeforeDrawObservable(): Observable<Mesh>;
  96622. private _onBeforeDrawObserver;
  96623. /**
  96624. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  96625. */
  96626. set onBeforeDraw(callback: () => void);
  96627. get hasInstances(): boolean;
  96628. /**
  96629. * Gets the delay loading state of the mesh (when delay loading is turned on)
  96630. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  96631. */
  96632. delayLoadState: number;
  96633. /**
  96634. * Gets the list of instances created from this mesh
  96635. * it is not supposed to be modified manually.
  96636. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  96637. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  96638. */
  96639. instances: InstancedMesh[];
  96640. /**
  96641. * Gets the file containing delay loading data for this mesh
  96642. */
  96643. delayLoadingFile: string;
  96644. /** @hidden */
  96645. _binaryInfo: any;
  96646. /**
  96647. * User defined function used to change how LOD level selection is done
  96648. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96649. */
  96650. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  96651. /**
  96652. * Gets or sets the morph target manager
  96653. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96654. */
  96655. get morphTargetManager(): Nullable<MorphTargetManager>;
  96656. set morphTargetManager(value: Nullable<MorphTargetManager>);
  96657. /** @hidden */
  96658. _creationDataStorage: Nullable<_CreationDataStorage>;
  96659. /** @hidden */
  96660. _geometry: Nullable<Geometry>;
  96661. /** @hidden */
  96662. _delayInfo: Array<string>;
  96663. /** @hidden */
  96664. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  96665. /** @hidden */
  96666. _instanceDataStorage: _InstanceDataStorage;
  96667. private _effectiveMaterial;
  96668. /** @hidden */
  96669. _shouldGenerateFlatShading: boolean;
  96670. /** @hidden */
  96671. _originalBuilderSideOrientation: number;
  96672. /**
  96673. * Use this property to change the original side orientation defined at construction time
  96674. */
  96675. overrideMaterialSideOrientation: Nullable<number>;
  96676. /**
  96677. * Gets the source mesh (the one used to clone this one from)
  96678. */
  96679. get source(): Nullable<Mesh>;
  96680. /**
  96681. * Gets or sets a boolean indicating that this mesh does not use index buffer
  96682. */
  96683. get isUnIndexed(): boolean;
  96684. set isUnIndexed(value: boolean);
  96685. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  96686. get worldMatrixInstancedBuffer(): Float32Array;
  96687. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  96688. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  96689. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  96690. /**
  96691. * @constructor
  96692. * @param name The value used by scene.getMeshByName() to do a lookup.
  96693. * @param scene The scene to add this mesh to.
  96694. * @param parent The parent of this mesh, if it has one
  96695. * @param source An optional Mesh from which geometry is shared, cloned.
  96696. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96697. * When false, achieved by calling a clone(), also passing False.
  96698. * This will make creation of children, recursive.
  96699. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  96700. */
  96701. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  96702. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  96703. doNotInstantiate: boolean;
  96704. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  96705. /**
  96706. * Gets the class name
  96707. * @returns the string "Mesh".
  96708. */
  96709. getClassName(): string;
  96710. /** @hidden */
  96711. get _isMesh(): boolean;
  96712. /**
  96713. * Returns a description of this mesh
  96714. * @param fullDetails define if full details about this mesh must be used
  96715. * @returns a descriptive string representing this mesh
  96716. */
  96717. toString(fullDetails?: boolean): string;
  96718. /** @hidden */
  96719. _unBindEffect(): void;
  96720. /**
  96721. * Gets a boolean indicating if this mesh has LOD
  96722. */
  96723. get hasLODLevels(): boolean;
  96724. /**
  96725. * Gets the list of MeshLODLevel associated with the current mesh
  96726. * @returns an array of MeshLODLevel
  96727. */
  96728. getLODLevels(): MeshLODLevel[];
  96729. private _sortLODLevels;
  96730. /**
  96731. * Add a mesh as LOD level triggered at the given distance.
  96732. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96733. * @param distance The distance from the center of the object to show this level
  96734. * @param mesh The mesh to be added as LOD level (can be null)
  96735. * @return This mesh (for chaining)
  96736. */
  96737. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  96738. /**
  96739. * Returns the LOD level mesh at the passed distance or null if not found.
  96740. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96741. * @param distance The distance from the center of the object to show this level
  96742. * @returns a Mesh or `null`
  96743. */
  96744. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  96745. /**
  96746. * Remove a mesh from the LOD array
  96747. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96748. * @param mesh defines the mesh to be removed
  96749. * @return This mesh (for chaining)
  96750. */
  96751. removeLODLevel(mesh: Mesh): Mesh;
  96752. /**
  96753. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  96754. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96755. * @param camera defines the camera to use to compute distance
  96756. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  96757. * @return This mesh (for chaining)
  96758. */
  96759. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  96760. /**
  96761. * Gets the mesh internal Geometry object
  96762. */
  96763. get geometry(): Nullable<Geometry>;
  96764. /**
  96765. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  96766. * @returns the total number of vertices
  96767. */
  96768. getTotalVertices(): number;
  96769. /**
  96770. * Returns the content of an associated vertex buffer
  96771. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96772. * - VertexBuffer.PositionKind
  96773. * - VertexBuffer.UVKind
  96774. * - VertexBuffer.UV2Kind
  96775. * - VertexBuffer.UV3Kind
  96776. * - VertexBuffer.UV4Kind
  96777. * - VertexBuffer.UV5Kind
  96778. * - VertexBuffer.UV6Kind
  96779. * - VertexBuffer.ColorKind
  96780. * - VertexBuffer.MatricesIndicesKind
  96781. * - VertexBuffer.MatricesIndicesExtraKind
  96782. * - VertexBuffer.MatricesWeightsKind
  96783. * - VertexBuffer.MatricesWeightsExtraKind
  96784. * @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
  96785. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  96786. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  96787. */
  96788. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96789. /**
  96790. * Returns the mesh VertexBuffer object from the requested `kind`
  96791. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96792. * - VertexBuffer.PositionKind
  96793. * - VertexBuffer.NormalKind
  96794. * - VertexBuffer.UVKind
  96795. * - VertexBuffer.UV2Kind
  96796. * - VertexBuffer.UV3Kind
  96797. * - VertexBuffer.UV4Kind
  96798. * - VertexBuffer.UV5Kind
  96799. * - VertexBuffer.UV6Kind
  96800. * - VertexBuffer.ColorKind
  96801. * - VertexBuffer.MatricesIndicesKind
  96802. * - VertexBuffer.MatricesIndicesExtraKind
  96803. * - VertexBuffer.MatricesWeightsKind
  96804. * - VertexBuffer.MatricesWeightsExtraKind
  96805. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  96806. */
  96807. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96808. /**
  96809. * Tests if a specific vertex buffer is associated with this mesh
  96810. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  96811. * - VertexBuffer.PositionKind
  96812. * - VertexBuffer.NormalKind
  96813. * - VertexBuffer.UVKind
  96814. * - VertexBuffer.UV2Kind
  96815. * - VertexBuffer.UV3Kind
  96816. * - VertexBuffer.UV4Kind
  96817. * - VertexBuffer.UV5Kind
  96818. * - VertexBuffer.UV6Kind
  96819. * - VertexBuffer.ColorKind
  96820. * - VertexBuffer.MatricesIndicesKind
  96821. * - VertexBuffer.MatricesIndicesExtraKind
  96822. * - VertexBuffer.MatricesWeightsKind
  96823. * - VertexBuffer.MatricesWeightsExtraKind
  96824. * @returns a boolean
  96825. */
  96826. isVerticesDataPresent(kind: string): boolean;
  96827. /**
  96828. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  96829. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  96830. * - VertexBuffer.PositionKind
  96831. * - VertexBuffer.UVKind
  96832. * - VertexBuffer.UV2Kind
  96833. * - VertexBuffer.UV3Kind
  96834. * - VertexBuffer.UV4Kind
  96835. * - VertexBuffer.UV5Kind
  96836. * - VertexBuffer.UV6Kind
  96837. * - VertexBuffer.ColorKind
  96838. * - VertexBuffer.MatricesIndicesKind
  96839. * - VertexBuffer.MatricesIndicesExtraKind
  96840. * - VertexBuffer.MatricesWeightsKind
  96841. * - VertexBuffer.MatricesWeightsExtraKind
  96842. * @returns a boolean
  96843. */
  96844. isVertexBufferUpdatable(kind: string): boolean;
  96845. /**
  96846. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  96847. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96848. * - VertexBuffer.PositionKind
  96849. * - VertexBuffer.NormalKind
  96850. * - VertexBuffer.UVKind
  96851. * - VertexBuffer.UV2Kind
  96852. * - VertexBuffer.UV3Kind
  96853. * - VertexBuffer.UV4Kind
  96854. * - VertexBuffer.UV5Kind
  96855. * - VertexBuffer.UV6Kind
  96856. * - VertexBuffer.ColorKind
  96857. * - VertexBuffer.MatricesIndicesKind
  96858. * - VertexBuffer.MatricesIndicesExtraKind
  96859. * - VertexBuffer.MatricesWeightsKind
  96860. * - VertexBuffer.MatricesWeightsExtraKind
  96861. * @returns an array of strings
  96862. */
  96863. getVerticesDataKinds(): string[];
  96864. /**
  96865. * Returns a positive integer : the total number of indices in this mesh geometry.
  96866. * @returns the numner of indices or zero if the mesh has no geometry.
  96867. */
  96868. getTotalIndices(): number;
  96869. /**
  96870. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96871. * @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.
  96872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96873. * @returns the indices array or an empty array if the mesh has no geometry
  96874. */
  96875. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96876. get isBlocked(): boolean;
  96877. /**
  96878. * Determine if the current mesh is ready to be rendered
  96879. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96880. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  96881. * @returns true if all associated assets are ready (material, textures, shaders)
  96882. */
  96883. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  96884. /**
  96885. * 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.
  96886. */
  96887. get areNormalsFrozen(): boolean;
  96888. /**
  96889. * 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.
  96890. * @returns the current mesh
  96891. */
  96892. freezeNormals(): Mesh;
  96893. /**
  96894. * 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
  96895. * @returns the current mesh
  96896. */
  96897. unfreezeNormals(): Mesh;
  96898. /**
  96899. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  96900. */
  96901. set overridenInstanceCount(count: number);
  96902. /** @hidden */
  96903. _preActivate(): Mesh;
  96904. /** @hidden */
  96905. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96906. /** @hidden */
  96907. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  96908. /**
  96909. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96910. * This means the mesh underlying bounding box and sphere are recomputed.
  96911. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96912. * @returns the current mesh
  96913. */
  96914. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  96915. /** @hidden */
  96916. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  96917. /**
  96918. * This function will subdivide the mesh into multiple submeshes
  96919. * @param count defines the expected number of submeshes
  96920. */
  96921. subdivide(count: number): void;
  96922. /**
  96923. * Copy a FloatArray into a specific associated vertex buffer
  96924. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96925. * - VertexBuffer.PositionKind
  96926. * - VertexBuffer.UVKind
  96927. * - VertexBuffer.UV2Kind
  96928. * - VertexBuffer.UV3Kind
  96929. * - VertexBuffer.UV4Kind
  96930. * - VertexBuffer.UV5Kind
  96931. * - VertexBuffer.UV6Kind
  96932. * - VertexBuffer.ColorKind
  96933. * - VertexBuffer.MatricesIndicesKind
  96934. * - VertexBuffer.MatricesIndicesExtraKind
  96935. * - VertexBuffer.MatricesWeightsKind
  96936. * - VertexBuffer.MatricesWeightsExtraKind
  96937. * @param data defines the data source
  96938. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  96939. * @param stride defines the data stride size (can be null)
  96940. * @returns the current mesh
  96941. */
  96942. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96943. /**
  96944. * Delete a vertex buffer associated with this mesh
  96945. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  96946. * - VertexBuffer.PositionKind
  96947. * - VertexBuffer.UVKind
  96948. * - VertexBuffer.UV2Kind
  96949. * - VertexBuffer.UV3Kind
  96950. * - VertexBuffer.UV4Kind
  96951. * - VertexBuffer.UV5Kind
  96952. * - VertexBuffer.UV6Kind
  96953. * - VertexBuffer.ColorKind
  96954. * - VertexBuffer.MatricesIndicesKind
  96955. * - VertexBuffer.MatricesIndicesExtraKind
  96956. * - VertexBuffer.MatricesWeightsKind
  96957. * - VertexBuffer.MatricesWeightsExtraKind
  96958. */
  96959. removeVerticesData(kind: string): void;
  96960. /**
  96961. * Flags an associated vertex buffer as updatable
  96962. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  96963. * - VertexBuffer.PositionKind
  96964. * - VertexBuffer.UVKind
  96965. * - VertexBuffer.UV2Kind
  96966. * - VertexBuffer.UV3Kind
  96967. * - VertexBuffer.UV4Kind
  96968. * - VertexBuffer.UV5Kind
  96969. * - VertexBuffer.UV6Kind
  96970. * - VertexBuffer.ColorKind
  96971. * - VertexBuffer.MatricesIndicesKind
  96972. * - VertexBuffer.MatricesIndicesExtraKind
  96973. * - VertexBuffer.MatricesWeightsKind
  96974. * - VertexBuffer.MatricesWeightsExtraKind
  96975. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  96976. */
  96977. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  96978. /**
  96979. * Sets the mesh global Vertex Buffer
  96980. * @param buffer defines the buffer to use
  96981. * @returns the current mesh
  96982. */
  96983. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  96984. /**
  96985. * Update a specific associated vertex buffer
  96986. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96987. * - VertexBuffer.PositionKind
  96988. * - VertexBuffer.UVKind
  96989. * - VertexBuffer.UV2Kind
  96990. * - VertexBuffer.UV3Kind
  96991. * - VertexBuffer.UV4Kind
  96992. * - VertexBuffer.UV5Kind
  96993. * - VertexBuffer.UV6Kind
  96994. * - VertexBuffer.ColorKind
  96995. * - VertexBuffer.MatricesIndicesKind
  96996. * - VertexBuffer.MatricesIndicesExtraKind
  96997. * - VertexBuffer.MatricesWeightsKind
  96998. * - VertexBuffer.MatricesWeightsExtraKind
  96999. * @param data defines the data source
  97000. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97001. * @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)
  97002. * @returns the current mesh
  97003. */
  97004. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97005. /**
  97006. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97007. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97008. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97009. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97010. * @returns the current mesh
  97011. */
  97012. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97013. /**
  97014. * Creates a un-shared specific occurence of the geometry for the mesh.
  97015. * @returns the current mesh
  97016. */
  97017. makeGeometryUnique(): Mesh;
  97018. /**
  97019. * Set the index buffer of this mesh
  97020. * @param indices defines the source data
  97021. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97022. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97023. * @returns the current mesh
  97024. */
  97025. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97026. /**
  97027. * Update the current index buffer
  97028. * @param indices defines the source data
  97029. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97030. * @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)
  97031. * @returns the current mesh
  97032. */
  97033. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97034. /**
  97035. * Invert the geometry to move from a right handed system to a left handed one.
  97036. * @returns the current mesh
  97037. */
  97038. toLeftHanded(): Mesh;
  97039. /** @hidden */
  97040. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97041. /** @hidden */
  97042. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97043. /**
  97044. * Registers for this mesh a javascript function called just before the rendering process
  97045. * @param func defines the function to call before rendering this mesh
  97046. * @returns the current mesh
  97047. */
  97048. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97049. /**
  97050. * Disposes a previously registered javascript function called before the rendering
  97051. * @param func defines the function to remove
  97052. * @returns the current mesh
  97053. */
  97054. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97055. /**
  97056. * Registers for this mesh a javascript function called just after the rendering is complete
  97057. * @param func defines the function to call after rendering this mesh
  97058. * @returns the current mesh
  97059. */
  97060. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97061. /**
  97062. * Disposes a previously registered javascript function called after the rendering.
  97063. * @param func defines the function to remove
  97064. * @returns the current mesh
  97065. */
  97066. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97067. /** @hidden */
  97068. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97069. /** @hidden */
  97070. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97071. /** @hidden */
  97072. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97073. /** @hidden */
  97074. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97075. /** @hidden */
  97076. _rebuild(): void;
  97077. /** @hidden */
  97078. _freeze(): void;
  97079. /** @hidden */
  97080. _unFreeze(): void;
  97081. /**
  97082. * 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
  97083. * @param subMesh defines the subMesh to render
  97084. * @param enableAlphaMode defines if alpha mode can be changed
  97085. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97086. * @returns the current mesh
  97087. */
  97088. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97089. private _onBeforeDraw;
  97090. /**
  97091. * Renormalize the mesh and patch it up if there are no weights
  97092. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97093. * However in the case of zero weights then we set just a single influence to 1.
  97094. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97095. */
  97096. cleanMatrixWeights(): void;
  97097. private normalizeSkinFourWeights;
  97098. private normalizeSkinWeightsAndExtra;
  97099. /**
  97100. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  97101. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  97102. * the user know there was an issue with importing the mesh
  97103. * @returns a validation object with skinned, valid and report string
  97104. */
  97105. validateSkinning(): {
  97106. skinned: boolean;
  97107. valid: boolean;
  97108. report: string;
  97109. };
  97110. /** @hidden */
  97111. _checkDelayState(): Mesh;
  97112. private _queueLoad;
  97113. /**
  97114. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97115. * A mesh is in the frustum if its bounding box intersects the frustum
  97116. * @param frustumPlanes defines the frustum to test
  97117. * @returns true if the mesh is in the frustum planes
  97118. */
  97119. isInFrustum(frustumPlanes: Plane[]): boolean;
  97120. /**
  97121. * Sets the mesh material by the material or multiMaterial `id` property
  97122. * @param id is a string identifying the material or the multiMaterial
  97123. * @returns the current mesh
  97124. */
  97125. setMaterialByID(id: string): Mesh;
  97126. /**
  97127. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  97128. * @returns an array of IAnimatable
  97129. */
  97130. getAnimatables(): IAnimatable[];
  97131. /**
  97132. * Modifies the mesh geometry according to the passed transformation matrix.
  97133. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  97134. * The mesh normals are modified using the same transformation.
  97135. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97136. * @param transform defines the transform matrix to use
  97137. * @see http://doc.babylonjs.com/resources/baking_transformations
  97138. * @returns the current mesh
  97139. */
  97140. bakeTransformIntoVertices(transform: Matrix): Mesh;
  97141. /**
  97142. * Modifies the mesh geometry according to its own current World Matrix.
  97143. * The mesh World Matrix is then reset.
  97144. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  97145. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97146. * @see http://doc.babylonjs.com/resources/baking_transformations
  97147. * @returns the current mesh
  97148. */
  97149. bakeCurrentTransformIntoVertices(): Mesh;
  97150. /** @hidden */
  97151. get _positions(): Nullable<Vector3[]>;
  97152. /** @hidden */
  97153. _resetPointsArrayCache(): Mesh;
  97154. /** @hidden */
  97155. _generatePointsArray(): boolean;
  97156. /**
  97157. * Returns a new Mesh object generated from the current mesh properties.
  97158. * This method must not get confused with createInstance()
  97159. * @param name is a string, the name given to the new mesh
  97160. * @param newParent can be any Node object (default `null`)
  97161. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  97162. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  97163. * @returns a new mesh
  97164. */
  97165. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  97166. /**
  97167. * Releases resources associated with this mesh.
  97168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97170. */
  97171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97172. /** @hidden */
  97173. _disposeInstanceSpecificData(): void;
  97174. /**
  97175. * Modifies the mesh geometry according to a displacement map.
  97176. * 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.
  97177. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97178. * @param url is a string, the URL from the image file is to be downloaded.
  97179. * @param minHeight is the lower limit of the displacement.
  97180. * @param maxHeight is the upper limit of the displacement.
  97181. * @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.
  97182. * @param uvOffset is an optional vector2 used to offset UV.
  97183. * @param uvScale is an optional vector2 used to scale UV.
  97184. * @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.
  97185. * @returns the Mesh.
  97186. */
  97187. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97188. /**
  97189. * Modifies the mesh geometry according to a displacementMap buffer.
  97190. * 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.
  97191. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97192. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  97193. * @param heightMapWidth is the width of the buffer image.
  97194. * @param heightMapHeight is the height of the buffer image.
  97195. * @param minHeight is the lower limit of the displacement.
  97196. * @param maxHeight is the upper limit of the displacement.
  97197. * @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.
  97198. * @param uvOffset is an optional vector2 used to offset UV.
  97199. * @param uvScale is an optional vector2 used to scale UV.
  97200. * @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.
  97201. * @returns the Mesh.
  97202. */
  97203. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97204. /**
  97205. * Modify the mesh to get a flat shading rendering.
  97206. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  97207. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  97208. * @returns current mesh
  97209. */
  97210. convertToFlatShadedMesh(): Mesh;
  97211. /**
  97212. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  97213. * In other words, more vertices, no more indices and a single bigger VBO.
  97214. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  97215. * @returns current mesh
  97216. */
  97217. convertToUnIndexedMesh(): Mesh;
  97218. /**
  97219. * Inverses facet orientations.
  97220. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97221. * @param flipNormals will also inverts the normals
  97222. * @returns current mesh
  97223. */
  97224. flipFaces(flipNormals?: boolean): Mesh;
  97225. /**
  97226. * Increase the number of facets and hence vertices in a mesh
  97227. * Vertex normals are interpolated from existing vertex normals
  97228. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97229. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  97230. */
  97231. increaseVertices(numberPerEdge: number): void;
  97232. /**
  97233. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  97234. * This will undo any application of covertToFlatShadedMesh
  97235. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97236. */
  97237. forceSharedVertices(): void;
  97238. /** @hidden */
  97239. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  97240. /** @hidden */
  97241. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  97242. /**
  97243. * Creates a new InstancedMesh object from the mesh model.
  97244. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97245. * @param name defines the name of the new instance
  97246. * @returns a new InstancedMesh
  97247. */
  97248. createInstance(name: string): InstancedMesh;
  97249. /**
  97250. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  97251. * After this call, all the mesh instances have the same submeshes than the current mesh.
  97252. * @returns the current mesh
  97253. */
  97254. synchronizeInstances(): Mesh;
  97255. /**
  97256. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  97257. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  97258. * This should be used together with the simplification to avoid disappearing triangles.
  97259. * @param successCallback an optional success callback to be called after the optimization finished.
  97260. * @returns the current mesh
  97261. */
  97262. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  97263. /**
  97264. * Serialize current mesh
  97265. * @param serializationObject defines the object which will receive the serialization data
  97266. */
  97267. serialize(serializationObject: any): void;
  97268. /** @hidden */
  97269. _syncGeometryWithMorphTargetManager(): void;
  97270. /** @hidden */
  97271. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  97272. /**
  97273. * Returns a new Mesh object parsed from the source provided.
  97274. * @param parsedMesh is the source
  97275. * @param scene defines the hosting scene
  97276. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  97277. * @returns a new Mesh
  97278. */
  97279. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  97280. /**
  97281. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  97282. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97283. * @param name defines the name of the mesh to create
  97284. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  97285. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  97286. * @param closePath creates a seam between the first and the last points of each path of the path array
  97287. * @param offset is taken in account only if the `pathArray` is containing a single path
  97288. * @param scene defines the hosting scene
  97289. * @param updatable defines if the mesh must be flagged as updatable
  97290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97291. * @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)
  97292. * @returns a new Mesh
  97293. */
  97294. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97295. /**
  97296. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  97297. * @param name defines the name of the mesh to create
  97298. * @param radius sets the radius size (float) of the polygon (default 0.5)
  97299. * @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
  97300. * @param scene defines the hosting scene
  97301. * @param updatable defines if the mesh must be flagged as updatable
  97302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97303. * @returns a new Mesh
  97304. */
  97305. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97306. /**
  97307. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  97308. * @param name defines the name of the mesh to create
  97309. * @param size sets the size (float) of each box side (default 1)
  97310. * @param scene defines the hosting scene
  97311. * @param updatable defines if the mesh must be flagged as updatable
  97312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97313. * @returns a new Mesh
  97314. */
  97315. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97316. /**
  97317. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  97318. * @param name defines the name of the mesh to create
  97319. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97320. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97321. * @param scene defines the hosting scene
  97322. * @param updatable defines if the mesh must be flagged as updatable
  97323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97324. * @returns a new Mesh
  97325. */
  97326. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97327. /**
  97328. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  97329. * @param name defines the name of the mesh to create
  97330. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97331. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97332. * @param scene defines the hosting scene
  97333. * @returns a new Mesh
  97334. */
  97335. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  97336. /**
  97337. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  97338. * @param name defines the name of the mesh to create
  97339. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  97340. * @param diameterTop set the top cap diameter (floats, default 1)
  97341. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  97342. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  97343. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  97344. * @param scene defines the hosting scene
  97345. * @param updatable defines if the mesh must be flagged as updatable
  97346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97347. * @returns a new Mesh
  97348. */
  97349. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  97350. /**
  97351. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  97352. * @param name defines the name of the mesh to create
  97353. * @param diameter sets the diameter size (float) of the torus (default 1)
  97354. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  97355. * @param tessellation sets the number of torus sides (postive integer, default 16)
  97356. * @param scene defines the hosting scene
  97357. * @param updatable defines if the mesh must be flagged as updatable
  97358. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97359. * @returns a new Mesh
  97360. */
  97361. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97362. /**
  97363. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  97364. * @param name defines the name of the mesh to create
  97365. * @param radius sets the global radius size (float) of the torus knot (default 2)
  97366. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  97367. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  97368. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  97369. * @param p the number of windings on X axis (positive integers, default 2)
  97370. * @param q the number of windings on Y axis (positive integers, default 3)
  97371. * @param scene defines the hosting scene
  97372. * @param updatable defines if the mesh must be flagged as updatable
  97373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97374. * @returns a new Mesh
  97375. */
  97376. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97377. /**
  97378. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  97379. * @param name defines the name of the mesh to create
  97380. * @param points is an array successive Vector3
  97381. * @param scene defines the hosting scene
  97382. * @param updatable defines if the mesh must be flagged as updatable
  97383. * @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).
  97384. * @returns a new Mesh
  97385. */
  97386. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  97387. /**
  97388. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  97389. * @param name defines the name of the mesh to create
  97390. * @param points is an array successive Vector3
  97391. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  97392. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97393. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  97394. * @param scene defines the hosting scene
  97395. * @param updatable defines if the mesh must be flagged as updatable
  97396. * @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)
  97397. * @returns a new Mesh
  97398. */
  97399. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  97400. /**
  97401. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  97402. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  97403. * 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.
  97404. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97405. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97406. * Remember you can only change the shape positions, not their number when updating a polygon.
  97407. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  97408. * @param name defines the name of the mesh to create
  97409. * @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
  97410. * @param scene defines the hosting scene
  97411. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97412. * @param updatable defines if the mesh must be flagged as updatable
  97413. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97414. * @param earcutInjection can be used to inject your own earcut reference
  97415. * @returns a new Mesh
  97416. */
  97417. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97418. /**
  97419. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  97420. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  97421. * @param name defines the name of the mesh to create
  97422. * @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
  97423. * @param depth defines the height of extrusion
  97424. * @param scene defines the hosting scene
  97425. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97426. * @param updatable defines if the mesh must be flagged as updatable
  97427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97428. * @param earcutInjection can be used to inject your own earcut reference
  97429. * @returns a new Mesh
  97430. */
  97431. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97432. /**
  97433. * Creates an extruded shape mesh.
  97434. * 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
  97435. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97436. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97437. * @param name defines the name of the mesh to create
  97438. * @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
  97439. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97440. * @param scale is the value to scale the shape
  97441. * @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
  97442. * @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
  97443. * @param scene defines the hosting scene
  97444. * @param updatable defines if the mesh must be flagged as updatable
  97445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97446. * @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)
  97447. * @returns a new Mesh
  97448. */
  97449. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97450. /**
  97451. * Creates an custom extruded shape mesh.
  97452. * The custom extrusion is a parametric shape.
  97453. * It has no predefined shape. Its final shape will depend on the input parameters.
  97454. * Please consider using the same method from the MeshBuilder class instead
  97455. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97456. * @param name defines the name of the mesh to create
  97457. * @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
  97458. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97459. * @param scaleFunction is a custom Javascript function called on each path point
  97460. * @param rotationFunction is a custom Javascript function called on each path point
  97461. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  97462. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  97463. * @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
  97464. * @param scene defines the hosting scene
  97465. * @param updatable defines if the mesh must be flagged as updatable
  97466. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97467. * @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)
  97468. * @returns a new Mesh
  97469. */
  97470. 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;
  97471. /**
  97472. * Creates lathe mesh.
  97473. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  97474. * Please consider using the same method from the MeshBuilder class instead
  97475. * @param name defines the name of the mesh to create
  97476. * @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
  97477. * @param radius is the radius value of the lathe
  97478. * @param tessellation is the side number of the lathe.
  97479. * @param scene defines the hosting scene
  97480. * @param updatable defines if the mesh must be flagged as updatable
  97481. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97482. * @returns a new Mesh
  97483. */
  97484. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97485. /**
  97486. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  97487. * @param name defines the name of the mesh to create
  97488. * @param size sets the size (float) of both sides of the plane at once (default 1)
  97489. * @param scene defines the hosting scene
  97490. * @param updatable defines if the mesh must be flagged as updatable
  97491. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97492. * @returns a new Mesh
  97493. */
  97494. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97495. /**
  97496. * Creates a ground mesh.
  97497. * Please consider using the same method from the MeshBuilder class instead
  97498. * @param name defines the name of the mesh to create
  97499. * @param width set the width of the ground
  97500. * @param height set the height of the ground
  97501. * @param subdivisions sets the number of subdivisions per side
  97502. * @param scene defines the hosting scene
  97503. * @param updatable defines if the mesh must be flagged as updatable
  97504. * @returns a new Mesh
  97505. */
  97506. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  97507. /**
  97508. * Creates a tiled ground mesh.
  97509. * Please consider using the same method from the MeshBuilder class instead
  97510. * @param name defines the name of the mesh to create
  97511. * @param xmin set the ground minimum X coordinate
  97512. * @param zmin set the ground minimum Y coordinate
  97513. * @param xmax set the ground maximum X coordinate
  97514. * @param zmax set the ground maximum Z coordinate
  97515. * @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
  97516. * @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
  97517. * @param scene defines the hosting scene
  97518. * @param updatable defines if the mesh must be flagged as updatable
  97519. * @returns a new Mesh
  97520. */
  97521. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  97522. w: number;
  97523. h: number;
  97524. }, precision: {
  97525. w: number;
  97526. h: number;
  97527. }, scene: Scene, updatable?: boolean): Mesh;
  97528. /**
  97529. * Creates a ground mesh from a height map.
  97530. * Please consider using the same method from the MeshBuilder class instead
  97531. * @see http://doc.babylonjs.com/babylon101/height_map
  97532. * @param name defines the name of the mesh to create
  97533. * @param url sets the URL of the height map image resource
  97534. * @param width set the ground width size
  97535. * @param height set the ground height size
  97536. * @param subdivisions sets the number of subdivision per side
  97537. * @param minHeight is the minimum altitude on the ground
  97538. * @param maxHeight is the maximum altitude on the ground
  97539. * @param scene defines the hosting scene
  97540. * @param updatable defines if the mesh must be flagged as updatable
  97541. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  97542. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97543. * @returns a new Mesh
  97544. */
  97545. 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;
  97546. /**
  97547. * Creates a tube mesh.
  97548. * The tube is a parametric shape.
  97549. * It has no predefined shape. Its final shape will depend on the input parameters.
  97550. * Please consider using the same method from the MeshBuilder class instead
  97551. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97552. * @param name defines the name of the mesh to create
  97553. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  97554. * @param radius sets the tube radius size
  97555. * @param tessellation is the number of sides on the tubular surface
  97556. * @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
  97557. * @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
  97558. * @param scene defines the hosting scene
  97559. * @param updatable defines if the mesh must be flagged as updatable
  97560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97561. * @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)
  97562. * @returns a new Mesh
  97563. */
  97564. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  97565. (i: number, distance: number): number;
  97566. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97567. /**
  97568. * Creates a polyhedron mesh.
  97569. * Please consider using the same method from the MeshBuilder class instead.
  97570. * * 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
  97571. * * The parameter `size` (positive float, default 1) sets the polygon size
  97572. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97573. * * 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`
  97574. * * 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
  97575. * * 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)`)
  97576. * * 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
  97577. * * 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
  97578. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97579. * * If you create a double-sided mesh, you can choose what parts of 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
  97580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97581. * @param name defines the name of the mesh to create
  97582. * @param options defines the options used to create the mesh
  97583. * @param scene defines the hosting scene
  97584. * @returns a new Mesh
  97585. */
  97586. static CreatePolyhedron(name: string, options: {
  97587. type?: number;
  97588. size?: number;
  97589. sizeX?: number;
  97590. sizeY?: number;
  97591. sizeZ?: number;
  97592. custom?: any;
  97593. faceUV?: Vector4[];
  97594. faceColors?: Color4[];
  97595. updatable?: boolean;
  97596. sideOrientation?: number;
  97597. }, scene: Scene): Mesh;
  97598. /**
  97599. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  97600. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  97601. * * 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`)
  97602. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  97603. * * 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
  97604. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97605. * * If you create a double-sided mesh, you can choose what parts of 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
  97606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97607. * @param name defines the name of the mesh
  97608. * @param options defines the options used to create the mesh
  97609. * @param scene defines the hosting scene
  97610. * @returns a new Mesh
  97611. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  97612. */
  97613. static CreateIcoSphere(name: string, options: {
  97614. radius?: number;
  97615. flat?: boolean;
  97616. subdivisions?: number;
  97617. sideOrientation?: number;
  97618. updatable?: boolean;
  97619. }, scene: Scene): Mesh;
  97620. /**
  97621. * Creates a decal mesh.
  97622. * Please consider using the same method from the MeshBuilder class instead.
  97623. * A decal is a mesh usually applied as a model onto the surface of another mesh
  97624. * @param name defines the name of the mesh
  97625. * @param sourceMesh defines the mesh receiving the decal
  97626. * @param position sets the position of the decal in world coordinates
  97627. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  97628. * @param size sets the decal scaling
  97629. * @param angle sets the angle to rotate the decal
  97630. * @returns a new Mesh
  97631. */
  97632. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  97633. /**
  97634. * Prepare internal position array for software CPU skinning
  97635. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  97636. */
  97637. setPositionsForCPUSkinning(): Float32Array;
  97638. /**
  97639. * Prepare internal normal array for software CPU skinning
  97640. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  97641. */
  97642. setNormalsForCPUSkinning(): Float32Array;
  97643. /**
  97644. * Updates the vertex buffer by applying transformation from the bones
  97645. * @param skeleton defines the skeleton to apply to current mesh
  97646. * @returns the current mesh
  97647. */
  97648. applySkeleton(skeleton: Skeleton): Mesh;
  97649. /**
  97650. * 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
  97651. * @param meshes defines the list of meshes to scan
  97652. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  97653. */
  97654. static MinMax(meshes: AbstractMesh[]): {
  97655. min: Vector3;
  97656. max: Vector3;
  97657. };
  97658. /**
  97659. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  97660. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  97661. * @returns a vector3
  97662. */
  97663. static Center(meshesOrMinMaxVector: {
  97664. min: Vector3;
  97665. max: Vector3;
  97666. } | AbstractMesh[]): Vector3;
  97667. /**
  97668. * Merge the array of meshes into a single mesh for performance reasons.
  97669. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  97670. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  97671. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  97672. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  97673. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  97674. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  97675. * @returns a new mesh
  97676. */
  97677. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  97678. /** @hidden */
  97679. addInstance(instance: InstancedMesh): void;
  97680. /** @hidden */
  97681. removeInstance(instance: InstancedMesh): void;
  97682. }
  97683. }
  97684. declare module BABYLON {
  97685. /**
  97686. * This is the base class of all the camera used in the application.
  97687. * @see http://doc.babylonjs.com/features/cameras
  97688. */
  97689. export class Camera extends Node {
  97690. /** @hidden */
  97691. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  97692. /**
  97693. * This is the default projection mode used by the cameras.
  97694. * It helps recreating a feeling of perspective and better appreciate depth.
  97695. * This is the best way to simulate real life cameras.
  97696. */
  97697. static readonly PERSPECTIVE_CAMERA: number;
  97698. /**
  97699. * This helps creating camera with an orthographic mode.
  97700. * 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.
  97701. */
  97702. static readonly ORTHOGRAPHIC_CAMERA: number;
  97703. /**
  97704. * This is the default FOV mode for perspective cameras.
  97705. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  97706. */
  97707. static readonly FOVMODE_VERTICAL_FIXED: number;
  97708. /**
  97709. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  97710. */
  97711. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  97712. /**
  97713. * This specifies ther is no need for a camera rig.
  97714. * Basically only one eye is rendered corresponding to the camera.
  97715. */
  97716. static readonly RIG_MODE_NONE: number;
  97717. /**
  97718. * Simulates a camera Rig with one blue eye and one red eye.
  97719. * This can be use with 3d blue and red glasses.
  97720. */
  97721. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  97722. /**
  97723. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  97724. */
  97725. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  97726. /**
  97727. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  97728. */
  97729. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  97730. /**
  97731. * Defines that both eyes of the camera will be rendered over under each other.
  97732. */
  97733. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  97734. /**
  97735. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  97736. */
  97737. static readonly RIG_MODE_VR: number;
  97738. /**
  97739. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  97740. */
  97741. static readonly RIG_MODE_WEBVR: number;
  97742. /**
  97743. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  97744. */
  97745. static readonly RIG_MODE_CUSTOM: number;
  97746. /**
  97747. * Defines if by default attaching controls should prevent the default javascript event to continue.
  97748. */
  97749. static ForceAttachControlToAlwaysPreventDefault: boolean;
  97750. /**
  97751. * Define the input manager associated with the camera.
  97752. */
  97753. inputs: CameraInputsManager<Camera>;
  97754. /** @hidden */
  97755. _position: Vector3;
  97756. /**
  97757. * Define the current local position of the camera in the scene
  97758. */
  97759. get position(): Vector3;
  97760. set position(newPosition: Vector3);
  97761. /**
  97762. * The vector the camera should consider as up.
  97763. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  97764. */
  97765. upVector: Vector3;
  97766. /**
  97767. * Define the current limit on the left side for an orthographic camera
  97768. * In scene unit
  97769. */
  97770. orthoLeft: Nullable<number>;
  97771. /**
  97772. * Define the current limit on the right side for an orthographic camera
  97773. * In scene unit
  97774. */
  97775. orthoRight: Nullable<number>;
  97776. /**
  97777. * Define the current limit on the bottom side for an orthographic camera
  97778. * In scene unit
  97779. */
  97780. orthoBottom: Nullable<number>;
  97781. /**
  97782. * Define the current limit on the top side for an orthographic camera
  97783. * In scene unit
  97784. */
  97785. orthoTop: Nullable<number>;
  97786. /**
  97787. * Field Of View is set in Radians. (default is 0.8)
  97788. */
  97789. fov: number;
  97790. /**
  97791. * Define the minimum distance the camera can see from.
  97792. * This is important to note that the depth buffer are not infinite and the closer it starts
  97793. * the more your scene might encounter depth fighting issue.
  97794. */
  97795. minZ: number;
  97796. /**
  97797. * Define the maximum distance the camera can see to.
  97798. * This is important to note that the depth buffer are not infinite and the further it end
  97799. * the more your scene might encounter depth fighting issue.
  97800. */
  97801. maxZ: number;
  97802. /**
  97803. * Define the default inertia of the camera.
  97804. * This helps giving a smooth feeling to the camera movement.
  97805. */
  97806. inertia: number;
  97807. /**
  97808. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  97809. */
  97810. mode: number;
  97811. /**
  97812. * Define wether the camera is intermediate.
  97813. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  97814. */
  97815. isIntermediate: boolean;
  97816. /**
  97817. * Define the viewport of the camera.
  97818. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  97819. */
  97820. viewport: Viewport;
  97821. /**
  97822. * Restricts the camera to viewing objects with the same layerMask.
  97823. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  97824. */
  97825. layerMask: number;
  97826. /**
  97827. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  97828. */
  97829. fovMode: number;
  97830. /**
  97831. * Rig mode of the camera.
  97832. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  97833. * This is normally controlled byt the camera themselves as internal use.
  97834. */
  97835. cameraRigMode: number;
  97836. /**
  97837. * Defines the distance between both "eyes" in case of a RIG
  97838. */
  97839. interaxialDistance: number;
  97840. /**
  97841. * Defines if stereoscopic rendering is done side by side or over under.
  97842. */
  97843. isStereoscopicSideBySide: boolean;
  97844. /**
  97845. * 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
  97846. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  97847. * else in the scene. (Eg. security camera)
  97848. *
  97849. * 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)
  97850. */
  97851. customRenderTargets: RenderTargetTexture[];
  97852. /**
  97853. * When set, the camera will render to this render target instead of the default canvas
  97854. *
  97855. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  97856. */
  97857. outputRenderTarget: Nullable<RenderTargetTexture>;
  97858. /**
  97859. * Observable triggered when the camera view matrix has changed.
  97860. */
  97861. onViewMatrixChangedObservable: Observable<Camera>;
  97862. /**
  97863. * Observable triggered when the camera Projection matrix has changed.
  97864. */
  97865. onProjectionMatrixChangedObservable: Observable<Camera>;
  97866. /**
  97867. * Observable triggered when the inputs have been processed.
  97868. */
  97869. onAfterCheckInputsObservable: Observable<Camera>;
  97870. /**
  97871. * Observable triggered when reset has been called and applied to the camera.
  97872. */
  97873. onRestoreStateObservable: Observable<Camera>;
  97874. /** @hidden */
  97875. _cameraRigParams: any;
  97876. /** @hidden */
  97877. _rigCameras: Camera[];
  97878. /** @hidden */
  97879. _rigPostProcess: Nullable<PostProcess>;
  97880. protected _webvrViewMatrix: Matrix;
  97881. /** @hidden */
  97882. _skipRendering: boolean;
  97883. /** @hidden */
  97884. _projectionMatrix: Matrix;
  97885. /** @hidden */
  97886. _postProcesses: Nullable<PostProcess>[];
  97887. /** @hidden */
  97888. _activeMeshes: SmartArray<AbstractMesh>;
  97889. protected _globalPosition: Vector3;
  97890. /** @hidden */
  97891. _computedViewMatrix: Matrix;
  97892. private _doNotComputeProjectionMatrix;
  97893. private _transformMatrix;
  97894. private _frustumPlanes;
  97895. private _refreshFrustumPlanes;
  97896. private _storedFov;
  97897. private _stateStored;
  97898. /**
  97899. * Instantiates a new camera object.
  97900. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  97901. * @see http://doc.babylonjs.com/features/cameras
  97902. * @param name Defines the name of the camera in the scene
  97903. * @param position Defines the position of the camera
  97904. * @param scene Defines the scene the camera belongs too
  97905. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  97906. */
  97907. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97908. /**
  97909. * Store current camera state (fov, position, etc..)
  97910. * @returns the camera
  97911. */
  97912. storeState(): Camera;
  97913. /**
  97914. * Restores the camera state values if it has been stored. You must call storeState() first
  97915. */
  97916. protected _restoreStateValues(): boolean;
  97917. /**
  97918. * Restored camera state. You must call storeState() first.
  97919. * @returns true if restored and false otherwise
  97920. */
  97921. restoreState(): boolean;
  97922. /**
  97923. * Gets the class name of the camera.
  97924. * @returns the class name
  97925. */
  97926. getClassName(): string;
  97927. /** @hidden */
  97928. readonly _isCamera: boolean;
  97929. /**
  97930. * Gets a string representation of the camera useful for debug purpose.
  97931. * @param fullDetails Defines that a more verboe level of logging is required
  97932. * @returns the string representation
  97933. */
  97934. toString(fullDetails?: boolean): string;
  97935. /**
  97936. * Gets the current world space position of the camera.
  97937. */
  97938. get globalPosition(): Vector3;
  97939. /**
  97940. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  97941. * @returns the active meshe list
  97942. */
  97943. getActiveMeshes(): SmartArray<AbstractMesh>;
  97944. /**
  97945. * Check wether a mesh is part of the current active mesh list of the camera
  97946. * @param mesh Defines the mesh to check
  97947. * @returns true if active, false otherwise
  97948. */
  97949. isActiveMesh(mesh: Mesh): boolean;
  97950. /**
  97951. * Is this camera ready to be used/rendered
  97952. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  97953. * @return true if the camera is ready
  97954. */
  97955. isReady(completeCheck?: boolean): boolean;
  97956. /** @hidden */
  97957. _initCache(): void;
  97958. /** @hidden */
  97959. _updateCache(ignoreParentClass?: boolean): void;
  97960. /** @hidden */
  97961. _isSynchronized(): boolean;
  97962. /** @hidden */
  97963. _isSynchronizedViewMatrix(): boolean;
  97964. /** @hidden */
  97965. _isSynchronizedProjectionMatrix(): boolean;
  97966. /**
  97967. * Attach the input controls to a specific dom element to get the input from.
  97968. * @param element Defines the element the controls should be listened from
  97969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97970. */
  97971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97972. /**
  97973. * Detach the current controls from the specified dom element.
  97974. * @param element Defines the element to stop listening the inputs from
  97975. */
  97976. detachControl(element: HTMLElement): void;
  97977. /**
  97978. * Update the camera state according to the different inputs gathered during the frame.
  97979. */
  97980. update(): void;
  97981. /** @hidden */
  97982. _checkInputs(): void;
  97983. /** @hidden */
  97984. get rigCameras(): Camera[];
  97985. /**
  97986. * Gets the post process used by the rig cameras
  97987. */
  97988. get rigPostProcess(): Nullable<PostProcess>;
  97989. /**
  97990. * Internal, gets the first post proces.
  97991. * @returns the first post process to be run on this camera.
  97992. */
  97993. _getFirstPostProcess(): Nullable<PostProcess>;
  97994. private _cascadePostProcessesToRigCams;
  97995. /**
  97996. * Attach a post process to the camera.
  97997. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  97998. * @param postProcess The post process to attach to the camera
  97999. * @param insertAt The position of the post process in case several of them are in use in the scene
  98000. * @returns the position the post process has been inserted at
  98001. */
  98002. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98003. /**
  98004. * Detach a post process to the camera.
  98005. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98006. * @param postProcess The post process to detach from the camera
  98007. */
  98008. detachPostProcess(postProcess: PostProcess): void;
  98009. /**
  98010. * Gets the current world matrix of the camera
  98011. */
  98012. getWorldMatrix(): Matrix;
  98013. /** @hidden */
  98014. _getViewMatrix(): Matrix;
  98015. /**
  98016. * Gets the current view matrix of the camera.
  98017. * @param force forces the camera to recompute the matrix without looking at the cached state
  98018. * @returns the view matrix
  98019. */
  98020. getViewMatrix(force?: boolean): Matrix;
  98021. /**
  98022. * Freeze the projection matrix.
  98023. * It will prevent the cache check of the camera projection compute and can speed up perf
  98024. * if no parameter of the camera are meant to change
  98025. * @param projection Defines manually a projection if necessary
  98026. */
  98027. freezeProjectionMatrix(projection?: Matrix): void;
  98028. /**
  98029. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98030. */
  98031. unfreezeProjectionMatrix(): void;
  98032. /**
  98033. * Gets the current projection matrix of the camera.
  98034. * @param force forces the camera to recompute the matrix without looking at the cached state
  98035. * @returns the projection matrix
  98036. */
  98037. getProjectionMatrix(force?: boolean): Matrix;
  98038. /**
  98039. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98040. * @returns a Matrix
  98041. */
  98042. getTransformationMatrix(): Matrix;
  98043. private _updateFrustumPlanes;
  98044. /**
  98045. * Checks if a cullable object (mesh...) is in the camera frustum
  98046. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98047. * @param target The object to check
  98048. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98049. * @returns true if the object is in frustum otherwise false
  98050. */
  98051. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98052. /**
  98053. * Checks if a cullable object (mesh...) is in the camera frustum
  98054. * Unlike isInFrustum this cheks the full bounding box
  98055. * @param target The object to check
  98056. * @returns true if the object is in frustum otherwise false
  98057. */
  98058. isCompletelyInFrustum(target: ICullable): boolean;
  98059. /**
  98060. * Gets a ray in the forward direction from the camera.
  98061. * @param length Defines the length of the ray to create
  98062. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98063. * @param origin Defines the start point of the ray which defaults to the camera position
  98064. * @returns the forward ray
  98065. */
  98066. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98067. /**
  98068. * Releases resources associated with this node.
  98069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98071. */
  98072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98073. /** @hidden */
  98074. _isLeftCamera: boolean;
  98075. /**
  98076. * Gets the left camera of a rig setup in case of Rigged Camera
  98077. */
  98078. get isLeftCamera(): boolean;
  98079. /** @hidden */
  98080. _isRightCamera: boolean;
  98081. /**
  98082. * Gets the right camera of a rig setup in case of Rigged Camera
  98083. */
  98084. get isRightCamera(): boolean;
  98085. /**
  98086. * Gets the left camera of a rig setup in case of Rigged Camera
  98087. */
  98088. get leftCamera(): Nullable<FreeCamera>;
  98089. /**
  98090. * Gets the right camera of a rig setup in case of Rigged Camera
  98091. */
  98092. get rightCamera(): Nullable<FreeCamera>;
  98093. /**
  98094. * Gets the left camera target of a rig setup in case of Rigged Camera
  98095. * @returns the target position
  98096. */
  98097. getLeftTarget(): Nullable<Vector3>;
  98098. /**
  98099. * Gets the right camera target of a rig setup in case of Rigged Camera
  98100. * @returns the target position
  98101. */
  98102. getRightTarget(): Nullable<Vector3>;
  98103. /**
  98104. * @hidden
  98105. */
  98106. setCameraRigMode(mode: number, rigParams: any): void;
  98107. /** @hidden */
  98108. static _setStereoscopicRigMode(camera: Camera): void;
  98109. /** @hidden */
  98110. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  98111. /** @hidden */
  98112. static _setVRRigMode(camera: Camera, rigParams: any): void;
  98113. /** @hidden */
  98114. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  98115. /** @hidden */
  98116. _getVRProjectionMatrix(): Matrix;
  98117. protected _updateCameraRotationMatrix(): void;
  98118. protected _updateWebVRCameraRotationMatrix(): void;
  98119. /**
  98120. * This function MUST be overwritten by the different WebVR cameras available.
  98121. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98122. * @hidden
  98123. */
  98124. _getWebVRProjectionMatrix(): Matrix;
  98125. /**
  98126. * This function MUST be overwritten by the different WebVR cameras available.
  98127. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98128. * @hidden
  98129. */
  98130. _getWebVRViewMatrix(): Matrix;
  98131. /** @hidden */
  98132. setCameraRigParameter(name: string, value: any): void;
  98133. /**
  98134. * needs to be overridden by children so sub has required properties to be copied
  98135. * @hidden
  98136. */
  98137. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98138. /**
  98139. * May need to be overridden by children
  98140. * @hidden
  98141. */
  98142. _updateRigCameras(): void;
  98143. /** @hidden */
  98144. _setupInputs(): void;
  98145. /**
  98146. * Serialiaze the camera setup to a json represention
  98147. * @returns the JSON representation
  98148. */
  98149. serialize(): any;
  98150. /**
  98151. * Clones the current camera.
  98152. * @param name The cloned camera name
  98153. * @returns the cloned camera
  98154. */
  98155. clone(name: string): Camera;
  98156. /**
  98157. * Gets the direction of the camera relative to a given local axis.
  98158. * @param localAxis Defines the reference axis to provide a relative direction.
  98159. * @return the direction
  98160. */
  98161. getDirection(localAxis: Vector3): Vector3;
  98162. /**
  98163. * Returns the current camera absolute rotation
  98164. */
  98165. get absoluteRotation(): Quaternion;
  98166. /**
  98167. * Gets the direction of the camera relative to a given local axis into a passed vector.
  98168. * @param localAxis Defines the reference axis to provide a relative direction.
  98169. * @param result Defines the vector to store the result in
  98170. */
  98171. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  98172. /**
  98173. * Gets a camera constructor for a given camera type
  98174. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  98175. * @param name The name of the camera the result will be able to instantiate
  98176. * @param scene The scene the result will construct the camera in
  98177. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  98178. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  98179. * @returns a factory method to construc the camera
  98180. */
  98181. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  98182. /**
  98183. * Compute the world matrix of the camera.
  98184. * @returns the camera world matrix
  98185. */
  98186. computeWorldMatrix(): Matrix;
  98187. /**
  98188. * Parse a JSON and creates the camera from the parsed information
  98189. * @param parsedCamera The JSON to parse
  98190. * @param scene The scene to instantiate the camera in
  98191. * @returns the newly constructed camera
  98192. */
  98193. static Parse(parsedCamera: any, scene: Scene): Camera;
  98194. }
  98195. }
  98196. declare module BABYLON {
  98197. /**
  98198. * Class containing static functions to help procedurally build meshes
  98199. */
  98200. export class DiscBuilder {
  98201. /**
  98202. * Creates a plane polygonal mesh. By default, this is a disc
  98203. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  98204. * * 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
  98205. * * 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
  98206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98209. * @param name defines the name of the mesh
  98210. * @param options defines the options used to create the mesh
  98211. * @param scene defines the hosting scene
  98212. * @returns the plane polygonal mesh
  98213. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  98214. */
  98215. static CreateDisc(name: string, options: {
  98216. radius?: number;
  98217. tessellation?: number;
  98218. arc?: number;
  98219. updatable?: boolean;
  98220. sideOrientation?: number;
  98221. frontUVs?: Vector4;
  98222. backUVs?: Vector4;
  98223. }, scene?: Nullable<Scene>): Mesh;
  98224. }
  98225. }
  98226. declare module BABYLON {
  98227. /**
  98228. * This represents all the required information to add a fresnel effect on a material:
  98229. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98230. */
  98231. export class FresnelParameters {
  98232. private _isEnabled;
  98233. /**
  98234. * Define if the fresnel effect is enable or not.
  98235. */
  98236. get isEnabled(): boolean;
  98237. set isEnabled(value: boolean);
  98238. /**
  98239. * Define the color used on edges (grazing angle)
  98240. */
  98241. leftColor: Color3;
  98242. /**
  98243. * Define the color used on center
  98244. */
  98245. rightColor: Color3;
  98246. /**
  98247. * Define bias applied to computed fresnel term
  98248. */
  98249. bias: number;
  98250. /**
  98251. * Defined the power exponent applied to fresnel term
  98252. */
  98253. power: number;
  98254. /**
  98255. * Clones the current fresnel and its valuues
  98256. * @returns a clone fresnel configuration
  98257. */
  98258. clone(): FresnelParameters;
  98259. /**
  98260. * Serializes the current fresnel parameters to a JSON representation.
  98261. * @return the JSON serialization
  98262. */
  98263. serialize(): any;
  98264. /**
  98265. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  98266. * @param parsedFresnelParameters Define the JSON representation
  98267. * @returns the parsed parameters
  98268. */
  98269. static Parse(parsedFresnelParameters: any): FresnelParameters;
  98270. }
  98271. }
  98272. declare module BABYLON {
  98273. /**
  98274. * Base class of materials working in push mode in babylon JS
  98275. * @hidden
  98276. */
  98277. export class PushMaterial extends Material {
  98278. protected _activeEffect: Effect;
  98279. protected _normalMatrix: Matrix;
  98280. /**
  98281. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98282. * This means that the material can keep using a previous shader while a new one is being compiled.
  98283. * This is mostly used when shader parallel compilation is supported (true by default)
  98284. */
  98285. allowShaderHotSwapping: boolean;
  98286. constructor(name: string, scene: Scene);
  98287. getEffect(): Effect;
  98288. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98289. /**
  98290. * Binds the given world matrix to the active effect
  98291. *
  98292. * @param world the matrix to bind
  98293. */
  98294. bindOnlyWorldMatrix(world: Matrix): void;
  98295. /**
  98296. * Binds the given normal matrix to the active effect
  98297. *
  98298. * @param normalMatrix the matrix to bind
  98299. */
  98300. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98301. bind(world: Matrix, mesh?: Mesh): void;
  98302. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98303. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98304. }
  98305. }
  98306. declare module BABYLON {
  98307. /**
  98308. * This groups all the flags used to control the materials channel.
  98309. */
  98310. export class MaterialFlags {
  98311. private static _DiffuseTextureEnabled;
  98312. /**
  98313. * Are diffuse textures enabled in the application.
  98314. */
  98315. static get DiffuseTextureEnabled(): boolean;
  98316. static set DiffuseTextureEnabled(value: boolean);
  98317. private static _AmbientTextureEnabled;
  98318. /**
  98319. * Are ambient textures enabled in the application.
  98320. */
  98321. static get AmbientTextureEnabled(): boolean;
  98322. static set AmbientTextureEnabled(value: boolean);
  98323. private static _OpacityTextureEnabled;
  98324. /**
  98325. * Are opacity textures enabled in the application.
  98326. */
  98327. static get OpacityTextureEnabled(): boolean;
  98328. static set OpacityTextureEnabled(value: boolean);
  98329. private static _ReflectionTextureEnabled;
  98330. /**
  98331. * Are reflection textures enabled in the application.
  98332. */
  98333. static get ReflectionTextureEnabled(): boolean;
  98334. static set ReflectionTextureEnabled(value: boolean);
  98335. private static _EmissiveTextureEnabled;
  98336. /**
  98337. * Are emissive textures enabled in the application.
  98338. */
  98339. static get EmissiveTextureEnabled(): boolean;
  98340. static set EmissiveTextureEnabled(value: boolean);
  98341. private static _SpecularTextureEnabled;
  98342. /**
  98343. * Are specular textures enabled in the application.
  98344. */
  98345. static get SpecularTextureEnabled(): boolean;
  98346. static set SpecularTextureEnabled(value: boolean);
  98347. private static _BumpTextureEnabled;
  98348. /**
  98349. * Are bump textures enabled in the application.
  98350. */
  98351. static get BumpTextureEnabled(): boolean;
  98352. static set BumpTextureEnabled(value: boolean);
  98353. private static _LightmapTextureEnabled;
  98354. /**
  98355. * Are lightmap textures enabled in the application.
  98356. */
  98357. static get LightmapTextureEnabled(): boolean;
  98358. static set LightmapTextureEnabled(value: boolean);
  98359. private static _RefractionTextureEnabled;
  98360. /**
  98361. * Are refraction textures enabled in the application.
  98362. */
  98363. static get RefractionTextureEnabled(): boolean;
  98364. static set RefractionTextureEnabled(value: boolean);
  98365. private static _ColorGradingTextureEnabled;
  98366. /**
  98367. * Are color grading textures enabled in the application.
  98368. */
  98369. static get ColorGradingTextureEnabled(): boolean;
  98370. static set ColorGradingTextureEnabled(value: boolean);
  98371. private static _FresnelEnabled;
  98372. /**
  98373. * Are fresnels enabled in the application.
  98374. */
  98375. static get FresnelEnabled(): boolean;
  98376. static set FresnelEnabled(value: boolean);
  98377. private static _ClearCoatTextureEnabled;
  98378. /**
  98379. * Are clear coat textures enabled in the application.
  98380. */
  98381. static get ClearCoatTextureEnabled(): boolean;
  98382. static set ClearCoatTextureEnabled(value: boolean);
  98383. private static _ClearCoatBumpTextureEnabled;
  98384. /**
  98385. * Are clear coat bump textures enabled in the application.
  98386. */
  98387. static get ClearCoatBumpTextureEnabled(): boolean;
  98388. static set ClearCoatBumpTextureEnabled(value: boolean);
  98389. private static _ClearCoatTintTextureEnabled;
  98390. /**
  98391. * Are clear coat tint textures enabled in the application.
  98392. */
  98393. static get ClearCoatTintTextureEnabled(): boolean;
  98394. static set ClearCoatTintTextureEnabled(value: boolean);
  98395. private static _SheenTextureEnabled;
  98396. /**
  98397. * Are sheen textures enabled in the application.
  98398. */
  98399. static get SheenTextureEnabled(): boolean;
  98400. static set SheenTextureEnabled(value: boolean);
  98401. private static _AnisotropicTextureEnabled;
  98402. /**
  98403. * Are anisotropic textures enabled in the application.
  98404. */
  98405. static get AnisotropicTextureEnabled(): boolean;
  98406. static set AnisotropicTextureEnabled(value: boolean);
  98407. private static _ThicknessTextureEnabled;
  98408. /**
  98409. * Are thickness textures enabled in the application.
  98410. */
  98411. static get ThicknessTextureEnabled(): boolean;
  98412. static set ThicknessTextureEnabled(value: boolean);
  98413. }
  98414. }
  98415. declare module BABYLON {
  98416. /** @hidden */
  98417. export var defaultFragmentDeclaration: {
  98418. name: string;
  98419. shader: string;
  98420. };
  98421. }
  98422. declare module BABYLON {
  98423. /** @hidden */
  98424. export var defaultUboDeclaration: {
  98425. name: string;
  98426. shader: string;
  98427. };
  98428. }
  98429. declare module BABYLON {
  98430. /** @hidden */
  98431. export var lightFragmentDeclaration: {
  98432. name: string;
  98433. shader: string;
  98434. };
  98435. }
  98436. declare module BABYLON {
  98437. /** @hidden */
  98438. export var lightUboDeclaration: {
  98439. name: string;
  98440. shader: string;
  98441. };
  98442. }
  98443. declare module BABYLON {
  98444. /** @hidden */
  98445. export var lightsFragmentFunctions: {
  98446. name: string;
  98447. shader: string;
  98448. };
  98449. }
  98450. declare module BABYLON {
  98451. /** @hidden */
  98452. export var shadowsFragmentFunctions: {
  98453. name: string;
  98454. shader: string;
  98455. };
  98456. }
  98457. declare module BABYLON {
  98458. /** @hidden */
  98459. export var fresnelFunction: {
  98460. name: string;
  98461. shader: string;
  98462. };
  98463. }
  98464. declare module BABYLON {
  98465. /** @hidden */
  98466. export var reflectionFunction: {
  98467. name: string;
  98468. shader: string;
  98469. };
  98470. }
  98471. declare module BABYLON {
  98472. /** @hidden */
  98473. export var bumpFragmentFunctions: {
  98474. name: string;
  98475. shader: string;
  98476. };
  98477. }
  98478. declare module BABYLON {
  98479. /** @hidden */
  98480. export var logDepthDeclaration: {
  98481. name: string;
  98482. shader: string;
  98483. };
  98484. }
  98485. declare module BABYLON {
  98486. /** @hidden */
  98487. export var bumpFragment: {
  98488. name: string;
  98489. shader: string;
  98490. };
  98491. }
  98492. declare module BABYLON {
  98493. /** @hidden */
  98494. export var depthPrePass: {
  98495. name: string;
  98496. shader: string;
  98497. };
  98498. }
  98499. declare module BABYLON {
  98500. /** @hidden */
  98501. export var lightFragment: {
  98502. name: string;
  98503. shader: string;
  98504. };
  98505. }
  98506. declare module BABYLON {
  98507. /** @hidden */
  98508. export var logDepthFragment: {
  98509. name: string;
  98510. shader: string;
  98511. };
  98512. }
  98513. declare module BABYLON {
  98514. /** @hidden */
  98515. export var defaultPixelShader: {
  98516. name: string;
  98517. shader: string;
  98518. };
  98519. }
  98520. declare module BABYLON {
  98521. /** @hidden */
  98522. export var defaultVertexDeclaration: {
  98523. name: string;
  98524. shader: string;
  98525. };
  98526. }
  98527. declare module BABYLON {
  98528. /** @hidden */
  98529. export var bumpVertexDeclaration: {
  98530. name: string;
  98531. shader: string;
  98532. };
  98533. }
  98534. declare module BABYLON {
  98535. /** @hidden */
  98536. export var bumpVertex: {
  98537. name: string;
  98538. shader: string;
  98539. };
  98540. }
  98541. declare module BABYLON {
  98542. /** @hidden */
  98543. export var fogVertex: {
  98544. name: string;
  98545. shader: string;
  98546. };
  98547. }
  98548. declare module BABYLON {
  98549. /** @hidden */
  98550. export var shadowsVertex: {
  98551. name: string;
  98552. shader: string;
  98553. };
  98554. }
  98555. declare module BABYLON {
  98556. /** @hidden */
  98557. export var pointCloudVertex: {
  98558. name: string;
  98559. shader: string;
  98560. };
  98561. }
  98562. declare module BABYLON {
  98563. /** @hidden */
  98564. export var logDepthVertex: {
  98565. name: string;
  98566. shader: string;
  98567. };
  98568. }
  98569. declare module BABYLON {
  98570. /** @hidden */
  98571. export var defaultVertexShader: {
  98572. name: string;
  98573. shader: string;
  98574. };
  98575. }
  98576. declare module BABYLON {
  98577. /** @hidden */
  98578. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98579. MAINUV1: boolean;
  98580. MAINUV2: boolean;
  98581. DIFFUSE: boolean;
  98582. DIFFUSEDIRECTUV: number;
  98583. AMBIENT: boolean;
  98584. AMBIENTDIRECTUV: number;
  98585. OPACITY: boolean;
  98586. OPACITYDIRECTUV: number;
  98587. OPACITYRGB: boolean;
  98588. REFLECTION: boolean;
  98589. EMISSIVE: boolean;
  98590. EMISSIVEDIRECTUV: number;
  98591. SPECULAR: boolean;
  98592. SPECULARDIRECTUV: number;
  98593. BUMP: boolean;
  98594. BUMPDIRECTUV: number;
  98595. PARALLAX: boolean;
  98596. PARALLAXOCCLUSION: boolean;
  98597. SPECULAROVERALPHA: boolean;
  98598. CLIPPLANE: boolean;
  98599. CLIPPLANE2: boolean;
  98600. CLIPPLANE3: boolean;
  98601. CLIPPLANE4: boolean;
  98602. CLIPPLANE5: boolean;
  98603. CLIPPLANE6: boolean;
  98604. ALPHATEST: boolean;
  98605. DEPTHPREPASS: boolean;
  98606. ALPHAFROMDIFFUSE: boolean;
  98607. POINTSIZE: boolean;
  98608. FOG: boolean;
  98609. SPECULARTERM: boolean;
  98610. DIFFUSEFRESNEL: boolean;
  98611. OPACITYFRESNEL: boolean;
  98612. REFLECTIONFRESNEL: boolean;
  98613. REFRACTIONFRESNEL: boolean;
  98614. EMISSIVEFRESNEL: boolean;
  98615. FRESNEL: boolean;
  98616. NORMAL: boolean;
  98617. UV1: boolean;
  98618. UV2: boolean;
  98619. VERTEXCOLOR: boolean;
  98620. VERTEXALPHA: boolean;
  98621. NUM_BONE_INFLUENCERS: number;
  98622. BonesPerMesh: number;
  98623. BONETEXTURE: boolean;
  98624. INSTANCES: boolean;
  98625. GLOSSINESS: boolean;
  98626. ROUGHNESS: boolean;
  98627. EMISSIVEASILLUMINATION: boolean;
  98628. LINKEMISSIVEWITHDIFFUSE: boolean;
  98629. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98630. LIGHTMAP: boolean;
  98631. LIGHTMAPDIRECTUV: number;
  98632. OBJECTSPACE_NORMALMAP: boolean;
  98633. USELIGHTMAPASSHADOWMAP: boolean;
  98634. REFLECTIONMAP_3D: boolean;
  98635. REFLECTIONMAP_SPHERICAL: boolean;
  98636. REFLECTIONMAP_PLANAR: boolean;
  98637. REFLECTIONMAP_CUBIC: boolean;
  98638. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98639. REFLECTIONMAP_PROJECTION: boolean;
  98640. REFLECTIONMAP_SKYBOX: boolean;
  98641. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98642. REFLECTIONMAP_EXPLICIT: boolean;
  98643. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98644. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98645. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98646. INVERTCUBICMAP: boolean;
  98647. LOGARITHMICDEPTH: boolean;
  98648. REFRACTION: boolean;
  98649. REFRACTIONMAP_3D: boolean;
  98650. REFLECTIONOVERALPHA: boolean;
  98651. TWOSIDEDLIGHTING: boolean;
  98652. SHADOWFLOAT: boolean;
  98653. MORPHTARGETS: boolean;
  98654. MORPHTARGETS_NORMAL: boolean;
  98655. MORPHTARGETS_TANGENT: boolean;
  98656. MORPHTARGETS_UV: boolean;
  98657. NUM_MORPH_INFLUENCERS: number;
  98658. NONUNIFORMSCALING: boolean;
  98659. PREMULTIPLYALPHA: boolean;
  98660. IMAGEPROCESSING: boolean;
  98661. VIGNETTE: boolean;
  98662. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98663. VIGNETTEBLENDMODEOPAQUE: boolean;
  98664. TONEMAPPING: boolean;
  98665. TONEMAPPING_ACES: boolean;
  98666. CONTRAST: boolean;
  98667. COLORCURVES: boolean;
  98668. COLORGRADING: boolean;
  98669. COLORGRADING3D: boolean;
  98670. SAMPLER3DGREENDEPTH: boolean;
  98671. SAMPLER3DBGRMAP: boolean;
  98672. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98673. MULTIVIEW: boolean;
  98674. /**
  98675. * If the reflection texture on this material is in linear color space
  98676. * @hidden
  98677. */
  98678. IS_REFLECTION_LINEAR: boolean;
  98679. /**
  98680. * If the refraction texture on this material is in linear color space
  98681. * @hidden
  98682. */
  98683. IS_REFRACTION_LINEAR: boolean;
  98684. EXPOSURE: boolean;
  98685. constructor();
  98686. setReflectionMode(modeToEnable: string): void;
  98687. }
  98688. /**
  98689. * This is the default material used in Babylon. It is the best trade off between quality
  98690. * and performances.
  98691. * @see http://doc.babylonjs.com/babylon101/materials
  98692. */
  98693. export class StandardMaterial extends PushMaterial {
  98694. private _diffuseTexture;
  98695. /**
  98696. * The basic texture of the material as viewed under a light.
  98697. */
  98698. diffuseTexture: Nullable<BaseTexture>;
  98699. private _ambientTexture;
  98700. /**
  98701. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98702. */
  98703. ambientTexture: Nullable<BaseTexture>;
  98704. private _opacityTexture;
  98705. /**
  98706. * Define the transparency of the material from a texture.
  98707. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98708. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98709. */
  98710. opacityTexture: Nullable<BaseTexture>;
  98711. private _reflectionTexture;
  98712. /**
  98713. * Define the texture used to display the reflection.
  98714. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98715. */
  98716. reflectionTexture: Nullable<BaseTexture>;
  98717. private _emissiveTexture;
  98718. /**
  98719. * Define texture of the material as if self lit.
  98720. * This will be mixed in the final result even in the absence of light.
  98721. */
  98722. emissiveTexture: Nullable<BaseTexture>;
  98723. private _specularTexture;
  98724. /**
  98725. * Define how the color and intensity of the highlight given by the light in the material.
  98726. */
  98727. specularTexture: Nullable<BaseTexture>;
  98728. private _bumpTexture;
  98729. /**
  98730. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98731. * 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.
  98732. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98733. */
  98734. bumpTexture: Nullable<BaseTexture>;
  98735. private _lightmapTexture;
  98736. /**
  98737. * Complex lighting can be computationally expensive to compute at runtime.
  98738. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98739. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98740. */
  98741. lightmapTexture: Nullable<BaseTexture>;
  98742. private _refractionTexture;
  98743. /**
  98744. * Define the texture used to display the refraction.
  98745. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98746. */
  98747. refractionTexture: Nullable<BaseTexture>;
  98748. /**
  98749. * The color of the material lit by the environmental background lighting.
  98750. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98751. */
  98752. ambientColor: Color3;
  98753. /**
  98754. * The basic color of the material as viewed under a light.
  98755. */
  98756. diffuseColor: Color3;
  98757. /**
  98758. * Define how the color and intensity of the highlight given by the light in the material.
  98759. */
  98760. specularColor: Color3;
  98761. /**
  98762. * Define the color of the material as if self lit.
  98763. * This will be mixed in the final result even in the absence of light.
  98764. */
  98765. emissiveColor: Color3;
  98766. /**
  98767. * Defines how sharp are the highlights in the material.
  98768. * The bigger the value the sharper giving a more glossy feeling to the result.
  98769. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98770. */
  98771. specularPower: number;
  98772. private _useAlphaFromDiffuseTexture;
  98773. /**
  98774. * Does the transparency come from the diffuse texture alpha channel.
  98775. */
  98776. useAlphaFromDiffuseTexture: boolean;
  98777. private _useEmissiveAsIllumination;
  98778. /**
  98779. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98780. */
  98781. useEmissiveAsIllumination: boolean;
  98782. private _linkEmissiveWithDiffuse;
  98783. /**
  98784. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98785. * the emissive level when the final color is close to one.
  98786. */
  98787. linkEmissiveWithDiffuse: boolean;
  98788. private _useSpecularOverAlpha;
  98789. /**
  98790. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98791. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98792. */
  98793. useSpecularOverAlpha: boolean;
  98794. private _useReflectionOverAlpha;
  98795. /**
  98796. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98797. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98798. */
  98799. useReflectionOverAlpha: boolean;
  98800. private _disableLighting;
  98801. /**
  98802. * Does lights from the scene impacts this material.
  98803. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98804. */
  98805. disableLighting: boolean;
  98806. private _useObjectSpaceNormalMap;
  98807. /**
  98808. * Allows using an object space normal map (instead of tangent space).
  98809. */
  98810. useObjectSpaceNormalMap: boolean;
  98811. private _useParallax;
  98812. /**
  98813. * Is parallax enabled or not.
  98814. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98815. */
  98816. useParallax: boolean;
  98817. private _useParallaxOcclusion;
  98818. /**
  98819. * Is parallax occlusion enabled or not.
  98820. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98821. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98822. */
  98823. useParallaxOcclusion: boolean;
  98824. /**
  98825. * 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.
  98826. */
  98827. parallaxScaleBias: number;
  98828. private _roughness;
  98829. /**
  98830. * Helps to define how blurry the reflections should appears in the material.
  98831. */
  98832. roughness: number;
  98833. /**
  98834. * In case of refraction, define the value of the index of refraction.
  98835. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98836. */
  98837. indexOfRefraction: number;
  98838. /**
  98839. * Invert the refraction texture alongside the y axis.
  98840. * It can be useful with procedural textures or probe for instance.
  98841. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98842. */
  98843. invertRefractionY: boolean;
  98844. /**
  98845. * Defines the alpha limits in alpha test mode.
  98846. */
  98847. alphaCutOff: number;
  98848. private _useLightmapAsShadowmap;
  98849. /**
  98850. * In case of light mapping, define whether the map contains light or shadow informations.
  98851. */
  98852. useLightmapAsShadowmap: boolean;
  98853. private _diffuseFresnelParameters;
  98854. /**
  98855. * Define the diffuse fresnel parameters of the material.
  98856. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98857. */
  98858. diffuseFresnelParameters: FresnelParameters;
  98859. private _opacityFresnelParameters;
  98860. /**
  98861. * Define the opacity fresnel parameters of the material.
  98862. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98863. */
  98864. opacityFresnelParameters: FresnelParameters;
  98865. private _reflectionFresnelParameters;
  98866. /**
  98867. * Define the reflection fresnel parameters of the material.
  98868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98869. */
  98870. reflectionFresnelParameters: FresnelParameters;
  98871. private _refractionFresnelParameters;
  98872. /**
  98873. * Define the refraction fresnel parameters of the material.
  98874. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98875. */
  98876. refractionFresnelParameters: FresnelParameters;
  98877. private _emissiveFresnelParameters;
  98878. /**
  98879. * Define the emissive fresnel parameters of the material.
  98880. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98881. */
  98882. emissiveFresnelParameters: FresnelParameters;
  98883. private _useReflectionFresnelFromSpecular;
  98884. /**
  98885. * If true automatically deducts the fresnels values from the material specularity.
  98886. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98887. */
  98888. useReflectionFresnelFromSpecular: boolean;
  98889. private _useGlossinessFromSpecularMapAlpha;
  98890. /**
  98891. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98892. */
  98893. useGlossinessFromSpecularMapAlpha: boolean;
  98894. private _maxSimultaneousLights;
  98895. /**
  98896. * Defines the maximum number of lights that can be used in the material
  98897. */
  98898. maxSimultaneousLights: number;
  98899. private _invertNormalMapX;
  98900. /**
  98901. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98902. */
  98903. invertNormalMapX: boolean;
  98904. private _invertNormalMapY;
  98905. /**
  98906. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98907. */
  98908. invertNormalMapY: boolean;
  98909. private _twoSidedLighting;
  98910. /**
  98911. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98912. */
  98913. twoSidedLighting: boolean;
  98914. /**
  98915. * Default configuration related to image processing available in the standard Material.
  98916. */
  98917. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98918. /**
  98919. * Gets the image processing configuration used either in this material.
  98920. */
  98921. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  98922. /**
  98923. * Sets the Default image processing configuration used either in the this material.
  98924. *
  98925. * If sets to null, the scene one is in use.
  98926. */
  98927. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  98928. /**
  98929. * Keep track of the image processing observer to allow dispose and replace.
  98930. */
  98931. private _imageProcessingObserver;
  98932. /**
  98933. * Attaches a new image processing configuration to the Standard Material.
  98934. * @param configuration
  98935. */
  98936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98937. /**
  98938. * Gets wether the color curves effect is enabled.
  98939. */
  98940. get cameraColorCurvesEnabled(): boolean;
  98941. /**
  98942. * Sets wether the color curves effect is enabled.
  98943. */
  98944. set cameraColorCurvesEnabled(value: boolean);
  98945. /**
  98946. * Gets wether the color grading effect is enabled.
  98947. */
  98948. get cameraColorGradingEnabled(): boolean;
  98949. /**
  98950. * Gets wether the color grading effect is enabled.
  98951. */
  98952. set cameraColorGradingEnabled(value: boolean);
  98953. /**
  98954. * Gets wether tonemapping is enabled or not.
  98955. */
  98956. get cameraToneMappingEnabled(): boolean;
  98957. /**
  98958. * Sets wether tonemapping is enabled or not
  98959. */
  98960. set cameraToneMappingEnabled(value: boolean);
  98961. /**
  98962. * The camera exposure used on this material.
  98963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98964. * This corresponds to a photographic exposure.
  98965. */
  98966. get cameraExposure(): number;
  98967. /**
  98968. * The camera exposure used on this material.
  98969. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98970. * This corresponds to a photographic exposure.
  98971. */
  98972. set cameraExposure(value: number);
  98973. /**
  98974. * Gets The camera contrast used on this material.
  98975. */
  98976. get cameraContrast(): number;
  98977. /**
  98978. * Sets The camera contrast used on this material.
  98979. */
  98980. set cameraContrast(value: number);
  98981. /**
  98982. * Gets the Color Grading 2D Lookup Texture.
  98983. */
  98984. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  98985. /**
  98986. * Sets the Color Grading 2D Lookup Texture.
  98987. */
  98988. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  98989. /**
  98990. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98991. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98992. * 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;
  98993. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98994. */
  98995. get cameraColorCurves(): Nullable<ColorCurves>;
  98996. /**
  98997. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98998. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98999. * 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;
  99000. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99001. */
  99002. set cameraColorCurves(value: Nullable<ColorCurves>);
  99003. /**
  99004. * Custom callback helping to override the default shader used in the material.
  99005. */
  99006. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99007. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99008. protected _worldViewProjectionMatrix: Matrix;
  99009. protected _globalAmbientColor: Color3;
  99010. protected _useLogarithmicDepth: boolean;
  99011. protected _rebuildInParallel: boolean;
  99012. /**
  99013. * Instantiates a new standard material.
  99014. * This is the default material used in Babylon. It is the best trade off between quality
  99015. * and performances.
  99016. * @see http://doc.babylonjs.com/babylon101/materials
  99017. * @param name Define the name of the material in the scene
  99018. * @param scene Define the scene the material belong to
  99019. */
  99020. constructor(name: string, scene: Scene);
  99021. /**
  99022. * Gets a boolean indicating that current material needs to register RTT
  99023. */
  99024. get hasRenderTargetTextures(): boolean;
  99025. /**
  99026. * Gets the current class name of the material e.g. "StandardMaterial"
  99027. * Mainly use in serialization.
  99028. * @returns the class name
  99029. */
  99030. getClassName(): string;
  99031. /**
  99032. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99033. * You can try switching to logarithmic depth.
  99034. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99035. */
  99036. get useLogarithmicDepth(): boolean;
  99037. set useLogarithmicDepth(value: boolean);
  99038. /**
  99039. * Specifies if the material will require alpha blending
  99040. * @returns a boolean specifying if alpha blending is needed
  99041. */
  99042. needAlphaBlending(): boolean;
  99043. /**
  99044. * Specifies if this material should be rendered in alpha test mode
  99045. * @returns a boolean specifying if an alpha test is needed.
  99046. */
  99047. needAlphaTesting(): boolean;
  99048. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99049. /**
  99050. * Get the texture used for alpha test purpose.
  99051. * @returns the diffuse texture in case of the standard material.
  99052. */
  99053. getAlphaTestTexture(): Nullable<BaseTexture>;
  99054. /**
  99055. * Get if the submesh is ready to be used and all its information available.
  99056. * Child classes can use it to update shaders
  99057. * @param mesh defines the mesh to check
  99058. * @param subMesh defines which submesh to check
  99059. * @param useInstances specifies that instances should be used
  99060. * @returns a boolean indicating that the submesh is ready or not
  99061. */
  99062. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99063. /**
  99064. * Builds the material UBO layouts.
  99065. * Used internally during the effect preparation.
  99066. */
  99067. buildUniformLayout(): void;
  99068. /**
  99069. * Unbinds the material from the mesh
  99070. */
  99071. unbind(): void;
  99072. /**
  99073. * Binds the submesh to this material by preparing the effect and shader to draw
  99074. * @param world defines the world transformation matrix
  99075. * @param mesh defines the mesh containing the submesh
  99076. * @param subMesh defines the submesh to bind the material to
  99077. */
  99078. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99079. /**
  99080. * Get the list of animatables in the material.
  99081. * @returns the list of animatables object used in the material
  99082. */
  99083. getAnimatables(): IAnimatable[];
  99084. /**
  99085. * Gets the active textures from the material
  99086. * @returns an array of textures
  99087. */
  99088. getActiveTextures(): BaseTexture[];
  99089. /**
  99090. * Specifies if the material uses a texture
  99091. * @param texture defines the texture to check against the material
  99092. * @returns a boolean specifying if the material uses the texture
  99093. */
  99094. hasTexture(texture: BaseTexture): boolean;
  99095. /**
  99096. * Disposes the material
  99097. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99098. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99099. */
  99100. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99101. /**
  99102. * Makes a duplicate of the material, and gives it a new name
  99103. * @param name defines the new name for the duplicated material
  99104. * @returns the cloned material
  99105. */
  99106. clone(name: string): StandardMaterial;
  99107. /**
  99108. * Serializes this material in a JSON representation
  99109. * @returns the serialized material object
  99110. */
  99111. serialize(): any;
  99112. /**
  99113. * Creates a standard material from parsed material data
  99114. * @param source defines the JSON representation of the material
  99115. * @param scene defines the hosting scene
  99116. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99117. * @returns a new standard material
  99118. */
  99119. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99120. /**
  99121. * Are diffuse textures enabled in the application.
  99122. */
  99123. static get DiffuseTextureEnabled(): boolean;
  99124. static set DiffuseTextureEnabled(value: boolean);
  99125. /**
  99126. * Are ambient textures enabled in the application.
  99127. */
  99128. static get AmbientTextureEnabled(): boolean;
  99129. static set AmbientTextureEnabled(value: boolean);
  99130. /**
  99131. * Are opacity textures enabled in the application.
  99132. */
  99133. static get OpacityTextureEnabled(): boolean;
  99134. static set OpacityTextureEnabled(value: boolean);
  99135. /**
  99136. * Are reflection textures enabled in the application.
  99137. */
  99138. static get ReflectionTextureEnabled(): boolean;
  99139. static set ReflectionTextureEnabled(value: boolean);
  99140. /**
  99141. * Are emissive textures enabled in the application.
  99142. */
  99143. static get EmissiveTextureEnabled(): boolean;
  99144. static set EmissiveTextureEnabled(value: boolean);
  99145. /**
  99146. * Are specular textures enabled in the application.
  99147. */
  99148. static get SpecularTextureEnabled(): boolean;
  99149. static set SpecularTextureEnabled(value: boolean);
  99150. /**
  99151. * Are bump textures enabled in the application.
  99152. */
  99153. static get BumpTextureEnabled(): boolean;
  99154. static set BumpTextureEnabled(value: boolean);
  99155. /**
  99156. * Are lightmap textures enabled in the application.
  99157. */
  99158. static get LightmapTextureEnabled(): boolean;
  99159. static set LightmapTextureEnabled(value: boolean);
  99160. /**
  99161. * Are refraction textures enabled in the application.
  99162. */
  99163. static get RefractionTextureEnabled(): boolean;
  99164. static set RefractionTextureEnabled(value: boolean);
  99165. /**
  99166. * Are color grading textures enabled in the application.
  99167. */
  99168. static get ColorGradingTextureEnabled(): boolean;
  99169. static set ColorGradingTextureEnabled(value: boolean);
  99170. /**
  99171. * Are fresnels enabled in the application.
  99172. */
  99173. static get FresnelEnabled(): boolean;
  99174. static set FresnelEnabled(value: boolean);
  99175. }
  99176. }
  99177. declare module BABYLON {
  99178. /**
  99179. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  99180. *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.
  99181. * The SPS is also a particle system. It provides some methods to manage the particles.
  99182. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  99183. *
  99184. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  99185. */
  99186. export class SolidParticleSystem implements IDisposable {
  99187. /**
  99188. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  99189. * Example : var p = SPS.particles[i];
  99190. */
  99191. particles: SolidParticle[];
  99192. /**
  99193. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  99194. */
  99195. nbParticles: number;
  99196. /**
  99197. * If the particles must ever face the camera (default false). Useful for planar particles.
  99198. */
  99199. billboard: boolean;
  99200. /**
  99201. * Recompute normals when adding a shape
  99202. */
  99203. recomputeNormals: boolean;
  99204. /**
  99205. * This a counter ofr your own usage. It's not set by any SPS functions.
  99206. */
  99207. counter: number;
  99208. /**
  99209. * The SPS name. This name is also given to the underlying mesh.
  99210. */
  99211. name: string;
  99212. /**
  99213. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  99214. */
  99215. mesh: Mesh;
  99216. /**
  99217. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  99218. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  99219. */
  99220. vars: any;
  99221. /**
  99222. * This array is populated when the SPS is set as 'pickable'.
  99223. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  99224. * Each element of this array is an object `{idx: int, faceId: int}`.
  99225. * `idx` is the picked particle index in the `SPS.particles` array
  99226. * `faceId` is the picked face index counted within this particle.
  99227. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  99228. */
  99229. pickedParticles: {
  99230. idx: number;
  99231. faceId: number;
  99232. }[];
  99233. /**
  99234. * This array is populated when `enableDepthSort` is set to true.
  99235. * Each element of this array is an instance of the class DepthSortedParticle.
  99236. */
  99237. depthSortedParticles: DepthSortedParticle[];
  99238. /**
  99239. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  99240. * @hidden
  99241. */
  99242. _bSphereOnly: boolean;
  99243. /**
  99244. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  99245. * @hidden
  99246. */
  99247. _bSphereRadiusFactor: number;
  99248. private _scene;
  99249. private _positions;
  99250. private _indices;
  99251. private _normals;
  99252. private _colors;
  99253. private _uvs;
  99254. private _indices32;
  99255. private _positions32;
  99256. private _normals32;
  99257. private _fixedNormal32;
  99258. private _colors32;
  99259. private _uvs32;
  99260. private _index;
  99261. private _updatable;
  99262. private _pickable;
  99263. private _isVisibilityBoxLocked;
  99264. private _alwaysVisible;
  99265. private _depthSort;
  99266. private _expandable;
  99267. private _shapeCounter;
  99268. private _copy;
  99269. private _color;
  99270. private _computeParticleColor;
  99271. private _computeParticleTexture;
  99272. private _computeParticleRotation;
  99273. private _computeParticleVertex;
  99274. private _computeBoundingBox;
  99275. private _depthSortParticles;
  99276. private _camera;
  99277. private _mustUnrotateFixedNormals;
  99278. private _particlesIntersect;
  99279. private _needs32Bits;
  99280. private _isNotBuilt;
  99281. private _lastParticleId;
  99282. private _idxOfId;
  99283. private _multimaterialEnabled;
  99284. private _useModelMaterial;
  99285. private _indicesByMaterial;
  99286. private _materialIndexes;
  99287. private _depthSortFunction;
  99288. private _materialSortFunction;
  99289. private _materials;
  99290. private _multimaterial;
  99291. private _materialIndexesById;
  99292. private _defaultMaterial;
  99293. private _autoUpdateSubMeshes;
  99294. /**
  99295. * Creates a SPS (Solid Particle System) object.
  99296. * @param name (String) is the SPS name, this will be the underlying mesh name.
  99297. * @param scene (Scene) is the scene in which the SPS is added.
  99298. * @param options defines the options of the sps e.g.
  99299. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  99300. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  99301. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  99302. * * 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.
  99303. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  99304. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  99305. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  99306. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  99307. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  99308. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  99309. */
  99310. constructor(name: string, scene: Scene, options?: {
  99311. updatable?: boolean;
  99312. isPickable?: boolean;
  99313. enableDepthSort?: boolean;
  99314. particleIntersection?: boolean;
  99315. boundingSphereOnly?: boolean;
  99316. bSphereRadiusFactor?: number;
  99317. expandable?: boolean;
  99318. useModelMaterial?: boolean;
  99319. enableMultiMaterial?: boolean;
  99320. });
  99321. /**
  99322. * Builds the SPS underlying mesh. Returns a standard Mesh.
  99323. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  99324. * @returns the created mesh
  99325. */
  99326. buildMesh(): Mesh;
  99327. /**
  99328. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  99329. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  99330. * Thus the particles generated from `digest()` have their property `position` set yet.
  99331. * @param mesh ( Mesh ) is the mesh to be digested
  99332. * @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
  99333. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  99334. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  99335. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99336. * @returns the current SPS
  99337. */
  99338. digest(mesh: Mesh, options?: {
  99339. facetNb?: number;
  99340. number?: number;
  99341. delta?: number;
  99342. storage?: [];
  99343. }): SolidParticleSystem;
  99344. /**
  99345. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  99346. * @hidden
  99347. */
  99348. private _unrotateFixedNormals;
  99349. /**
  99350. * Resets the temporary working copy particle
  99351. * @hidden
  99352. */
  99353. private _resetCopy;
  99354. /**
  99355. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  99356. * @param p the current index in the positions array to be updated
  99357. * @param ind the current index in the indices array
  99358. * @param shape a Vector3 array, the shape geometry
  99359. * @param positions the positions array to be updated
  99360. * @param meshInd the shape indices array
  99361. * @param indices the indices array to be updated
  99362. * @param meshUV the shape uv array
  99363. * @param uvs the uv array to be updated
  99364. * @param meshCol the shape color array
  99365. * @param colors the color array to be updated
  99366. * @param meshNor the shape normals array
  99367. * @param normals the normals array to be updated
  99368. * @param idx the particle index
  99369. * @param idxInShape the particle index in its shape
  99370. * @param options the addShape() method passed options
  99371. * @model the particle model
  99372. * @hidden
  99373. */
  99374. private _meshBuilder;
  99375. /**
  99376. * Returns a shape Vector3 array from positions float array
  99377. * @param positions float array
  99378. * @returns a vector3 array
  99379. * @hidden
  99380. */
  99381. private _posToShape;
  99382. /**
  99383. * Returns a shapeUV array from a float uvs (array deep copy)
  99384. * @param uvs as a float array
  99385. * @returns a shapeUV array
  99386. * @hidden
  99387. */
  99388. private _uvsToShapeUV;
  99389. /**
  99390. * Adds a new particle object in the particles array
  99391. * @param idx particle index in particles array
  99392. * @param id particle id
  99393. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  99394. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  99395. * @param model particle ModelShape object
  99396. * @param shapeId model shape identifier
  99397. * @param idxInShape index of the particle in the current model
  99398. * @param bInfo model bounding info object
  99399. * @param storage target storage array, if any
  99400. * @hidden
  99401. */
  99402. private _addParticle;
  99403. /**
  99404. * Adds some particles to the SPS from the model shape. Returns the shape id.
  99405. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  99406. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  99407. * @param nb (positive integer) the number of particles to be created from this model
  99408. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  99409. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  99410. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99411. * @returns the number of shapes in the system
  99412. */
  99413. addShape(mesh: Mesh, nb: number, options?: {
  99414. positionFunction?: any;
  99415. vertexFunction?: any;
  99416. storage?: [];
  99417. }): number;
  99418. /**
  99419. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  99420. * @hidden
  99421. */
  99422. private _rebuildParticle;
  99423. /**
  99424. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  99425. * @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.
  99426. * @returns the SPS.
  99427. */
  99428. rebuildMesh(reset?: boolean): SolidParticleSystem;
  99429. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  99430. * Returns an array with the removed particles.
  99431. * 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.
  99432. * The SPS can't be empty so at least one particle needs to remain in place.
  99433. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  99434. * @param start index of the first particle to remove
  99435. * @param end index of the last particle to remove (included)
  99436. * @returns an array populated with the removed particles
  99437. */
  99438. removeParticles(start: number, end: number): SolidParticle[];
  99439. /**
  99440. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  99441. * @param solidParticleArray an array populated with Solid Particles objects
  99442. * @returns the SPS
  99443. */
  99444. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  99445. /**
  99446. * Creates a new particle and modifies the SPS mesh geometry :
  99447. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  99448. * - calls _addParticle() to populate the particle array
  99449. * factorized code from addShape() and insertParticlesFromArray()
  99450. * @param idx particle index in the particles array
  99451. * @param i particle index in its shape
  99452. * @param modelShape particle ModelShape object
  99453. * @param shape shape vertex array
  99454. * @param meshInd shape indices array
  99455. * @param meshUV shape uv array
  99456. * @param meshCol shape color array
  99457. * @param meshNor shape normals array
  99458. * @param bbInfo shape bounding info
  99459. * @param storage target particle storage
  99460. * @options addShape() passed options
  99461. * @hidden
  99462. */
  99463. private _insertNewParticle;
  99464. /**
  99465. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  99466. * This method calls `updateParticle()` for each particle of the SPS.
  99467. * For an animated SPS, it is usually called within the render loop.
  99468. * 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.
  99469. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  99470. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  99471. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  99472. * @returns the SPS.
  99473. */
  99474. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  99475. /**
  99476. * Disposes the SPS.
  99477. */
  99478. dispose(): void;
  99479. /**
  99480. * Returns a SolidParticle object from its identifier : particle.id
  99481. * @param id (integer) the particle Id
  99482. * @returns the searched particle or null if not found in the SPS.
  99483. */
  99484. getParticleById(id: number): Nullable<SolidParticle>;
  99485. /**
  99486. * Returns a new array populated with the particles having the passed shapeId.
  99487. * @param shapeId (integer) the shape identifier
  99488. * @returns a new solid particle array
  99489. */
  99490. getParticlesByShapeId(shapeId: number): SolidParticle[];
  99491. /**
  99492. * Populates the passed array "ref" with the particles having the passed shapeId.
  99493. * @param shapeId the shape identifier
  99494. * @returns the SPS
  99495. * @param ref
  99496. */
  99497. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  99498. /**
  99499. * Computes the required SubMeshes according the materials assigned to the particles.
  99500. * @returns the solid particle system.
  99501. * Does nothing if called before the SPS mesh is built.
  99502. */
  99503. computeSubMeshes(): SolidParticleSystem;
  99504. /**
  99505. * Sorts the solid particles by material when MultiMaterial is enabled.
  99506. * Updates the indices32 array.
  99507. * Updates the indicesByMaterial array.
  99508. * Updates the mesh indices array.
  99509. * @returns the SPS
  99510. * @hidden
  99511. */
  99512. private _sortParticlesByMaterial;
  99513. /**
  99514. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  99515. * @hidden
  99516. */
  99517. private _setMaterialIndexesById;
  99518. /**
  99519. * Returns an array with unique values of Materials from the passed array
  99520. * @param array the material array to be checked and filtered
  99521. * @hidden
  99522. */
  99523. private _filterUniqueMaterialId;
  99524. /**
  99525. * Sets a new Standard Material as _defaultMaterial if not already set.
  99526. * @hidden
  99527. */
  99528. private _setDefaultMaterial;
  99529. /**
  99530. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  99531. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99532. * @returns the SPS.
  99533. */
  99534. refreshVisibleSize(): SolidParticleSystem;
  99535. /**
  99536. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  99537. * @param size the size (float) of the visibility box
  99538. * note : this doesn't lock the SPS mesh bounding box.
  99539. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99540. */
  99541. setVisibilityBox(size: number): void;
  99542. /**
  99543. * Gets whether the SPS as always visible or not
  99544. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99545. */
  99546. get isAlwaysVisible(): boolean;
  99547. /**
  99548. * Sets the SPS as always visible or not
  99549. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99550. */
  99551. set isAlwaysVisible(val: boolean);
  99552. /**
  99553. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  99554. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99555. */
  99556. set isVisibilityBoxLocked(val: boolean);
  99557. /**
  99558. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  99559. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99560. */
  99561. get isVisibilityBoxLocked(): boolean;
  99562. /**
  99563. * Tells to `setParticles()` to compute the particle rotations or not.
  99564. * Default value : true. The SPS is faster when it's set to false.
  99565. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  99566. */
  99567. set computeParticleRotation(val: boolean);
  99568. /**
  99569. * Tells to `setParticles()` to compute the particle colors or not.
  99570. * Default value : true. The SPS is faster when it's set to false.
  99571. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  99572. */
  99573. set computeParticleColor(val: boolean);
  99574. set computeParticleTexture(val: boolean);
  99575. /**
  99576. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  99577. * Default value : false. The SPS is faster when it's set to false.
  99578. * Note : the particle custom vertex positions aren't stored values.
  99579. */
  99580. set computeParticleVertex(val: boolean);
  99581. /**
  99582. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  99583. */
  99584. set computeBoundingBox(val: boolean);
  99585. /**
  99586. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  99587. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  99588. * Default : `true`
  99589. */
  99590. set depthSortParticles(val: boolean);
  99591. /**
  99592. * Gets if `setParticles()` computes the particle rotations or not.
  99593. * Default value : true. The SPS is faster when it's set to false.
  99594. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  99595. */
  99596. get computeParticleRotation(): boolean;
  99597. /**
  99598. * Gets if `setParticles()` computes the particle colors or not.
  99599. * Default value : true. The SPS is faster when it's set to false.
  99600. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  99601. */
  99602. get computeParticleColor(): boolean;
  99603. /**
  99604. * Gets if `setParticles()` computes the particle textures or not.
  99605. * Default value : true. The SPS is faster when it's set to false.
  99606. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  99607. */
  99608. get computeParticleTexture(): boolean;
  99609. /**
  99610. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  99611. * Default value : false. The SPS is faster when it's set to false.
  99612. * Note : the particle custom vertex positions aren't stored values.
  99613. */
  99614. get computeParticleVertex(): boolean;
  99615. /**
  99616. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  99617. */
  99618. get computeBoundingBox(): boolean;
  99619. /**
  99620. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  99621. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  99622. * Default : `true`
  99623. */
  99624. get depthSortParticles(): boolean;
  99625. /**
  99626. * Gets if the SPS is created as expandable at construction time.
  99627. * Default : `false`
  99628. */
  99629. get expandable(): boolean;
  99630. /**
  99631. * Gets if the SPS supports the Multi Materials
  99632. */
  99633. get multimaterialEnabled(): boolean;
  99634. /**
  99635. * Gets if the SPS uses the model materials for its own multimaterial.
  99636. */
  99637. get useModelMaterial(): boolean;
  99638. /**
  99639. * The SPS used material array.
  99640. */
  99641. get materials(): Material[];
  99642. /**
  99643. * Sets the SPS MultiMaterial from the passed materials.
  99644. * Note : the passed array is internally copied and not used then by reference.
  99645. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  99646. */
  99647. setMultiMaterial(materials: Material[]): void;
  99648. /**
  99649. * The SPS computed multimaterial object
  99650. */
  99651. get multimaterial(): MultiMaterial;
  99652. set multimaterial(mm: MultiMaterial);
  99653. /**
  99654. * If the subMeshes must be updated on the next call to setParticles()
  99655. */
  99656. get autoUpdateSubMeshes(): boolean;
  99657. set autoUpdateSubMeshes(val: boolean);
  99658. /**
  99659. * This function does nothing. It may be overwritten to set all the particle first values.
  99660. * The SPS doesn't call this function, you may have to call it by your own.
  99661. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99662. */
  99663. initParticles(): void;
  99664. /**
  99665. * This function does nothing. It may be overwritten to recycle a particle.
  99666. * The SPS doesn't call this function, you may have to call it by your own.
  99667. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99668. * @param particle The particle to recycle
  99669. * @returns the recycled particle
  99670. */
  99671. recycleParticle(particle: SolidParticle): SolidParticle;
  99672. /**
  99673. * Updates a particle : this function should be overwritten by the user.
  99674. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  99675. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99676. * @example : just set a particle position or velocity and recycle conditions
  99677. * @param particle The particle to update
  99678. * @returns the updated particle
  99679. */
  99680. updateParticle(particle: SolidParticle): SolidParticle;
  99681. /**
  99682. * Updates a vertex of a particle : it can be overwritten by the user.
  99683. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  99684. * @param particle the current particle
  99685. * @param vertex the current index of the current particle
  99686. * @param pt the index of the current vertex in the particle shape
  99687. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  99688. * @example : just set a vertex particle position
  99689. * @returns the updated vertex
  99690. */
  99691. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  99692. /**
  99693. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  99694. * This does nothing and may be overwritten by the user.
  99695. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99696. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99697. * @param update the boolean update value actually passed to setParticles()
  99698. */
  99699. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  99700. /**
  99701. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  99702. * This will be passed three parameters.
  99703. * This does nothing and may be overwritten by the user.
  99704. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99705. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99706. * @param update the boolean update value actually passed to setParticles()
  99707. */
  99708. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  99709. }
  99710. }
  99711. declare module BABYLON {
  99712. /**
  99713. * Represents one particle of a solid particle system.
  99714. */
  99715. export class SolidParticle {
  99716. /**
  99717. * particle global index
  99718. */
  99719. idx: number;
  99720. /**
  99721. * particle identifier
  99722. */
  99723. id: number;
  99724. /**
  99725. * The color of the particle
  99726. */
  99727. color: Nullable<Color4>;
  99728. /**
  99729. * The world space position of the particle.
  99730. */
  99731. position: Vector3;
  99732. /**
  99733. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  99734. */
  99735. rotation: Vector3;
  99736. /**
  99737. * The world space rotation quaternion of the particle.
  99738. */
  99739. rotationQuaternion: Nullable<Quaternion>;
  99740. /**
  99741. * The scaling of the particle.
  99742. */
  99743. scaling: Vector3;
  99744. /**
  99745. * The uvs of the particle.
  99746. */
  99747. uvs: Vector4;
  99748. /**
  99749. * The current speed of the particle.
  99750. */
  99751. velocity: Vector3;
  99752. /**
  99753. * The pivot point in the particle local space.
  99754. */
  99755. pivot: Vector3;
  99756. /**
  99757. * Must the particle be translated from its pivot point in its local space ?
  99758. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  99759. * Default : false
  99760. */
  99761. translateFromPivot: boolean;
  99762. /**
  99763. * Is the particle active or not ?
  99764. */
  99765. alive: boolean;
  99766. /**
  99767. * Is the particle visible or not ?
  99768. */
  99769. isVisible: boolean;
  99770. /**
  99771. * Index of this particle in the global "positions" array (Internal use)
  99772. * @hidden
  99773. */
  99774. _pos: number;
  99775. /**
  99776. * @hidden Index of this particle in the global "indices" array (Internal use)
  99777. */
  99778. _ind: number;
  99779. /**
  99780. * @hidden ModelShape of this particle (Internal use)
  99781. */
  99782. _model: ModelShape;
  99783. /**
  99784. * ModelShape id of this particle
  99785. */
  99786. shapeId: number;
  99787. /**
  99788. * Index of the particle in its shape id
  99789. */
  99790. idxInShape: number;
  99791. /**
  99792. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  99793. */
  99794. _modelBoundingInfo: BoundingInfo;
  99795. /**
  99796. * @hidden Particle BoundingInfo object (Internal use)
  99797. */
  99798. _boundingInfo: BoundingInfo;
  99799. /**
  99800. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  99801. */
  99802. _sps: SolidParticleSystem;
  99803. /**
  99804. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  99805. */
  99806. _stillInvisible: boolean;
  99807. /**
  99808. * @hidden Last computed particle rotation matrix
  99809. */
  99810. _rotationMatrix: number[];
  99811. /**
  99812. * Parent particle Id, if any.
  99813. * Default null.
  99814. */
  99815. parentId: Nullable<number>;
  99816. /**
  99817. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  99818. */
  99819. materialIndex: Nullable<number>;
  99820. /**
  99821. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  99822. * The possible values are :
  99823. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  99824. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  99826. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  99827. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99828. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  99829. * */
  99830. cullingStrategy: number;
  99831. /**
  99832. * @hidden Internal global position in the SPS.
  99833. */
  99834. _globalPosition: Vector3;
  99835. /**
  99836. * Creates a Solid Particle object.
  99837. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  99838. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  99839. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  99840. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  99841. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  99842. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  99843. * @param shapeId (integer) is the model shape identifier in the SPS.
  99844. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  99845. * @param sps defines the sps it is associated to
  99846. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  99847. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  99848. */
  99849. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  99850. /**
  99851. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  99852. * @param target the particle target
  99853. * @returns the current particle
  99854. */
  99855. copyToRef(target: SolidParticle): SolidParticle;
  99856. /**
  99857. * Legacy support, changed scale to scaling
  99858. */
  99859. get scale(): Vector3;
  99860. /**
  99861. * Legacy support, changed scale to scaling
  99862. */
  99863. set scale(scale: Vector3);
  99864. /**
  99865. * Legacy support, changed quaternion to rotationQuaternion
  99866. */
  99867. get quaternion(): Nullable<Quaternion>;
  99868. /**
  99869. * Legacy support, changed quaternion to rotationQuaternion
  99870. */
  99871. set quaternion(q: Nullable<Quaternion>);
  99872. /**
  99873. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  99874. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  99875. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  99876. * @returns true if it intersects
  99877. */
  99878. intersectsMesh(target: Mesh | SolidParticle): boolean;
  99879. /**
  99880. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  99881. * A particle is in the frustum if its bounding box intersects the frustum
  99882. * @param frustumPlanes defines the frustum to test
  99883. * @returns true if the particle is in the frustum planes
  99884. */
  99885. isInFrustum(frustumPlanes: Plane[]): boolean;
  99886. /**
  99887. * get the rotation matrix of the particle
  99888. * @hidden
  99889. */
  99890. getRotationMatrix(m: Matrix): void;
  99891. }
  99892. /**
  99893. * Represents the shape of the model used by one particle of a solid particle system.
  99894. * SPS internal tool, don't use it manually.
  99895. */
  99896. export class ModelShape {
  99897. /**
  99898. * The shape id
  99899. * @hidden
  99900. */
  99901. shapeID: number;
  99902. /**
  99903. * flat array of model positions (internal use)
  99904. * @hidden
  99905. */
  99906. _shape: Vector3[];
  99907. /**
  99908. * flat array of model UVs (internal use)
  99909. * @hidden
  99910. */
  99911. _shapeUV: number[];
  99912. /**
  99913. * color array of the model
  99914. * @hidden
  99915. */
  99916. _shapeColors: number[];
  99917. /**
  99918. * indices array of the model
  99919. * @hidden
  99920. */
  99921. _indices: number[];
  99922. /**
  99923. * normals array of the model
  99924. * @hidden
  99925. */
  99926. _normals: number[];
  99927. /**
  99928. * length of the shape in the model indices array (internal use)
  99929. * @hidden
  99930. */
  99931. _indicesLength: number;
  99932. /**
  99933. * Custom position function (internal use)
  99934. * @hidden
  99935. */
  99936. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  99937. /**
  99938. * Custom vertex function (internal use)
  99939. * @hidden
  99940. */
  99941. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  99942. /**
  99943. * Model material (internal use)
  99944. * @hidden
  99945. */
  99946. _material: Nullable<Material>;
  99947. /**
  99948. * 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.
  99949. * SPS internal tool, don't use it manually.
  99950. * @hidden
  99951. */
  99952. 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>);
  99953. }
  99954. /**
  99955. * Represents a Depth Sorted Particle in the solid particle system.
  99956. * @hidden
  99957. */
  99958. export class DepthSortedParticle {
  99959. /**
  99960. * Index of the particle in the "indices" array
  99961. */
  99962. ind: number;
  99963. /**
  99964. * Length of the particle shape in the "indices" array
  99965. */
  99966. indicesLength: number;
  99967. /**
  99968. * Squared distance from the particle to the camera
  99969. */
  99970. sqDistance: number;
  99971. /**
  99972. * Material index when used with MultiMaterials
  99973. */
  99974. materialIndex: number;
  99975. /**
  99976. * Creates a new sorted particle
  99977. * @param materialIndex
  99978. */
  99979. constructor(ind: number, indLength: number, materialIndex: number);
  99980. }
  99981. }
  99982. declare module BABYLON {
  99983. /**
  99984. * @hidden
  99985. */
  99986. export class _MeshCollisionData {
  99987. _checkCollisions: boolean;
  99988. _collisionMask: number;
  99989. _collisionGroup: number;
  99990. _collider: Nullable<Collider>;
  99991. _oldPositionForCollisions: Vector3;
  99992. _diffPositionForCollisions: Vector3;
  99993. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  99994. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  99995. }
  99996. }
  99997. declare module BABYLON {
  99998. /** @hidden */
  99999. class _FacetDataStorage {
  100000. facetPositions: Vector3[];
  100001. facetNormals: Vector3[];
  100002. facetPartitioning: number[][];
  100003. facetNb: number;
  100004. partitioningSubdivisions: number;
  100005. partitioningBBoxRatio: number;
  100006. facetDataEnabled: boolean;
  100007. facetParameters: any;
  100008. bbSize: Vector3;
  100009. subDiv: {
  100010. max: number;
  100011. X: number;
  100012. Y: number;
  100013. Z: number;
  100014. };
  100015. facetDepthSort: boolean;
  100016. facetDepthSortEnabled: boolean;
  100017. depthSortedIndices: IndicesArray;
  100018. depthSortedFacets: {
  100019. ind: number;
  100020. sqDistance: number;
  100021. }[];
  100022. facetDepthSortFunction: (f1: {
  100023. ind: number;
  100024. sqDistance: number;
  100025. }, f2: {
  100026. ind: number;
  100027. sqDistance: number;
  100028. }) => number;
  100029. facetDepthSortFrom: Vector3;
  100030. facetDepthSortOrigin: Vector3;
  100031. invertedMatrix: Matrix;
  100032. }
  100033. /**
  100034. * @hidden
  100035. **/
  100036. class _InternalAbstractMeshDataInfo {
  100037. _hasVertexAlpha: boolean;
  100038. _useVertexColors: boolean;
  100039. _numBoneInfluencers: number;
  100040. _applyFog: boolean;
  100041. _receiveShadows: boolean;
  100042. _facetData: _FacetDataStorage;
  100043. _visibility: number;
  100044. _skeleton: Nullable<Skeleton>;
  100045. _layerMask: number;
  100046. _computeBonesUsingShaders: boolean;
  100047. _isActive: boolean;
  100048. _onlyForInstances: boolean;
  100049. _isActiveIntermediate: boolean;
  100050. _onlyForInstancesIntermediate: boolean;
  100051. _actAsRegularMesh: boolean;
  100052. }
  100053. /**
  100054. * Class used to store all common mesh properties
  100055. */
  100056. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100057. /** No occlusion */
  100058. static OCCLUSION_TYPE_NONE: number;
  100059. /** Occlusion set to optimisitic */
  100060. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100061. /** Occlusion set to strict */
  100062. static OCCLUSION_TYPE_STRICT: number;
  100063. /** Use an accurante occlusion algorithm */
  100064. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100065. /** Use a conservative occlusion algorithm */
  100066. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100067. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100068. * Test order :
  100069. * Is the bounding sphere outside the frustum ?
  100070. * If not, are the bounding box vertices outside the frustum ?
  100071. * It not, then the cullable object is in the frustum.
  100072. */
  100073. static readonly CULLINGSTRATEGY_STANDARD: number;
  100074. /** Culling strategy : Bounding Sphere Only.
  100075. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100076. * It's also less accurate than the standard because some not visible objects can still be selected.
  100077. * Test : is the bounding sphere outside the frustum ?
  100078. * If not, then the cullable object is in the frustum.
  100079. */
  100080. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100081. /** Culling strategy : Optimistic Inclusion.
  100082. * This in an inclusion test first, then the standard exclusion test.
  100083. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  100084. * 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.
  100085. * Anyway, it's as accurate as the standard strategy.
  100086. * Test :
  100087. * Is the cullable object bounding sphere center in the frustum ?
  100088. * If not, apply the default culling strategy.
  100089. */
  100090. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  100091. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  100092. * This in an inclusion test first, then the bounding sphere only exclusion test.
  100093. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  100094. * 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.
  100095. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  100096. * Test :
  100097. * Is the cullable object bounding sphere center in the frustum ?
  100098. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  100099. */
  100100. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  100101. /**
  100102. * No billboard
  100103. */
  100104. static get BILLBOARDMODE_NONE(): number;
  100105. /** Billboard on X axis */
  100106. static get BILLBOARDMODE_X(): number;
  100107. /** Billboard on Y axis */
  100108. static get BILLBOARDMODE_Y(): number;
  100109. /** Billboard on Z axis */
  100110. static get BILLBOARDMODE_Z(): number;
  100111. /** Billboard on all axes */
  100112. static get BILLBOARDMODE_ALL(): number;
  100113. /** Billboard on using position instead of orientation */
  100114. static get BILLBOARDMODE_USE_POSITION(): number;
  100115. /** @hidden */
  100116. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  100117. /**
  100118. * The culling strategy to use to check whether the mesh must be rendered or not.
  100119. * This value can be changed at any time and will be used on the next render mesh selection.
  100120. * The possible values are :
  100121. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100122. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100123. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100124. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100125. * Please read each static variable documentation to get details about the culling process.
  100126. * */
  100127. cullingStrategy: number;
  100128. /**
  100129. * Gets the number of facets in the mesh
  100130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100131. */
  100132. get facetNb(): number;
  100133. /**
  100134. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  100135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100136. */
  100137. get partitioningSubdivisions(): number;
  100138. set partitioningSubdivisions(nb: number);
  100139. /**
  100140. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  100141. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  100142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100143. */
  100144. get partitioningBBoxRatio(): number;
  100145. set partitioningBBoxRatio(ratio: number);
  100146. /**
  100147. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  100148. * Works only for updatable meshes.
  100149. * Doesn't work with multi-materials
  100150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100151. */
  100152. get mustDepthSortFacets(): boolean;
  100153. set mustDepthSortFacets(sort: boolean);
  100154. /**
  100155. * The location (Vector3) where the facet depth sort must be computed from.
  100156. * By default, the active camera position.
  100157. * Used only when facet depth sort is enabled
  100158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100159. */
  100160. get facetDepthSortFrom(): Vector3;
  100161. set facetDepthSortFrom(location: Vector3);
  100162. /**
  100163. * gets a boolean indicating if facetData is enabled
  100164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100165. */
  100166. get isFacetDataEnabled(): boolean;
  100167. /** @hidden */
  100168. _updateNonUniformScalingState(value: boolean): boolean;
  100169. /**
  100170. * An event triggered when this mesh collides with another one
  100171. */
  100172. onCollideObservable: Observable<AbstractMesh>;
  100173. /** Set a function to call when this mesh collides with another one */
  100174. set onCollide(callback: () => void);
  100175. /**
  100176. * An event triggered when the collision's position changes
  100177. */
  100178. onCollisionPositionChangeObservable: Observable<Vector3>;
  100179. /** Set a function to call when the collision's position changes */
  100180. set onCollisionPositionChange(callback: () => void);
  100181. /**
  100182. * An event triggered when material is changed
  100183. */
  100184. onMaterialChangedObservable: Observable<AbstractMesh>;
  100185. /**
  100186. * Gets or sets the orientation for POV movement & rotation
  100187. */
  100188. definedFacingForward: boolean;
  100189. /** @hidden */
  100190. _occlusionQuery: Nullable<WebGLQuery>;
  100191. /** @hidden */
  100192. _renderingGroup: Nullable<RenderingGroup>;
  100193. /**
  100194. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100195. */
  100196. get visibility(): number;
  100197. /**
  100198. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100199. */
  100200. set visibility(value: number);
  100201. /** Gets or sets the alpha index used to sort transparent meshes
  100202. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  100203. */
  100204. alphaIndex: number;
  100205. /**
  100206. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  100207. */
  100208. isVisible: boolean;
  100209. /**
  100210. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  100211. */
  100212. isPickable: boolean;
  100213. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  100214. showSubMeshesBoundingBox: boolean;
  100215. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  100216. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100217. */
  100218. isBlocker: boolean;
  100219. /**
  100220. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  100221. */
  100222. enablePointerMoveEvents: boolean;
  100223. /**
  100224. * Specifies the rendering group id for this mesh (0 by default)
  100225. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  100226. */
  100227. renderingGroupId: number;
  100228. private _material;
  100229. /** Gets or sets current material */
  100230. get material(): Nullable<Material>;
  100231. set material(value: Nullable<Material>);
  100232. /**
  100233. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  100234. * @see http://doc.babylonjs.com/babylon101/shadows
  100235. */
  100236. get receiveShadows(): boolean;
  100237. set receiveShadows(value: boolean);
  100238. /** Defines color to use when rendering outline */
  100239. outlineColor: Color3;
  100240. /** Define width to use when rendering outline */
  100241. outlineWidth: number;
  100242. /** Defines color to use when rendering overlay */
  100243. overlayColor: Color3;
  100244. /** Defines alpha to use when rendering overlay */
  100245. overlayAlpha: number;
  100246. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  100247. get hasVertexAlpha(): boolean;
  100248. set hasVertexAlpha(value: boolean);
  100249. /** 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) */
  100250. get useVertexColors(): boolean;
  100251. set useVertexColors(value: boolean);
  100252. /**
  100253. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  100254. */
  100255. get computeBonesUsingShaders(): boolean;
  100256. set computeBonesUsingShaders(value: boolean);
  100257. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  100258. get numBoneInfluencers(): number;
  100259. set numBoneInfluencers(value: number);
  100260. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  100261. get applyFog(): boolean;
  100262. set applyFog(value: boolean);
  100263. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  100264. useOctreeForRenderingSelection: boolean;
  100265. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  100266. useOctreeForPicking: boolean;
  100267. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  100268. useOctreeForCollisions: boolean;
  100269. /**
  100270. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  100271. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  100272. */
  100273. get layerMask(): number;
  100274. set layerMask(value: number);
  100275. /**
  100276. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  100277. */
  100278. alwaysSelectAsActiveMesh: boolean;
  100279. /**
  100280. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  100281. */
  100282. doNotSyncBoundingInfo: boolean;
  100283. /**
  100284. * Gets or sets the current action manager
  100285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100286. */
  100287. actionManager: Nullable<AbstractActionManager>;
  100288. private _meshCollisionData;
  100289. /**
  100290. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  100291. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100292. */
  100293. ellipsoid: Vector3;
  100294. /**
  100295. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  100296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100297. */
  100298. ellipsoidOffset: Vector3;
  100299. /**
  100300. * Gets or sets a collision mask used to mask collisions (default is -1).
  100301. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100302. */
  100303. get collisionMask(): number;
  100304. set collisionMask(mask: number);
  100305. /**
  100306. * Gets or sets the current collision group mask (-1 by default).
  100307. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100308. */
  100309. get collisionGroup(): number;
  100310. set collisionGroup(mask: number);
  100311. /**
  100312. * Defines edge width used when edgesRenderer is enabled
  100313. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100314. */
  100315. edgesWidth: number;
  100316. /**
  100317. * Defines edge color used when edgesRenderer is enabled
  100318. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100319. */
  100320. edgesColor: Color4;
  100321. /** @hidden */
  100322. _edgesRenderer: Nullable<IEdgesRenderer>;
  100323. /** @hidden */
  100324. _masterMesh: Nullable<AbstractMesh>;
  100325. /** @hidden */
  100326. _boundingInfo: Nullable<BoundingInfo>;
  100327. /** @hidden */
  100328. _renderId: number;
  100329. /**
  100330. * Gets or sets the list of subMeshes
  100331. * @see http://doc.babylonjs.com/how_to/multi_materials
  100332. */
  100333. subMeshes: SubMesh[];
  100334. /** @hidden */
  100335. _intersectionsInProgress: AbstractMesh[];
  100336. /** @hidden */
  100337. _unIndexed: boolean;
  100338. /** @hidden */
  100339. _lightSources: Light[];
  100340. /** Gets the list of lights affecting that mesh */
  100341. get lightSources(): Light[];
  100342. /** @hidden */
  100343. get _positions(): Nullable<Vector3[]>;
  100344. /** @hidden */
  100345. _waitingData: {
  100346. lods: Nullable<any>;
  100347. actions: Nullable<any>;
  100348. freezeWorldMatrix: Nullable<boolean>;
  100349. };
  100350. /** @hidden */
  100351. _bonesTransformMatrices: Nullable<Float32Array>;
  100352. /** @hidden */
  100353. _transformMatrixTexture: Nullable<RawTexture>;
  100354. /**
  100355. * Gets or sets a skeleton to apply skining transformations
  100356. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100357. */
  100358. set skeleton(value: Nullable<Skeleton>);
  100359. get skeleton(): Nullable<Skeleton>;
  100360. /**
  100361. * An event triggered when the mesh is rebuilt.
  100362. */
  100363. onRebuildObservable: Observable<AbstractMesh>;
  100364. /**
  100365. * Creates a new AbstractMesh
  100366. * @param name defines the name of the mesh
  100367. * @param scene defines the hosting scene
  100368. */
  100369. constructor(name: string, scene?: Nullable<Scene>);
  100370. /**
  100371. * Returns the string "AbstractMesh"
  100372. * @returns "AbstractMesh"
  100373. */
  100374. getClassName(): string;
  100375. /**
  100376. * Gets a string representation of the current mesh
  100377. * @param fullDetails defines a boolean indicating if full details must be included
  100378. * @returns a string representation of the current mesh
  100379. */
  100380. toString(fullDetails?: boolean): string;
  100381. /**
  100382. * @hidden
  100383. */
  100384. protected _getEffectiveParent(): Nullable<Node>;
  100385. /** @hidden */
  100386. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100387. /** @hidden */
  100388. _rebuild(): void;
  100389. /** @hidden */
  100390. _resyncLightSources(): void;
  100391. /** @hidden */
  100392. _resyncLightSource(light: Light): void;
  100393. /** @hidden */
  100394. _unBindEffect(): void;
  100395. /** @hidden */
  100396. _removeLightSource(light: Light, dispose: boolean): void;
  100397. private _markSubMeshesAsDirty;
  100398. /** @hidden */
  100399. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  100400. /** @hidden */
  100401. _markSubMeshesAsAttributesDirty(): void;
  100402. /** @hidden */
  100403. _markSubMeshesAsMiscDirty(): void;
  100404. /**
  100405. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  100406. */
  100407. get scaling(): Vector3;
  100408. set scaling(newScaling: Vector3);
  100409. /**
  100410. * Returns true if the mesh is blocked. Implemented by child classes
  100411. */
  100412. get isBlocked(): boolean;
  100413. /**
  100414. * Returns the mesh itself by default. Implemented by child classes
  100415. * @param camera defines the camera to use to pick the right LOD level
  100416. * @returns the currentAbstractMesh
  100417. */
  100418. getLOD(camera: Camera): Nullable<AbstractMesh>;
  100419. /**
  100420. * Returns 0 by default. Implemented by child classes
  100421. * @returns an integer
  100422. */
  100423. getTotalVertices(): number;
  100424. /**
  100425. * Returns a positive integer : the total number of indices in this mesh geometry.
  100426. * @returns the numner of indices or zero if the mesh has no geometry.
  100427. */
  100428. getTotalIndices(): number;
  100429. /**
  100430. * Returns null by default. Implemented by child classes
  100431. * @returns null
  100432. */
  100433. getIndices(): Nullable<IndicesArray>;
  100434. /**
  100435. * Returns the array of the requested vertex data kind. Implemented by child classes
  100436. * @param kind defines the vertex data kind to use
  100437. * @returns null
  100438. */
  100439. getVerticesData(kind: string): Nullable<FloatArray>;
  100440. /**
  100441. * Sets the vertex data of the mesh geometry for the requested `kind`.
  100442. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  100443. * Note that a new underlying VertexBuffer object is created each call.
  100444. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  100445. * @param kind defines vertex data kind:
  100446. * * VertexBuffer.PositionKind
  100447. * * VertexBuffer.UVKind
  100448. * * VertexBuffer.UV2Kind
  100449. * * VertexBuffer.UV3Kind
  100450. * * VertexBuffer.UV4Kind
  100451. * * VertexBuffer.UV5Kind
  100452. * * VertexBuffer.UV6Kind
  100453. * * VertexBuffer.ColorKind
  100454. * * VertexBuffer.MatricesIndicesKind
  100455. * * VertexBuffer.MatricesIndicesExtraKind
  100456. * * VertexBuffer.MatricesWeightsKind
  100457. * * VertexBuffer.MatricesWeightsExtraKind
  100458. * @param data defines the data source
  100459. * @param updatable defines if the data must be flagged as updatable (or static)
  100460. * @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
  100461. * @returns the current mesh
  100462. */
  100463. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100464. /**
  100465. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  100466. * If the mesh has no geometry, it is simply returned as it is.
  100467. * @param kind defines vertex data kind:
  100468. * * VertexBuffer.PositionKind
  100469. * * VertexBuffer.UVKind
  100470. * * VertexBuffer.UV2Kind
  100471. * * VertexBuffer.UV3Kind
  100472. * * VertexBuffer.UV4Kind
  100473. * * VertexBuffer.UV5Kind
  100474. * * VertexBuffer.UV6Kind
  100475. * * VertexBuffer.ColorKind
  100476. * * VertexBuffer.MatricesIndicesKind
  100477. * * VertexBuffer.MatricesIndicesExtraKind
  100478. * * VertexBuffer.MatricesWeightsKind
  100479. * * VertexBuffer.MatricesWeightsExtraKind
  100480. * @param data defines the data source
  100481. * @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
  100482. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  100483. * @returns the current mesh
  100484. */
  100485. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100486. /**
  100487. * Sets the mesh indices,
  100488. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  100489. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  100490. * @param totalVertices Defines the total number of vertices
  100491. * @returns the current mesh
  100492. */
  100493. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  100494. /**
  100495. * Gets a boolean indicating if specific vertex data is present
  100496. * @param kind defines the vertex data kind to use
  100497. * @returns true is data kind is present
  100498. */
  100499. isVerticesDataPresent(kind: string): boolean;
  100500. /**
  100501. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  100502. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  100503. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  100504. * @returns a BoundingInfo
  100505. */
  100506. getBoundingInfo(): BoundingInfo;
  100507. /**
  100508. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  100509. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  100510. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  100511. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  100512. * @returns the current mesh
  100513. */
  100514. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  100515. /**
  100516. * Overwrite the current bounding info
  100517. * @param boundingInfo defines the new bounding info
  100518. * @returns the current mesh
  100519. */
  100520. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  100521. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  100522. get useBones(): boolean;
  100523. /** @hidden */
  100524. _preActivate(): void;
  100525. /** @hidden */
  100526. _preActivateForIntermediateRendering(renderId: number): void;
  100527. /** @hidden */
  100528. _activate(renderId: number, intermediateRendering: boolean): boolean;
  100529. /** @hidden */
  100530. _postActivate(): void;
  100531. /** @hidden */
  100532. _freeze(): void;
  100533. /** @hidden */
  100534. _unFreeze(): void;
  100535. /**
  100536. * Gets the current world matrix
  100537. * @returns a Matrix
  100538. */
  100539. getWorldMatrix(): Matrix;
  100540. /** @hidden */
  100541. _getWorldMatrixDeterminant(): number;
  100542. /**
  100543. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  100544. */
  100545. get isAnInstance(): boolean;
  100546. /**
  100547. * Gets a boolean indicating if this mesh has instances
  100548. */
  100549. get hasInstances(): boolean;
  100550. /**
  100551. * Perform relative position change from the point of view of behind the front of the mesh.
  100552. * This is performed taking into account the meshes current rotation, so you do not have to care.
  100553. * Supports definition of mesh facing forward or backward
  100554. * @param amountRight defines the distance on the right axis
  100555. * @param amountUp defines the distance on the up axis
  100556. * @param amountForward defines the distance on the forward axis
  100557. * @returns the current mesh
  100558. */
  100559. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  100560. /**
  100561. * Calculate relative position change from the point of view of behind the front of the mesh.
  100562. * This is performed taking into account the meshes current rotation, so you do not have to care.
  100563. * Supports definition of mesh facing forward or backward
  100564. * @param amountRight defines the distance on the right axis
  100565. * @param amountUp defines the distance on the up axis
  100566. * @param amountForward defines the distance on the forward axis
  100567. * @returns the new displacement vector
  100568. */
  100569. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  100570. /**
  100571. * Perform relative rotation change from the point of view of behind the front of the mesh.
  100572. * Supports definition of mesh facing forward or backward
  100573. * @param flipBack defines the flip
  100574. * @param twirlClockwise defines the twirl
  100575. * @param tiltRight defines the tilt
  100576. * @returns the current mesh
  100577. */
  100578. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  100579. /**
  100580. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  100581. * Supports definition of mesh facing forward or backward.
  100582. * @param flipBack defines the flip
  100583. * @param twirlClockwise defines the twirl
  100584. * @param tiltRight defines the tilt
  100585. * @returns the new rotation vector
  100586. */
  100587. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  100588. /**
  100589. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  100590. * This means the mesh underlying bounding box and sphere are recomputed.
  100591. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  100592. * @returns the current mesh
  100593. */
  100594. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  100595. /** @hidden */
  100596. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  100597. /** @hidden */
  100598. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  100599. /** @hidden */
  100600. _updateBoundingInfo(): AbstractMesh;
  100601. /** @hidden */
  100602. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  100603. /** @hidden */
  100604. protected _afterComputeWorldMatrix(): void;
  100605. /** @hidden */
  100606. get _effectiveMesh(): AbstractMesh;
  100607. /**
  100608. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  100609. * A mesh is in the frustum if its bounding box intersects the frustum
  100610. * @param frustumPlanes defines the frustum to test
  100611. * @returns true if the mesh is in the frustum planes
  100612. */
  100613. isInFrustum(frustumPlanes: Plane[]): boolean;
  100614. /**
  100615. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  100616. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  100617. * @param frustumPlanes defines the frustum to test
  100618. * @returns true if the mesh is completely in the frustum planes
  100619. */
  100620. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  100621. /**
  100622. * True if the mesh intersects another mesh or a SolidParticle object
  100623. * @param mesh defines a target mesh or SolidParticle to test
  100624. * @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)
  100625. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  100626. * @returns true if there is an intersection
  100627. */
  100628. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  100629. /**
  100630. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  100631. * @param point defines the point to test
  100632. * @returns true if there is an intersection
  100633. */
  100634. intersectsPoint(point: Vector3): boolean;
  100635. /**
  100636. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  100637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100638. */
  100639. get checkCollisions(): boolean;
  100640. set checkCollisions(collisionEnabled: boolean);
  100641. /**
  100642. * Gets Collider object used to compute collisions (not physics)
  100643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100644. */
  100645. get collider(): Nullable<Collider>;
  100646. /**
  100647. * Move the mesh using collision engine
  100648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100649. * @param displacement defines the requested displacement vector
  100650. * @returns the current mesh
  100651. */
  100652. moveWithCollisions(displacement: Vector3): AbstractMesh;
  100653. private _onCollisionPositionChange;
  100654. /** @hidden */
  100655. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  100656. /** @hidden */
  100657. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  100658. /** @hidden */
  100659. _checkCollision(collider: Collider): AbstractMesh;
  100660. /** @hidden */
  100661. _generatePointsArray(): boolean;
  100662. /**
  100663. * Checks if the passed Ray intersects with the mesh
  100664. * @param ray defines the ray to use
  100665. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  100666. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100667. * @returns the picking info
  100668. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  100669. */
  100670. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  100671. /**
  100672. * Clones the current mesh
  100673. * @param name defines the mesh name
  100674. * @param newParent defines the new mesh parent
  100675. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  100676. * @returns the new mesh
  100677. */
  100678. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  100679. /**
  100680. * Disposes all the submeshes of the current meshnp
  100681. * @returns the current mesh
  100682. */
  100683. releaseSubMeshes(): AbstractMesh;
  100684. /**
  100685. * Releases resources associated with this abstract mesh.
  100686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100688. */
  100689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100690. /**
  100691. * Adds the passed mesh as a child to the current mesh
  100692. * @param mesh defines the child mesh
  100693. * @returns the current mesh
  100694. */
  100695. addChild(mesh: AbstractMesh): AbstractMesh;
  100696. /**
  100697. * Removes the passed mesh from the current mesh children list
  100698. * @param mesh defines the child mesh
  100699. * @returns the current mesh
  100700. */
  100701. removeChild(mesh: AbstractMesh): AbstractMesh;
  100702. /** @hidden */
  100703. private _initFacetData;
  100704. /**
  100705. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  100706. * This method can be called within the render loop.
  100707. * 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
  100708. * @returns the current mesh
  100709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100710. */
  100711. updateFacetData(): AbstractMesh;
  100712. /**
  100713. * Returns the facetLocalNormals array.
  100714. * The normals are expressed in the mesh local spac
  100715. * @returns an array of Vector3
  100716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100717. */
  100718. getFacetLocalNormals(): Vector3[];
  100719. /**
  100720. * Returns the facetLocalPositions array.
  100721. * The facet positions are expressed in the mesh local space
  100722. * @returns an array of Vector3
  100723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100724. */
  100725. getFacetLocalPositions(): Vector3[];
  100726. /**
  100727. * Returns the facetLocalPartioning array
  100728. * @returns an array of array of numbers
  100729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100730. */
  100731. getFacetLocalPartitioning(): number[][];
  100732. /**
  100733. * Returns the i-th facet position in the world system.
  100734. * This method allocates a new Vector3 per call
  100735. * @param i defines the facet index
  100736. * @returns a new Vector3
  100737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100738. */
  100739. getFacetPosition(i: number): Vector3;
  100740. /**
  100741. * Sets the reference Vector3 with the i-th facet position in the world system
  100742. * @param i defines the facet index
  100743. * @param ref defines the target vector
  100744. * @returns the current mesh
  100745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100746. */
  100747. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  100748. /**
  100749. * Returns the i-th facet normal in the world system.
  100750. * This method allocates a new Vector3 per call
  100751. * @param i defines the facet index
  100752. * @returns a new Vector3
  100753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100754. */
  100755. getFacetNormal(i: number): Vector3;
  100756. /**
  100757. * Sets the reference Vector3 with the i-th facet normal in the world system
  100758. * @param i defines the facet index
  100759. * @param ref defines the target vector
  100760. * @returns the current mesh
  100761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100762. */
  100763. getFacetNormalToRef(i: number, ref: Vector3): this;
  100764. /**
  100765. * 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)
  100766. * @param x defines x coordinate
  100767. * @param y defines y coordinate
  100768. * @param z defines z coordinate
  100769. * @returns the array of facet indexes
  100770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100771. */
  100772. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  100773. /**
  100774. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  100775. * @param projected sets as the (x,y,z) world projection on the facet
  100776. * @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
  100777. * @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
  100778. * @param x defines x coordinate
  100779. * @param y defines y coordinate
  100780. * @param z defines z coordinate
  100781. * @returns the face index if found (or null instead)
  100782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100783. */
  100784. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  100785. /**
  100786. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  100787. * @param projected sets as the (x,y,z) local projection on the facet
  100788. * @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
  100789. * @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
  100790. * @param x defines x coordinate
  100791. * @param y defines y coordinate
  100792. * @param z defines z coordinate
  100793. * @returns the face index if found (or null instead)
  100794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100795. */
  100796. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  100797. /**
  100798. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  100799. * @returns the parameters
  100800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100801. */
  100802. getFacetDataParameters(): any;
  100803. /**
  100804. * Disables the feature FacetData and frees the related memory
  100805. * @returns the current mesh
  100806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100807. */
  100808. disableFacetData(): AbstractMesh;
  100809. /**
  100810. * Updates the AbstractMesh indices array
  100811. * @param indices defines the data source
  100812. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  100813. * @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)
  100814. * @returns the current mesh
  100815. */
  100816. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  100817. /**
  100818. * Creates new normals data for the mesh
  100819. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  100820. * @returns the current mesh
  100821. */
  100822. createNormals(updatable: boolean): AbstractMesh;
  100823. /**
  100824. * Align the mesh with a normal
  100825. * @param normal defines the normal to use
  100826. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  100827. * @returns the current mesh
  100828. */
  100829. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  100830. /** @hidden */
  100831. _checkOcclusionQuery(): boolean;
  100832. /**
  100833. * Disables the mesh edge rendering mode
  100834. * @returns the currentAbstractMesh
  100835. */
  100836. disableEdgesRendering(): AbstractMesh;
  100837. /**
  100838. * Enables the edge rendering mode on the mesh.
  100839. * This mode makes the mesh edges visible
  100840. * @param epsilon defines the maximal distance between two angles to detect a face
  100841. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  100842. * @returns the currentAbstractMesh
  100843. * @see https://www.babylonjs-playground.com/#19O9TU#0
  100844. */
  100845. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  100846. }
  100847. }
  100848. declare module BABYLON {
  100849. /**
  100850. * Interface used to define ActionEvent
  100851. */
  100852. export interface IActionEvent {
  100853. /** The mesh or sprite that triggered the action */
  100854. source: any;
  100855. /** The X mouse cursor position at the time of the event */
  100856. pointerX: number;
  100857. /** The Y mouse cursor position at the time of the event */
  100858. pointerY: number;
  100859. /** The mesh that is currently pointed at (can be null) */
  100860. meshUnderPointer: Nullable<AbstractMesh>;
  100861. /** the original (browser) event that triggered the ActionEvent */
  100862. sourceEvent?: any;
  100863. /** additional data for the event */
  100864. additionalData?: any;
  100865. }
  100866. /**
  100867. * ActionEvent is the event being sent when an action is triggered.
  100868. */
  100869. export class ActionEvent implements IActionEvent {
  100870. /** The mesh or sprite that triggered the action */
  100871. source: any;
  100872. /** The X mouse cursor position at the time of the event */
  100873. pointerX: number;
  100874. /** The Y mouse cursor position at the time of the event */
  100875. pointerY: number;
  100876. /** The mesh that is currently pointed at (can be null) */
  100877. meshUnderPointer: Nullable<AbstractMesh>;
  100878. /** the original (browser) event that triggered the ActionEvent */
  100879. sourceEvent?: any;
  100880. /** additional data for the event */
  100881. additionalData?: any;
  100882. /**
  100883. * Creates a new ActionEvent
  100884. * @param source The mesh or sprite that triggered the action
  100885. * @param pointerX The X mouse cursor position at the time of the event
  100886. * @param pointerY The Y mouse cursor position at the time of the event
  100887. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  100888. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  100889. * @param additionalData additional data for the event
  100890. */
  100891. constructor(
  100892. /** The mesh or sprite that triggered the action */
  100893. source: any,
  100894. /** The X mouse cursor position at the time of the event */
  100895. pointerX: number,
  100896. /** The Y mouse cursor position at the time of the event */
  100897. pointerY: number,
  100898. /** The mesh that is currently pointed at (can be null) */
  100899. meshUnderPointer: Nullable<AbstractMesh>,
  100900. /** the original (browser) event that triggered the ActionEvent */
  100901. sourceEvent?: any,
  100902. /** additional data for the event */
  100903. additionalData?: any);
  100904. /**
  100905. * Helper function to auto-create an ActionEvent from a source mesh.
  100906. * @param source The source mesh that triggered the event
  100907. * @param evt The original (browser) event
  100908. * @param additionalData additional data for the event
  100909. * @returns the new ActionEvent
  100910. */
  100911. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  100912. /**
  100913. * Helper function to auto-create an ActionEvent from a source sprite
  100914. * @param source The source sprite that triggered the event
  100915. * @param scene Scene associated with the sprite
  100916. * @param evt The original (browser) event
  100917. * @param additionalData additional data for the event
  100918. * @returns the new ActionEvent
  100919. */
  100920. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  100921. /**
  100922. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  100923. * @param scene the scene where the event occurred
  100924. * @param evt The original (browser) event
  100925. * @returns the new ActionEvent
  100926. */
  100927. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  100928. /**
  100929. * Helper function to auto-create an ActionEvent from a primitive
  100930. * @param prim defines the target primitive
  100931. * @param pointerPos defines the pointer position
  100932. * @param evt The original (browser) event
  100933. * @param additionalData additional data for the event
  100934. * @returns the new ActionEvent
  100935. */
  100936. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  100937. }
  100938. }
  100939. declare module BABYLON {
  100940. /**
  100941. * Abstract class used to decouple action Manager from scene and meshes.
  100942. * Do not instantiate.
  100943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100944. */
  100945. export abstract class AbstractActionManager implements IDisposable {
  100946. /** Gets the list of active triggers */
  100947. static Triggers: {
  100948. [key: string]: number;
  100949. };
  100950. /** Gets the cursor to use when hovering items */
  100951. hoverCursor: string;
  100952. /** Gets the list of actions */
  100953. actions: IAction[];
  100954. /**
  100955. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  100956. */
  100957. isRecursive: boolean;
  100958. /**
  100959. * Releases all associated resources
  100960. */
  100961. abstract dispose(): void;
  100962. /**
  100963. * Does this action manager has pointer triggers
  100964. */
  100965. abstract get hasPointerTriggers(): boolean;
  100966. /**
  100967. * Does this action manager has pick triggers
  100968. */
  100969. abstract get hasPickTriggers(): boolean;
  100970. /**
  100971. * Process a specific trigger
  100972. * @param trigger defines the trigger to process
  100973. * @param evt defines the event details to be processed
  100974. */
  100975. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  100976. /**
  100977. * Does this action manager handles actions of any of the given triggers
  100978. * @param triggers defines the triggers to be tested
  100979. * @return a boolean indicating whether one (or more) of the triggers is handled
  100980. */
  100981. abstract hasSpecificTriggers(triggers: number[]): boolean;
  100982. /**
  100983. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  100984. * speed.
  100985. * @param triggerA defines the trigger to be tested
  100986. * @param triggerB defines the trigger to be tested
  100987. * @return a boolean indicating whether one (or more) of the triggers is handled
  100988. */
  100989. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  100990. /**
  100991. * Does this action manager handles actions of a given trigger
  100992. * @param trigger defines the trigger to be tested
  100993. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  100994. * @return whether the trigger is handled
  100995. */
  100996. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  100997. /**
  100998. * Serialize this manager to a JSON object
  100999. * @param name defines the property name to store this manager
  101000. * @returns a JSON representation of this manager
  101001. */
  101002. abstract serialize(name: string): any;
  101003. /**
  101004. * Registers an action to this action manager
  101005. * @param action defines the action to be registered
  101006. * @return the action amended (prepared) after registration
  101007. */
  101008. abstract registerAction(action: IAction): Nullable<IAction>;
  101009. /**
  101010. * Unregisters an action to this action manager
  101011. * @param action defines the action to be unregistered
  101012. * @return a boolean indicating whether the action has been unregistered
  101013. */
  101014. abstract unregisterAction(action: IAction): Boolean;
  101015. /**
  101016. * Does exist one action manager with at least one trigger
  101017. **/
  101018. static get HasTriggers(): boolean;
  101019. /**
  101020. * Does exist one action manager with at least one pick trigger
  101021. **/
  101022. static get HasPickTriggers(): boolean;
  101023. /**
  101024. * Does exist one action manager that handles actions of a given trigger
  101025. * @param trigger defines the trigger to be tested
  101026. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101027. **/
  101028. static HasSpecificTrigger(trigger: number): boolean;
  101029. }
  101030. }
  101031. declare module BABYLON {
  101032. /**
  101033. * Defines how a node can be built from a string name.
  101034. */
  101035. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101036. /**
  101037. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101038. */
  101039. export class Node implements IBehaviorAware<Node> {
  101040. /** @hidden */
  101041. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101042. private static _NodeConstructors;
  101043. /**
  101044. * Add a new node constructor
  101045. * @param type defines the type name of the node to construct
  101046. * @param constructorFunc defines the constructor function
  101047. */
  101048. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101049. /**
  101050. * Returns a node constructor based on type name
  101051. * @param type defines the type name
  101052. * @param name defines the new node name
  101053. * @param scene defines the hosting scene
  101054. * @param options defines optional options to transmit to constructors
  101055. * @returns the new constructor or null
  101056. */
  101057. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101058. /**
  101059. * Gets or sets the name of the node
  101060. */
  101061. name: string;
  101062. /**
  101063. * Gets or sets the id of the node
  101064. */
  101065. id: string;
  101066. /**
  101067. * Gets or sets the unique id of the node
  101068. */
  101069. uniqueId: number;
  101070. /**
  101071. * Gets or sets a string used to store user defined state for the node
  101072. */
  101073. state: string;
  101074. /**
  101075. * Gets or sets an object used to store user defined information for the node
  101076. */
  101077. metadata: any;
  101078. /**
  101079. * For internal use only. Please do not use.
  101080. */
  101081. reservedDataStore: any;
  101082. /**
  101083. * List of inspectable custom properties (used by the Inspector)
  101084. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101085. */
  101086. inspectableCustomProperties: IInspectable[];
  101087. private _doNotSerialize;
  101088. /**
  101089. * Gets or sets a boolean used to define if the node must be serialized
  101090. */
  101091. get doNotSerialize(): boolean;
  101092. set doNotSerialize(value: boolean);
  101093. /** @hidden */
  101094. _isDisposed: boolean;
  101095. /**
  101096. * Gets a list of Animations associated with the node
  101097. */
  101098. animations: Animation[];
  101099. protected _ranges: {
  101100. [name: string]: Nullable<AnimationRange>;
  101101. };
  101102. /**
  101103. * Callback raised when the node is ready to be used
  101104. */
  101105. onReady: Nullable<(node: Node) => void>;
  101106. private _isEnabled;
  101107. private _isParentEnabled;
  101108. private _isReady;
  101109. /** @hidden */
  101110. _currentRenderId: number;
  101111. private _parentUpdateId;
  101112. /** @hidden */
  101113. _childUpdateId: number;
  101114. /** @hidden */
  101115. _waitingParentId: Nullable<string>;
  101116. /** @hidden */
  101117. _scene: Scene;
  101118. /** @hidden */
  101119. _cache: any;
  101120. private _parentNode;
  101121. private _children;
  101122. /** @hidden */
  101123. _worldMatrix: Matrix;
  101124. /** @hidden */
  101125. _worldMatrixDeterminant: number;
  101126. /** @hidden */
  101127. _worldMatrixDeterminantIsDirty: boolean;
  101128. /** @hidden */
  101129. private _sceneRootNodesIndex;
  101130. /**
  101131. * Gets a boolean indicating if the node has been disposed
  101132. * @returns true if the node was disposed
  101133. */
  101134. isDisposed(): boolean;
  101135. /**
  101136. * Gets or sets the parent of the node (without keeping the current position in the scene)
  101137. * @see https://doc.babylonjs.com/how_to/parenting
  101138. */
  101139. set parent(parent: Nullable<Node>);
  101140. get parent(): Nullable<Node>;
  101141. /** @hidden */
  101142. _addToSceneRootNodes(): void;
  101143. /** @hidden */
  101144. _removeFromSceneRootNodes(): void;
  101145. private _animationPropertiesOverride;
  101146. /**
  101147. * Gets or sets the animation properties override
  101148. */
  101149. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  101150. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  101151. /**
  101152. * Gets a string idenfifying the name of the class
  101153. * @returns "Node" string
  101154. */
  101155. getClassName(): string;
  101156. /** @hidden */
  101157. readonly _isNode: boolean;
  101158. /**
  101159. * An event triggered when the mesh is disposed
  101160. */
  101161. onDisposeObservable: Observable<Node>;
  101162. private _onDisposeObserver;
  101163. /**
  101164. * Sets a callback that will be raised when the node will be disposed
  101165. */
  101166. set onDispose(callback: () => void);
  101167. /**
  101168. * Creates a new Node
  101169. * @param name the name and id to be given to this node
  101170. * @param scene the scene this node will be added to
  101171. */
  101172. constructor(name: string, scene?: Nullable<Scene>);
  101173. /**
  101174. * Gets the scene of the node
  101175. * @returns a scene
  101176. */
  101177. getScene(): Scene;
  101178. /**
  101179. * Gets the engine of the node
  101180. * @returns a Engine
  101181. */
  101182. getEngine(): Engine;
  101183. private _behaviors;
  101184. /**
  101185. * Attach a behavior to the node
  101186. * @see http://doc.babylonjs.com/features/behaviour
  101187. * @param behavior defines the behavior to attach
  101188. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  101189. * @returns the current Node
  101190. */
  101191. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  101192. /**
  101193. * Remove an attached behavior
  101194. * @see http://doc.babylonjs.com/features/behaviour
  101195. * @param behavior defines the behavior to attach
  101196. * @returns the current Node
  101197. */
  101198. removeBehavior(behavior: Behavior<Node>): Node;
  101199. /**
  101200. * Gets the list of attached behaviors
  101201. * @see http://doc.babylonjs.com/features/behaviour
  101202. */
  101203. get behaviors(): Behavior<Node>[];
  101204. /**
  101205. * Gets an attached behavior by name
  101206. * @param name defines the name of the behavior to look for
  101207. * @see http://doc.babylonjs.com/features/behaviour
  101208. * @returns null if behavior was not found else the requested behavior
  101209. */
  101210. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  101211. /**
  101212. * Returns the latest update of the World matrix
  101213. * @returns a Matrix
  101214. */
  101215. getWorldMatrix(): Matrix;
  101216. /** @hidden */
  101217. _getWorldMatrixDeterminant(): number;
  101218. /**
  101219. * Returns directly the latest state of the mesh World matrix.
  101220. * A Matrix is returned.
  101221. */
  101222. get worldMatrixFromCache(): Matrix;
  101223. /** @hidden */
  101224. _initCache(): void;
  101225. /** @hidden */
  101226. updateCache(force?: boolean): void;
  101227. /** @hidden */
  101228. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101229. /** @hidden */
  101230. _updateCache(ignoreParentClass?: boolean): void;
  101231. /** @hidden */
  101232. _isSynchronized(): boolean;
  101233. /** @hidden */
  101234. _markSyncedWithParent(): void;
  101235. /** @hidden */
  101236. isSynchronizedWithParent(): boolean;
  101237. /** @hidden */
  101238. isSynchronized(): boolean;
  101239. /**
  101240. * Is this node ready to be used/rendered
  101241. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101242. * @return true if the node is ready
  101243. */
  101244. isReady(completeCheck?: boolean): boolean;
  101245. /**
  101246. * Is this node enabled?
  101247. * 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
  101248. * @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
  101249. * @return whether this node (and its parent) is enabled
  101250. */
  101251. isEnabled(checkAncestors?: boolean): boolean;
  101252. /** @hidden */
  101253. protected _syncParentEnabledState(): void;
  101254. /**
  101255. * Set the enabled state of this node
  101256. * @param value defines the new enabled state
  101257. */
  101258. setEnabled(value: boolean): void;
  101259. /**
  101260. * Is this node a descendant of the given node?
  101261. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  101262. * @param ancestor defines the parent node to inspect
  101263. * @returns a boolean indicating if this node is a descendant of the given node
  101264. */
  101265. isDescendantOf(ancestor: Node): boolean;
  101266. /** @hidden */
  101267. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  101268. /**
  101269. * Will return all nodes that have this node as ascendant
  101270. * @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
  101271. * @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
  101272. * @return all children nodes of all types
  101273. */
  101274. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  101275. /**
  101276. * Get all child-meshes of this node
  101277. * @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)
  101278. * @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
  101279. * @returns an array of AbstractMesh
  101280. */
  101281. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  101282. /**
  101283. * Get all direct children of this node
  101284. * @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
  101285. * @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)
  101286. * @returns an array of Node
  101287. */
  101288. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  101289. /** @hidden */
  101290. _setReady(state: boolean): void;
  101291. /**
  101292. * Get an animation by name
  101293. * @param name defines the name of the animation to look for
  101294. * @returns null if not found else the requested animation
  101295. */
  101296. getAnimationByName(name: string): Nullable<Animation>;
  101297. /**
  101298. * Creates an animation range for this node
  101299. * @param name defines the name of the range
  101300. * @param from defines the starting key
  101301. * @param to defines the end key
  101302. */
  101303. createAnimationRange(name: string, from: number, to: number): void;
  101304. /**
  101305. * Delete a specific animation range
  101306. * @param name defines the name of the range to delete
  101307. * @param deleteFrames defines if animation frames from the range must be deleted as well
  101308. */
  101309. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  101310. /**
  101311. * Get an animation range by name
  101312. * @param name defines the name of the animation range to look for
  101313. * @returns null if not found else the requested animation range
  101314. */
  101315. getAnimationRange(name: string): Nullable<AnimationRange>;
  101316. /**
  101317. * Gets the list of all animation ranges defined on this node
  101318. * @returns an array
  101319. */
  101320. getAnimationRanges(): Nullable<AnimationRange>[];
  101321. /**
  101322. * Will start the animation sequence
  101323. * @param name defines the range frames for animation sequence
  101324. * @param loop defines if the animation should loop (false by default)
  101325. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  101326. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  101327. * @returns the object created for this animation. If range does not exist, it will return null
  101328. */
  101329. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  101330. /**
  101331. * Serialize animation ranges into a JSON compatible object
  101332. * @returns serialization object
  101333. */
  101334. serializeAnimationRanges(): any;
  101335. /**
  101336. * Computes the world matrix of the node
  101337. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101338. * @returns the world matrix
  101339. */
  101340. computeWorldMatrix(force?: boolean): Matrix;
  101341. /**
  101342. * Releases resources associated with this node.
  101343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101345. */
  101346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101347. /**
  101348. * Parse animation range data from a serialization object and store them into a given node
  101349. * @param node defines where to store the animation ranges
  101350. * @param parsedNode defines the serialization object to read data from
  101351. * @param scene defines the hosting scene
  101352. */
  101353. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  101354. /**
  101355. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  101356. * @param includeDescendants Include bounding info from descendants as well (true by default)
  101357. * @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
  101358. * @returns the new bounding vectors
  101359. */
  101360. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  101361. min: Vector3;
  101362. max: Vector3;
  101363. };
  101364. }
  101365. }
  101366. declare module BABYLON {
  101367. /**
  101368. * @hidden
  101369. */
  101370. export class _IAnimationState {
  101371. key: number;
  101372. repeatCount: number;
  101373. workValue?: any;
  101374. loopMode?: number;
  101375. offsetValue?: any;
  101376. highLimitValue?: any;
  101377. }
  101378. /**
  101379. * Class used to store any kind of animation
  101380. */
  101381. export class Animation {
  101382. /**Name of the animation */
  101383. name: string;
  101384. /**Property to animate */
  101385. targetProperty: string;
  101386. /**The frames per second of the animation */
  101387. framePerSecond: number;
  101388. /**The data type of the animation */
  101389. dataType: number;
  101390. /**The loop mode of the animation */
  101391. loopMode?: number | undefined;
  101392. /**Specifies if blending should be enabled */
  101393. enableBlending?: boolean | undefined;
  101394. /**
  101395. * Use matrix interpolation instead of using direct key value when animating matrices
  101396. */
  101397. static AllowMatricesInterpolation: boolean;
  101398. /**
  101399. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  101400. */
  101401. static AllowMatrixDecomposeForInterpolation: boolean;
  101402. /**
  101403. * Stores the key frames of the animation
  101404. */
  101405. private _keys;
  101406. /**
  101407. * Stores the easing function of the animation
  101408. */
  101409. private _easingFunction;
  101410. /**
  101411. * @hidden Internal use only
  101412. */
  101413. _runtimeAnimations: RuntimeAnimation[];
  101414. /**
  101415. * The set of event that will be linked to this animation
  101416. */
  101417. private _events;
  101418. /**
  101419. * Stores an array of target property paths
  101420. */
  101421. targetPropertyPath: string[];
  101422. /**
  101423. * Stores the blending speed of the animation
  101424. */
  101425. blendingSpeed: number;
  101426. /**
  101427. * Stores the animation ranges for the animation
  101428. */
  101429. private _ranges;
  101430. /**
  101431. * @hidden Internal use
  101432. */
  101433. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  101434. /**
  101435. * Sets up an animation
  101436. * @param property The property to animate
  101437. * @param animationType The animation type to apply
  101438. * @param framePerSecond The frames per second of the animation
  101439. * @param easingFunction The easing function used in the animation
  101440. * @returns The created animation
  101441. */
  101442. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  101443. /**
  101444. * Create and start an animation on a node
  101445. * @param name defines the name of the global animation that will be run on all nodes
  101446. * @param node defines the root node where the animation will take place
  101447. * @param targetProperty defines property to animate
  101448. * @param framePerSecond defines the number of frame per second yo use
  101449. * @param totalFrame defines the number of frames in total
  101450. * @param from defines the initial value
  101451. * @param to defines the final value
  101452. * @param loopMode defines which loop mode you want to use (off by default)
  101453. * @param easingFunction defines the easing function to use (linear by default)
  101454. * @param onAnimationEnd defines the callback to call when animation end
  101455. * @returns the animatable created for this animation
  101456. */
  101457. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101458. /**
  101459. * Create and start an animation on a node and its descendants
  101460. * @param name defines the name of the global animation that will be run on all nodes
  101461. * @param node defines the root node where the animation will take place
  101462. * @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
  101463. * @param targetProperty defines property to animate
  101464. * @param framePerSecond defines the number of frame per second to use
  101465. * @param totalFrame defines the number of frames in total
  101466. * @param from defines the initial value
  101467. * @param to defines the final value
  101468. * @param loopMode defines which loop mode you want to use (off by default)
  101469. * @param easingFunction defines the easing function to use (linear by default)
  101470. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  101471. * @returns the list of animatables created for all nodes
  101472. * @example https://www.babylonjs-playground.com/#MH0VLI
  101473. */
  101474. 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[]>;
  101475. /**
  101476. * Creates a new animation, merges it with the existing animations and starts it
  101477. * @param name Name of the animation
  101478. * @param node Node which contains the scene that begins the animations
  101479. * @param targetProperty Specifies which property to animate
  101480. * @param framePerSecond The frames per second of the animation
  101481. * @param totalFrame The total number of frames
  101482. * @param from The frame at the beginning of the animation
  101483. * @param to The frame at the end of the animation
  101484. * @param loopMode Specifies the loop mode of the animation
  101485. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  101486. * @param onAnimationEnd Callback to run once the animation is complete
  101487. * @returns Nullable animation
  101488. */
  101489. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101490. /**
  101491. * Transition property of an host to the target Value
  101492. * @param property The property to transition
  101493. * @param targetValue The target Value of the property
  101494. * @param host The object where the property to animate belongs
  101495. * @param scene Scene used to run the animation
  101496. * @param frameRate Framerate (in frame/s) to use
  101497. * @param transition The transition type we want to use
  101498. * @param duration The duration of the animation, in milliseconds
  101499. * @param onAnimationEnd Callback trigger at the end of the animation
  101500. * @returns Nullable animation
  101501. */
  101502. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  101503. /**
  101504. * Return the array of runtime animations currently using this animation
  101505. */
  101506. get runtimeAnimations(): RuntimeAnimation[];
  101507. /**
  101508. * Specifies if any of the runtime animations are currently running
  101509. */
  101510. get hasRunningRuntimeAnimations(): boolean;
  101511. /**
  101512. * Initializes the animation
  101513. * @param name Name of the animation
  101514. * @param targetProperty Property to animate
  101515. * @param framePerSecond The frames per second of the animation
  101516. * @param dataType The data type of the animation
  101517. * @param loopMode The loop mode of the animation
  101518. * @param enableBlending Specifies if blending should be enabled
  101519. */
  101520. constructor(
  101521. /**Name of the animation */
  101522. name: string,
  101523. /**Property to animate */
  101524. targetProperty: string,
  101525. /**The frames per second of the animation */
  101526. framePerSecond: number,
  101527. /**The data type of the animation */
  101528. dataType: number,
  101529. /**The loop mode of the animation */
  101530. loopMode?: number | undefined,
  101531. /**Specifies if blending should be enabled */
  101532. enableBlending?: boolean | undefined);
  101533. /**
  101534. * Converts the animation to a string
  101535. * @param fullDetails support for multiple levels of logging within scene loading
  101536. * @returns String form of the animation
  101537. */
  101538. toString(fullDetails?: boolean): string;
  101539. /**
  101540. * Add an event to this animation
  101541. * @param event Event to add
  101542. */
  101543. addEvent(event: AnimationEvent): void;
  101544. /**
  101545. * Remove all events found at the given frame
  101546. * @param frame The frame to remove events from
  101547. */
  101548. removeEvents(frame: number): void;
  101549. /**
  101550. * Retrieves all the events from the animation
  101551. * @returns Events from the animation
  101552. */
  101553. getEvents(): AnimationEvent[];
  101554. /**
  101555. * Creates an animation range
  101556. * @param name Name of the animation range
  101557. * @param from Starting frame of the animation range
  101558. * @param to Ending frame of the animation
  101559. */
  101560. createRange(name: string, from: number, to: number): void;
  101561. /**
  101562. * Deletes an animation range by name
  101563. * @param name Name of the animation range to delete
  101564. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  101565. */
  101566. deleteRange(name: string, deleteFrames?: boolean): void;
  101567. /**
  101568. * Gets the animation range by name, or null if not defined
  101569. * @param name Name of the animation range
  101570. * @returns Nullable animation range
  101571. */
  101572. getRange(name: string): Nullable<AnimationRange>;
  101573. /**
  101574. * Gets the key frames from the animation
  101575. * @returns The key frames of the animation
  101576. */
  101577. getKeys(): Array<IAnimationKey>;
  101578. /**
  101579. * Gets the highest frame rate of the animation
  101580. * @returns Highest frame rate of the animation
  101581. */
  101582. getHighestFrame(): number;
  101583. /**
  101584. * Gets the easing function of the animation
  101585. * @returns Easing function of the animation
  101586. */
  101587. getEasingFunction(): IEasingFunction;
  101588. /**
  101589. * Sets the easing function of the animation
  101590. * @param easingFunction A custom mathematical formula for animation
  101591. */
  101592. setEasingFunction(easingFunction: EasingFunction): void;
  101593. /**
  101594. * Interpolates a scalar linearly
  101595. * @param startValue Start value of the animation curve
  101596. * @param endValue End value of the animation curve
  101597. * @param gradient Scalar amount to interpolate
  101598. * @returns Interpolated scalar value
  101599. */
  101600. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  101601. /**
  101602. * Interpolates a scalar cubically
  101603. * @param startValue Start value of the animation curve
  101604. * @param outTangent End tangent of the animation
  101605. * @param endValue End value of the animation curve
  101606. * @param inTangent Start tangent of the animation curve
  101607. * @param gradient Scalar amount to interpolate
  101608. * @returns Interpolated scalar value
  101609. */
  101610. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  101611. /**
  101612. * Interpolates a quaternion using a spherical linear interpolation
  101613. * @param startValue Start value of the animation curve
  101614. * @param endValue End value of the animation curve
  101615. * @param gradient Scalar amount to interpolate
  101616. * @returns Interpolated quaternion value
  101617. */
  101618. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  101619. /**
  101620. * Interpolates a quaternion cubically
  101621. * @param startValue Start value of the animation curve
  101622. * @param outTangent End tangent of the animation curve
  101623. * @param endValue End value of the animation curve
  101624. * @param inTangent Start tangent of the animation curve
  101625. * @param gradient Scalar amount to interpolate
  101626. * @returns Interpolated quaternion value
  101627. */
  101628. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  101629. /**
  101630. * Interpolates a Vector3 linearl
  101631. * @param startValue Start value of the animation curve
  101632. * @param endValue End value of the animation curve
  101633. * @param gradient Scalar amount to interpolate
  101634. * @returns Interpolated scalar value
  101635. */
  101636. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  101637. /**
  101638. * Interpolates a Vector3 cubically
  101639. * @param startValue Start value of the animation curve
  101640. * @param outTangent End tangent of the animation
  101641. * @param endValue End value of the animation curve
  101642. * @param inTangent Start tangent of the animation curve
  101643. * @param gradient Scalar amount to interpolate
  101644. * @returns InterpolatedVector3 value
  101645. */
  101646. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  101647. /**
  101648. * Interpolates a Vector2 linearly
  101649. * @param startValue Start value of the animation curve
  101650. * @param endValue End value of the animation curve
  101651. * @param gradient Scalar amount to interpolate
  101652. * @returns Interpolated Vector2 value
  101653. */
  101654. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  101655. /**
  101656. * Interpolates a Vector2 cubically
  101657. * @param startValue Start value of the animation curve
  101658. * @param outTangent End tangent of the animation
  101659. * @param endValue End value of the animation curve
  101660. * @param inTangent Start tangent of the animation curve
  101661. * @param gradient Scalar amount to interpolate
  101662. * @returns Interpolated Vector2 value
  101663. */
  101664. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  101665. /**
  101666. * Interpolates a size linearly
  101667. * @param startValue Start value of the animation curve
  101668. * @param endValue End value of the animation curve
  101669. * @param gradient Scalar amount to interpolate
  101670. * @returns Interpolated Size value
  101671. */
  101672. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  101673. /**
  101674. * Interpolates a Color3 linearly
  101675. * @param startValue Start value of the animation curve
  101676. * @param endValue End value of the animation curve
  101677. * @param gradient Scalar amount to interpolate
  101678. * @returns Interpolated Color3 value
  101679. */
  101680. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  101681. /**
  101682. * Interpolates a Color4 linearly
  101683. * @param startValue Start value of the animation curve
  101684. * @param endValue End value of the animation curve
  101685. * @param gradient Scalar amount to interpolate
  101686. * @returns Interpolated Color3 value
  101687. */
  101688. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  101689. /**
  101690. * @hidden Internal use only
  101691. */
  101692. _getKeyValue(value: any): any;
  101693. /**
  101694. * @hidden Internal use only
  101695. */
  101696. _interpolate(currentFrame: number, state: _IAnimationState): any;
  101697. /**
  101698. * Defines the function to use to interpolate matrices
  101699. * @param startValue defines the start matrix
  101700. * @param endValue defines the end matrix
  101701. * @param gradient defines the gradient between both matrices
  101702. * @param result defines an optional target matrix where to store the interpolation
  101703. * @returns the interpolated matrix
  101704. */
  101705. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  101706. /**
  101707. * Makes a copy of the animation
  101708. * @returns Cloned animation
  101709. */
  101710. clone(): Animation;
  101711. /**
  101712. * Sets the key frames of the animation
  101713. * @param values The animation key frames to set
  101714. */
  101715. setKeys(values: Array<IAnimationKey>): void;
  101716. /**
  101717. * Serializes the animation to an object
  101718. * @returns Serialized object
  101719. */
  101720. serialize(): any;
  101721. /**
  101722. * Float animation type
  101723. */
  101724. static readonly ANIMATIONTYPE_FLOAT: number;
  101725. /**
  101726. * Vector3 animation type
  101727. */
  101728. static readonly ANIMATIONTYPE_VECTOR3: number;
  101729. /**
  101730. * Quaternion animation type
  101731. */
  101732. static readonly ANIMATIONTYPE_QUATERNION: number;
  101733. /**
  101734. * Matrix animation type
  101735. */
  101736. static readonly ANIMATIONTYPE_MATRIX: number;
  101737. /**
  101738. * Color3 animation type
  101739. */
  101740. static readonly ANIMATIONTYPE_COLOR3: number;
  101741. /**
  101742. * Color3 animation type
  101743. */
  101744. static readonly ANIMATIONTYPE_COLOR4: number;
  101745. /**
  101746. * Vector2 animation type
  101747. */
  101748. static readonly ANIMATIONTYPE_VECTOR2: number;
  101749. /**
  101750. * Size animation type
  101751. */
  101752. static readonly ANIMATIONTYPE_SIZE: number;
  101753. /**
  101754. * Relative Loop Mode
  101755. */
  101756. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  101757. /**
  101758. * Cycle Loop Mode
  101759. */
  101760. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  101761. /**
  101762. * Constant Loop Mode
  101763. */
  101764. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  101765. /** @hidden */
  101766. static _UniversalLerp(left: any, right: any, amount: number): any;
  101767. /**
  101768. * Parses an animation object and creates an animation
  101769. * @param parsedAnimation Parsed animation object
  101770. * @returns Animation object
  101771. */
  101772. static Parse(parsedAnimation: any): Animation;
  101773. /**
  101774. * Appends the serialized animations from the source animations
  101775. * @param source Source containing the animations
  101776. * @param destination Target to store the animations
  101777. */
  101778. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  101779. }
  101780. }
  101781. declare module BABYLON {
  101782. /**
  101783. * Interface containing an array of animations
  101784. */
  101785. export interface IAnimatable {
  101786. /**
  101787. * Array of animations
  101788. */
  101789. animations: Nullable<Array<Animation>>;
  101790. }
  101791. }
  101792. declare module BABYLON {
  101793. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  101794. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101795. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101796. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101797. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101798. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101799. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101800. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101801. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101802. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101803. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101804. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101805. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101806. /**
  101807. * Decorator used to define property that can be serialized as reference to a camera
  101808. * @param sourceName defines the name of the property to decorate
  101809. */
  101810. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101811. /**
  101812. * Class used to help serialization objects
  101813. */
  101814. export class SerializationHelper {
  101815. /** @hidden */
  101816. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  101817. /** @hidden */
  101818. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  101819. /** @hidden */
  101820. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  101821. /** @hidden */
  101822. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  101823. /**
  101824. * Appends the serialized animations from the source animations
  101825. * @param source Source containing the animations
  101826. * @param destination Target to store the animations
  101827. */
  101828. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  101829. /**
  101830. * Static function used to serialized a specific entity
  101831. * @param entity defines the entity to serialize
  101832. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  101833. * @returns a JSON compatible object representing the serialization of the entity
  101834. */
  101835. static Serialize<T>(entity: T, serializationObject?: any): any;
  101836. /**
  101837. * Creates a new entity from a serialization data object
  101838. * @param creationFunction defines a function used to instanciated the new entity
  101839. * @param source defines the source serialization data
  101840. * @param scene defines the hosting scene
  101841. * @param rootUrl defines the root url for resources
  101842. * @returns a new entity
  101843. */
  101844. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  101845. /**
  101846. * Clones an object
  101847. * @param creationFunction defines the function used to instanciate the new object
  101848. * @param source defines the source object
  101849. * @returns the cloned object
  101850. */
  101851. static Clone<T>(creationFunction: () => T, source: T): T;
  101852. /**
  101853. * Instanciates a new object based on a source one (some data will be shared between both object)
  101854. * @param creationFunction defines the function used to instanciate the new object
  101855. * @param source defines the source object
  101856. * @returns the new object
  101857. */
  101858. static Instanciate<T>(creationFunction: () => T, source: T): T;
  101859. }
  101860. }
  101861. declare module BABYLON {
  101862. /**
  101863. * Class used to manipulate GUIDs
  101864. */
  101865. export class GUID {
  101866. /**
  101867. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101868. * Be aware Math.random() could cause collisions, but:
  101869. * "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"
  101870. * @returns a pseudo random id
  101871. */
  101872. static RandomId(): string;
  101873. }
  101874. }
  101875. declare module BABYLON {
  101876. /**
  101877. * Base class of all the textures in babylon.
  101878. * It groups all the common properties the materials, post process, lights... might need
  101879. * in order to make a correct use of the texture.
  101880. */
  101881. export class BaseTexture implements IAnimatable {
  101882. /**
  101883. * Default anisotropic filtering level for the application.
  101884. * It is set to 4 as a good tradeoff between perf and quality.
  101885. */
  101886. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  101887. /**
  101888. * Gets or sets the unique id of the texture
  101889. */
  101890. uniqueId: number;
  101891. /**
  101892. * Define the name of the texture.
  101893. */
  101894. name: string;
  101895. /**
  101896. * Gets or sets an object used to store user defined information.
  101897. */
  101898. metadata: any;
  101899. /**
  101900. * For internal use only. Please do not use.
  101901. */
  101902. reservedDataStore: any;
  101903. private _hasAlpha;
  101904. /**
  101905. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  101906. */
  101907. set hasAlpha(value: boolean);
  101908. get hasAlpha(): boolean;
  101909. /**
  101910. * Defines if the alpha value should be determined via the rgb values.
  101911. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  101912. */
  101913. getAlphaFromRGB: boolean;
  101914. /**
  101915. * Intensity or strength of the texture.
  101916. * It is commonly used by materials to fine tune the intensity of the texture
  101917. */
  101918. level: number;
  101919. /**
  101920. * Define the UV chanel to use starting from 0 and defaulting to 0.
  101921. * This is part of the texture as textures usually maps to one uv set.
  101922. */
  101923. coordinatesIndex: number;
  101924. private _coordinatesMode;
  101925. /**
  101926. * How a texture is mapped.
  101927. *
  101928. * | Value | Type | Description |
  101929. * | ----- | ----------------------------------- | ----------- |
  101930. * | 0 | EXPLICIT_MODE | |
  101931. * | 1 | SPHERICAL_MODE | |
  101932. * | 2 | PLANAR_MODE | |
  101933. * | 3 | CUBIC_MODE | |
  101934. * | 4 | PROJECTION_MODE | |
  101935. * | 5 | SKYBOX_MODE | |
  101936. * | 6 | INVCUBIC_MODE | |
  101937. * | 7 | EQUIRECTANGULAR_MODE | |
  101938. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  101939. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  101940. */
  101941. set coordinatesMode(value: number);
  101942. get coordinatesMode(): number;
  101943. /**
  101944. * | Value | Type | Description |
  101945. * | ----- | ------------------ | ----------- |
  101946. * | 0 | CLAMP_ADDRESSMODE | |
  101947. * | 1 | WRAP_ADDRESSMODE | |
  101948. * | 2 | MIRROR_ADDRESSMODE | |
  101949. */
  101950. wrapU: number;
  101951. /**
  101952. * | Value | Type | Description |
  101953. * | ----- | ------------------ | ----------- |
  101954. * | 0 | CLAMP_ADDRESSMODE | |
  101955. * | 1 | WRAP_ADDRESSMODE | |
  101956. * | 2 | MIRROR_ADDRESSMODE | |
  101957. */
  101958. wrapV: number;
  101959. /**
  101960. * | Value | Type | Description |
  101961. * | ----- | ------------------ | ----------- |
  101962. * | 0 | CLAMP_ADDRESSMODE | |
  101963. * | 1 | WRAP_ADDRESSMODE | |
  101964. * | 2 | MIRROR_ADDRESSMODE | |
  101965. */
  101966. wrapR: number;
  101967. /**
  101968. * With compliant hardware and browser (supporting anisotropic filtering)
  101969. * this defines the level of anisotropic filtering in the texture.
  101970. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  101971. */
  101972. anisotropicFilteringLevel: number;
  101973. /**
  101974. * Define if the texture is a cube texture or if false a 2d texture.
  101975. */
  101976. get isCube(): boolean;
  101977. set isCube(value: boolean);
  101978. /**
  101979. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  101980. */
  101981. get is3D(): boolean;
  101982. set is3D(value: boolean);
  101983. /**
  101984. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  101985. */
  101986. get is2DArray(): boolean;
  101987. set is2DArray(value: boolean);
  101988. /**
  101989. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  101990. * HDR texture are usually stored in linear space.
  101991. * This only impacts the PBR and Background materials
  101992. */
  101993. gammaSpace: boolean;
  101994. /**
  101995. * Gets or sets whether or not the texture contains RGBD data.
  101996. */
  101997. get isRGBD(): boolean;
  101998. set isRGBD(value: boolean);
  101999. /**
  102000. * Is Z inverted in the texture (useful in a cube texture).
  102001. */
  102002. invertZ: boolean;
  102003. /**
  102004. * Are mip maps generated for this texture or not.
  102005. */
  102006. get noMipmap(): boolean;
  102007. /**
  102008. * @hidden
  102009. */
  102010. lodLevelInAlpha: boolean;
  102011. /**
  102012. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102013. */
  102014. get lodGenerationOffset(): number;
  102015. set lodGenerationOffset(value: number);
  102016. /**
  102017. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102018. */
  102019. get lodGenerationScale(): number;
  102020. set lodGenerationScale(value: number);
  102021. /**
  102022. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102023. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102024. * average roughness values.
  102025. */
  102026. get linearSpecularLOD(): boolean;
  102027. set linearSpecularLOD(value: boolean);
  102028. /**
  102029. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102030. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102031. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102032. */
  102033. get irradianceTexture(): Nullable<BaseTexture>;
  102034. set irradianceTexture(value: Nullable<BaseTexture>);
  102035. /**
  102036. * Define if the texture is a render target.
  102037. */
  102038. isRenderTarget: boolean;
  102039. /**
  102040. * Define the unique id of the texture in the scene.
  102041. */
  102042. get uid(): string;
  102043. /**
  102044. * Return a string representation of the texture.
  102045. * @returns the texture as a string
  102046. */
  102047. toString(): string;
  102048. /**
  102049. * Get the class name of the texture.
  102050. * @returns "BaseTexture"
  102051. */
  102052. getClassName(): string;
  102053. /**
  102054. * Define the list of animation attached to the texture.
  102055. */
  102056. animations: Animation[];
  102057. /**
  102058. * An event triggered when the texture is disposed.
  102059. */
  102060. onDisposeObservable: Observable<BaseTexture>;
  102061. private _onDisposeObserver;
  102062. /**
  102063. * Callback triggered when the texture has been disposed.
  102064. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102065. */
  102066. set onDispose(callback: () => void);
  102067. /**
  102068. * Define the current state of the loading sequence when in delayed load mode.
  102069. */
  102070. delayLoadState: number;
  102071. private _scene;
  102072. /** @hidden */
  102073. _texture: Nullable<InternalTexture>;
  102074. private _uid;
  102075. /**
  102076. * Define if the texture is preventinga material to render or not.
  102077. * If not and the texture is not ready, the engine will use a default black texture instead.
  102078. */
  102079. get isBlocking(): boolean;
  102080. /**
  102081. * Instantiates a new BaseTexture.
  102082. * Base class of all the textures in babylon.
  102083. * It groups all the common properties the materials, post process, lights... might need
  102084. * in order to make a correct use of the texture.
  102085. * @param scene Define the scene the texture blongs to
  102086. */
  102087. constructor(scene: Nullable<Scene>);
  102088. /**
  102089. * Get the scene the texture belongs to.
  102090. * @returns the scene or null if undefined
  102091. */
  102092. getScene(): Nullable<Scene>;
  102093. /**
  102094. * Get the texture transform matrix used to offset tile the texture for istance.
  102095. * @returns the transformation matrix
  102096. */
  102097. getTextureMatrix(): Matrix;
  102098. /**
  102099. * Get the texture reflection matrix used to rotate/transform the reflection.
  102100. * @returns the reflection matrix
  102101. */
  102102. getReflectionTextureMatrix(): Matrix;
  102103. /**
  102104. * Get the underlying lower level texture from Babylon.
  102105. * @returns the insternal texture
  102106. */
  102107. getInternalTexture(): Nullable<InternalTexture>;
  102108. /**
  102109. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  102110. * @returns true if ready or not blocking
  102111. */
  102112. isReadyOrNotBlocking(): boolean;
  102113. /**
  102114. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  102115. * @returns true if fully ready
  102116. */
  102117. isReady(): boolean;
  102118. private _cachedSize;
  102119. /**
  102120. * Get the size of the texture.
  102121. * @returns the texture size.
  102122. */
  102123. getSize(): ISize;
  102124. /**
  102125. * Get the base size of the texture.
  102126. * It can be different from the size if the texture has been resized for POT for instance
  102127. * @returns the base size
  102128. */
  102129. getBaseSize(): ISize;
  102130. /**
  102131. * Update the sampling mode of the texture.
  102132. * Default is Trilinear mode.
  102133. *
  102134. * | Value | Type | Description |
  102135. * | ----- | ------------------ | ----------- |
  102136. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  102137. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  102138. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  102139. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  102140. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  102141. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  102142. * | 7 | NEAREST_LINEAR | |
  102143. * | 8 | NEAREST_NEAREST | |
  102144. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  102145. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  102146. * | 11 | LINEAR_LINEAR | |
  102147. * | 12 | LINEAR_NEAREST | |
  102148. *
  102149. * > _mag_: magnification filter (close to the viewer)
  102150. * > _min_: minification filter (far from the viewer)
  102151. * > _mip_: filter used between mip map levels
  102152. *@param samplingMode Define the new sampling mode of the texture
  102153. */
  102154. updateSamplingMode(samplingMode: number): void;
  102155. /**
  102156. * Scales the texture if is `canRescale()`
  102157. * @param ratio the resize factor we want to use to rescale
  102158. */
  102159. scale(ratio: number): void;
  102160. /**
  102161. * Get if the texture can rescale.
  102162. */
  102163. get canRescale(): boolean;
  102164. /** @hidden */
  102165. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  102166. /** @hidden */
  102167. _rebuild(): void;
  102168. /**
  102169. * Triggers the load sequence in delayed load mode.
  102170. */
  102171. delayLoad(): void;
  102172. /**
  102173. * Clones the texture.
  102174. * @returns the cloned texture
  102175. */
  102176. clone(): Nullable<BaseTexture>;
  102177. /**
  102178. * Get the texture underlying type (INT, FLOAT...)
  102179. */
  102180. get textureType(): number;
  102181. /**
  102182. * Get the texture underlying format (RGB, RGBA...)
  102183. */
  102184. get textureFormat(): number;
  102185. /**
  102186. * Indicates that textures need to be re-calculated for all materials
  102187. */
  102188. protected _markAllSubMeshesAsTexturesDirty(): void;
  102189. /**
  102190. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  102191. * This will returns an RGBA array buffer containing either in values (0-255) or
  102192. * float values (0-1) depending of the underlying buffer type.
  102193. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  102194. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  102195. * @param buffer defines a user defined buffer to fill with data (can be null)
  102196. * @returns The Array buffer containing the pixels data.
  102197. */
  102198. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  102199. /**
  102200. * Release and destroy the underlying lower level texture aka internalTexture.
  102201. */
  102202. releaseInternalTexture(): void;
  102203. /** @hidden */
  102204. get _lodTextureHigh(): Nullable<BaseTexture>;
  102205. /** @hidden */
  102206. get _lodTextureMid(): Nullable<BaseTexture>;
  102207. /** @hidden */
  102208. get _lodTextureLow(): Nullable<BaseTexture>;
  102209. /**
  102210. * Dispose the texture and release its associated resources.
  102211. */
  102212. dispose(): void;
  102213. /**
  102214. * Serialize the texture into a JSON representation that can be parsed later on.
  102215. * @returns the JSON representation of the texture
  102216. */
  102217. serialize(): any;
  102218. /**
  102219. * Helper function to be called back once a list of texture contains only ready textures.
  102220. * @param textures Define the list of textures to wait for
  102221. * @param callback Define the callback triggered once the entire list will be ready
  102222. */
  102223. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  102224. }
  102225. }
  102226. declare module BABYLON {
  102227. /**
  102228. * Options to be used when creating an effect.
  102229. */
  102230. export interface IEffectCreationOptions {
  102231. /**
  102232. * Atrributes that will be used in the shader.
  102233. */
  102234. attributes: string[];
  102235. /**
  102236. * Uniform varible names that will be set in the shader.
  102237. */
  102238. uniformsNames: string[];
  102239. /**
  102240. * Uniform buffer variable names that will be set in the shader.
  102241. */
  102242. uniformBuffersNames: string[];
  102243. /**
  102244. * Sampler texture variable names that will be set in the shader.
  102245. */
  102246. samplers: string[];
  102247. /**
  102248. * Define statements that will be set in the shader.
  102249. */
  102250. defines: any;
  102251. /**
  102252. * Possible fallbacks for this effect to improve performance when needed.
  102253. */
  102254. fallbacks: Nullable<IEffectFallbacks>;
  102255. /**
  102256. * Callback that will be called when the shader is compiled.
  102257. */
  102258. onCompiled: Nullable<(effect: Effect) => void>;
  102259. /**
  102260. * Callback that will be called if an error occurs during shader compilation.
  102261. */
  102262. onError: Nullable<(effect: Effect, errors: string) => void>;
  102263. /**
  102264. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102265. */
  102266. indexParameters?: any;
  102267. /**
  102268. * Max number of lights that can be used in the shader.
  102269. */
  102270. maxSimultaneousLights?: number;
  102271. /**
  102272. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  102273. */
  102274. transformFeedbackVaryings?: Nullable<string[]>;
  102275. }
  102276. /**
  102277. * Effect containing vertex and fragment shader that can be executed on an object.
  102278. */
  102279. export class Effect implements IDisposable {
  102280. /**
  102281. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102282. */
  102283. static ShadersRepository: string;
  102284. /**
  102285. * Name of the effect.
  102286. */
  102287. name: any;
  102288. /**
  102289. * String container all the define statements that should be set on the shader.
  102290. */
  102291. defines: string;
  102292. /**
  102293. * Callback that will be called when the shader is compiled.
  102294. */
  102295. onCompiled: Nullable<(effect: Effect) => void>;
  102296. /**
  102297. * Callback that will be called if an error occurs during shader compilation.
  102298. */
  102299. onError: Nullable<(effect: Effect, errors: string) => void>;
  102300. /**
  102301. * Callback that will be called when effect is bound.
  102302. */
  102303. onBind: Nullable<(effect: Effect) => void>;
  102304. /**
  102305. * Unique ID of the effect.
  102306. */
  102307. uniqueId: number;
  102308. /**
  102309. * Observable that will be called when the shader is compiled.
  102310. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  102311. */
  102312. onCompileObservable: Observable<Effect>;
  102313. /**
  102314. * Observable that will be called if an error occurs during shader compilation.
  102315. */
  102316. onErrorObservable: Observable<Effect>;
  102317. /** @hidden */
  102318. _onBindObservable: Nullable<Observable<Effect>>;
  102319. /**
  102320. * @hidden
  102321. * Specifies if the effect was previously ready
  102322. */
  102323. _wasPreviouslyReady: boolean;
  102324. /**
  102325. * Observable that will be called when effect is bound.
  102326. */
  102327. get onBindObservable(): Observable<Effect>;
  102328. /** @hidden */
  102329. _bonesComputationForcedToCPU: boolean;
  102330. private static _uniqueIdSeed;
  102331. private _engine;
  102332. private _uniformBuffersNames;
  102333. private _uniformsNames;
  102334. private _samplerList;
  102335. private _samplers;
  102336. private _isReady;
  102337. private _compilationError;
  102338. private _allFallbacksProcessed;
  102339. private _attributesNames;
  102340. private _attributes;
  102341. private _attributeLocationByName;
  102342. private _uniforms;
  102343. /**
  102344. * Key for the effect.
  102345. * @hidden
  102346. */
  102347. _key: string;
  102348. private _indexParameters;
  102349. private _fallbacks;
  102350. private _vertexSourceCode;
  102351. private _fragmentSourceCode;
  102352. private _vertexSourceCodeOverride;
  102353. private _fragmentSourceCodeOverride;
  102354. private _transformFeedbackVaryings;
  102355. /**
  102356. * Compiled shader to webGL program.
  102357. * @hidden
  102358. */
  102359. _pipelineContext: Nullable<IPipelineContext>;
  102360. private _valueCache;
  102361. private static _baseCache;
  102362. /**
  102363. * Instantiates an effect.
  102364. * An effect can be used to create/manage/execute vertex and fragment shaders.
  102365. * @param baseName Name of the effect.
  102366. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  102367. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  102368. * @param samplers List of sampler variables that will be passed to the shader.
  102369. * @param engine Engine to be used to render the effect
  102370. * @param defines Define statements to be added to the shader.
  102371. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  102372. * @param onCompiled Callback that will be called when the shader is compiled.
  102373. * @param onError Callback that will be called if an error occurs during shader compilation.
  102374. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102375. */
  102376. 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);
  102377. private _useFinalCode;
  102378. /**
  102379. * Unique key for this effect
  102380. */
  102381. get key(): string;
  102382. /**
  102383. * If the effect has been compiled and prepared.
  102384. * @returns if the effect is compiled and prepared.
  102385. */
  102386. isReady(): boolean;
  102387. private _isReadyInternal;
  102388. /**
  102389. * The engine the effect was initialized with.
  102390. * @returns the engine.
  102391. */
  102392. getEngine(): Engine;
  102393. /**
  102394. * The pipeline context for this effect
  102395. * @returns the associated pipeline context
  102396. */
  102397. getPipelineContext(): Nullable<IPipelineContext>;
  102398. /**
  102399. * The set of names of attribute variables for the shader.
  102400. * @returns An array of attribute names.
  102401. */
  102402. getAttributesNames(): string[];
  102403. /**
  102404. * Returns the attribute at the given index.
  102405. * @param index The index of the attribute.
  102406. * @returns The location of the attribute.
  102407. */
  102408. getAttributeLocation(index: number): number;
  102409. /**
  102410. * Returns the attribute based on the name of the variable.
  102411. * @param name of the attribute to look up.
  102412. * @returns the attribute location.
  102413. */
  102414. getAttributeLocationByName(name: string): number;
  102415. /**
  102416. * The number of attributes.
  102417. * @returns the numnber of attributes.
  102418. */
  102419. getAttributesCount(): number;
  102420. /**
  102421. * Gets the index of a uniform variable.
  102422. * @param uniformName of the uniform to look up.
  102423. * @returns the index.
  102424. */
  102425. getUniformIndex(uniformName: string): number;
  102426. /**
  102427. * Returns the attribute based on the name of the variable.
  102428. * @param uniformName of the uniform to look up.
  102429. * @returns the location of the uniform.
  102430. */
  102431. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  102432. /**
  102433. * Returns an array of sampler variable names
  102434. * @returns The array of sampler variable neames.
  102435. */
  102436. getSamplers(): string[];
  102437. /**
  102438. * The error from the last compilation.
  102439. * @returns the error string.
  102440. */
  102441. getCompilationError(): string;
  102442. /**
  102443. * Gets a boolean indicating that all fallbacks were used during compilation
  102444. * @returns true if all fallbacks were used
  102445. */
  102446. allFallbacksProcessed(): boolean;
  102447. /**
  102448. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  102449. * @param func The callback to be used.
  102450. */
  102451. executeWhenCompiled(func: (effect: Effect) => void): void;
  102452. private _checkIsReady;
  102453. private _loadShader;
  102454. /**
  102455. * Recompiles the webGL program
  102456. * @param vertexSourceCode The source code for the vertex shader.
  102457. * @param fragmentSourceCode The source code for the fragment shader.
  102458. * @param onCompiled Callback called when completed.
  102459. * @param onError Callback called on error.
  102460. * @hidden
  102461. */
  102462. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  102463. /**
  102464. * Prepares the effect
  102465. * @hidden
  102466. */
  102467. _prepareEffect(): void;
  102468. private _processCompilationErrors;
  102469. /**
  102470. * Checks if the effect is supported. (Must be called after compilation)
  102471. */
  102472. get isSupported(): boolean;
  102473. /**
  102474. * Binds a texture to the engine to be used as output of the shader.
  102475. * @param channel Name of the output variable.
  102476. * @param texture Texture to bind.
  102477. * @hidden
  102478. */
  102479. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  102480. /**
  102481. * Sets a texture on the engine to be used in the shader.
  102482. * @param channel Name of the sampler variable.
  102483. * @param texture Texture to set.
  102484. */
  102485. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  102486. /**
  102487. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  102488. * @param channel Name of the sampler variable.
  102489. * @param texture Texture to set.
  102490. */
  102491. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  102492. /**
  102493. * Sets an array of textures on the engine to be used in the shader.
  102494. * @param channel Name of the variable.
  102495. * @param textures Textures to set.
  102496. */
  102497. setTextureArray(channel: string, textures: BaseTexture[]): void;
  102498. /**
  102499. * 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)
  102500. * @param channel Name of the sampler variable.
  102501. * @param postProcess Post process to get the input texture from.
  102502. */
  102503. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  102504. /**
  102505. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  102506. * 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)
  102507. * @param channel Name of the sampler variable.
  102508. * @param postProcess Post process to get the output texture from.
  102509. */
  102510. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  102511. /** @hidden */
  102512. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  102513. /** @hidden */
  102514. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  102515. /** @hidden */
  102516. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  102517. /** @hidden */
  102518. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  102519. /**
  102520. * Binds a buffer to a uniform.
  102521. * @param buffer Buffer to bind.
  102522. * @param name Name of the uniform variable to bind to.
  102523. */
  102524. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  102525. /**
  102526. * Binds block to a uniform.
  102527. * @param blockName Name of the block to bind.
  102528. * @param index Index to bind.
  102529. */
  102530. bindUniformBlock(blockName: string, index: number): void;
  102531. /**
  102532. * Sets an interger value on a uniform variable.
  102533. * @param uniformName Name of the variable.
  102534. * @param value Value to be set.
  102535. * @returns this effect.
  102536. */
  102537. setInt(uniformName: string, value: number): Effect;
  102538. /**
  102539. * Sets an int array on a uniform variable.
  102540. * @param uniformName Name of the variable.
  102541. * @param array array to be set.
  102542. * @returns this effect.
  102543. */
  102544. setIntArray(uniformName: string, array: Int32Array): Effect;
  102545. /**
  102546. * 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)
  102547. * @param uniformName Name of the variable.
  102548. * @param array array to be set.
  102549. * @returns this effect.
  102550. */
  102551. setIntArray2(uniformName: string, array: Int32Array): Effect;
  102552. /**
  102553. * 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)
  102554. * @param uniformName Name of the variable.
  102555. * @param array array to be set.
  102556. * @returns this effect.
  102557. */
  102558. setIntArray3(uniformName: string, array: Int32Array): Effect;
  102559. /**
  102560. * 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)
  102561. * @param uniformName Name of the variable.
  102562. * @param array array to be set.
  102563. * @returns this effect.
  102564. */
  102565. setIntArray4(uniformName: string, array: Int32Array): Effect;
  102566. /**
  102567. * Sets an float array on a uniform variable.
  102568. * @param uniformName Name of the variable.
  102569. * @param array array to be set.
  102570. * @returns this effect.
  102571. */
  102572. setFloatArray(uniformName: string, array: Float32Array): Effect;
  102573. /**
  102574. * 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)
  102575. * @param uniformName Name of the variable.
  102576. * @param array array to be set.
  102577. * @returns this effect.
  102578. */
  102579. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  102580. /**
  102581. * 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)
  102582. * @param uniformName Name of the variable.
  102583. * @param array array to be set.
  102584. * @returns this effect.
  102585. */
  102586. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  102587. /**
  102588. * 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)
  102589. * @param uniformName Name of the variable.
  102590. * @param array array to be set.
  102591. * @returns this effect.
  102592. */
  102593. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  102594. /**
  102595. * Sets an array on a uniform variable.
  102596. * @param uniformName Name of the variable.
  102597. * @param array array to be set.
  102598. * @returns this effect.
  102599. */
  102600. setArray(uniformName: string, array: number[]): Effect;
  102601. /**
  102602. * 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)
  102603. * @param uniformName Name of the variable.
  102604. * @param array array to be set.
  102605. * @returns this effect.
  102606. */
  102607. setArray2(uniformName: string, array: number[]): Effect;
  102608. /**
  102609. * 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)
  102610. * @param uniformName Name of the variable.
  102611. * @param array array to be set.
  102612. * @returns this effect.
  102613. */
  102614. setArray3(uniformName: string, array: number[]): Effect;
  102615. /**
  102616. * 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)
  102617. * @param uniformName Name of the variable.
  102618. * @param array array to be set.
  102619. * @returns this effect.
  102620. */
  102621. setArray4(uniformName: string, array: number[]): Effect;
  102622. /**
  102623. * Sets matrices on a uniform variable.
  102624. * @param uniformName Name of the variable.
  102625. * @param matrices matrices to be set.
  102626. * @returns this effect.
  102627. */
  102628. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  102629. /**
  102630. * Sets matrix on a uniform variable.
  102631. * @param uniformName Name of the variable.
  102632. * @param matrix matrix to be set.
  102633. * @returns this effect.
  102634. */
  102635. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  102636. /**
  102637. * 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)
  102638. * @param uniformName Name of the variable.
  102639. * @param matrix matrix to be set.
  102640. * @returns this effect.
  102641. */
  102642. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  102643. /**
  102644. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  102645. * @param uniformName Name of the variable.
  102646. * @param matrix matrix to be set.
  102647. * @returns this effect.
  102648. */
  102649. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  102650. /**
  102651. * Sets a float on a uniform variable.
  102652. * @param uniformName Name of the variable.
  102653. * @param value value to be set.
  102654. * @returns this effect.
  102655. */
  102656. setFloat(uniformName: string, value: number): Effect;
  102657. /**
  102658. * Sets a boolean on a uniform variable.
  102659. * @param uniformName Name of the variable.
  102660. * @param bool value to be set.
  102661. * @returns this effect.
  102662. */
  102663. setBool(uniformName: string, bool: boolean): Effect;
  102664. /**
  102665. * Sets a Vector2 on a uniform variable.
  102666. * @param uniformName Name of the variable.
  102667. * @param vector2 vector2 to be set.
  102668. * @returns this effect.
  102669. */
  102670. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  102671. /**
  102672. * Sets a float2 on a uniform variable.
  102673. * @param uniformName Name of the variable.
  102674. * @param x First float in float2.
  102675. * @param y Second float in float2.
  102676. * @returns this effect.
  102677. */
  102678. setFloat2(uniformName: string, x: number, y: number): Effect;
  102679. /**
  102680. * Sets a Vector3 on a uniform variable.
  102681. * @param uniformName Name of the variable.
  102682. * @param vector3 Value to be set.
  102683. * @returns this effect.
  102684. */
  102685. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  102686. /**
  102687. * Sets a float3 on a uniform variable.
  102688. * @param uniformName Name of the variable.
  102689. * @param x First float in float3.
  102690. * @param y Second float in float3.
  102691. * @param z Third float in float3.
  102692. * @returns this effect.
  102693. */
  102694. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  102695. /**
  102696. * Sets a Vector4 on a uniform variable.
  102697. * @param uniformName Name of the variable.
  102698. * @param vector4 Value to be set.
  102699. * @returns this effect.
  102700. */
  102701. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  102702. /**
  102703. * Sets a float4 on a uniform variable.
  102704. * @param uniformName Name of the variable.
  102705. * @param x First float in float4.
  102706. * @param y Second float in float4.
  102707. * @param z Third float in float4.
  102708. * @param w Fourth float in float4.
  102709. * @returns this effect.
  102710. */
  102711. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  102712. /**
  102713. * Sets a Color3 on a uniform variable.
  102714. * @param uniformName Name of the variable.
  102715. * @param color3 Value to be set.
  102716. * @returns this effect.
  102717. */
  102718. setColor3(uniformName: string, color3: IColor3Like): Effect;
  102719. /**
  102720. * Sets a Color4 on a uniform variable.
  102721. * @param uniformName Name of the variable.
  102722. * @param color3 Value to be set.
  102723. * @param alpha Alpha value to be set.
  102724. * @returns this effect.
  102725. */
  102726. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  102727. /**
  102728. * Sets a Color4 on a uniform variable
  102729. * @param uniformName defines the name of the variable
  102730. * @param color4 defines the value to be set
  102731. * @returns this effect.
  102732. */
  102733. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  102734. /** Release all associated resources */
  102735. dispose(): void;
  102736. /**
  102737. * This function will add a new shader to the shader store
  102738. * @param name the name of the shader
  102739. * @param pixelShader optional pixel shader content
  102740. * @param vertexShader optional vertex shader content
  102741. */
  102742. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  102743. /**
  102744. * Store of each shader (The can be looked up using effect.key)
  102745. */
  102746. static ShadersStore: {
  102747. [key: string]: string;
  102748. };
  102749. /**
  102750. * Store of each included file for a shader (The can be looked up using effect.key)
  102751. */
  102752. static IncludesShadersStore: {
  102753. [key: string]: string;
  102754. };
  102755. /**
  102756. * Resets the cache of effects.
  102757. */
  102758. static ResetCache(): void;
  102759. }
  102760. }
  102761. declare module BABYLON {
  102762. /**
  102763. * Interface used to describe the capabilities of the engine relatively to the current browser
  102764. */
  102765. export interface EngineCapabilities {
  102766. /** Maximum textures units per fragment shader */
  102767. maxTexturesImageUnits: number;
  102768. /** Maximum texture units per vertex shader */
  102769. maxVertexTextureImageUnits: number;
  102770. /** Maximum textures units in the entire pipeline */
  102771. maxCombinedTexturesImageUnits: number;
  102772. /** Maximum texture size */
  102773. maxTextureSize: number;
  102774. /** Maximum texture samples */
  102775. maxSamples?: number;
  102776. /** Maximum cube texture size */
  102777. maxCubemapTextureSize: number;
  102778. /** Maximum render texture size */
  102779. maxRenderTextureSize: number;
  102780. /** Maximum number of vertex attributes */
  102781. maxVertexAttribs: number;
  102782. /** Maximum number of varyings */
  102783. maxVaryingVectors: number;
  102784. /** Maximum number of uniforms per vertex shader */
  102785. maxVertexUniformVectors: number;
  102786. /** Maximum number of uniforms per fragment shader */
  102787. maxFragmentUniformVectors: number;
  102788. /** Defines if standard derivates (dx/dy) are supported */
  102789. standardDerivatives: boolean;
  102790. /** Defines if s3tc texture compression is supported */
  102791. s3tc?: WEBGL_compressed_texture_s3tc;
  102792. /** Defines if pvrtc texture compression is supported */
  102793. pvrtc: any;
  102794. /** Defines if etc1 texture compression is supported */
  102795. etc1: any;
  102796. /** Defines if etc2 texture compression is supported */
  102797. etc2: any;
  102798. /** Defines if astc texture compression is supported */
  102799. astc: any;
  102800. /** Defines if float textures are supported */
  102801. textureFloat: boolean;
  102802. /** Defines if vertex array objects are supported */
  102803. vertexArrayObject: boolean;
  102804. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  102805. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  102806. /** Gets the maximum level of anisotropy supported */
  102807. maxAnisotropy: number;
  102808. /** Defines if instancing is supported */
  102809. instancedArrays: boolean;
  102810. /** Defines if 32 bits indices are supported */
  102811. uintIndices: boolean;
  102812. /** Defines if high precision shaders are supported */
  102813. highPrecisionShaderSupported: boolean;
  102814. /** Defines if depth reading in the fragment shader is supported */
  102815. fragmentDepthSupported: boolean;
  102816. /** Defines if float texture linear filtering is supported*/
  102817. textureFloatLinearFiltering: boolean;
  102818. /** Defines if rendering to float textures is supported */
  102819. textureFloatRender: boolean;
  102820. /** Defines if half float textures are supported*/
  102821. textureHalfFloat: boolean;
  102822. /** Defines if half float texture linear filtering is supported*/
  102823. textureHalfFloatLinearFiltering: boolean;
  102824. /** Defines if rendering to half float textures is supported */
  102825. textureHalfFloatRender: boolean;
  102826. /** Defines if textureLOD shader command is supported */
  102827. textureLOD: boolean;
  102828. /** Defines if draw buffers extension is supported */
  102829. drawBuffersExtension: boolean;
  102830. /** Defines if depth textures are supported */
  102831. depthTextureExtension: boolean;
  102832. /** Defines if float color buffer are supported */
  102833. colorBufferFloat: boolean;
  102834. /** Gets disjoint timer query extension (null if not supported) */
  102835. timerQuery?: EXT_disjoint_timer_query;
  102836. /** Defines if timestamp can be used with timer query */
  102837. canUseTimestampForTimerQuery: boolean;
  102838. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  102839. multiview?: any;
  102840. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  102841. oculusMultiview?: any;
  102842. /** Function used to let the system compiles shaders in background */
  102843. parallelShaderCompile?: {
  102844. COMPLETION_STATUS_KHR: number;
  102845. };
  102846. /** Max number of texture samples for MSAA */
  102847. maxMSAASamples: number;
  102848. /** Defines if the blend min max extension is supported */
  102849. blendMinMax: boolean;
  102850. }
  102851. }
  102852. declare module BABYLON {
  102853. /**
  102854. * @hidden
  102855. **/
  102856. export class DepthCullingState {
  102857. private _isDepthTestDirty;
  102858. private _isDepthMaskDirty;
  102859. private _isDepthFuncDirty;
  102860. private _isCullFaceDirty;
  102861. private _isCullDirty;
  102862. private _isZOffsetDirty;
  102863. private _isFrontFaceDirty;
  102864. private _depthTest;
  102865. private _depthMask;
  102866. private _depthFunc;
  102867. private _cull;
  102868. private _cullFace;
  102869. private _zOffset;
  102870. private _frontFace;
  102871. /**
  102872. * Initializes the state.
  102873. */
  102874. constructor();
  102875. get isDirty(): boolean;
  102876. get zOffset(): number;
  102877. set zOffset(value: number);
  102878. get cullFace(): Nullable<number>;
  102879. set cullFace(value: Nullable<number>);
  102880. get cull(): Nullable<boolean>;
  102881. set cull(value: Nullable<boolean>);
  102882. get depthFunc(): Nullable<number>;
  102883. set depthFunc(value: Nullable<number>);
  102884. get depthMask(): boolean;
  102885. set depthMask(value: boolean);
  102886. get depthTest(): boolean;
  102887. set depthTest(value: boolean);
  102888. get frontFace(): Nullable<number>;
  102889. set frontFace(value: Nullable<number>);
  102890. reset(): void;
  102891. apply(gl: WebGLRenderingContext): void;
  102892. }
  102893. }
  102894. declare module BABYLON {
  102895. /**
  102896. * @hidden
  102897. **/
  102898. export class StencilState {
  102899. /** 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 */
  102900. static readonly ALWAYS: number;
  102901. /** Passed to stencilOperation to specify that stencil value must be kept */
  102902. static readonly KEEP: number;
  102903. /** Passed to stencilOperation to specify that stencil value must be replaced */
  102904. static readonly REPLACE: number;
  102905. private _isStencilTestDirty;
  102906. private _isStencilMaskDirty;
  102907. private _isStencilFuncDirty;
  102908. private _isStencilOpDirty;
  102909. private _stencilTest;
  102910. private _stencilMask;
  102911. private _stencilFunc;
  102912. private _stencilFuncRef;
  102913. private _stencilFuncMask;
  102914. private _stencilOpStencilFail;
  102915. private _stencilOpDepthFail;
  102916. private _stencilOpStencilDepthPass;
  102917. get isDirty(): boolean;
  102918. get stencilFunc(): number;
  102919. set stencilFunc(value: number);
  102920. get stencilFuncRef(): number;
  102921. set stencilFuncRef(value: number);
  102922. get stencilFuncMask(): number;
  102923. set stencilFuncMask(value: number);
  102924. get stencilOpStencilFail(): number;
  102925. set stencilOpStencilFail(value: number);
  102926. get stencilOpDepthFail(): number;
  102927. set stencilOpDepthFail(value: number);
  102928. get stencilOpStencilDepthPass(): number;
  102929. set stencilOpStencilDepthPass(value: number);
  102930. get stencilMask(): number;
  102931. set stencilMask(value: number);
  102932. get stencilTest(): boolean;
  102933. set stencilTest(value: boolean);
  102934. constructor();
  102935. reset(): void;
  102936. apply(gl: WebGLRenderingContext): void;
  102937. }
  102938. }
  102939. declare module BABYLON {
  102940. /**
  102941. * @hidden
  102942. **/
  102943. export class AlphaState {
  102944. private _isAlphaBlendDirty;
  102945. private _isBlendFunctionParametersDirty;
  102946. private _isBlendEquationParametersDirty;
  102947. private _isBlendConstantsDirty;
  102948. private _alphaBlend;
  102949. private _blendFunctionParameters;
  102950. private _blendEquationParameters;
  102951. private _blendConstants;
  102952. /**
  102953. * Initializes the state.
  102954. */
  102955. constructor();
  102956. get isDirty(): boolean;
  102957. get alphaBlend(): boolean;
  102958. set alphaBlend(value: boolean);
  102959. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  102960. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  102961. setAlphaEquationParameters(rgb: number, alpha: number): void;
  102962. reset(): void;
  102963. apply(gl: WebGLRenderingContext): void;
  102964. }
  102965. }
  102966. declare module BABYLON {
  102967. /** @hidden */
  102968. export class WebGL2ShaderProcessor implements IShaderProcessor {
  102969. attributeProcessor(attribute: string): string;
  102970. varyingProcessor(varying: string, isFragment: boolean): string;
  102971. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  102972. }
  102973. }
  102974. declare module BABYLON {
  102975. /**
  102976. * Interface for attribute information associated with buffer instanciation
  102977. */
  102978. export interface InstancingAttributeInfo {
  102979. /**
  102980. * Name of the GLSL attribute
  102981. * if attribute index is not specified, this is used to retrieve the index from the effect
  102982. */
  102983. attributeName: string;
  102984. /**
  102985. * Index/offset of the attribute in the vertex shader
  102986. * if not specified, this will be computes from the name.
  102987. */
  102988. index?: number;
  102989. /**
  102990. * size of the attribute, 1, 2, 3 or 4
  102991. */
  102992. attributeSize: number;
  102993. /**
  102994. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  102995. */
  102996. offset: number;
  102997. /**
  102998. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  102999. * default to 1
  103000. */
  103001. divisor?: number;
  103002. /**
  103003. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103004. * default is FLOAT
  103005. */
  103006. attributeType?: number;
  103007. /**
  103008. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103009. */
  103010. normalized?: boolean;
  103011. }
  103012. }
  103013. declare module BABYLON {
  103014. interface ThinEngine {
  103015. /**
  103016. * Update a video texture
  103017. * @param texture defines the texture to update
  103018. * @param video defines the video element to use
  103019. * @param invertY defines if data must be stored with Y axis inverted
  103020. */
  103021. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103022. }
  103023. }
  103024. declare module BABYLON {
  103025. /**
  103026. * Settings for finer control over video usage
  103027. */
  103028. export interface VideoTextureSettings {
  103029. /**
  103030. * Applies `autoplay` to video, if specified
  103031. */
  103032. autoPlay?: boolean;
  103033. /**
  103034. * Applies `loop` to video, if specified
  103035. */
  103036. loop?: boolean;
  103037. /**
  103038. * Automatically updates internal texture from video at every frame in the render loop
  103039. */
  103040. autoUpdateTexture: boolean;
  103041. /**
  103042. * Image src displayed during the video loading or until the user interacts with the video.
  103043. */
  103044. poster?: string;
  103045. }
  103046. /**
  103047. * If you want to display a video in your scene, this is the special texture for that.
  103048. * This special texture works similar to other textures, with the exception of a few parameters.
  103049. * @see https://doc.babylonjs.com/how_to/video_texture
  103050. */
  103051. export class VideoTexture extends Texture {
  103052. /**
  103053. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103054. */
  103055. readonly autoUpdateTexture: boolean;
  103056. /**
  103057. * The video instance used by the texture internally
  103058. */
  103059. readonly video: HTMLVideoElement;
  103060. private _onUserActionRequestedObservable;
  103061. /**
  103062. * Event triggerd when a dom action is required by the user to play the video.
  103063. * This happens due to recent changes in browser policies preventing video to auto start.
  103064. */
  103065. get onUserActionRequestedObservable(): Observable<Texture>;
  103066. private _generateMipMaps;
  103067. private _engine;
  103068. private _stillImageCaptured;
  103069. private _displayingPosterTexture;
  103070. private _settings;
  103071. private _createInternalTextureOnEvent;
  103072. private _frameId;
  103073. private _currentSrc;
  103074. /**
  103075. * Creates a video texture.
  103076. * If you want to display a video in your scene, this is the special texture for that.
  103077. * This special texture works similar to other textures, with the exception of a few parameters.
  103078. * @see https://doc.babylonjs.com/how_to/video_texture
  103079. * @param name optional name, will detect from video source, if not defined
  103080. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103081. * @param scene is obviously the current scene.
  103082. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  103083. * @param invertY is false by default but can be used to invert video on Y axis
  103084. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  103085. * @param settings allows finer control over video usage
  103086. */
  103087. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  103088. private _getName;
  103089. private _getVideo;
  103090. private _createInternalTexture;
  103091. private reset;
  103092. /**
  103093. * @hidden Internal method to initiate `update`.
  103094. */
  103095. _rebuild(): void;
  103096. /**
  103097. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  103098. */
  103099. update(): void;
  103100. /**
  103101. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  103102. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  103103. */
  103104. updateTexture(isVisible: boolean): void;
  103105. protected _updateInternalTexture: () => void;
  103106. /**
  103107. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  103108. * @param url New url.
  103109. */
  103110. updateURL(url: string): void;
  103111. /**
  103112. * Clones the texture.
  103113. * @returns the cloned texture
  103114. */
  103115. clone(): VideoTexture;
  103116. /**
  103117. * Dispose the texture and release its associated resources.
  103118. */
  103119. dispose(): void;
  103120. /**
  103121. * Creates a video texture straight from a stream.
  103122. * @param scene Define the scene the texture should be created in
  103123. * @param stream Define the stream the texture should be created from
  103124. * @returns The created video texture as a promise
  103125. */
  103126. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  103127. /**
  103128. * Creates a video texture straight from your WebCam video feed.
  103129. * @param scene Define the scene the texture should be created in
  103130. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103131. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103132. * @returns The created video texture as a promise
  103133. */
  103134. static CreateFromWebCamAsync(scene: Scene, constraints: {
  103135. minWidth: number;
  103136. maxWidth: number;
  103137. minHeight: number;
  103138. maxHeight: number;
  103139. deviceId: string;
  103140. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  103141. /**
  103142. * Creates a video texture straight from your WebCam video feed.
  103143. * @param scene Define the scene the texture should be created in
  103144. * @param onReady Define a callback to triggered once the texture will be ready
  103145. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103146. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103147. */
  103148. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  103149. minWidth: number;
  103150. maxWidth: number;
  103151. minHeight: number;
  103152. maxHeight: number;
  103153. deviceId: string;
  103154. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  103155. }
  103156. }
  103157. declare module BABYLON {
  103158. /**
  103159. * Defines the interface used by objects working like Scene
  103160. * @hidden
  103161. */
  103162. interface ISceneLike {
  103163. _addPendingData(data: any): void;
  103164. _removePendingData(data: any): void;
  103165. offlineProvider: IOfflineProvider;
  103166. }
  103167. /** Interface defining initialization parameters for Engine class */
  103168. export interface EngineOptions extends WebGLContextAttributes {
  103169. /**
  103170. * Defines if the engine should no exceed a specified device ratio
  103171. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  103172. */
  103173. limitDeviceRatio?: number;
  103174. /**
  103175. * Defines if webvr should be enabled automatically
  103176. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103177. */
  103178. autoEnableWebVR?: boolean;
  103179. /**
  103180. * Defines if webgl2 should be turned off even if supported
  103181. * @see http://doc.babylonjs.com/features/webgl2
  103182. */
  103183. disableWebGL2Support?: boolean;
  103184. /**
  103185. * Defines if webaudio should be initialized as well
  103186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103187. */
  103188. audioEngine?: boolean;
  103189. /**
  103190. * Defines if animations should run using a deterministic lock step
  103191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103192. */
  103193. deterministicLockstep?: boolean;
  103194. /** Defines the maximum steps to use with deterministic lock step mode */
  103195. lockstepMaxSteps?: number;
  103196. /** Defines the seconds between each deterministic lock step */
  103197. timeStep?: number;
  103198. /**
  103199. * Defines that engine should ignore context lost events
  103200. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  103201. */
  103202. doNotHandleContextLost?: boolean;
  103203. /**
  103204. * Defines that engine should ignore modifying touch action attribute and style
  103205. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  103206. */
  103207. doNotHandleTouchAction?: boolean;
  103208. /**
  103209. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  103210. */
  103211. useHighPrecisionFloats?: boolean;
  103212. }
  103213. /**
  103214. * The base engine class (root of all engines)
  103215. */
  103216. export class ThinEngine {
  103217. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  103218. static ExceptionList: ({
  103219. key: string;
  103220. capture: string;
  103221. captureConstraint: number;
  103222. targets: string[];
  103223. } | {
  103224. key: string;
  103225. capture: null;
  103226. captureConstraint: null;
  103227. targets: string[];
  103228. })[];
  103229. /** @hidden */
  103230. static _TextureLoaders: IInternalTextureLoader[];
  103231. /**
  103232. * Returns the current npm package of the sdk
  103233. */
  103234. static get NpmPackage(): string;
  103235. /**
  103236. * Returns the current version of the framework
  103237. */
  103238. static get Version(): string;
  103239. /**
  103240. * Returns a string describing the current engine
  103241. */
  103242. get description(): string;
  103243. /**
  103244. * Gets or sets the epsilon value used by collision engine
  103245. */
  103246. static CollisionsEpsilon: number;
  103247. /**
  103248. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103249. */
  103250. static get ShadersRepository(): string;
  103251. static set ShadersRepository(value: string);
  103252. /**
  103253. * Gets or sets the textures that the engine should not attempt to load as compressed
  103254. */
  103255. protected _excludedCompressedTextures: string[];
  103256. /**
  103257. * Filters the compressed texture formats to only include
  103258. * files that are not included in the skippable list
  103259. *
  103260. * @param url the current extension
  103261. * @param textureFormatInUse the current compressed texture format
  103262. * @returns "format" string
  103263. */
  103264. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  103265. /** @hidden */
  103266. _shaderProcessor: IShaderProcessor;
  103267. /**
  103268. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  103269. */
  103270. forcePOTTextures: boolean;
  103271. /**
  103272. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  103273. */
  103274. isFullscreen: boolean;
  103275. /**
  103276. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  103277. */
  103278. cullBackFaces: boolean;
  103279. /**
  103280. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  103281. */
  103282. renderEvenInBackground: boolean;
  103283. /**
  103284. * Gets or sets a boolean indicating that cache can be kept between frames
  103285. */
  103286. preventCacheWipeBetweenFrames: boolean;
  103287. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  103288. validateShaderPrograms: boolean;
  103289. /**
  103290. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  103291. * This can provide greater z depth for distant objects.
  103292. */
  103293. useReverseDepthBuffer: boolean;
  103294. /**
  103295. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  103296. */
  103297. disableUniformBuffers: boolean;
  103298. /** @hidden */
  103299. _uniformBuffers: UniformBuffer[];
  103300. /**
  103301. * Gets a boolean indicating that the engine supports uniform buffers
  103302. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  103303. */
  103304. get supportsUniformBuffers(): boolean;
  103305. /** @hidden */
  103306. _gl: WebGLRenderingContext;
  103307. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  103308. protected _windowIsBackground: boolean;
  103309. protected _webGLVersion: number;
  103310. protected _creationOptions: EngineOptions;
  103311. protected _highPrecisionShadersAllowed: boolean;
  103312. /** @hidden */
  103313. get _shouldUseHighPrecisionShader(): boolean;
  103314. /**
  103315. * Gets a boolean indicating that only power of 2 textures are supported
  103316. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  103317. */
  103318. get needPOTTextures(): boolean;
  103319. /** @hidden */
  103320. _badOS: boolean;
  103321. /** @hidden */
  103322. _badDesktopOS: boolean;
  103323. private _hardwareScalingLevel;
  103324. /** @hidden */
  103325. _caps: EngineCapabilities;
  103326. private _isStencilEnable;
  103327. private _glVersion;
  103328. private _glRenderer;
  103329. private _glVendor;
  103330. /** @hidden */
  103331. _videoTextureSupported: boolean;
  103332. protected _renderingQueueLaunched: boolean;
  103333. protected _activeRenderLoops: (() => void)[];
  103334. /**
  103335. * Observable signaled when a context lost event is raised
  103336. */
  103337. onContextLostObservable: Observable<ThinEngine>;
  103338. /**
  103339. * Observable signaled when a context restored event is raised
  103340. */
  103341. onContextRestoredObservable: Observable<ThinEngine>;
  103342. private _onContextLost;
  103343. private _onContextRestored;
  103344. protected _contextWasLost: boolean;
  103345. /** @hidden */
  103346. _doNotHandleContextLost: boolean;
  103347. /**
  103348. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  103349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  103350. */
  103351. get doNotHandleContextLost(): boolean;
  103352. set doNotHandleContextLost(value: boolean);
  103353. /**
  103354. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  103355. */
  103356. disableVertexArrayObjects: boolean;
  103357. /** @hidden */
  103358. protected _colorWrite: boolean;
  103359. /** @hidden */
  103360. protected _colorWriteChanged: boolean;
  103361. /** @hidden */
  103362. protected _depthCullingState: DepthCullingState;
  103363. /** @hidden */
  103364. protected _stencilState: StencilState;
  103365. /** @hidden */
  103366. _alphaState: AlphaState;
  103367. /** @hidden */
  103368. _alphaMode: number;
  103369. /** @hidden */
  103370. _alphaEquation: number;
  103371. /** @hidden */
  103372. _internalTexturesCache: InternalTexture[];
  103373. /** @hidden */
  103374. protected _activeChannel: number;
  103375. private _currentTextureChannel;
  103376. /** @hidden */
  103377. protected _boundTexturesCache: {
  103378. [key: string]: Nullable<InternalTexture>;
  103379. };
  103380. /** @hidden */
  103381. protected _currentEffect: Nullable<Effect>;
  103382. /** @hidden */
  103383. protected _currentProgram: Nullable<WebGLProgram>;
  103384. private _compiledEffects;
  103385. private _vertexAttribArraysEnabled;
  103386. /** @hidden */
  103387. protected _cachedViewport: Nullable<IViewportLike>;
  103388. private _cachedVertexArrayObject;
  103389. /** @hidden */
  103390. protected _cachedVertexBuffers: any;
  103391. /** @hidden */
  103392. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  103393. /** @hidden */
  103394. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  103395. /** @hidden */
  103396. _currentRenderTarget: Nullable<InternalTexture>;
  103397. private _uintIndicesCurrentlySet;
  103398. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  103399. /** @hidden */
  103400. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  103401. private _currentBufferPointers;
  103402. private _currentInstanceLocations;
  103403. private _currentInstanceBuffers;
  103404. private _textureUnits;
  103405. /** @hidden */
  103406. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103407. /** @hidden */
  103408. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103409. /** @hidden */
  103410. _boundRenderFunction: any;
  103411. private _vaoRecordInProgress;
  103412. private _mustWipeVertexAttributes;
  103413. private _emptyTexture;
  103414. private _emptyCubeTexture;
  103415. private _emptyTexture3D;
  103416. private _emptyTexture2DArray;
  103417. /** @hidden */
  103418. _frameHandler: number;
  103419. private _nextFreeTextureSlots;
  103420. private _maxSimultaneousTextures;
  103421. private _activeRequests;
  103422. protected _texturesSupported: string[];
  103423. /** @hidden */
  103424. _textureFormatInUse: Nullable<string>;
  103425. protected get _supportsHardwareTextureRescaling(): boolean;
  103426. /**
  103427. * Gets the list of texture formats supported
  103428. */
  103429. get texturesSupported(): Array<string>;
  103430. /**
  103431. * Gets the list of texture formats in use
  103432. */
  103433. get textureFormatInUse(): Nullable<string>;
  103434. /**
  103435. * Gets the current viewport
  103436. */
  103437. get currentViewport(): Nullable<IViewportLike>;
  103438. /**
  103439. * Gets the default empty texture
  103440. */
  103441. get emptyTexture(): InternalTexture;
  103442. /**
  103443. * Gets the default empty 3D texture
  103444. */
  103445. get emptyTexture3D(): InternalTexture;
  103446. /**
  103447. * Gets the default empty 2D array texture
  103448. */
  103449. get emptyTexture2DArray(): InternalTexture;
  103450. /**
  103451. * Gets the default empty cube texture
  103452. */
  103453. get emptyCubeTexture(): InternalTexture;
  103454. /**
  103455. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  103456. */
  103457. readonly premultipliedAlpha: boolean;
  103458. /**
  103459. * Observable event triggered before each texture is initialized
  103460. */
  103461. onBeforeTextureInitObservable: Observable<Texture>;
  103462. /**
  103463. * Creates a new engine
  103464. * @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
  103465. * @param antialias defines enable antialiasing (default: false)
  103466. * @param options defines further options to be sent to the getContext() function
  103467. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103468. */
  103469. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103470. private _rebuildInternalTextures;
  103471. private _rebuildEffects;
  103472. /**
  103473. * Gets a boolean indicating if all created effects are ready
  103474. * @returns true if all effects are ready
  103475. */
  103476. areAllEffectsReady(): boolean;
  103477. protected _rebuildBuffers(): void;
  103478. private _initGLContext;
  103479. /**
  103480. * Gets version of the current webGL context
  103481. */
  103482. get webGLVersion(): number;
  103483. /**
  103484. * Gets a string idenfifying the name of the class
  103485. * @returns "Engine" string
  103486. */
  103487. getClassName(): string;
  103488. /**
  103489. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  103490. */
  103491. get isStencilEnable(): boolean;
  103492. /** @hidden */
  103493. _prepareWorkingCanvas(): void;
  103494. /**
  103495. * Reset the texture cache to empty state
  103496. */
  103497. resetTextureCache(): void;
  103498. /**
  103499. * Gets an object containing information about the current webGL context
  103500. * @returns an object containing the vender, the renderer and the version of the current webGL context
  103501. */
  103502. getGlInfo(): {
  103503. vendor: string;
  103504. renderer: string;
  103505. version: string;
  103506. };
  103507. /**
  103508. * Defines the hardware scaling level.
  103509. * By default the hardware scaling level is computed from the window device ratio.
  103510. * 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.
  103511. * @param level defines the level to use
  103512. */
  103513. setHardwareScalingLevel(level: number): void;
  103514. /**
  103515. * Gets the current hardware scaling level.
  103516. * By default the hardware scaling level is computed from the window device ratio.
  103517. * 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.
  103518. * @returns a number indicating the current hardware scaling level
  103519. */
  103520. getHardwareScalingLevel(): number;
  103521. /**
  103522. * Gets the list of loaded textures
  103523. * @returns an array containing all loaded textures
  103524. */
  103525. getLoadedTexturesCache(): InternalTexture[];
  103526. /**
  103527. * Gets the object containing all engine capabilities
  103528. * @returns the EngineCapabilities object
  103529. */
  103530. getCaps(): EngineCapabilities;
  103531. /**
  103532. * stop executing a render loop function and remove it from the execution array
  103533. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  103534. */
  103535. stopRenderLoop(renderFunction?: () => void): void;
  103536. /** @hidden */
  103537. _renderLoop(): void;
  103538. /**
  103539. * Gets the HTML canvas attached with the current webGL context
  103540. * @returns a HTML canvas
  103541. */
  103542. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  103543. /**
  103544. * Gets host window
  103545. * @returns the host window object
  103546. */
  103547. getHostWindow(): Nullable<Window>;
  103548. /**
  103549. * Gets the current render width
  103550. * @param useScreen defines if screen size must be used (or the current render target if any)
  103551. * @returns a number defining the current render width
  103552. */
  103553. getRenderWidth(useScreen?: boolean): number;
  103554. /**
  103555. * Gets the current render height
  103556. * @param useScreen defines if screen size must be used (or the current render target if any)
  103557. * @returns a number defining the current render height
  103558. */
  103559. getRenderHeight(useScreen?: boolean): number;
  103560. /**
  103561. * Can be used to override the current requestAnimationFrame requester.
  103562. * @hidden
  103563. */
  103564. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  103565. /**
  103566. * Register and execute a render loop. The engine can have more than one render function
  103567. * @param renderFunction defines the function to continuously execute
  103568. */
  103569. runRenderLoop(renderFunction: () => void): void;
  103570. /**
  103571. * Clear the current render buffer or the current render target (if any is set up)
  103572. * @param color defines the color to use
  103573. * @param backBuffer defines if the back buffer must be cleared
  103574. * @param depth defines if the depth buffer must be cleared
  103575. * @param stencil defines if the stencil buffer must be cleared
  103576. */
  103577. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  103578. private _viewportCached;
  103579. /** @hidden */
  103580. _viewport(x: number, y: number, width: number, height: number): void;
  103581. /**
  103582. * Set the WebGL's viewport
  103583. * @param viewport defines the viewport element to be used
  103584. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  103585. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  103586. */
  103587. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  103588. /**
  103589. * Begin a new frame
  103590. */
  103591. beginFrame(): void;
  103592. /**
  103593. * Enf the current frame
  103594. */
  103595. endFrame(): void;
  103596. /**
  103597. * Resize the view according to the canvas' size
  103598. */
  103599. resize(): void;
  103600. /**
  103601. * Force a specific size of the canvas
  103602. * @param width defines the new canvas' width
  103603. * @param height defines the new canvas' height
  103604. */
  103605. setSize(width: number, height: number): void;
  103606. /**
  103607. * Binds the frame buffer to the specified texture.
  103608. * @param texture The texture to render to or null for the default canvas
  103609. * @param faceIndex The face of the texture to render to in case of cube texture
  103610. * @param requiredWidth The width of the target to render to
  103611. * @param requiredHeight The height of the target to render to
  103612. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  103613. * @param lodLevel defines the lod level to bind to the frame buffer
  103614. * @param layer defines the 2d array index to bind to frame buffer to
  103615. */
  103616. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  103617. /** @hidden */
  103618. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  103619. /**
  103620. * Unbind the current render target texture from the webGL context
  103621. * @param texture defines the render target texture to unbind
  103622. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103623. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103624. */
  103625. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  103626. /**
  103627. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  103628. */
  103629. flushFramebuffer(): void;
  103630. /**
  103631. * Unbind the current render target and bind the default framebuffer
  103632. */
  103633. restoreDefaultFramebuffer(): void;
  103634. /** @hidden */
  103635. protected _resetVertexBufferBinding(): void;
  103636. /**
  103637. * Creates a vertex buffer
  103638. * @param data the data for the vertex buffer
  103639. * @returns the new WebGL static buffer
  103640. */
  103641. createVertexBuffer(data: DataArray): DataBuffer;
  103642. private _createVertexBuffer;
  103643. /**
  103644. * Creates a dynamic vertex buffer
  103645. * @param data the data for the dynamic vertex buffer
  103646. * @returns the new WebGL dynamic buffer
  103647. */
  103648. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  103649. protected _resetIndexBufferBinding(): void;
  103650. /**
  103651. * Creates a new index buffer
  103652. * @param indices defines the content of the index buffer
  103653. * @param updatable defines if the index buffer must be updatable
  103654. * @returns a new webGL buffer
  103655. */
  103656. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  103657. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  103658. /**
  103659. * Bind a webGL buffer to the webGL context
  103660. * @param buffer defines the buffer to bind
  103661. */
  103662. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  103663. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  103664. private bindBuffer;
  103665. /**
  103666. * update the bound buffer with the given data
  103667. * @param data defines the data to update
  103668. */
  103669. updateArrayBuffer(data: Float32Array): void;
  103670. private _vertexAttribPointer;
  103671. private _bindIndexBufferWithCache;
  103672. private _bindVertexBuffersAttributes;
  103673. /**
  103674. * Records a vertex array object
  103675. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  103676. * @param vertexBuffers defines the list of vertex buffers to store
  103677. * @param indexBuffer defines the index buffer to store
  103678. * @param effect defines the effect to store
  103679. * @returns the new vertex array object
  103680. */
  103681. recordVertexArrayObject(vertexBuffers: {
  103682. [key: string]: VertexBuffer;
  103683. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  103684. /**
  103685. * Bind a specific vertex array object
  103686. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  103687. * @param vertexArrayObject defines the vertex array object to bind
  103688. * @param indexBuffer defines the index buffer to bind
  103689. */
  103690. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  103691. /**
  103692. * Bind webGl buffers directly to the webGL context
  103693. * @param vertexBuffer defines the vertex buffer to bind
  103694. * @param indexBuffer defines the index buffer to bind
  103695. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  103696. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  103697. * @param effect defines the effect associated with the vertex buffer
  103698. */
  103699. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  103700. private _unbindVertexArrayObject;
  103701. /**
  103702. * Bind a list of vertex buffers to the webGL context
  103703. * @param vertexBuffers defines the list of vertex buffers to bind
  103704. * @param indexBuffer defines the index buffer to bind
  103705. * @param effect defines the effect associated with the vertex buffers
  103706. */
  103707. bindBuffers(vertexBuffers: {
  103708. [key: string]: Nullable<VertexBuffer>;
  103709. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  103710. /**
  103711. * Unbind all instance attributes
  103712. */
  103713. unbindInstanceAttributes(): void;
  103714. /**
  103715. * Release and free the memory of a vertex array object
  103716. * @param vao defines the vertex array object to delete
  103717. */
  103718. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  103719. /** @hidden */
  103720. _releaseBuffer(buffer: DataBuffer): boolean;
  103721. protected _deleteBuffer(buffer: DataBuffer): void;
  103722. /**
  103723. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  103724. * @param instancesBuffer defines the webGL buffer to update and bind
  103725. * @param data defines the data to store in the buffer
  103726. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  103727. */
  103728. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  103729. /**
  103730. * Bind the content of a webGL buffer used with instanciation
  103731. * @param instancesBuffer defines the webGL buffer to bind
  103732. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  103733. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  103734. */
  103735. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  103736. /**
  103737. * Disable the instance attribute corresponding to the name in parameter
  103738. * @param name defines the name of the attribute to disable
  103739. */
  103740. disableInstanceAttributeByName(name: string): void;
  103741. /**
  103742. * Disable the instance attribute corresponding to the location in parameter
  103743. * @param attributeLocation defines the attribute location of the attribute to disable
  103744. */
  103745. disableInstanceAttribute(attributeLocation: number): void;
  103746. /**
  103747. * Disable the attribute corresponding to the location in parameter
  103748. * @param attributeLocation defines the attribute location of the attribute to disable
  103749. */
  103750. disableAttributeByIndex(attributeLocation: number): void;
  103751. /**
  103752. * Send a draw order
  103753. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  103754. * @param indexStart defines the starting index
  103755. * @param indexCount defines the number of index to draw
  103756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103757. */
  103758. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  103759. /**
  103760. * Draw a list of points
  103761. * @param verticesStart defines the index of first vertex to draw
  103762. * @param verticesCount defines the count of vertices to draw
  103763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103764. */
  103765. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103766. /**
  103767. * Draw a list of unindexed primitives
  103768. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  103769. * @param verticesStart defines the index of first vertex to draw
  103770. * @param verticesCount defines the count of vertices to draw
  103771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103772. */
  103773. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103774. /**
  103775. * Draw a list of indexed primitives
  103776. * @param fillMode defines the primitive to use
  103777. * @param indexStart defines the starting index
  103778. * @param indexCount defines the number of index to draw
  103779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103780. */
  103781. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  103782. /**
  103783. * Draw a list of unindexed primitives
  103784. * @param fillMode defines the primitive to use
  103785. * @param verticesStart defines the index of first vertex to draw
  103786. * @param verticesCount defines the count of vertices to draw
  103787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103788. */
  103789. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103790. private _drawMode;
  103791. /** @hidden */
  103792. protected _reportDrawCall(): void;
  103793. /** @hidden */
  103794. _releaseEffect(effect: Effect): void;
  103795. /** @hidden */
  103796. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  103797. /**
  103798. * Create a new effect (used to store vertex/fragment shaders)
  103799. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  103800. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  103801. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  103802. * @param samplers defines an array of string used to represent textures
  103803. * @param defines defines the string containing the defines to use to compile the shaders
  103804. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  103805. * @param onCompiled defines a function to call when the effect creation is successful
  103806. * @param onError defines a function to call when the effect creation has failed
  103807. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  103808. * @returns the new Effect
  103809. */
  103810. 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;
  103811. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  103812. private _compileShader;
  103813. private _compileRawShader;
  103814. /**
  103815. * Directly creates a webGL program
  103816. * @param pipelineContext defines the pipeline context to attach to
  103817. * @param vertexCode defines the vertex shader code to use
  103818. * @param fragmentCode defines the fragment shader code to use
  103819. * @param context defines the webGL context to use (if not set, the current one will be used)
  103820. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  103821. * @returns the new webGL program
  103822. */
  103823. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103824. /**
  103825. * Creates a webGL program
  103826. * @param pipelineContext defines the pipeline context to attach to
  103827. * @param vertexCode defines the vertex shader code to use
  103828. * @param fragmentCode defines the fragment shader code to use
  103829. * @param defines defines the string containing the defines to use to compile the shaders
  103830. * @param context defines the webGL context to use (if not set, the current one will be used)
  103831. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  103832. * @returns the new webGL program
  103833. */
  103834. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103835. /**
  103836. * Creates a new pipeline context
  103837. * @returns the new pipeline
  103838. */
  103839. createPipelineContext(): IPipelineContext;
  103840. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103841. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  103842. /** @hidden */
  103843. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  103844. /** @hidden */
  103845. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  103846. /** @hidden */
  103847. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  103848. /**
  103849. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  103850. * @param pipelineContext defines the pipeline context to use
  103851. * @param uniformsNames defines the list of uniform names
  103852. * @returns an array of webGL uniform locations
  103853. */
  103854. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  103855. /**
  103856. * Gets the lsit of active attributes for a given webGL program
  103857. * @param pipelineContext defines the pipeline context to use
  103858. * @param attributesNames defines the list of attribute names to get
  103859. * @returns an array of indices indicating the offset of each attribute
  103860. */
  103861. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  103862. /**
  103863. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  103864. * @param effect defines the effect to activate
  103865. */
  103866. enableEffect(effect: Nullable<Effect>): void;
  103867. /**
  103868. * Set the value of an uniform to a number (int)
  103869. * @param uniform defines the webGL uniform location where to store the value
  103870. * @param value defines the int number to store
  103871. */
  103872. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  103873. /**
  103874. * Set the value of an uniform to an array of int32
  103875. * @param uniform defines the webGL uniform location where to store the value
  103876. * @param array defines the array of int32 to store
  103877. */
  103878. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103879. /**
  103880. * Set the value of an uniform to an array of int32 (stored as vec2)
  103881. * @param uniform defines the webGL uniform location where to store the value
  103882. * @param array defines the array of int32 to store
  103883. */
  103884. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103885. /**
  103886. * Set the value of an uniform to an array of int32 (stored as vec3)
  103887. * @param uniform defines the webGL uniform location where to store the value
  103888. * @param array defines the array of int32 to store
  103889. */
  103890. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103891. /**
  103892. * Set the value of an uniform to an array of int32 (stored as vec4)
  103893. * @param uniform defines the webGL uniform location where to store the value
  103894. * @param array defines the array of int32 to store
  103895. */
  103896. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103897. /**
  103898. * Set the value of an uniform to an array of number
  103899. * @param uniform defines the webGL uniform location where to store the value
  103900. * @param array defines the array of number to store
  103901. */
  103902. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103903. /**
  103904. * Set the value of an uniform to an array of number (stored as vec2)
  103905. * @param uniform defines the webGL uniform location where to store the value
  103906. * @param array defines the array of number to store
  103907. */
  103908. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103909. /**
  103910. * Set the value of an uniform to an array of number (stored as vec3)
  103911. * @param uniform defines the webGL uniform location where to store the value
  103912. * @param array defines the array of number to store
  103913. */
  103914. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103915. /**
  103916. * Set the value of an uniform to an array of number (stored as vec4)
  103917. * @param uniform defines the webGL uniform location where to store the value
  103918. * @param array defines the array of number to store
  103919. */
  103920. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103921. /**
  103922. * Set the value of an uniform to an array of float32 (stored as matrices)
  103923. * @param uniform defines the webGL uniform location where to store the value
  103924. * @param matrices defines the array of float32 to store
  103925. */
  103926. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  103927. /**
  103928. * Set the value of an uniform to a matrix (3x3)
  103929. * @param uniform defines the webGL uniform location where to store the value
  103930. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  103931. */
  103932. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  103933. /**
  103934. * Set the value of an uniform to a matrix (2x2)
  103935. * @param uniform defines the webGL uniform location where to store the value
  103936. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  103937. */
  103938. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  103939. /**
  103940. * Set the value of an uniform to a number (float)
  103941. * @param uniform defines the webGL uniform location where to store the value
  103942. * @param value defines the float number to store
  103943. */
  103944. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  103945. /**
  103946. * Set the value of an uniform to a vec2
  103947. * @param uniform defines the webGL uniform location where to store the value
  103948. * @param x defines the 1st component of the value
  103949. * @param y defines the 2nd component of the value
  103950. */
  103951. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  103952. /**
  103953. * Set the value of an uniform to a vec3
  103954. * @param uniform defines the webGL uniform location where to store the value
  103955. * @param x defines the 1st component of the value
  103956. * @param y defines the 2nd component of the value
  103957. * @param z defines the 3rd component of the value
  103958. */
  103959. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  103960. /**
  103961. * Set the value of an uniform to a vec4
  103962. * @param uniform defines the webGL uniform location where to store the value
  103963. * @param x defines the 1st component of the value
  103964. * @param y defines the 2nd component of the value
  103965. * @param z defines the 3rd component of the value
  103966. * @param w defines the 4th component of the value
  103967. */
  103968. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  103969. /**
  103970. * Apply all cached states (depth, culling, stencil and alpha)
  103971. */
  103972. applyStates(): void;
  103973. /**
  103974. * Enable or disable color writing
  103975. * @param enable defines the state to set
  103976. */
  103977. setColorWrite(enable: boolean): void;
  103978. /**
  103979. * Gets a boolean indicating if color writing is enabled
  103980. * @returns the current color writing state
  103981. */
  103982. getColorWrite(): boolean;
  103983. /**
  103984. * Gets the depth culling state manager
  103985. */
  103986. get depthCullingState(): DepthCullingState;
  103987. /**
  103988. * Gets the alpha state manager
  103989. */
  103990. get alphaState(): AlphaState;
  103991. /**
  103992. * Gets the stencil state manager
  103993. */
  103994. get stencilState(): StencilState;
  103995. /**
  103996. * Clears the list of texture accessible through engine.
  103997. * This can help preventing texture load conflict due to name collision.
  103998. */
  103999. clearInternalTexturesCache(): void;
  104000. /**
  104001. * Force the entire cache to be cleared
  104002. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104003. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104004. */
  104005. wipeCaches(bruteForce?: boolean): void;
  104006. /** @hidden */
  104007. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104008. min: number;
  104009. mag: number;
  104010. };
  104011. /** @hidden */
  104012. _createTexture(): WebGLTexture;
  104013. /**
  104014. * Usually called from Texture.ts.
  104015. * Passed information to create a WebGLTexture
  104016. * @param urlArg defines a value which contains one of the following:
  104017. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104018. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104019. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104020. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104021. * @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)
  104022. * @param scene needed for loading to the correct scene
  104023. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104024. * @param onLoad optional callback to be called upon successful completion
  104025. * @param onError optional callback to be called upon failure
  104026. * @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
  104027. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104028. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104029. * @param forcedExtension defines the extension to use to pick the right loader
  104030. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  104031. * @param mimeType defines an optional mime type
  104032. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104033. */
  104034. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  104035. /**
  104036. * Loads an image as an HTMLImageElement.
  104037. * @param input url string, ArrayBuffer, or Blob to load
  104038. * @param onLoad callback called when the image successfully loads
  104039. * @param onError callback called when the image fails to load
  104040. * @param offlineProvider offline provider for caching
  104041. * @param mimeType optional mime type
  104042. * @returns the HTMLImageElement of the loaded image
  104043. * @hidden
  104044. */
  104045. 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>;
  104046. /**
  104047. * @hidden
  104048. */
  104049. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104050. /**
  104051. * Creates a raw texture
  104052. * @param data defines the data to store in the texture
  104053. * @param width defines the width of the texture
  104054. * @param height defines the height of the texture
  104055. * @param format defines the format of the data
  104056. * @param generateMipMaps defines if the engine should generate the mip levels
  104057. * @param invertY defines if data must be stored with Y axis inverted
  104058. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104059. * @param compression defines the compression used (null by default)
  104060. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104061. * @returns the raw texture inside an InternalTexture
  104062. */
  104063. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104064. /**
  104065. * Creates a new raw cube texture
  104066. * @param data defines the array of data to use to create each face
  104067. * @param size defines the size of the textures
  104068. * @param format defines the format of the data
  104069. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104070. * @param generateMipMaps defines if the engine should generate the mip levels
  104071. * @param invertY defines if data must be stored with Y axis inverted
  104072. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104073. * @param compression defines the compression used (null by default)
  104074. * @returns the cube texture as an InternalTexture
  104075. */
  104076. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104077. /**
  104078. * Creates a new raw 3D texture
  104079. * @param data defines the data used to create the texture
  104080. * @param width defines the width of the texture
  104081. * @param height defines the height of the texture
  104082. * @param depth defines the depth of the texture
  104083. * @param format defines the format of the texture
  104084. * @param generateMipMaps defines if the engine must generate mip levels
  104085. * @param invertY defines if data must be stored with Y axis inverted
  104086. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104087. * @param compression defines the compressed used (can be null)
  104088. * @param textureType defines the compressed used (can be null)
  104089. * @returns a new raw 3D texture (stored in an InternalTexture)
  104090. */
  104091. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104092. /**
  104093. * Creates a new raw 2D array texture
  104094. * @param data defines the data used to create the texture
  104095. * @param width defines the width of the texture
  104096. * @param height defines the height of the texture
  104097. * @param depth defines the number of layers of the texture
  104098. * @param format defines the format of the texture
  104099. * @param generateMipMaps defines if the engine must generate mip levels
  104100. * @param invertY defines if data must be stored with Y axis inverted
  104101. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104102. * @param compression defines the compressed used (can be null)
  104103. * @param textureType defines the compressed used (can be null)
  104104. * @returns a new raw 2D array texture (stored in an InternalTexture)
  104105. */
  104106. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104107. private _unpackFlipYCached;
  104108. /**
  104109. * In case you are sharing the context with other applications, it might
  104110. * be interested to not cache the unpack flip y state to ensure a consistent
  104111. * value would be set.
  104112. */
  104113. enableUnpackFlipYCached: boolean;
  104114. /** @hidden */
  104115. _unpackFlipY(value: boolean): void;
  104116. /** @hidden */
  104117. _getUnpackAlignement(): number;
  104118. private _getTextureTarget;
  104119. /**
  104120. * Update the sampling mode of a given texture
  104121. * @param samplingMode defines the required sampling mode
  104122. * @param texture defines the texture to update
  104123. * @param generateMipMaps defines whether to generate mipmaps for the texture
  104124. */
  104125. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  104126. /**
  104127. * Update the sampling mode of a given texture
  104128. * @param texture defines the texture to update
  104129. * @param wrapU defines the texture wrap mode of the u coordinates
  104130. * @param wrapV defines the texture wrap mode of the v coordinates
  104131. * @param wrapR defines the texture wrap mode of the r coordinates
  104132. */
  104133. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  104134. /** @hidden */
  104135. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  104136. width: number;
  104137. height: number;
  104138. layers?: number;
  104139. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  104140. /** @hidden */
  104141. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104142. /** @hidden */
  104143. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  104144. /**
  104145. * Update a portion of an internal texture
  104146. * @param texture defines the texture to update
  104147. * @param imageData defines the data to store into the texture
  104148. * @param xOffset defines the x coordinates of the update rectangle
  104149. * @param yOffset defines the y coordinates of the update rectangle
  104150. * @param width defines the width of the update rectangle
  104151. * @param height defines the height of the update rectangle
  104152. * @param faceIndex defines the face index if texture is a cube (0 by default)
  104153. * @param lod defines the lod level to update (0 by default)
  104154. */
  104155. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  104156. /** @hidden */
  104157. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104158. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  104159. private _prepareWebGLTexture;
  104160. /** @hidden */
  104161. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  104162. private _getDepthStencilBuffer;
  104163. /** @hidden */
  104164. _releaseFramebufferObjects(texture: InternalTexture): void;
  104165. /** @hidden */
  104166. _releaseTexture(texture: InternalTexture): void;
  104167. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  104168. protected _setProgram(program: WebGLProgram): void;
  104169. protected _boundUniforms: {
  104170. [key: number]: WebGLUniformLocation;
  104171. };
  104172. /**
  104173. * Binds an effect to the webGL context
  104174. * @param effect defines the effect to bind
  104175. */
  104176. bindSamplers(effect: Effect): void;
  104177. private _activateCurrentTexture;
  104178. /** @hidden */
  104179. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  104180. /** @hidden */
  104181. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  104182. /**
  104183. * Unbind all textures from the webGL context
  104184. */
  104185. unbindAllTextures(): void;
  104186. /**
  104187. * Sets a texture to the according uniform.
  104188. * @param channel The texture channel
  104189. * @param uniform The uniform to set
  104190. * @param texture The texture to apply
  104191. */
  104192. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  104193. private _bindSamplerUniformToChannel;
  104194. private _getTextureWrapMode;
  104195. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  104196. /**
  104197. * Sets an array of texture to the webGL context
  104198. * @param channel defines the channel where the texture array must be set
  104199. * @param uniform defines the associated uniform location
  104200. * @param textures defines the array of textures to bind
  104201. */
  104202. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  104203. /** @hidden */
  104204. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  104205. private _setTextureParameterFloat;
  104206. private _setTextureParameterInteger;
  104207. /**
  104208. * Unbind all vertex attributes from the webGL context
  104209. */
  104210. unbindAllAttributes(): void;
  104211. /**
  104212. * 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
  104213. */
  104214. releaseEffects(): void;
  104215. /**
  104216. * Dispose and release all associated resources
  104217. */
  104218. dispose(): void;
  104219. /**
  104220. * Attach a new callback raised when context lost event is fired
  104221. * @param callback defines the callback to call
  104222. */
  104223. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104224. /**
  104225. * Attach a new callback raised when context restored event is fired
  104226. * @param callback defines the callback to call
  104227. */
  104228. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104229. /**
  104230. * Get the current error code of the webGL context
  104231. * @returns the error code
  104232. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104233. */
  104234. getError(): number;
  104235. private _canRenderToFloatFramebuffer;
  104236. private _canRenderToHalfFloatFramebuffer;
  104237. private _canRenderToFramebuffer;
  104238. /** @hidden */
  104239. _getWebGLTextureType(type: number): number;
  104240. /** @hidden */
  104241. _getInternalFormat(format: number): number;
  104242. /** @hidden */
  104243. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  104244. /** @hidden */
  104245. _getRGBAMultiSampleBufferFormat(type: number): number;
  104246. /** @hidden */
  104247. _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;
  104248. /**
  104249. * Loads a file from a url
  104250. * @param url url to load
  104251. * @param onSuccess callback called when the file successfully loads
  104252. * @param onProgress callback called while file is loading (if the server supports this mode)
  104253. * @param offlineProvider defines the offline provider for caching
  104254. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104255. * @param onError callback called when the file fails to load
  104256. * @returns a file request object
  104257. * @hidden
  104258. */
  104259. 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;
  104260. /**
  104261. * Reads pixels from the current frame buffer. Please note that this function can be slow
  104262. * @param x defines the x coordinate of the rectangle where pixels must be read
  104263. * @param y defines the y coordinate of the rectangle where pixels must be read
  104264. * @param width defines the width of the rectangle where pixels must be read
  104265. * @param height defines the height of the rectangle where pixels must be read
  104266. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  104267. * @returns a Uint8Array containing RGBA colors
  104268. */
  104269. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  104270. private static _isSupported;
  104271. /**
  104272. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  104273. * @returns true if the engine can be created
  104274. * @ignorenaming
  104275. */
  104276. static isSupported(): boolean;
  104277. /**
  104278. * Find the next highest power of two.
  104279. * @param x Number to start search from.
  104280. * @return Next highest power of two.
  104281. */
  104282. static CeilingPOT(x: number): number;
  104283. /**
  104284. * Find the next lowest power of two.
  104285. * @param x Number to start search from.
  104286. * @return Next lowest power of two.
  104287. */
  104288. static FloorPOT(x: number): number;
  104289. /**
  104290. * Find the nearest power of two.
  104291. * @param x Number to start search from.
  104292. * @return Next nearest power of two.
  104293. */
  104294. static NearestPOT(x: number): number;
  104295. /**
  104296. * Get the closest exponent of two
  104297. * @param value defines the value to approximate
  104298. * @param max defines the maximum value to return
  104299. * @param mode defines how to define the closest value
  104300. * @returns closest exponent of two of the given value
  104301. */
  104302. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  104303. /**
  104304. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  104305. * @param func - the function to be called
  104306. * @param requester - the object that will request the next frame. Falls back to window.
  104307. * @returns frame number
  104308. */
  104309. static QueueNewFrame(func: () => void, requester?: any): number;
  104310. /**
  104311. * Gets host document
  104312. * @returns the host document object
  104313. */
  104314. getHostDocument(): Nullable<Document>;
  104315. }
  104316. }
  104317. declare module BABYLON {
  104318. /**
  104319. * Class representing spherical harmonics coefficients to the 3rd degree
  104320. */
  104321. export class SphericalHarmonics {
  104322. /**
  104323. * Defines whether or not the harmonics have been prescaled for rendering.
  104324. */
  104325. preScaled: boolean;
  104326. /**
  104327. * The l0,0 coefficients of the spherical harmonics
  104328. */
  104329. l00: Vector3;
  104330. /**
  104331. * The l1,-1 coefficients of the spherical harmonics
  104332. */
  104333. l1_1: Vector3;
  104334. /**
  104335. * The l1,0 coefficients of the spherical harmonics
  104336. */
  104337. l10: Vector3;
  104338. /**
  104339. * The l1,1 coefficients of the spherical harmonics
  104340. */
  104341. l11: Vector3;
  104342. /**
  104343. * The l2,-2 coefficients of the spherical harmonics
  104344. */
  104345. l2_2: Vector3;
  104346. /**
  104347. * The l2,-1 coefficients of the spherical harmonics
  104348. */
  104349. l2_1: Vector3;
  104350. /**
  104351. * The l2,0 coefficients of the spherical harmonics
  104352. */
  104353. l20: Vector3;
  104354. /**
  104355. * The l2,1 coefficients of the spherical harmonics
  104356. */
  104357. l21: Vector3;
  104358. /**
  104359. * The l2,2 coefficients of the spherical harmonics
  104360. */
  104361. l22: Vector3;
  104362. /**
  104363. * Adds a light to the spherical harmonics
  104364. * @param direction the direction of the light
  104365. * @param color the color of the light
  104366. * @param deltaSolidAngle the delta solid angle of the light
  104367. */
  104368. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  104369. /**
  104370. * Scales the spherical harmonics by the given amount
  104371. * @param scale the amount to scale
  104372. */
  104373. scaleInPlace(scale: number): void;
  104374. /**
  104375. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  104376. *
  104377. * ```
  104378. * E_lm = A_l * L_lm
  104379. * ```
  104380. *
  104381. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  104382. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  104383. * the scaling factors are given in equation 9.
  104384. */
  104385. convertIncidentRadianceToIrradiance(): void;
  104386. /**
  104387. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  104388. *
  104389. * ```
  104390. * L = (1/pi) * E * rho
  104391. * ```
  104392. *
  104393. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  104394. */
  104395. convertIrradianceToLambertianRadiance(): void;
  104396. /**
  104397. * Integrates the reconstruction coefficients directly in to the SH preventing further
  104398. * required operations at run time.
  104399. *
  104400. * This is simply done by scaling back the SH with Ylm constants parameter.
  104401. * The trigonometric part being applied by the shader at run time.
  104402. */
  104403. preScaleForRendering(): void;
  104404. /**
  104405. * Constructs a spherical harmonics from an array.
  104406. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  104407. * @returns the spherical harmonics
  104408. */
  104409. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  104410. /**
  104411. * Gets the spherical harmonics from polynomial
  104412. * @param polynomial the spherical polynomial
  104413. * @returns the spherical harmonics
  104414. */
  104415. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  104416. }
  104417. /**
  104418. * Class representing spherical polynomial coefficients to the 3rd degree
  104419. */
  104420. export class SphericalPolynomial {
  104421. private _harmonics;
  104422. /**
  104423. * The spherical harmonics used to create the polynomials.
  104424. */
  104425. get preScaledHarmonics(): SphericalHarmonics;
  104426. /**
  104427. * The x coefficients of the spherical polynomial
  104428. */
  104429. x: Vector3;
  104430. /**
  104431. * The y coefficients of the spherical polynomial
  104432. */
  104433. y: Vector3;
  104434. /**
  104435. * The z coefficients of the spherical polynomial
  104436. */
  104437. z: Vector3;
  104438. /**
  104439. * The xx coefficients of the spherical polynomial
  104440. */
  104441. xx: Vector3;
  104442. /**
  104443. * The yy coefficients of the spherical polynomial
  104444. */
  104445. yy: Vector3;
  104446. /**
  104447. * The zz coefficients of the spherical polynomial
  104448. */
  104449. zz: Vector3;
  104450. /**
  104451. * The xy coefficients of the spherical polynomial
  104452. */
  104453. xy: Vector3;
  104454. /**
  104455. * The yz coefficients of the spherical polynomial
  104456. */
  104457. yz: Vector3;
  104458. /**
  104459. * The zx coefficients of the spherical polynomial
  104460. */
  104461. zx: Vector3;
  104462. /**
  104463. * Adds an ambient color to the spherical polynomial
  104464. * @param color the color to add
  104465. */
  104466. addAmbient(color: Color3): void;
  104467. /**
  104468. * Scales the spherical polynomial by the given amount
  104469. * @param scale the amount to scale
  104470. */
  104471. scaleInPlace(scale: number): void;
  104472. /**
  104473. * Gets the spherical polynomial from harmonics
  104474. * @param harmonics the spherical harmonics
  104475. * @returns the spherical polynomial
  104476. */
  104477. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  104478. /**
  104479. * Constructs a spherical polynomial from an array.
  104480. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  104481. * @returns the spherical polynomial
  104482. */
  104483. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  104484. }
  104485. }
  104486. declare module BABYLON {
  104487. /**
  104488. * Defines the source of the internal texture
  104489. */
  104490. export enum InternalTextureSource {
  104491. /**
  104492. * The source of the texture data is unknown
  104493. */
  104494. Unknown = 0,
  104495. /**
  104496. * Texture data comes from an URL
  104497. */
  104498. Url = 1,
  104499. /**
  104500. * Texture data is only used for temporary storage
  104501. */
  104502. Temp = 2,
  104503. /**
  104504. * Texture data comes from raw data (ArrayBuffer)
  104505. */
  104506. Raw = 3,
  104507. /**
  104508. * Texture content is dynamic (video or dynamic texture)
  104509. */
  104510. Dynamic = 4,
  104511. /**
  104512. * Texture content is generated by rendering to it
  104513. */
  104514. RenderTarget = 5,
  104515. /**
  104516. * Texture content is part of a multi render target process
  104517. */
  104518. MultiRenderTarget = 6,
  104519. /**
  104520. * Texture data comes from a cube data file
  104521. */
  104522. Cube = 7,
  104523. /**
  104524. * Texture data comes from a raw cube data
  104525. */
  104526. CubeRaw = 8,
  104527. /**
  104528. * Texture data come from a prefiltered cube data file
  104529. */
  104530. CubePrefiltered = 9,
  104531. /**
  104532. * Texture content is raw 3D data
  104533. */
  104534. Raw3D = 10,
  104535. /**
  104536. * Texture content is raw 2D array data
  104537. */
  104538. Raw2DArray = 11,
  104539. /**
  104540. * Texture content is a depth texture
  104541. */
  104542. Depth = 12,
  104543. /**
  104544. * Texture data comes from a raw cube data encoded with RGBD
  104545. */
  104546. CubeRawRGBD = 13
  104547. }
  104548. /**
  104549. * Class used to store data associated with WebGL texture data for the engine
  104550. * This class should not be used directly
  104551. */
  104552. export class InternalTexture {
  104553. /** @hidden */
  104554. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  104555. /**
  104556. * Defines if the texture is ready
  104557. */
  104558. isReady: boolean;
  104559. /**
  104560. * Defines if the texture is a cube texture
  104561. */
  104562. isCube: boolean;
  104563. /**
  104564. * Defines if the texture contains 3D data
  104565. */
  104566. is3D: boolean;
  104567. /**
  104568. * Defines if the texture contains 2D array data
  104569. */
  104570. is2DArray: boolean;
  104571. /**
  104572. * Defines if the texture contains multiview data
  104573. */
  104574. isMultiview: boolean;
  104575. /**
  104576. * Gets the URL used to load this texture
  104577. */
  104578. url: string;
  104579. /**
  104580. * Gets the sampling mode of the texture
  104581. */
  104582. samplingMode: number;
  104583. /**
  104584. * Gets a boolean indicating if the texture needs mipmaps generation
  104585. */
  104586. generateMipMaps: boolean;
  104587. /**
  104588. * Gets the number of samples used by the texture (WebGL2+ only)
  104589. */
  104590. samples: number;
  104591. /**
  104592. * Gets the type of the texture (int, float...)
  104593. */
  104594. type: number;
  104595. /**
  104596. * Gets the format of the texture (RGB, RGBA...)
  104597. */
  104598. format: number;
  104599. /**
  104600. * Observable called when the texture is loaded
  104601. */
  104602. onLoadedObservable: Observable<InternalTexture>;
  104603. /**
  104604. * Gets the width of the texture
  104605. */
  104606. width: number;
  104607. /**
  104608. * Gets the height of the texture
  104609. */
  104610. height: number;
  104611. /**
  104612. * Gets the depth of the texture
  104613. */
  104614. depth: number;
  104615. /**
  104616. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  104617. */
  104618. baseWidth: number;
  104619. /**
  104620. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  104621. */
  104622. baseHeight: number;
  104623. /**
  104624. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  104625. */
  104626. baseDepth: number;
  104627. /**
  104628. * Gets a boolean indicating if the texture is inverted on Y axis
  104629. */
  104630. invertY: boolean;
  104631. /** @hidden */
  104632. _invertVScale: boolean;
  104633. /** @hidden */
  104634. _associatedChannel: number;
  104635. /** @hidden */
  104636. _source: InternalTextureSource;
  104637. /** @hidden */
  104638. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104639. /** @hidden */
  104640. _bufferView: Nullable<ArrayBufferView>;
  104641. /** @hidden */
  104642. _bufferViewArray: Nullable<ArrayBufferView[]>;
  104643. /** @hidden */
  104644. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  104645. /** @hidden */
  104646. _size: number;
  104647. /** @hidden */
  104648. _extension: string;
  104649. /** @hidden */
  104650. _files: Nullable<string[]>;
  104651. /** @hidden */
  104652. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104653. /** @hidden */
  104654. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104655. /** @hidden */
  104656. _framebuffer: Nullable<WebGLFramebuffer>;
  104657. /** @hidden */
  104658. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  104659. /** @hidden */
  104660. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  104661. /** @hidden */
  104662. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  104663. /** @hidden */
  104664. _attachments: Nullable<number[]>;
  104665. /** @hidden */
  104666. _cachedCoordinatesMode: Nullable<number>;
  104667. /** @hidden */
  104668. _cachedWrapU: Nullable<number>;
  104669. /** @hidden */
  104670. _cachedWrapV: Nullable<number>;
  104671. /** @hidden */
  104672. _cachedWrapR: Nullable<number>;
  104673. /** @hidden */
  104674. _cachedAnisotropicFilteringLevel: Nullable<number>;
  104675. /** @hidden */
  104676. _isDisabled: boolean;
  104677. /** @hidden */
  104678. _compression: Nullable<string>;
  104679. /** @hidden */
  104680. _generateStencilBuffer: boolean;
  104681. /** @hidden */
  104682. _generateDepthBuffer: boolean;
  104683. /** @hidden */
  104684. _comparisonFunction: number;
  104685. /** @hidden */
  104686. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  104687. /** @hidden */
  104688. _lodGenerationScale: number;
  104689. /** @hidden */
  104690. _lodGenerationOffset: number;
  104691. /** @hidden */
  104692. _depthStencilTexture: Nullable<InternalTexture>;
  104693. /** @hidden */
  104694. _colorTextureArray: Nullable<WebGLTexture>;
  104695. /** @hidden */
  104696. _depthStencilTextureArray: Nullable<WebGLTexture>;
  104697. /** @hidden */
  104698. _lodTextureHigh: Nullable<BaseTexture>;
  104699. /** @hidden */
  104700. _lodTextureMid: Nullable<BaseTexture>;
  104701. /** @hidden */
  104702. _lodTextureLow: Nullable<BaseTexture>;
  104703. /** @hidden */
  104704. _isRGBD: boolean;
  104705. /** @hidden */
  104706. _linearSpecularLOD: boolean;
  104707. /** @hidden */
  104708. _irradianceTexture: Nullable<BaseTexture>;
  104709. /** @hidden */
  104710. _webGLTexture: Nullable<WebGLTexture>;
  104711. /** @hidden */
  104712. _references: number;
  104713. private _engine;
  104714. /**
  104715. * Gets the Engine the texture belongs to.
  104716. * @returns The babylon engine
  104717. */
  104718. getEngine(): ThinEngine;
  104719. /**
  104720. * Gets the data source type of the texture
  104721. */
  104722. get source(): InternalTextureSource;
  104723. /**
  104724. * Creates a new InternalTexture
  104725. * @param engine defines the engine to use
  104726. * @param source defines the type of data that will be used
  104727. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104728. */
  104729. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  104730. /**
  104731. * Increments the number of references (ie. the number of Texture that point to it)
  104732. */
  104733. incrementReferences(): void;
  104734. /**
  104735. * Change the size of the texture (not the size of the content)
  104736. * @param width defines the new width
  104737. * @param height defines the new height
  104738. * @param depth defines the new depth (1 by default)
  104739. */
  104740. updateSize(width: int, height: int, depth?: int): void;
  104741. /** @hidden */
  104742. _rebuild(): void;
  104743. /** @hidden */
  104744. _swapAndDie(target: InternalTexture): void;
  104745. /**
  104746. * Dispose the current allocated resources
  104747. */
  104748. dispose(): void;
  104749. }
  104750. }
  104751. declare module BABYLON {
  104752. /**
  104753. * Class used to work with sound analyzer using fast fourier transform (FFT)
  104754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104755. */
  104756. export class Analyser {
  104757. /**
  104758. * Gets or sets the smoothing
  104759. * @ignorenaming
  104760. */
  104761. SMOOTHING: number;
  104762. /**
  104763. * Gets or sets the FFT table size
  104764. * @ignorenaming
  104765. */
  104766. FFT_SIZE: number;
  104767. /**
  104768. * Gets or sets the bar graph amplitude
  104769. * @ignorenaming
  104770. */
  104771. BARGRAPHAMPLITUDE: number;
  104772. /**
  104773. * Gets or sets the position of the debug canvas
  104774. * @ignorenaming
  104775. */
  104776. DEBUGCANVASPOS: {
  104777. x: number;
  104778. y: number;
  104779. };
  104780. /**
  104781. * Gets or sets the debug canvas size
  104782. * @ignorenaming
  104783. */
  104784. DEBUGCANVASSIZE: {
  104785. width: number;
  104786. height: number;
  104787. };
  104788. private _byteFreqs;
  104789. private _byteTime;
  104790. private _floatFreqs;
  104791. private _webAudioAnalyser;
  104792. private _debugCanvas;
  104793. private _debugCanvasContext;
  104794. private _scene;
  104795. private _registerFunc;
  104796. private _audioEngine;
  104797. /**
  104798. * Creates a new analyser
  104799. * @param scene defines hosting scene
  104800. */
  104801. constructor(scene: Scene);
  104802. /**
  104803. * Get the number of data values you will have to play with for the visualization
  104804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  104805. * @returns a number
  104806. */
  104807. getFrequencyBinCount(): number;
  104808. /**
  104809. * Gets the current frequency data as a byte array
  104810. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  104811. * @returns a Uint8Array
  104812. */
  104813. getByteFrequencyData(): Uint8Array;
  104814. /**
  104815. * Gets the current waveform as a byte array
  104816. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  104817. * @returns a Uint8Array
  104818. */
  104819. getByteTimeDomainData(): Uint8Array;
  104820. /**
  104821. * Gets the current frequency data as a float array
  104822. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  104823. * @returns a Float32Array
  104824. */
  104825. getFloatFrequencyData(): Float32Array;
  104826. /**
  104827. * Renders the debug canvas
  104828. */
  104829. drawDebugCanvas(): void;
  104830. /**
  104831. * Stops rendering the debug canvas and removes it
  104832. */
  104833. stopDebugCanvas(): void;
  104834. /**
  104835. * Connects two audio nodes
  104836. * @param inputAudioNode defines first node to connect
  104837. * @param outputAudioNode defines second node to connect
  104838. */
  104839. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  104840. /**
  104841. * Releases all associated resources
  104842. */
  104843. dispose(): void;
  104844. }
  104845. }
  104846. declare module BABYLON {
  104847. /**
  104848. * This represents an audio engine and it is responsible
  104849. * to play, synchronize and analyse sounds throughout the application.
  104850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104851. */
  104852. export interface IAudioEngine extends IDisposable {
  104853. /**
  104854. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  104855. */
  104856. readonly canUseWebAudio: boolean;
  104857. /**
  104858. * Gets the current AudioContext if available.
  104859. */
  104860. readonly audioContext: Nullable<AudioContext>;
  104861. /**
  104862. * The master gain node defines the global audio volume of your audio engine.
  104863. */
  104864. readonly masterGain: GainNode;
  104865. /**
  104866. * Gets whether or not mp3 are supported by your browser.
  104867. */
  104868. readonly isMP3supported: boolean;
  104869. /**
  104870. * Gets whether or not ogg are supported by your browser.
  104871. */
  104872. readonly isOGGsupported: boolean;
  104873. /**
  104874. * Defines if Babylon should emit a warning if WebAudio is not supported.
  104875. * @ignoreNaming
  104876. */
  104877. WarnedWebAudioUnsupported: boolean;
  104878. /**
  104879. * Defines if the audio engine relies on a custom unlocked button.
  104880. * In this case, the embedded button will not be displayed.
  104881. */
  104882. useCustomUnlockedButton: boolean;
  104883. /**
  104884. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  104885. */
  104886. readonly unlocked: boolean;
  104887. /**
  104888. * Event raised when audio has been unlocked on the browser.
  104889. */
  104890. onAudioUnlockedObservable: Observable<AudioEngine>;
  104891. /**
  104892. * Event raised when audio has been locked on the browser.
  104893. */
  104894. onAudioLockedObservable: Observable<AudioEngine>;
  104895. /**
  104896. * Flags the audio engine in Locked state.
  104897. * This happens due to new browser policies preventing audio to autoplay.
  104898. */
  104899. lock(): void;
  104900. /**
  104901. * Unlocks the audio engine once a user action has been done on the dom.
  104902. * This is helpful to resume play once browser policies have been satisfied.
  104903. */
  104904. unlock(): void;
  104905. }
  104906. /**
  104907. * This represents the default audio engine used in babylon.
  104908. * It is responsible to play, synchronize and analyse sounds throughout the application.
  104909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104910. */
  104911. export class AudioEngine implements IAudioEngine {
  104912. private _audioContext;
  104913. private _audioContextInitialized;
  104914. private _muteButton;
  104915. private _hostElement;
  104916. /**
  104917. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  104918. */
  104919. canUseWebAudio: boolean;
  104920. /**
  104921. * The master gain node defines the global audio volume of your audio engine.
  104922. */
  104923. masterGain: GainNode;
  104924. /**
  104925. * Defines if Babylon should emit a warning if WebAudio is not supported.
  104926. * @ignoreNaming
  104927. */
  104928. WarnedWebAudioUnsupported: boolean;
  104929. /**
  104930. * Gets whether or not mp3 are supported by your browser.
  104931. */
  104932. isMP3supported: boolean;
  104933. /**
  104934. * Gets whether or not ogg are supported by your browser.
  104935. */
  104936. isOGGsupported: boolean;
  104937. /**
  104938. * Gets whether audio has been unlocked on the device.
  104939. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  104940. * a user interaction has happened.
  104941. */
  104942. unlocked: boolean;
  104943. /**
  104944. * Defines if the audio engine relies on a custom unlocked button.
  104945. * In this case, the embedded button will not be displayed.
  104946. */
  104947. useCustomUnlockedButton: boolean;
  104948. /**
  104949. * Event raised when audio has been unlocked on the browser.
  104950. */
  104951. onAudioUnlockedObservable: Observable<AudioEngine>;
  104952. /**
  104953. * Event raised when audio has been locked on the browser.
  104954. */
  104955. onAudioLockedObservable: Observable<AudioEngine>;
  104956. /**
  104957. * Gets the current AudioContext if available.
  104958. */
  104959. get audioContext(): Nullable<AudioContext>;
  104960. private _connectedAnalyser;
  104961. /**
  104962. * Instantiates a new audio engine.
  104963. *
  104964. * There should be only one per page as some browsers restrict the number
  104965. * of audio contexts you can create.
  104966. * @param hostElement defines the host element where to display the mute icon if necessary
  104967. */
  104968. constructor(hostElement?: Nullable<HTMLElement>);
  104969. /**
  104970. * Flags the audio engine in Locked state.
  104971. * This happens due to new browser policies preventing audio to autoplay.
  104972. */
  104973. lock(): void;
  104974. /**
  104975. * Unlocks the audio engine once a user action has been done on the dom.
  104976. * This is helpful to resume play once browser policies have been satisfied.
  104977. */
  104978. unlock(): void;
  104979. private _resumeAudioContext;
  104980. private _initializeAudioContext;
  104981. private _tryToRun;
  104982. private _triggerRunningState;
  104983. private _triggerSuspendedState;
  104984. private _displayMuteButton;
  104985. private _moveButtonToTopLeft;
  104986. private _onResize;
  104987. private _hideMuteButton;
  104988. /**
  104989. * Destroy and release the resources associated with the audio ccontext.
  104990. */
  104991. dispose(): void;
  104992. /**
  104993. * Gets the global volume sets on the master gain.
  104994. * @returns the global volume if set or -1 otherwise
  104995. */
  104996. getGlobalVolume(): number;
  104997. /**
  104998. * Sets the global volume of your experience (sets on the master gain).
  104999. * @param newVolume Defines the new global volume of the application
  105000. */
  105001. setGlobalVolume(newVolume: number): void;
  105002. /**
  105003. * Connect the audio engine to an audio analyser allowing some amazing
  105004. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105006. * @param analyser The analyser to connect to the engine
  105007. */
  105008. connectToAnalyser(analyser: Analyser): void;
  105009. }
  105010. }
  105011. declare module BABYLON {
  105012. /**
  105013. * Interface used to present a loading screen while loading a scene
  105014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105015. */
  105016. export interface ILoadingScreen {
  105017. /**
  105018. * Function called to display the loading screen
  105019. */
  105020. displayLoadingUI: () => void;
  105021. /**
  105022. * Function called to hide the loading screen
  105023. */
  105024. hideLoadingUI: () => void;
  105025. /**
  105026. * Gets or sets the color to use for the background
  105027. */
  105028. loadingUIBackgroundColor: string;
  105029. /**
  105030. * Gets or sets the text to display while loading
  105031. */
  105032. loadingUIText: string;
  105033. }
  105034. /**
  105035. * Class used for the default loading screen
  105036. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105037. */
  105038. export class DefaultLoadingScreen implements ILoadingScreen {
  105039. private _renderingCanvas;
  105040. private _loadingText;
  105041. private _loadingDivBackgroundColor;
  105042. private _loadingDiv;
  105043. private _loadingTextDiv;
  105044. /** Gets or sets the logo url to use for the default loading screen */
  105045. static DefaultLogoUrl: string;
  105046. /** Gets or sets the spinner url to use for the default loading screen */
  105047. static DefaultSpinnerUrl: string;
  105048. /**
  105049. * Creates a new default loading screen
  105050. * @param _renderingCanvas defines the canvas used to render the scene
  105051. * @param _loadingText defines the default text to display
  105052. * @param _loadingDivBackgroundColor defines the default background color
  105053. */
  105054. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105055. /**
  105056. * Function called to display the loading screen
  105057. */
  105058. displayLoadingUI(): void;
  105059. /**
  105060. * Function called to hide the loading screen
  105061. */
  105062. hideLoadingUI(): void;
  105063. /**
  105064. * Gets or sets the text to display while loading
  105065. */
  105066. set loadingUIText(text: string);
  105067. get loadingUIText(): string;
  105068. /**
  105069. * Gets or sets the color to use for the background
  105070. */
  105071. get loadingUIBackgroundColor(): string;
  105072. set loadingUIBackgroundColor(color: string);
  105073. private _resizeLoadingUI;
  105074. }
  105075. }
  105076. declare module BABYLON {
  105077. /**
  105078. * Interface for any object that can request an animation frame
  105079. */
  105080. export interface ICustomAnimationFrameRequester {
  105081. /**
  105082. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105083. */
  105084. renderFunction?: Function;
  105085. /**
  105086. * Called to request the next frame to render to
  105087. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105088. */
  105089. requestAnimationFrame: Function;
  105090. /**
  105091. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  105092. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  105093. */
  105094. requestID?: number;
  105095. }
  105096. }
  105097. declare module BABYLON {
  105098. /**
  105099. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  105100. */
  105101. export class PerformanceMonitor {
  105102. private _enabled;
  105103. private _rollingFrameTime;
  105104. private _lastFrameTimeMs;
  105105. /**
  105106. * constructor
  105107. * @param frameSampleSize The number of samples required to saturate the sliding window
  105108. */
  105109. constructor(frameSampleSize?: number);
  105110. /**
  105111. * Samples current frame
  105112. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  105113. */
  105114. sampleFrame(timeMs?: number): void;
  105115. /**
  105116. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105117. */
  105118. get averageFrameTime(): number;
  105119. /**
  105120. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105121. */
  105122. get averageFrameTimeVariance(): number;
  105123. /**
  105124. * Returns the frame time of the most recent frame
  105125. */
  105126. get instantaneousFrameTime(): number;
  105127. /**
  105128. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  105129. */
  105130. get averageFPS(): number;
  105131. /**
  105132. * Returns the average framerate in frames per second using the most recent frame time
  105133. */
  105134. get instantaneousFPS(): number;
  105135. /**
  105136. * Returns true if enough samples have been taken to completely fill the sliding window
  105137. */
  105138. get isSaturated(): boolean;
  105139. /**
  105140. * Enables contributions to the sliding window sample set
  105141. */
  105142. enable(): void;
  105143. /**
  105144. * Disables contributions to the sliding window sample set
  105145. * Samples will not be interpolated over the disabled period
  105146. */
  105147. disable(): void;
  105148. /**
  105149. * Returns true if sampling is enabled
  105150. */
  105151. get isEnabled(): boolean;
  105152. /**
  105153. * Resets performance monitor
  105154. */
  105155. reset(): void;
  105156. }
  105157. /**
  105158. * RollingAverage
  105159. *
  105160. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  105161. */
  105162. export class RollingAverage {
  105163. /**
  105164. * Current average
  105165. */
  105166. average: number;
  105167. /**
  105168. * Current variance
  105169. */
  105170. variance: number;
  105171. protected _samples: Array<number>;
  105172. protected _sampleCount: number;
  105173. protected _pos: number;
  105174. protected _m2: number;
  105175. /**
  105176. * constructor
  105177. * @param length The number of samples required to saturate the sliding window
  105178. */
  105179. constructor(length: number);
  105180. /**
  105181. * Adds a sample to the sample set
  105182. * @param v The sample value
  105183. */
  105184. add(v: number): void;
  105185. /**
  105186. * Returns previously added values or null if outside of history or outside the sliding window domain
  105187. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  105188. * @return Value previously recorded with add() or null if outside of range
  105189. */
  105190. history(i: number): number;
  105191. /**
  105192. * Returns true if enough samples have been taken to completely fill the sliding window
  105193. * @return true if sample-set saturated
  105194. */
  105195. isSaturated(): boolean;
  105196. /**
  105197. * Resets the rolling average (equivalent to 0 samples taken so far)
  105198. */
  105199. reset(): void;
  105200. /**
  105201. * Wraps a value around the sample range boundaries
  105202. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  105203. * @return Wrapped position in sample range
  105204. */
  105205. protected _wrapPosition(i: number): number;
  105206. }
  105207. }
  105208. declare module BABYLON {
  105209. /**
  105210. * This class is used to track a performance counter which is number based.
  105211. * The user has access to many properties which give statistics of different nature.
  105212. *
  105213. * The implementer can track two kinds of Performance Counter: time and count.
  105214. * 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.
  105215. * 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.
  105216. */
  105217. export class PerfCounter {
  105218. /**
  105219. * Gets or sets a global boolean to turn on and off all the counters
  105220. */
  105221. static Enabled: boolean;
  105222. /**
  105223. * Returns the smallest value ever
  105224. */
  105225. get min(): number;
  105226. /**
  105227. * Returns the biggest value ever
  105228. */
  105229. get max(): number;
  105230. /**
  105231. * Returns the average value since the performance counter is running
  105232. */
  105233. get average(): number;
  105234. /**
  105235. * Returns the average value of the last second the counter was monitored
  105236. */
  105237. get lastSecAverage(): number;
  105238. /**
  105239. * Returns the current value
  105240. */
  105241. get current(): number;
  105242. /**
  105243. * Gets the accumulated total
  105244. */
  105245. get total(): number;
  105246. /**
  105247. * Gets the total value count
  105248. */
  105249. get count(): number;
  105250. /**
  105251. * Creates a new counter
  105252. */
  105253. constructor();
  105254. /**
  105255. * Call this method to start monitoring a new frame.
  105256. * 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.
  105257. */
  105258. fetchNewFrame(): void;
  105259. /**
  105260. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  105261. * @param newCount the count value to add to the monitored count
  105262. * @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.
  105263. */
  105264. addCount(newCount: number, fetchResult: boolean): void;
  105265. /**
  105266. * Start monitoring this performance counter
  105267. */
  105268. beginMonitoring(): void;
  105269. /**
  105270. * Compute the time lapsed since the previous beginMonitoring() call.
  105271. * @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
  105272. */
  105273. endMonitoring(newFrame?: boolean): void;
  105274. private _fetchResult;
  105275. private _startMonitoringTime;
  105276. private _min;
  105277. private _max;
  105278. private _average;
  105279. private _current;
  105280. private _totalValueCount;
  105281. private _totalAccumulated;
  105282. private _lastSecAverage;
  105283. private _lastSecAccumulated;
  105284. private _lastSecTime;
  105285. private _lastSecValueCount;
  105286. }
  105287. }
  105288. declare module BABYLON {
  105289. interface ThinEngine {
  105290. /**
  105291. * Sets alpha constants used by some alpha blending modes
  105292. * @param r defines the red component
  105293. * @param g defines the green component
  105294. * @param b defines the blue component
  105295. * @param a defines the alpha component
  105296. */
  105297. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  105298. /**
  105299. * Sets the current alpha mode
  105300. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  105301. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  105302. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105303. */
  105304. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105305. /**
  105306. * Gets the current alpha mode
  105307. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105308. * @returns the current alpha mode
  105309. */
  105310. getAlphaMode(): number;
  105311. /**
  105312. * Sets the current alpha equation
  105313. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  105314. */
  105315. setAlphaEquation(equation: number): void;
  105316. /**
  105317. * Gets the current alpha equation.
  105318. * @returns the current alpha equation
  105319. */
  105320. getAlphaEquation(): number;
  105321. }
  105322. }
  105323. declare module BABYLON {
  105324. /**
  105325. * Defines the interface used by display changed events
  105326. */
  105327. export interface IDisplayChangedEventArgs {
  105328. /** Gets the vrDisplay object (if any) */
  105329. vrDisplay: Nullable<any>;
  105330. /** Gets a boolean indicating if webVR is supported */
  105331. vrSupported: boolean;
  105332. }
  105333. /**
  105334. * Defines the interface used by objects containing a viewport (like a camera)
  105335. */
  105336. interface IViewportOwnerLike {
  105337. /**
  105338. * Gets or sets the viewport
  105339. */
  105340. viewport: IViewportLike;
  105341. }
  105342. /**
  105343. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  105344. */
  105345. export class Engine extends ThinEngine {
  105346. /** Defines that alpha blending is disabled */
  105347. static readonly ALPHA_DISABLE: number;
  105348. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  105349. static readonly ALPHA_ADD: number;
  105350. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  105351. static readonly ALPHA_COMBINE: number;
  105352. /** Defines that alpha blending to DEST - SRC * DEST */
  105353. static readonly ALPHA_SUBTRACT: number;
  105354. /** Defines that alpha blending to SRC * DEST */
  105355. static readonly ALPHA_MULTIPLY: number;
  105356. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  105357. static readonly ALPHA_MAXIMIZED: number;
  105358. /** Defines that alpha blending to SRC + DEST */
  105359. static readonly ALPHA_ONEONE: number;
  105360. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  105361. static readonly ALPHA_PREMULTIPLIED: number;
  105362. /**
  105363. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  105364. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  105365. */
  105366. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  105367. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  105368. static readonly ALPHA_INTERPOLATE: number;
  105369. /**
  105370. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  105371. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  105372. */
  105373. static readonly ALPHA_SCREENMODE: number;
  105374. /** Defines that the ressource is not delayed*/
  105375. static readonly DELAYLOADSTATE_NONE: number;
  105376. /** Defines that the ressource was successfully delay loaded */
  105377. static readonly DELAYLOADSTATE_LOADED: number;
  105378. /** Defines that the ressource is currently delay loading */
  105379. static readonly DELAYLOADSTATE_LOADING: number;
  105380. /** Defines that the ressource is delayed and has not started loading */
  105381. static readonly DELAYLOADSTATE_NOTLOADED: number;
  105382. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  105383. static readonly NEVER: number;
  105384. /** 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 */
  105385. static readonly ALWAYS: number;
  105386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  105387. static readonly LESS: number;
  105388. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  105389. static readonly EQUAL: number;
  105390. /** 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 */
  105391. static readonly LEQUAL: number;
  105392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  105393. static readonly GREATER: number;
  105394. /** 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 */
  105395. static readonly GEQUAL: number;
  105396. /** 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 */
  105397. static readonly NOTEQUAL: number;
  105398. /** Passed to stencilOperation to specify that stencil value must be kept */
  105399. static readonly KEEP: number;
  105400. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105401. static readonly REPLACE: number;
  105402. /** Passed to stencilOperation to specify that stencil value must be incremented */
  105403. static readonly INCR: number;
  105404. /** Passed to stencilOperation to specify that stencil value must be decremented */
  105405. static readonly DECR: number;
  105406. /** Passed to stencilOperation to specify that stencil value must be inverted */
  105407. static readonly INVERT: number;
  105408. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  105409. static readonly INCR_WRAP: number;
  105410. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  105411. static readonly DECR_WRAP: number;
  105412. /** Texture is not repeating outside of 0..1 UVs */
  105413. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  105414. /** Texture is repeating outside of 0..1 UVs */
  105415. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  105416. /** Texture is repeating and mirrored */
  105417. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  105418. /** ALPHA */
  105419. static readonly TEXTUREFORMAT_ALPHA: number;
  105420. /** LUMINANCE */
  105421. static readonly TEXTUREFORMAT_LUMINANCE: number;
  105422. /** LUMINANCE_ALPHA */
  105423. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  105424. /** RGB */
  105425. static readonly TEXTUREFORMAT_RGB: number;
  105426. /** RGBA */
  105427. static readonly TEXTUREFORMAT_RGBA: number;
  105428. /** RED */
  105429. static readonly TEXTUREFORMAT_RED: number;
  105430. /** RED (2nd reference) */
  105431. static readonly TEXTUREFORMAT_R: number;
  105432. /** RG */
  105433. static readonly TEXTUREFORMAT_RG: number;
  105434. /** RED_INTEGER */
  105435. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  105436. /** RED_INTEGER (2nd reference) */
  105437. static readonly TEXTUREFORMAT_R_INTEGER: number;
  105438. /** RG_INTEGER */
  105439. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  105440. /** RGB_INTEGER */
  105441. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  105442. /** RGBA_INTEGER */
  105443. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  105444. /** UNSIGNED_BYTE */
  105445. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  105446. /** UNSIGNED_BYTE (2nd reference) */
  105447. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  105448. /** FLOAT */
  105449. static readonly TEXTURETYPE_FLOAT: number;
  105450. /** HALF_FLOAT */
  105451. static readonly TEXTURETYPE_HALF_FLOAT: number;
  105452. /** BYTE */
  105453. static readonly TEXTURETYPE_BYTE: number;
  105454. /** SHORT */
  105455. static readonly TEXTURETYPE_SHORT: number;
  105456. /** UNSIGNED_SHORT */
  105457. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  105458. /** INT */
  105459. static readonly TEXTURETYPE_INT: number;
  105460. /** UNSIGNED_INT */
  105461. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  105462. /** UNSIGNED_SHORT_4_4_4_4 */
  105463. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  105464. /** UNSIGNED_SHORT_5_5_5_1 */
  105465. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  105466. /** UNSIGNED_SHORT_5_6_5 */
  105467. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  105468. /** UNSIGNED_INT_2_10_10_10_REV */
  105469. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  105470. /** UNSIGNED_INT_24_8 */
  105471. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  105472. /** UNSIGNED_INT_10F_11F_11F_REV */
  105473. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  105474. /** UNSIGNED_INT_5_9_9_9_REV */
  105475. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  105476. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  105477. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  105478. /** nearest is mag = nearest and min = nearest and mip = linear */
  105479. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  105480. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105481. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  105482. /** Trilinear is mag = linear and min = linear and mip = linear */
  105483. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  105484. /** nearest is mag = nearest and min = nearest and mip = linear */
  105485. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  105486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105487. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  105488. /** Trilinear is mag = linear and min = linear and mip = linear */
  105489. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  105490. /** mag = nearest and min = nearest and mip = nearest */
  105491. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  105492. /** mag = nearest and min = linear and mip = nearest */
  105493. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  105494. /** mag = nearest and min = linear and mip = linear */
  105495. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  105496. /** mag = nearest and min = linear and mip = none */
  105497. static readonly TEXTURE_NEAREST_LINEAR: number;
  105498. /** mag = nearest and min = nearest and mip = none */
  105499. static readonly TEXTURE_NEAREST_NEAREST: number;
  105500. /** mag = linear and min = nearest and mip = nearest */
  105501. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  105502. /** mag = linear and min = nearest and mip = linear */
  105503. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  105504. /** mag = linear and min = linear and mip = none */
  105505. static readonly TEXTURE_LINEAR_LINEAR: number;
  105506. /** mag = linear and min = nearest and mip = none */
  105507. static readonly TEXTURE_LINEAR_NEAREST: number;
  105508. /** Explicit coordinates mode */
  105509. static readonly TEXTURE_EXPLICIT_MODE: number;
  105510. /** Spherical coordinates mode */
  105511. static readonly TEXTURE_SPHERICAL_MODE: number;
  105512. /** Planar coordinates mode */
  105513. static readonly TEXTURE_PLANAR_MODE: number;
  105514. /** Cubic coordinates mode */
  105515. static readonly TEXTURE_CUBIC_MODE: number;
  105516. /** Projection coordinates mode */
  105517. static readonly TEXTURE_PROJECTION_MODE: number;
  105518. /** Skybox coordinates mode */
  105519. static readonly TEXTURE_SKYBOX_MODE: number;
  105520. /** Inverse Cubic coordinates mode */
  105521. static readonly TEXTURE_INVCUBIC_MODE: number;
  105522. /** Equirectangular coordinates mode */
  105523. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  105524. /** Equirectangular Fixed coordinates mode */
  105525. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  105526. /** Equirectangular Fixed Mirrored coordinates mode */
  105527. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  105528. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  105529. static readonly SCALEMODE_FLOOR: number;
  105530. /** Defines that texture rescaling will look for the nearest power of 2 size */
  105531. static readonly SCALEMODE_NEAREST: number;
  105532. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  105533. static readonly SCALEMODE_CEILING: number;
  105534. /**
  105535. * Returns the current npm package of the sdk
  105536. */
  105537. static get NpmPackage(): string;
  105538. /**
  105539. * Returns the current version of the framework
  105540. */
  105541. static get Version(): string;
  105542. /** Gets the list of created engines */
  105543. static get Instances(): Engine[];
  105544. /**
  105545. * Gets the latest created engine
  105546. */
  105547. static get LastCreatedEngine(): Nullable<Engine>;
  105548. /**
  105549. * Gets the latest created scene
  105550. */
  105551. static get LastCreatedScene(): Nullable<Scene>;
  105552. /**
  105553. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  105554. * @param flag defines which part of the materials must be marked as dirty
  105555. * @param predicate defines a predicate used to filter which materials should be affected
  105556. */
  105557. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105558. /**
  105559. * Method called to create the default loading screen.
  105560. * This can be overriden in your own app.
  105561. * @param canvas The rendering canvas element
  105562. * @returns The loading screen
  105563. */
  105564. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  105565. /**
  105566. * Method called to create the default rescale post process on each engine.
  105567. */
  105568. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  105569. /**
  105570. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  105571. **/
  105572. enableOfflineSupport: boolean;
  105573. /**
  105574. * 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)
  105575. **/
  105576. disableManifestCheck: boolean;
  105577. /**
  105578. * Gets the list of created scenes
  105579. */
  105580. scenes: Scene[];
  105581. /**
  105582. * Event raised when a new scene is created
  105583. */
  105584. onNewSceneAddedObservable: Observable<Scene>;
  105585. /**
  105586. * Gets the list of created postprocesses
  105587. */
  105588. postProcesses: PostProcess[];
  105589. /**
  105590. * Gets a boolean indicating if the pointer is currently locked
  105591. */
  105592. isPointerLock: boolean;
  105593. /**
  105594. * Observable event triggered each time the rendering canvas is resized
  105595. */
  105596. onResizeObservable: Observable<Engine>;
  105597. /**
  105598. * Observable event triggered each time the canvas loses focus
  105599. */
  105600. onCanvasBlurObservable: Observable<Engine>;
  105601. /**
  105602. * Observable event triggered each time the canvas gains focus
  105603. */
  105604. onCanvasFocusObservable: Observable<Engine>;
  105605. /**
  105606. * Observable event triggered each time the canvas receives pointerout event
  105607. */
  105608. onCanvasPointerOutObservable: Observable<PointerEvent>;
  105609. /**
  105610. * Observable raised when the engine begins a new frame
  105611. */
  105612. onBeginFrameObservable: Observable<Engine>;
  105613. /**
  105614. * If set, will be used to request the next animation frame for the render loop
  105615. */
  105616. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  105617. /**
  105618. * Observable raised when the engine ends the current frame
  105619. */
  105620. onEndFrameObservable: Observable<Engine>;
  105621. /**
  105622. * Observable raised when the engine is about to compile a shader
  105623. */
  105624. onBeforeShaderCompilationObservable: Observable<Engine>;
  105625. /**
  105626. * Observable raised when the engine has jsut compiled a shader
  105627. */
  105628. onAfterShaderCompilationObservable: Observable<Engine>;
  105629. /**
  105630. * Gets the audio engine
  105631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105632. * @ignorenaming
  105633. */
  105634. static audioEngine: IAudioEngine;
  105635. /**
  105636. * Default AudioEngine factory responsible of creating the Audio Engine.
  105637. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  105638. */
  105639. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  105640. /**
  105641. * Default offline support factory responsible of creating a tool used to store data locally.
  105642. * By default, this will create a Database object if the workload has been embedded.
  105643. */
  105644. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  105645. private _loadingScreen;
  105646. private _pointerLockRequested;
  105647. private _dummyFramebuffer;
  105648. private _rescalePostProcess;
  105649. private _deterministicLockstep;
  105650. private _lockstepMaxSteps;
  105651. private _timeStep;
  105652. protected get _supportsHardwareTextureRescaling(): boolean;
  105653. private _fps;
  105654. private _deltaTime;
  105655. /** @hidden */
  105656. _drawCalls: PerfCounter;
  105657. /**
  105658. * Turn this value on if you want to pause FPS computation when in background
  105659. */
  105660. disablePerformanceMonitorInBackground: boolean;
  105661. private _performanceMonitor;
  105662. /**
  105663. * Gets the performance monitor attached to this engine
  105664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105665. */
  105666. get performanceMonitor(): PerformanceMonitor;
  105667. private _onFocus;
  105668. private _onBlur;
  105669. private _onCanvasPointerOut;
  105670. private _onCanvasBlur;
  105671. private _onCanvasFocus;
  105672. private _onFullscreenChange;
  105673. private _onPointerLockChange;
  105674. /**
  105675. * Gets the HTML element used to attach event listeners
  105676. * @returns a HTML element
  105677. */
  105678. getInputElement(): Nullable<HTMLElement>;
  105679. /**
  105680. * Creates a new engine
  105681. * @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
  105682. * @param antialias defines enable antialiasing (default: false)
  105683. * @param options defines further options to be sent to the getContext() function
  105684. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105685. */
  105686. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105687. /**
  105688. * Gets current aspect ratio
  105689. * @param viewportOwner defines the camera to use to get the aspect ratio
  105690. * @param useScreen defines if screen size must be used (or the current render target if any)
  105691. * @returns a number defining the aspect ratio
  105692. */
  105693. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  105694. /**
  105695. * Gets current screen aspect ratio
  105696. * @returns a number defining the aspect ratio
  105697. */
  105698. getScreenAspectRatio(): number;
  105699. /**
  105700. * Gets the client rect of the HTML canvas attached with the current webGL context
  105701. * @returns a client rectanglee
  105702. */
  105703. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  105704. /**
  105705. * Gets the client rect of the HTML element used for events
  105706. * @returns a client rectanglee
  105707. */
  105708. getInputElementClientRect(): Nullable<ClientRect>;
  105709. /**
  105710. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  105711. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105712. * @returns true if engine is in deterministic lock step mode
  105713. */
  105714. isDeterministicLockStep(): boolean;
  105715. /**
  105716. * Gets the max steps when engine is running in deterministic lock step
  105717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105718. * @returns the max steps
  105719. */
  105720. getLockstepMaxSteps(): number;
  105721. /**
  105722. * Returns the time in ms between steps when using deterministic lock step.
  105723. * @returns time step in (ms)
  105724. */
  105725. getTimeStep(): number;
  105726. /**
  105727. * Force the mipmap generation for the given render target texture
  105728. * @param texture defines the render target texture to use
  105729. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  105730. */
  105731. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  105732. /** States */
  105733. /**
  105734. * Set various states to the webGL context
  105735. * @param culling defines backface culling state
  105736. * @param zOffset defines the value to apply to zOffset (0 by default)
  105737. * @param force defines if states must be applied even if cache is up to date
  105738. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  105739. */
  105740. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  105741. /**
  105742. * Set the z offset to apply to current rendering
  105743. * @param value defines the offset to apply
  105744. */
  105745. setZOffset(value: number): void;
  105746. /**
  105747. * Gets the current value of the zOffset
  105748. * @returns the current zOffset state
  105749. */
  105750. getZOffset(): number;
  105751. /**
  105752. * Enable or disable depth buffering
  105753. * @param enable defines the state to set
  105754. */
  105755. setDepthBuffer(enable: boolean): void;
  105756. /**
  105757. * Gets a boolean indicating if depth writing is enabled
  105758. * @returns the current depth writing state
  105759. */
  105760. getDepthWrite(): boolean;
  105761. /**
  105762. * Enable or disable depth writing
  105763. * @param enable defines the state to set
  105764. */
  105765. setDepthWrite(enable: boolean): void;
  105766. /**
  105767. * Gets a boolean indicating if stencil buffer is enabled
  105768. * @returns the current stencil buffer state
  105769. */
  105770. getStencilBuffer(): boolean;
  105771. /**
  105772. * Enable or disable the stencil buffer
  105773. * @param enable defines if the stencil buffer must be enabled or disabled
  105774. */
  105775. setStencilBuffer(enable: boolean): void;
  105776. /**
  105777. * Gets the current stencil mask
  105778. * @returns a number defining the new stencil mask to use
  105779. */
  105780. getStencilMask(): number;
  105781. /**
  105782. * Sets the current stencil mask
  105783. * @param mask defines the new stencil mask to use
  105784. */
  105785. setStencilMask(mask: number): void;
  105786. /**
  105787. * Gets the current stencil function
  105788. * @returns a number defining the stencil function to use
  105789. */
  105790. getStencilFunction(): number;
  105791. /**
  105792. * Gets the current stencil reference value
  105793. * @returns a number defining the stencil reference value to use
  105794. */
  105795. getStencilFunctionReference(): number;
  105796. /**
  105797. * Gets the current stencil mask
  105798. * @returns a number defining the stencil mask to use
  105799. */
  105800. getStencilFunctionMask(): number;
  105801. /**
  105802. * Sets the current stencil function
  105803. * @param stencilFunc defines the new stencil function to use
  105804. */
  105805. setStencilFunction(stencilFunc: number): void;
  105806. /**
  105807. * Sets the current stencil reference
  105808. * @param reference defines the new stencil reference to use
  105809. */
  105810. setStencilFunctionReference(reference: number): void;
  105811. /**
  105812. * Sets the current stencil mask
  105813. * @param mask defines the new stencil mask to use
  105814. */
  105815. setStencilFunctionMask(mask: number): void;
  105816. /**
  105817. * Gets the current stencil operation when stencil fails
  105818. * @returns a number defining stencil operation to use when stencil fails
  105819. */
  105820. getStencilOperationFail(): number;
  105821. /**
  105822. * Gets the current stencil operation when depth fails
  105823. * @returns a number defining stencil operation to use when depth fails
  105824. */
  105825. getStencilOperationDepthFail(): number;
  105826. /**
  105827. * Gets the current stencil operation when stencil passes
  105828. * @returns a number defining stencil operation to use when stencil passes
  105829. */
  105830. getStencilOperationPass(): number;
  105831. /**
  105832. * Sets the stencil operation to use when stencil fails
  105833. * @param operation defines the stencil operation to use when stencil fails
  105834. */
  105835. setStencilOperationFail(operation: number): void;
  105836. /**
  105837. * Sets the stencil operation to use when depth fails
  105838. * @param operation defines the stencil operation to use when depth fails
  105839. */
  105840. setStencilOperationDepthFail(operation: number): void;
  105841. /**
  105842. * Sets the stencil operation to use when stencil passes
  105843. * @param operation defines the stencil operation to use when stencil passes
  105844. */
  105845. setStencilOperationPass(operation: number): void;
  105846. /**
  105847. * Sets a boolean indicating if the dithering state is enabled or disabled
  105848. * @param value defines the dithering state
  105849. */
  105850. setDitheringState(value: boolean): void;
  105851. /**
  105852. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  105853. * @param value defines the rasterizer state
  105854. */
  105855. setRasterizerState(value: boolean): void;
  105856. /**
  105857. * Gets the current depth function
  105858. * @returns a number defining the depth function
  105859. */
  105860. getDepthFunction(): Nullable<number>;
  105861. /**
  105862. * Sets the current depth function
  105863. * @param depthFunc defines the function to use
  105864. */
  105865. setDepthFunction(depthFunc: number): void;
  105866. /**
  105867. * Sets the current depth function to GREATER
  105868. */
  105869. setDepthFunctionToGreater(): void;
  105870. /**
  105871. * Sets the current depth function to GEQUAL
  105872. */
  105873. setDepthFunctionToGreaterOrEqual(): void;
  105874. /**
  105875. * Sets the current depth function to LESS
  105876. */
  105877. setDepthFunctionToLess(): void;
  105878. /**
  105879. * Sets the current depth function to LEQUAL
  105880. */
  105881. setDepthFunctionToLessOrEqual(): void;
  105882. private _cachedStencilBuffer;
  105883. private _cachedStencilFunction;
  105884. private _cachedStencilMask;
  105885. private _cachedStencilOperationPass;
  105886. private _cachedStencilOperationFail;
  105887. private _cachedStencilOperationDepthFail;
  105888. private _cachedStencilReference;
  105889. /**
  105890. * Caches the the state of the stencil buffer
  105891. */
  105892. cacheStencilState(): void;
  105893. /**
  105894. * Restores the state of the stencil buffer
  105895. */
  105896. restoreStencilState(): void;
  105897. /**
  105898. * Directly set the WebGL Viewport
  105899. * @param x defines the x coordinate of the viewport (in screen space)
  105900. * @param y defines the y coordinate of the viewport (in screen space)
  105901. * @param width defines the width of the viewport (in screen space)
  105902. * @param height defines the height of the viewport (in screen space)
  105903. * @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
  105904. */
  105905. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  105906. /**
  105907. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  105908. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  105909. * @param y defines the y-coordinate of the corner of the clear rectangle
  105910. * @param width defines the width of the clear rectangle
  105911. * @param height defines the height of the clear rectangle
  105912. * @param clearColor defines the clear color
  105913. */
  105914. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  105915. /**
  105916. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  105917. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  105918. * @param y defines the y-coordinate of the corner of the clear rectangle
  105919. * @param width defines the width of the clear rectangle
  105920. * @param height defines the height of the clear rectangle
  105921. */
  105922. enableScissor(x: number, y: number, width: number, height: number): void;
  105923. /**
  105924. * Disable previously set scissor test rectangle
  105925. */
  105926. disableScissor(): void;
  105927. protected _reportDrawCall(): void;
  105928. /**
  105929. * Initializes a webVR display and starts listening to display change events
  105930. * The onVRDisplayChangedObservable will be notified upon these changes
  105931. * @returns The onVRDisplayChangedObservable
  105932. */
  105933. initWebVR(): Observable<IDisplayChangedEventArgs>;
  105934. /** @hidden */
  105935. _prepareVRComponent(): void;
  105936. /** @hidden */
  105937. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  105938. /** @hidden */
  105939. _submitVRFrame(): void;
  105940. /**
  105941. * Call this function to leave webVR mode
  105942. * Will do nothing if webVR is not supported or if there is no webVR device
  105943. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105944. */
  105945. disableVR(): void;
  105946. /**
  105947. * Gets a boolean indicating that the system is in VR mode and is presenting
  105948. * @returns true if VR mode is engaged
  105949. */
  105950. isVRPresenting(): boolean;
  105951. /** @hidden */
  105952. _requestVRFrame(): void;
  105953. /** @hidden */
  105954. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105955. /**
  105956. * Gets the source code of the vertex shader associated with a specific webGL program
  105957. * @param program defines the program to use
  105958. * @returns a string containing the source code of the vertex shader associated with the program
  105959. */
  105960. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  105961. /**
  105962. * Gets the source code of the fragment shader associated with a specific webGL program
  105963. * @param program defines the program to use
  105964. * @returns a string containing the source code of the fragment shader associated with the program
  105965. */
  105966. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  105967. /**
  105968. * Sets a depth stencil texture from a render target to the according uniform.
  105969. * @param channel The texture channel
  105970. * @param uniform The uniform to set
  105971. * @param texture The render target texture containing the depth stencil texture to apply
  105972. */
  105973. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  105974. /**
  105975. * Sets a texture to the webGL context from a postprocess
  105976. * @param channel defines the channel to use
  105977. * @param postProcess defines the source postprocess
  105978. */
  105979. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  105980. /**
  105981. * Binds the output of the passed in post process to the texture channel specified
  105982. * @param channel The channel the texture should be bound to
  105983. * @param postProcess The post process which's output should be bound
  105984. */
  105985. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  105986. /** @hidden */
  105987. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  105988. protected _rebuildBuffers(): void;
  105989. /** @hidden */
  105990. _renderFrame(): void;
  105991. _renderLoop(): void;
  105992. /** @hidden */
  105993. _renderViews(): boolean;
  105994. /**
  105995. * Toggle full screen mode
  105996. * @param requestPointerLock defines if a pointer lock should be requested from the user
  105997. */
  105998. switchFullscreen(requestPointerLock: boolean): void;
  105999. /**
  106000. * Enters full screen mode
  106001. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106002. */
  106003. enterFullscreen(requestPointerLock: boolean): void;
  106004. /**
  106005. * Exits full screen mode
  106006. */
  106007. exitFullscreen(): void;
  106008. /**
  106009. * Enters Pointerlock mode
  106010. */
  106011. enterPointerlock(): void;
  106012. /**
  106013. * Exits Pointerlock mode
  106014. */
  106015. exitPointerlock(): void;
  106016. /**
  106017. * Begin a new frame
  106018. */
  106019. beginFrame(): void;
  106020. /**
  106021. * Enf the current frame
  106022. */
  106023. endFrame(): void;
  106024. resize(): void;
  106025. /**
  106026. * Set the compressed texture format to use, based on the formats you have, and the formats
  106027. * supported by the hardware / browser.
  106028. *
  106029. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  106030. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  106031. * to API arguments needed to compressed textures. This puts the burden on the container
  106032. * generator to house the arcane code for determining these for current & future formats.
  106033. *
  106034. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106035. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106036. *
  106037. * Note: The result of this call is not taken into account when a texture is base64.
  106038. *
  106039. * @param formatsAvailable defines the list of those format families you have created
  106040. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  106041. *
  106042. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  106043. * @returns The extension selected.
  106044. */
  106045. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  106046. /**
  106047. * Set the compressed texture extensions or file names to skip.
  106048. *
  106049. * @param skippedFiles defines the list of those texture files you want to skip
  106050. * Example: [".dds", ".env", "myfile.png"]
  106051. */
  106052. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  106053. /**
  106054. * Force a specific size of the canvas
  106055. * @param width defines the new canvas' width
  106056. * @param height defines the new canvas' height
  106057. */
  106058. setSize(width: number, height: number): void;
  106059. /**
  106060. * Updates a dynamic vertex buffer.
  106061. * @param vertexBuffer the vertex buffer to update
  106062. * @param data the data used to update the vertex buffer
  106063. * @param byteOffset the byte offset of the data
  106064. * @param byteLength the byte length of the data
  106065. */
  106066. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106067. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106068. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106069. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106070. _releaseTexture(texture: InternalTexture): void;
  106071. /**
  106072. * @hidden
  106073. * Rescales a texture
  106074. * @param source input texutre
  106075. * @param destination destination texture
  106076. * @param scene scene to use to render the resize
  106077. * @param internalFormat format to use when resizing
  106078. * @param onComplete callback to be called when resize has completed
  106079. */
  106080. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106081. /**
  106082. * Gets the current framerate
  106083. * @returns a number representing the framerate
  106084. */
  106085. getFps(): number;
  106086. /**
  106087. * Gets the time spent between current and previous frame
  106088. * @returns a number representing the delta time in ms
  106089. */
  106090. getDeltaTime(): number;
  106091. private _measureFps;
  106092. /** @hidden */
  106093. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106094. /**
  106095. * Update a dynamic index buffer
  106096. * @param indexBuffer defines the target index buffer
  106097. * @param indices defines the data to update
  106098. * @param offset defines the offset in the target index buffer where update should start
  106099. */
  106100. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106101. /**
  106102. * Updates the sample count of a render target texture
  106103. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106104. * @param texture defines the texture to update
  106105. * @param samples defines the sample count to set
  106106. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106107. */
  106108. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106109. /**
  106110. * Updates a depth texture Comparison Mode and Function.
  106111. * If the comparison Function is equal to 0, the mode will be set to none.
  106112. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106113. * @param texture The texture to set the comparison function for
  106114. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106115. */
  106116. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  106117. /**
  106118. * Creates a webGL buffer to use with instanciation
  106119. * @param capacity defines the size of the buffer
  106120. * @returns the webGL buffer
  106121. */
  106122. createInstancesBuffer(capacity: number): DataBuffer;
  106123. /**
  106124. * Delete a webGL buffer used with instanciation
  106125. * @param buffer defines the webGL buffer to delete
  106126. */
  106127. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  106128. /** @hidden */
  106129. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  106130. dispose(): void;
  106131. private _disableTouchAction;
  106132. /**
  106133. * Display the loading screen
  106134. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106135. */
  106136. displayLoadingUI(): void;
  106137. /**
  106138. * Hide the loading screen
  106139. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106140. */
  106141. hideLoadingUI(): void;
  106142. /**
  106143. * Gets the current loading screen object
  106144. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106145. */
  106146. get loadingScreen(): ILoadingScreen;
  106147. /**
  106148. * Sets the current loading screen object
  106149. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106150. */
  106151. set loadingScreen(loadingScreen: ILoadingScreen);
  106152. /**
  106153. * Sets the current loading screen text
  106154. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106155. */
  106156. set loadingUIText(text: string);
  106157. /**
  106158. * Sets the current loading screen background color
  106159. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106160. */
  106161. set loadingUIBackgroundColor(color: string);
  106162. /** Pointerlock and fullscreen */
  106163. /**
  106164. * Ask the browser to promote the current element to pointerlock mode
  106165. * @param element defines the DOM element to promote
  106166. */
  106167. static _RequestPointerlock(element: HTMLElement): void;
  106168. /**
  106169. * Asks the browser to exit pointerlock mode
  106170. */
  106171. static _ExitPointerlock(): void;
  106172. /**
  106173. * Ask the browser to promote the current element to fullscreen rendering mode
  106174. * @param element defines the DOM element to promote
  106175. */
  106176. static _RequestFullscreen(element: HTMLElement): void;
  106177. /**
  106178. * Asks the browser to exit fullscreen mode
  106179. */
  106180. static _ExitFullscreen(): void;
  106181. }
  106182. }
  106183. declare module BABYLON {
  106184. /**
  106185. * The engine store class is responsible to hold all the instances of Engine and Scene created
  106186. * during the life time of the application.
  106187. */
  106188. export class EngineStore {
  106189. /** Gets the list of created engines */
  106190. static Instances: Engine[];
  106191. /** @hidden */
  106192. static _LastCreatedScene: Nullable<Scene>;
  106193. /**
  106194. * Gets the latest created engine
  106195. */
  106196. static get LastCreatedEngine(): Nullable<Engine>;
  106197. /**
  106198. * Gets the latest created scene
  106199. */
  106200. static get LastCreatedScene(): Nullable<Scene>;
  106201. /**
  106202. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106203. * @ignorenaming
  106204. */
  106205. static UseFallbackTexture: boolean;
  106206. /**
  106207. * Texture content used if a texture cannot loaded
  106208. * @ignorenaming
  106209. */
  106210. static FallbackTexture: string;
  106211. }
  106212. }
  106213. declare module BABYLON {
  106214. /**
  106215. * Helper class that provides a small promise polyfill
  106216. */
  106217. export class PromisePolyfill {
  106218. /**
  106219. * Static function used to check if the polyfill is required
  106220. * If this is the case then the function will inject the polyfill to window.Promise
  106221. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  106222. */
  106223. static Apply(force?: boolean): void;
  106224. }
  106225. }
  106226. declare module BABYLON {
  106227. /**
  106228. * Interface for screenshot methods with describe argument called `size` as object with options
  106229. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  106230. */
  106231. export interface IScreenshotSize {
  106232. /**
  106233. * number in pixels for canvas height
  106234. */
  106235. height?: number;
  106236. /**
  106237. * multiplier allowing render at a higher or lower resolution
  106238. * If value is defined then height and width will be ignored and taken from camera
  106239. */
  106240. precision?: number;
  106241. /**
  106242. * number in pixels for canvas width
  106243. */
  106244. width?: number;
  106245. }
  106246. }
  106247. declare module BABYLON {
  106248. interface IColor4Like {
  106249. r: float;
  106250. g: float;
  106251. b: float;
  106252. a: float;
  106253. }
  106254. /**
  106255. * Class containing a set of static utilities functions
  106256. */
  106257. export class Tools {
  106258. /**
  106259. * Gets or sets the base URL to use to load assets
  106260. */
  106261. static get BaseUrl(): string;
  106262. static set BaseUrl(value: string);
  106263. /**
  106264. * Enable/Disable Custom HTTP Request Headers globally.
  106265. * default = false
  106266. * @see CustomRequestHeaders
  106267. */
  106268. static UseCustomRequestHeaders: boolean;
  106269. /**
  106270. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  106271. * i.e. when loading files, where the server/service expects an Authorization header
  106272. */
  106273. static CustomRequestHeaders: {
  106274. [key: string]: string;
  106275. };
  106276. /**
  106277. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  106278. */
  106279. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  106280. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  106281. /**
  106282. * Default behaviour for cors in the application.
  106283. * It can be a string if the expected behavior is identical in the entire app.
  106284. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  106285. */
  106286. static CorsBehavior: string | ((url: string | string[]) => string);
  106287. /**
  106288. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106289. * @ignorenaming
  106290. */
  106291. static get UseFallbackTexture(): boolean;
  106292. static set UseFallbackTexture(value: boolean);
  106293. /**
  106294. * Use this object to register external classes like custom textures or material
  106295. * to allow the laoders to instantiate them
  106296. */
  106297. static get RegisteredExternalClasses(): {
  106298. [key: string]: Object;
  106299. };
  106300. static set RegisteredExternalClasses(classes: {
  106301. [key: string]: Object;
  106302. });
  106303. /**
  106304. * Texture content used if a texture cannot loaded
  106305. * @ignorenaming
  106306. */
  106307. static get fallbackTexture(): string;
  106308. static set fallbackTexture(value: string);
  106309. /**
  106310. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  106311. * @param u defines the coordinate on X axis
  106312. * @param v defines the coordinate on Y axis
  106313. * @param width defines the width of the source data
  106314. * @param height defines the height of the source data
  106315. * @param pixels defines the source byte array
  106316. * @param color defines the output color
  106317. */
  106318. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  106319. /**
  106320. * Interpolates between a and b via alpha
  106321. * @param a The lower value (returned when alpha = 0)
  106322. * @param b The upper value (returned when alpha = 1)
  106323. * @param alpha The interpolation-factor
  106324. * @return The mixed value
  106325. */
  106326. static Mix(a: number, b: number, alpha: number): number;
  106327. /**
  106328. * Tries to instantiate a new object from a given class name
  106329. * @param className defines the class name to instantiate
  106330. * @returns the new object or null if the system was not able to do the instantiation
  106331. */
  106332. static Instantiate(className: string): any;
  106333. /**
  106334. * Provides a slice function that will work even on IE
  106335. * @param data defines the array to slice
  106336. * @param start defines the start of the data (optional)
  106337. * @param end defines the end of the data (optional)
  106338. * @returns the new sliced array
  106339. */
  106340. static Slice<T>(data: T, start?: number, end?: number): T;
  106341. /**
  106342. * Polyfill for setImmediate
  106343. * @param action defines the action to execute after the current execution block
  106344. */
  106345. static SetImmediate(action: () => void): void;
  106346. /**
  106347. * Function indicating if a number is an exponent of 2
  106348. * @param value defines the value to test
  106349. * @returns true if the value is an exponent of 2
  106350. */
  106351. static IsExponentOfTwo(value: number): boolean;
  106352. private static _tmpFloatArray;
  106353. /**
  106354. * Returns the nearest 32-bit single precision float representation of a Number
  106355. * @param value A Number. If the parameter is of a different type, it will get converted
  106356. * to a number or to NaN if it cannot be converted
  106357. * @returns number
  106358. */
  106359. static FloatRound(value: number): number;
  106360. /**
  106361. * Extracts the filename from a path
  106362. * @param path defines the path to use
  106363. * @returns the filename
  106364. */
  106365. static GetFilename(path: string): string;
  106366. /**
  106367. * Extracts the "folder" part of a path (everything before the filename).
  106368. * @param uri The URI to extract the info from
  106369. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  106370. * @returns The "folder" part of the path
  106371. */
  106372. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  106373. /**
  106374. * Extracts text content from a DOM element hierarchy
  106375. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  106376. */
  106377. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  106378. /**
  106379. * Convert an angle in radians to degrees
  106380. * @param angle defines the angle to convert
  106381. * @returns the angle in degrees
  106382. */
  106383. static ToDegrees(angle: number): number;
  106384. /**
  106385. * Convert an angle in degrees to radians
  106386. * @param angle defines the angle to convert
  106387. * @returns the angle in radians
  106388. */
  106389. static ToRadians(angle: number): number;
  106390. /**
  106391. * Returns an array if obj is not an array
  106392. * @param obj defines the object to evaluate as an array
  106393. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  106394. * @returns either obj directly if obj is an array or a new array containing obj
  106395. */
  106396. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  106397. /**
  106398. * Gets the pointer prefix to use
  106399. * @returns "pointer" if touch is enabled. Else returns "mouse"
  106400. */
  106401. static GetPointerPrefix(): string;
  106402. /**
  106403. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  106404. * @param url define the url we are trying
  106405. * @param element define the dom element where to configure the cors policy
  106406. */
  106407. static SetCorsBehavior(url: string | string[], element: {
  106408. crossOrigin: string | null;
  106409. }): void;
  106410. /**
  106411. * Removes unwanted characters from an url
  106412. * @param url defines the url to clean
  106413. * @returns the cleaned url
  106414. */
  106415. static CleanUrl(url: string): string;
  106416. /**
  106417. * Gets or sets a function used to pre-process url before using them to load assets
  106418. */
  106419. static get PreprocessUrl(): (url: string) => string;
  106420. static set PreprocessUrl(processor: (url: string) => string);
  106421. /**
  106422. * Loads an image as an HTMLImageElement.
  106423. * @param input url string, ArrayBuffer, or Blob to load
  106424. * @param onLoad callback called when the image successfully loads
  106425. * @param onError callback called when the image fails to load
  106426. * @param offlineProvider offline provider for caching
  106427. * @param mimeType optional mime type
  106428. * @returns the HTMLImageElement of the loaded image
  106429. */
  106430. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  106431. /**
  106432. * Loads a file from a url
  106433. * @param url url string, ArrayBuffer, or Blob to load
  106434. * @param onSuccess callback called when the file successfully loads
  106435. * @param onProgress callback called while file is loading (if the server supports this mode)
  106436. * @param offlineProvider defines the offline provider for caching
  106437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106438. * @param onError callback called when the file fails to load
  106439. * @returns a file request object
  106440. */
  106441. 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;
  106442. /**
  106443. * Loads a file from a url
  106444. * @param url the file url to load
  106445. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  106446. */
  106447. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  106448. /**
  106449. * Load a script (identified by an url). When the url returns, the
  106450. * content of this file is added into a new script element, attached to the DOM (body element)
  106451. * @param scriptUrl defines the url of the script to laod
  106452. * @param onSuccess defines the callback called when the script is loaded
  106453. * @param onError defines the callback to call if an error occurs
  106454. * @param scriptId defines the id of the script element
  106455. */
  106456. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  106457. /**
  106458. * Load an asynchronous script (identified by an url). When the url returns, the
  106459. * content of this file is added into a new script element, attached to the DOM (body element)
  106460. * @param scriptUrl defines the url of the script to laod
  106461. * @param scriptId defines the id of the script element
  106462. * @returns a promise request object
  106463. */
  106464. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  106465. /**
  106466. * Loads a file from a blob
  106467. * @param fileToLoad defines the blob to use
  106468. * @param callback defines the callback to call when data is loaded
  106469. * @param progressCallback defines the callback to call during loading process
  106470. * @returns a file request object
  106471. */
  106472. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  106473. /**
  106474. * Reads a file from a File object
  106475. * @param file defines the file to load
  106476. * @param onSuccess defines the callback to call when data is loaded
  106477. * @param onProgress defines the callback to call during loading process
  106478. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  106479. * @param onError defines the callback to call when an error occurs
  106480. * @returns a file request object
  106481. */
  106482. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  106483. /**
  106484. * Creates a data url from a given string content
  106485. * @param content defines the content to convert
  106486. * @returns the new data url link
  106487. */
  106488. static FileAsURL(content: string): string;
  106489. /**
  106490. * Format the given number to a specific decimal format
  106491. * @param value defines the number to format
  106492. * @param decimals defines the number of decimals to use
  106493. * @returns the formatted string
  106494. */
  106495. static Format(value: number, decimals?: number): string;
  106496. /**
  106497. * Tries to copy an object by duplicating every property
  106498. * @param source defines the source object
  106499. * @param destination defines the target object
  106500. * @param doNotCopyList defines a list of properties to avoid
  106501. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  106502. */
  106503. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  106504. /**
  106505. * Gets a boolean indicating if the given object has no own property
  106506. * @param obj defines the object to test
  106507. * @returns true if object has no own property
  106508. */
  106509. static IsEmpty(obj: any): boolean;
  106510. /**
  106511. * Function used to register events at window level
  106512. * @param windowElement defines the Window object to use
  106513. * @param events defines the events to register
  106514. */
  106515. static RegisterTopRootEvents(windowElement: Window, events: {
  106516. name: string;
  106517. handler: Nullable<(e: FocusEvent) => any>;
  106518. }[]): void;
  106519. /**
  106520. * Function used to unregister events from window level
  106521. * @param windowElement defines the Window object to use
  106522. * @param events defines the events to unregister
  106523. */
  106524. static UnregisterTopRootEvents(windowElement: Window, events: {
  106525. name: string;
  106526. handler: Nullable<(e: FocusEvent) => any>;
  106527. }[]): void;
  106528. /**
  106529. * @ignore
  106530. */
  106531. static _ScreenshotCanvas: HTMLCanvasElement;
  106532. /**
  106533. * Dumps the current bound framebuffer
  106534. * @param width defines the rendering width
  106535. * @param height defines the rendering height
  106536. * @param engine defines the hosting engine
  106537. * @param successCallback defines the callback triggered once the data are available
  106538. * @param mimeType defines the mime type of the result
  106539. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  106540. */
  106541. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  106542. /**
  106543. * Converts the canvas data to blob.
  106544. * This acts as a polyfill for browsers not supporting the to blob function.
  106545. * @param canvas Defines the canvas to extract the data from
  106546. * @param successCallback Defines the callback triggered once the data are available
  106547. * @param mimeType Defines the mime type of the result
  106548. */
  106549. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  106550. /**
  106551. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  106552. * @param successCallback defines the callback triggered once the data are available
  106553. * @param mimeType defines the mime type of the result
  106554. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  106555. */
  106556. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  106557. /**
  106558. * Downloads a blob in the browser
  106559. * @param blob defines the blob to download
  106560. * @param fileName defines the name of the downloaded file
  106561. */
  106562. static Download(blob: Blob, fileName: string): void;
  106563. /**
  106564. * Captures a screenshot of the current rendering
  106565. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106566. * @param engine defines the rendering engine
  106567. * @param camera defines the source camera
  106568. * @param size This parameter can be set to a single number or to an object with the
  106569. * following (optional) properties: precision, width, height. If a single number is passed,
  106570. * it will be used for both width and height. If an object is passed, the screenshot size
  106571. * will be derived from the parameters. The precision property is a multiplier allowing
  106572. * rendering at a higher or lower resolution
  106573. * @param successCallback defines the callback receives a single parameter which contains the
  106574. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106575. * src parameter of an <img> to display it
  106576. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106577. * Check your browser for supported MIME types
  106578. */
  106579. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  106580. /**
  106581. * Captures a screenshot of the current rendering
  106582. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106583. * @param engine defines the rendering engine
  106584. * @param camera defines the source camera
  106585. * @param size This parameter can be set to a single number or to an object with the
  106586. * following (optional) properties: precision, width, height. If a single number is passed,
  106587. * it will be used for both width and height. If an object is passed, the screenshot size
  106588. * will be derived from the parameters. The precision property is a multiplier allowing
  106589. * rendering at a higher or lower resolution
  106590. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106591. * Check your browser for supported MIME types
  106592. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  106593. * to the src parameter of an <img> to display it
  106594. */
  106595. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  106596. /**
  106597. * Generates an image screenshot from the specified camera.
  106598. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106599. * @param engine The engine to use for rendering
  106600. * @param camera The camera to use for rendering
  106601. * @param size This parameter can be set to a single number or to an object with the
  106602. * following (optional) properties: precision, width, height. If a single number is passed,
  106603. * it will be used for both width and height. If an object is passed, the screenshot size
  106604. * will be derived from the parameters. The precision property is a multiplier allowing
  106605. * rendering at a higher or lower resolution
  106606. * @param successCallback The callback receives a single parameter which contains the
  106607. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106608. * src parameter of an <img> to display it
  106609. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106610. * Check your browser for supported MIME types
  106611. * @param samples Texture samples (default: 1)
  106612. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106613. * @param fileName A name for for the downloaded file.
  106614. */
  106615. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  106616. /**
  106617. * Generates an image screenshot from the specified camera.
  106618. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106619. * @param engine The engine to use for rendering
  106620. * @param camera The camera to use for rendering
  106621. * @param size This parameter can be set to a single number or to an object with the
  106622. * following (optional) properties: precision, width, height. If a single number is passed,
  106623. * it will be used for both width and height. If an object is passed, the screenshot size
  106624. * will be derived from the parameters. The precision property is a multiplier allowing
  106625. * rendering at a higher or lower resolution
  106626. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106627. * Check your browser for supported MIME types
  106628. * @param samples Texture samples (default: 1)
  106629. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106630. * @param fileName A name for for the downloaded file.
  106631. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  106632. * to the src parameter of an <img> to display it
  106633. */
  106634. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  106635. /**
  106636. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106637. * Be aware Math.random() could cause collisions, but:
  106638. * "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"
  106639. * @returns a pseudo random id
  106640. */
  106641. static RandomId(): string;
  106642. /**
  106643. * Test if the given uri is a base64 string
  106644. * @param uri The uri to test
  106645. * @return True if the uri is a base64 string or false otherwise
  106646. */
  106647. static IsBase64(uri: string): boolean;
  106648. /**
  106649. * Decode the given base64 uri.
  106650. * @param uri The uri to decode
  106651. * @return The decoded base64 data.
  106652. */
  106653. static DecodeBase64(uri: string): ArrayBuffer;
  106654. /**
  106655. * Gets the absolute url.
  106656. * @param url the input url
  106657. * @return the absolute url
  106658. */
  106659. static GetAbsoluteUrl(url: string): string;
  106660. /**
  106661. * No log
  106662. */
  106663. static readonly NoneLogLevel: number;
  106664. /**
  106665. * Only message logs
  106666. */
  106667. static readonly MessageLogLevel: number;
  106668. /**
  106669. * Only warning logs
  106670. */
  106671. static readonly WarningLogLevel: number;
  106672. /**
  106673. * Only error logs
  106674. */
  106675. static readonly ErrorLogLevel: number;
  106676. /**
  106677. * All logs
  106678. */
  106679. static readonly AllLogLevel: number;
  106680. /**
  106681. * Gets a value indicating the number of loading errors
  106682. * @ignorenaming
  106683. */
  106684. static get errorsCount(): number;
  106685. /**
  106686. * Callback called when a new log is added
  106687. */
  106688. static OnNewCacheEntry: (entry: string) => void;
  106689. /**
  106690. * Log a message to the console
  106691. * @param message defines the message to log
  106692. */
  106693. static Log(message: string): void;
  106694. /**
  106695. * Write a warning message to the console
  106696. * @param message defines the message to log
  106697. */
  106698. static Warn(message: string): void;
  106699. /**
  106700. * Write an error message to the console
  106701. * @param message defines the message to log
  106702. */
  106703. static Error(message: string): void;
  106704. /**
  106705. * Gets current log cache (list of logs)
  106706. */
  106707. static get LogCache(): string;
  106708. /**
  106709. * Clears the log cache
  106710. */
  106711. static ClearLogCache(): void;
  106712. /**
  106713. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  106714. */
  106715. static set LogLevels(level: number);
  106716. /**
  106717. * Checks if the window object exists
  106718. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  106719. */
  106720. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  106721. /**
  106722. * No performance log
  106723. */
  106724. static readonly PerformanceNoneLogLevel: number;
  106725. /**
  106726. * Use user marks to log performance
  106727. */
  106728. static readonly PerformanceUserMarkLogLevel: number;
  106729. /**
  106730. * Log performance to the console
  106731. */
  106732. static readonly PerformanceConsoleLogLevel: number;
  106733. private static _performance;
  106734. /**
  106735. * Sets the current performance log level
  106736. */
  106737. static set PerformanceLogLevel(level: number);
  106738. private static _StartPerformanceCounterDisabled;
  106739. private static _EndPerformanceCounterDisabled;
  106740. private static _StartUserMark;
  106741. private static _EndUserMark;
  106742. private static _StartPerformanceConsole;
  106743. private static _EndPerformanceConsole;
  106744. /**
  106745. * Starts a performance counter
  106746. */
  106747. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  106748. /**
  106749. * Ends a specific performance coutner
  106750. */
  106751. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  106752. /**
  106753. * Gets either window.performance.now() if supported or Date.now() else
  106754. */
  106755. static get Now(): number;
  106756. /**
  106757. * This method will return the name of the class used to create the instance of the given object.
  106758. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  106759. * @param object the object to get the class name from
  106760. * @param isType defines if the object is actually a type
  106761. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  106762. */
  106763. static GetClassName(object: any, isType?: boolean): string;
  106764. /**
  106765. * Gets the first element of an array satisfying a given predicate
  106766. * @param array defines the array to browse
  106767. * @param predicate defines the predicate to use
  106768. * @returns null if not found or the element
  106769. */
  106770. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  106771. /**
  106772. * This method will return the name of the full name of the class, including its owning module (if any).
  106773. * 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).
  106774. * @param object the object to get the class name from
  106775. * @param isType defines if the object is actually a type
  106776. * @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.
  106777. * @ignorenaming
  106778. */
  106779. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  106780. /**
  106781. * Returns a promise that resolves after the given amount of time.
  106782. * @param delay Number of milliseconds to delay
  106783. * @returns Promise that resolves after the given amount of time
  106784. */
  106785. static DelayAsync(delay: number): Promise<void>;
  106786. /**
  106787. * Utility function to detect if the current user agent is Safari
  106788. * @returns whether or not the current user agent is safari
  106789. */
  106790. static IsSafari(): boolean;
  106791. }
  106792. /**
  106793. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  106794. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  106795. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  106796. * @param name The name of the class, case should be preserved
  106797. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  106798. */
  106799. export function className(name: string, module?: string): (target: Object) => void;
  106800. /**
  106801. * An implementation of a loop for asynchronous functions.
  106802. */
  106803. export class AsyncLoop {
  106804. /**
  106805. * Defines the number of iterations for the loop
  106806. */
  106807. iterations: number;
  106808. /**
  106809. * Defines the current index of the loop.
  106810. */
  106811. index: number;
  106812. private _done;
  106813. private _fn;
  106814. private _successCallback;
  106815. /**
  106816. * Constructor.
  106817. * @param iterations the number of iterations.
  106818. * @param func the function to run each iteration
  106819. * @param successCallback the callback that will be called upon succesful execution
  106820. * @param offset starting offset.
  106821. */
  106822. constructor(
  106823. /**
  106824. * Defines the number of iterations for the loop
  106825. */
  106826. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  106827. /**
  106828. * Execute the next iteration. Must be called after the last iteration was finished.
  106829. */
  106830. executeNext(): void;
  106831. /**
  106832. * Break the loop and run the success callback.
  106833. */
  106834. breakLoop(): void;
  106835. /**
  106836. * Create and run an async loop.
  106837. * @param iterations the number of iterations.
  106838. * @param fn the function to run each iteration
  106839. * @param successCallback the callback that will be called upon succesful execution
  106840. * @param offset starting offset.
  106841. * @returns the created async loop object
  106842. */
  106843. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  106844. /**
  106845. * A for-loop that will run a given number of iterations synchronous and the rest async.
  106846. * @param iterations total number of iterations
  106847. * @param syncedIterations number of synchronous iterations in each async iteration.
  106848. * @param fn the function to call each iteration.
  106849. * @param callback a success call back that will be called when iterating stops.
  106850. * @param breakFunction a break condition (optional)
  106851. * @param timeout timeout settings for the setTimeout function. default - 0.
  106852. * @returns the created async loop object
  106853. */
  106854. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  106855. }
  106856. }
  106857. declare module BABYLON {
  106858. /**
  106859. * This class implement a typical dictionary using a string as key and the generic type T as value.
  106860. * The underlying implementation relies on an associative array to ensure the best performances.
  106861. * The value can be anything including 'null' but except 'undefined'
  106862. */
  106863. export class StringDictionary<T> {
  106864. /**
  106865. * This will clear this dictionary and copy the content from the 'source' one.
  106866. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  106867. * @param source the dictionary to take the content from and copy to this dictionary
  106868. */
  106869. copyFrom(source: StringDictionary<T>): void;
  106870. /**
  106871. * Get a value based from its key
  106872. * @param key the given key to get the matching value from
  106873. * @return the value if found, otherwise undefined is returned
  106874. */
  106875. get(key: string): T | undefined;
  106876. /**
  106877. * Get a value from its key or add it if it doesn't exist.
  106878. * This method will ensure you that a given key/data will be present in the dictionary.
  106879. * @param key the given key to get the matching value from
  106880. * @param factory the factory that will create the value if the key is not present in the dictionary.
  106881. * The factory will only be invoked if there's no data for the given key.
  106882. * @return the value corresponding to the key.
  106883. */
  106884. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  106885. /**
  106886. * Get a value from its key if present in the dictionary otherwise add it
  106887. * @param key the key to get the value from
  106888. * @param val if there's no such key/value pair in the dictionary add it with this value
  106889. * @return the value corresponding to the key
  106890. */
  106891. getOrAdd(key: string, val: T): T;
  106892. /**
  106893. * Check if there's a given key in the dictionary
  106894. * @param key the key to check for
  106895. * @return true if the key is present, false otherwise
  106896. */
  106897. contains(key: string): boolean;
  106898. /**
  106899. * Add a new key and its corresponding value
  106900. * @param key the key to add
  106901. * @param value the value corresponding to the key
  106902. * @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
  106903. */
  106904. add(key: string, value: T): boolean;
  106905. /**
  106906. * Update a specific value associated to a key
  106907. * @param key defines the key to use
  106908. * @param value defines the value to store
  106909. * @returns true if the value was updated (or false if the key was not found)
  106910. */
  106911. set(key: string, value: T): boolean;
  106912. /**
  106913. * Get the element of the given key and remove it from the dictionary
  106914. * @param key defines the key to search
  106915. * @returns the value associated with the key or null if not found
  106916. */
  106917. getAndRemove(key: string): Nullable<T>;
  106918. /**
  106919. * Remove a key/value from the dictionary.
  106920. * @param key the key to remove
  106921. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  106922. */
  106923. remove(key: string): boolean;
  106924. /**
  106925. * Clear the whole content of the dictionary
  106926. */
  106927. clear(): void;
  106928. /**
  106929. * Gets the current count
  106930. */
  106931. get count(): number;
  106932. /**
  106933. * Execute a callback on each key/val of the dictionary.
  106934. * Note that you can remove any element in this dictionary in the callback implementation
  106935. * @param callback the callback to execute on a given key/value pair
  106936. */
  106937. forEach(callback: (key: string, val: T) => void): void;
  106938. /**
  106939. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  106940. * If the callback returns null or undefined the method will iterate to the next key/value pair
  106941. * Note that you can remove any element in this dictionary in the callback implementation
  106942. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  106943. * @returns the first item
  106944. */
  106945. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  106946. private _count;
  106947. private _data;
  106948. }
  106949. }
  106950. declare module BABYLON {
  106951. /** @hidden */
  106952. export interface ICollisionCoordinator {
  106953. createCollider(): Collider;
  106954. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  106955. init(scene: Scene): void;
  106956. }
  106957. /** @hidden */
  106958. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  106959. private _scene;
  106960. private _scaledPosition;
  106961. private _scaledVelocity;
  106962. private _finalPosition;
  106963. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  106964. createCollider(): Collider;
  106965. init(scene: Scene): void;
  106966. private _collideWithWorld;
  106967. }
  106968. }
  106969. declare module BABYLON {
  106970. /**
  106971. * Class used to manage all inputs for the scene.
  106972. */
  106973. export class InputManager {
  106974. /** The distance in pixel that you have to move to prevent some events */
  106975. static DragMovementThreshold: number;
  106976. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  106977. static LongPressDelay: number;
  106978. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  106979. static DoubleClickDelay: number;
  106980. /** If you need to check double click without raising a single click at first click, enable this flag */
  106981. static ExclusiveDoubleClickMode: boolean;
  106982. private _wheelEventName;
  106983. private _onPointerMove;
  106984. private _onPointerDown;
  106985. private _onPointerUp;
  106986. private _initClickEvent;
  106987. private _initActionManager;
  106988. private _delayedSimpleClick;
  106989. private _delayedSimpleClickTimeout;
  106990. private _previousDelayedSimpleClickTimeout;
  106991. private _meshPickProceed;
  106992. private _previousButtonPressed;
  106993. private _currentPickResult;
  106994. private _previousPickResult;
  106995. private _totalPointersPressed;
  106996. private _doubleClickOccured;
  106997. private _pointerOverMesh;
  106998. private _pickedDownMesh;
  106999. private _pickedUpMesh;
  107000. private _pointerX;
  107001. private _pointerY;
  107002. private _unTranslatedPointerX;
  107003. private _unTranslatedPointerY;
  107004. private _startingPointerPosition;
  107005. private _previousStartingPointerPosition;
  107006. private _startingPointerTime;
  107007. private _previousStartingPointerTime;
  107008. private _pointerCaptures;
  107009. private _onKeyDown;
  107010. private _onKeyUp;
  107011. private _onCanvasFocusObserver;
  107012. private _onCanvasBlurObserver;
  107013. private _scene;
  107014. /**
  107015. * Creates a new InputManager
  107016. * @param scene defines the hosting scene
  107017. */
  107018. constructor(scene: Scene);
  107019. /**
  107020. * Gets the mesh that is currently under the pointer
  107021. */
  107022. get meshUnderPointer(): Nullable<AbstractMesh>;
  107023. /**
  107024. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107025. */
  107026. get unTranslatedPointer(): Vector2;
  107027. /**
  107028. * Gets or sets the current on-screen X position of the pointer
  107029. */
  107030. get pointerX(): number;
  107031. set pointerX(value: number);
  107032. /**
  107033. * Gets or sets the current on-screen Y position of the pointer
  107034. */
  107035. get pointerY(): number;
  107036. set pointerY(value: number);
  107037. private _updatePointerPosition;
  107038. private _processPointerMove;
  107039. private _setRayOnPointerInfo;
  107040. private _checkPrePointerObservable;
  107041. /**
  107042. * Use this method to simulate a pointer move on a mesh
  107043. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107044. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107045. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107046. */
  107047. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107048. /**
  107049. * Use this method to simulate a pointer down on a mesh
  107050. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107051. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107052. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107053. */
  107054. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107055. private _processPointerDown;
  107056. /** @hidden */
  107057. _isPointerSwiping(): boolean;
  107058. /**
  107059. * Use this method to simulate a pointer up on a mesh
  107060. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107061. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107062. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107063. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107064. */
  107065. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107066. private _processPointerUp;
  107067. /**
  107068. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107069. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107070. * @returns true if the pointer was captured
  107071. */
  107072. isPointerCaptured(pointerId?: number): boolean;
  107073. /**
  107074. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107075. * @param attachUp defines if you want to attach events to pointerup
  107076. * @param attachDown defines if you want to attach events to pointerdown
  107077. * @param attachMove defines if you want to attach events to pointermove
  107078. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107079. */
  107080. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107081. /**
  107082. * Detaches all event handlers
  107083. */
  107084. detachControl(): void;
  107085. /**
  107086. * Force the value of meshUnderPointer
  107087. * @param mesh defines the mesh to use
  107088. */
  107089. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107090. /**
  107091. * Gets the mesh under the pointer
  107092. * @returns a Mesh or null if no mesh is under the pointer
  107093. */
  107094. getPointerOverMesh(): Nullable<AbstractMesh>;
  107095. }
  107096. }
  107097. declare module BABYLON {
  107098. /**
  107099. * Helper class used to generate session unique ID
  107100. */
  107101. export class UniqueIdGenerator {
  107102. private static _UniqueIdCounter;
  107103. /**
  107104. * Gets an unique (relatively to the current scene) Id
  107105. */
  107106. static get UniqueId(): number;
  107107. }
  107108. }
  107109. declare module BABYLON {
  107110. /**
  107111. * This class defines the direct association between an animation and a target
  107112. */
  107113. export class TargetedAnimation {
  107114. /**
  107115. * Animation to perform
  107116. */
  107117. animation: Animation;
  107118. /**
  107119. * Target to animate
  107120. */
  107121. target: any;
  107122. /**
  107123. * Serialize the object
  107124. * @returns the JSON object representing the current entity
  107125. */
  107126. serialize(): any;
  107127. }
  107128. /**
  107129. * Use this class to create coordinated animations on multiple targets
  107130. */
  107131. export class AnimationGroup implements IDisposable {
  107132. /** The name of the animation group */
  107133. name: string;
  107134. private _scene;
  107135. private _targetedAnimations;
  107136. private _animatables;
  107137. private _from;
  107138. private _to;
  107139. private _isStarted;
  107140. private _isPaused;
  107141. private _speedRatio;
  107142. private _loopAnimation;
  107143. /**
  107144. * Gets or sets the unique id of the node
  107145. */
  107146. uniqueId: number;
  107147. /**
  107148. * This observable will notify when one animation have ended
  107149. */
  107150. onAnimationEndObservable: Observable<TargetedAnimation>;
  107151. /**
  107152. * Observer raised when one animation loops
  107153. */
  107154. onAnimationLoopObservable: Observable<TargetedAnimation>;
  107155. /**
  107156. * Observer raised when all animations have looped
  107157. */
  107158. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  107159. /**
  107160. * This observable will notify when all animations have ended.
  107161. */
  107162. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  107163. /**
  107164. * This observable will notify when all animations have paused.
  107165. */
  107166. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  107167. /**
  107168. * This observable will notify when all animations are playing.
  107169. */
  107170. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  107171. /**
  107172. * Gets the first frame
  107173. */
  107174. get from(): number;
  107175. /**
  107176. * Gets the last frame
  107177. */
  107178. get to(): number;
  107179. /**
  107180. * Define if the animations are started
  107181. */
  107182. get isStarted(): boolean;
  107183. /**
  107184. * Gets a value indicating that the current group is playing
  107185. */
  107186. get isPlaying(): boolean;
  107187. /**
  107188. * Gets or sets the speed ratio to use for all animations
  107189. */
  107190. get speedRatio(): number;
  107191. /**
  107192. * Gets or sets the speed ratio to use for all animations
  107193. */
  107194. set speedRatio(value: number);
  107195. /**
  107196. * Gets or sets if all animations should loop or not
  107197. */
  107198. get loopAnimation(): boolean;
  107199. set loopAnimation(value: boolean);
  107200. /**
  107201. * Gets the targeted animations for this animation group
  107202. */
  107203. get targetedAnimations(): Array<TargetedAnimation>;
  107204. /**
  107205. * returning the list of animatables controlled by this animation group.
  107206. */
  107207. get animatables(): Array<Animatable>;
  107208. /**
  107209. * Instantiates a new Animation Group.
  107210. * This helps managing several animations at once.
  107211. * @see http://doc.babylonjs.com/how_to/group
  107212. * @param name Defines the name of the group
  107213. * @param scene Defines the scene the group belongs to
  107214. */
  107215. constructor(
  107216. /** The name of the animation group */
  107217. name: string, scene?: Nullable<Scene>);
  107218. /**
  107219. * Add an animation (with its target) in the group
  107220. * @param animation defines the animation we want to add
  107221. * @param target defines the target of the animation
  107222. * @returns the TargetedAnimation object
  107223. */
  107224. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  107225. /**
  107226. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  107227. * It can add constant keys at begin or end
  107228. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  107229. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  107230. * @returns the animation group
  107231. */
  107232. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  107233. private _animationLoopCount;
  107234. private _animationLoopFlags;
  107235. private _processLoop;
  107236. /**
  107237. * Start all animations on given targets
  107238. * @param loop defines if animations must loop
  107239. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  107240. * @param from defines the from key (optional)
  107241. * @param to defines the to key (optional)
  107242. * @returns the current animation group
  107243. */
  107244. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  107245. /**
  107246. * Pause all animations
  107247. * @returns the animation group
  107248. */
  107249. pause(): AnimationGroup;
  107250. /**
  107251. * Play all animations to initial state
  107252. * This function will start() the animations if they were not started or will restart() them if they were paused
  107253. * @param loop defines if animations must loop
  107254. * @returns the animation group
  107255. */
  107256. play(loop?: boolean): AnimationGroup;
  107257. /**
  107258. * Reset all animations to initial state
  107259. * @returns the animation group
  107260. */
  107261. reset(): AnimationGroup;
  107262. /**
  107263. * Restart animations from key 0
  107264. * @returns the animation group
  107265. */
  107266. restart(): AnimationGroup;
  107267. /**
  107268. * Stop all animations
  107269. * @returns the animation group
  107270. */
  107271. stop(): AnimationGroup;
  107272. /**
  107273. * Set animation weight for all animatables
  107274. * @param weight defines the weight to use
  107275. * @return the animationGroup
  107276. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107277. */
  107278. setWeightForAllAnimatables(weight: number): AnimationGroup;
  107279. /**
  107280. * Synchronize and normalize all animatables with a source animatable
  107281. * @param root defines the root animatable to synchronize with
  107282. * @return the animationGroup
  107283. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107284. */
  107285. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  107286. /**
  107287. * Goes to a specific frame in this animation group
  107288. * @param frame the frame number to go to
  107289. * @return the animationGroup
  107290. */
  107291. goToFrame(frame: number): AnimationGroup;
  107292. /**
  107293. * Dispose all associated resources
  107294. */
  107295. dispose(): void;
  107296. private _checkAnimationGroupEnded;
  107297. /**
  107298. * Clone the current animation group and returns a copy
  107299. * @param newName defines the name of the new group
  107300. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  107301. * @returns the new aniamtion group
  107302. */
  107303. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  107304. /**
  107305. * Serializes the animationGroup to an object
  107306. * @returns Serialized object
  107307. */
  107308. serialize(): any;
  107309. /**
  107310. * Returns a new AnimationGroup object parsed from the source provided.
  107311. * @param parsedAnimationGroup defines the source
  107312. * @param scene defines the scene that will receive the animationGroup
  107313. * @returns a new AnimationGroup
  107314. */
  107315. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  107316. /**
  107317. * Returns the string "AnimationGroup"
  107318. * @returns "AnimationGroup"
  107319. */
  107320. getClassName(): string;
  107321. /**
  107322. * Creates a detailled string about the object
  107323. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  107324. * @returns a string representing the object
  107325. */
  107326. toString(fullDetails?: boolean): string;
  107327. }
  107328. }
  107329. declare module BABYLON {
  107330. /**
  107331. * Define an interface for all classes that will hold resources
  107332. */
  107333. export interface IDisposable {
  107334. /**
  107335. * Releases all held resources
  107336. */
  107337. dispose(): void;
  107338. }
  107339. /** Interface defining initialization parameters for Scene class */
  107340. export interface SceneOptions {
  107341. /**
  107342. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  107343. * It will improve performance when the number of geometries becomes important.
  107344. */
  107345. useGeometryUniqueIdsMap?: boolean;
  107346. /**
  107347. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  107348. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107349. */
  107350. useMaterialMeshMap?: boolean;
  107351. /**
  107352. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  107353. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107354. */
  107355. useClonedMeshMap?: boolean;
  107356. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  107357. virtual?: boolean;
  107358. }
  107359. /**
  107360. * Represents a scene to be rendered by the engine.
  107361. * @see http://doc.babylonjs.com/features/scene
  107362. */
  107363. export class Scene extends AbstractScene implements IAnimatable {
  107364. /** The fog is deactivated */
  107365. static readonly FOGMODE_NONE: number;
  107366. /** The fog density is following an exponential function */
  107367. static readonly FOGMODE_EXP: number;
  107368. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  107369. static readonly FOGMODE_EXP2: number;
  107370. /** The fog density is following a linear function. */
  107371. static readonly FOGMODE_LINEAR: number;
  107372. /**
  107373. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  107374. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107375. */
  107376. static MinDeltaTime: number;
  107377. /**
  107378. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  107379. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107380. */
  107381. static MaxDeltaTime: number;
  107382. /**
  107383. * Factory used to create the default material.
  107384. * @param name The name of the material to create
  107385. * @param scene The scene to create the material for
  107386. * @returns The default material
  107387. */
  107388. static DefaultMaterialFactory(scene: Scene): Material;
  107389. /**
  107390. * Factory used to create the a collision coordinator.
  107391. * @returns The collision coordinator
  107392. */
  107393. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  107394. /** @hidden */
  107395. _inputManager: InputManager;
  107396. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  107397. cameraToUseForPointers: Nullable<Camera>;
  107398. /** @hidden */
  107399. readonly _isScene: boolean;
  107400. /**
  107401. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  107402. */
  107403. autoClear: boolean;
  107404. /**
  107405. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  107406. */
  107407. autoClearDepthAndStencil: boolean;
  107408. /**
  107409. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  107410. */
  107411. clearColor: Color4;
  107412. /**
  107413. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  107414. */
  107415. ambientColor: Color3;
  107416. /**
  107417. * This is use to store the default BRDF lookup for PBR materials in your scene.
  107418. * It should only be one of the following (if not the default embedded one):
  107419. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107420. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  107421. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107422. * The material properties need to be setup according to the type of texture in use.
  107423. */
  107424. environmentBRDFTexture: BaseTexture;
  107425. /** @hidden */
  107426. protected _environmentTexture: Nullable<BaseTexture>;
  107427. /**
  107428. * Texture used in all pbr material as the reflection texture.
  107429. * As in the majority of the scene they are the same (exception for multi room and so on),
  107430. * this is easier to reference from here than from all the materials.
  107431. */
  107432. get environmentTexture(): Nullable<BaseTexture>;
  107433. /**
  107434. * Texture used in all pbr material as the reflection texture.
  107435. * As in the majority of the scene they are the same (exception for multi room and so on),
  107436. * this is easier to set here than in all the materials.
  107437. */
  107438. set environmentTexture(value: Nullable<BaseTexture>);
  107439. /** @hidden */
  107440. protected _environmentIntensity: number;
  107441. /**
  107442. * Intensity of the environment in all pbr material.
  107443. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107444. * As in the majority of the scene they are the same (exception for multi room and so on),
  107445. * this is easier to reference from here than from all the materials.
  107446. */
  107447. get environmentIntensity(): number;
  107448. /**
  107449. * Intensity of the environment in all pbr material.
  107450. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107451. * As in the majority of the scene they are the same (exception for multi room and so on),
  107452. * this is easier to set here than in all the materials.
  107453. */
  107454. set environmentIntensity(value: number);
  107455. /** @hidden */
  107456. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107457. /**
  107458. * Default image processing configuration used either in the rendering
  107459. * Forward main pass or through the imageProcessingPostProcess if present.
  107460. * As in the majority of the scene they are the same (exception for multi camera),
  107461. * this is easier to reference from here than from all the materials and post process.
  107462. *
  107463. * No setter as we it is a shared configuration, you can set the values instead.
  107464. */
  107465. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107466. private _forceWireframe;
  107467. /**
  107468. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  107469. */
  107470. set forceWireframe(value: boolean);
  107471. get forceWireframe(): boolean;
  107472. private _skipFrustumClipping;
  107473. /**
  107474. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  107475. */
  107476. set skipFrustumClipping(value: boolean);
  107477. get skipFrustumClipping(): boolean;
  107478. private _forcePointsCloud;
  107479. /**
  107480. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  107481. */
  107482. set forcePointsCloud(value: boolean);
  107483. get forcePointsCloud(): boolean;
  107484. /**
  107485. * Gets or sets the active clipplane 1
  107486. */
  107487. clipPlane: Nullable<Plane>;
  107488. /**
  107489. * Gets or sets the active clipplane 2
  107490. */
  107491. clipPlane2: Nullable<Plane>;
  107492. /**
  107493. * Gets or sets the active clipplane 3
  107494. */
  107495. clipPlane3: Nullable<Plane>;
  107496. /**
  107497. * Gets or sets the active clipplane 4
  107498. */
  107499. clipPlane4: Nullable<Plane>;
  107500. /**
  107501. * Gets or sets the active clipplane 5
  107502. */
  107503. clipPlane5: Nullable<Plane>;
  107504. /**
  107505. * Gets or sets the active clipplane 6
  107506. */
  107507. clipPlane6: Nullable<Plane>;
  107508. /**
  107509. * Gets or sets a boolean indicating if animations are enabled
  107510. */
  107511. animationsEnabled: boolean;
  107512. private _animationPropertiesOverride;
  107513. /**
  107514. * Gets or sets the animation properties override
  107515. */
  107516. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107517. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107518. /**
  107519. * Gets or sets a boolean indicating if a constant deltatime has to be used
  107520. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  107521. */
  107522. useConstantAnimationDeltaTime: boolean;
  107523. /**
  107524. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  107525. * Please note that it requires to run a ray cast through the scene on every frame
  107526. */
  107527. constantlyUpdateMeshUnderPointer: boolean;
  107528. /**
  107529. * Defines the HTML cursor to use when hovering over interactive elements
  107530. */
  107531. hoverCursor: string;
  107532. /**
  107533. * Defines the HTML default cursor to use (empty by default)
  107534. */
  107535. defaultCursor: string;
  107536. /**
  107537. * Defines wether cursors are handled by the scene.
  107538. */
  107539. doNotHandleCursors: boolean;
  107540. /**
  107541. * This is used to call preventDefault() on pointer down
  107542. * in order to block unwanted artifacts like system double clicks
  107543. */
  107544. preventDefaultOnPointerDown: boolean;
  107545. /**
  107546. * This is used to call preventDefault() on pointer up
  107547. * in order to block unwanted artifacts like system double clicks
  107548. */
  107549. preventDefaultOnPointerUp: boolean;
  107550. /**
  107551. * Gets or sets user defined metadata
  107552. */
  107553. metadata: any;
  107554. /**
  107555. * For internal use only. Please do not use.
  107556. */
  107557. reservedDataStore: any;
  107558. /**
  107559. * Gets the name of the plugin used to load this scene (null by default)
  107560. */
  107561. loadingPluginName: string;
  107562. /**
  107563. * Use this array to add regular expressions used to disable offline support for specific urls
  107564. */
  107565. disableOfflineSupportExceptionRules: RegExp[];
  107566. /**
  107567. * An event triggered when the scene is disposed.
  107568. */
  107569. onDisposeObservable: Observable<Scene>;
  107570. private _onDisposeObserver;
  107571. /** Sets a function to be executed when this scene is disposed. */
  107572. set onDispose(callback: () => void);
  107573. /**
  107574. * An event triggered before rendering the scene (right after animations and physics)
  107575. */
  107576. onBeforeRenderObservable: Observable<Scene>;
  107577. private _onBeforeRenderObserver;
  107578. /** Sets a function to be executed before rendering this scene */
  107579. set beforeRender(callback: Nullable<() => void>);
  107580. /**
  107581. * An event triggered after rendering the scene
  107582. */
  107583. onAfterRenderObservable: Observable<Scene>;
  107584. /**
  107585. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  107586. */
  107587. onAfterRenderCameraObservable: Observable<Camera>;
  107588. private _onAfterRenderObserver;
  107589. /** Sets a function to be executed after rendering this scene */
  107590. set afterRender(callback: Nullable<() => void>);
  107591. /**
  107592. * An event triggered before animating the scene
  107593. */
  107594. onBeforeAnimationsObservable: Observable<Scene>;
  107595. /**
  107596. * An event triggered after animations processing
  107597. */
  107598. onAfterAnimationsObservable: Observable<Scene>;
  107599. /**
  107600. * An event triggered before draw calls are ready to be sent
  107601. */
  107602. onBeforeDrawPhaseObservable: Observable<Scene>;
  107603. /**
  107604. * An event triggered after draw calls have been sent
  107605. */
  107606. onAfterDrawPhaseObservable: Observable<Scene>;
  107607. /**
  107608. * An event triggered when the scene is ready
  107609. */
  107610. onReadyObservable: Observable<Scene>;
  107611. /**
  107612. * An event triggered before rendering a camera
  107613. */
  107614. onBeforeCameraRenderObservable: Observable<Camera>;
  107615. private _onBeforeCameraRenderObserver;
  107616. /** Sets a function to be executed before rendering a camera*/
  107617. set beforeCameraRender(callback: () => void);
  107618. /**
  107619. * An event triggered after rendering a camera
  107620. */
  107621. onAfterCameraRenderObservable: Observable<Camera>;
  107622. private _onAfterCameraRenderObserver;
  107623. /** Sets a function to be executed after rendering a camera*/
  107624. set afterCameraRender(callback: () => void);
  107625. /**
  107626. * An event triggered when active meshes evaluation is about to start
  107627. */
  107628. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  107629. /**
  107630. * An event triggered when active meshes evaluation is done
  107631. */
  107632. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  107633. /**
  107634. * An event triggered when particles rendering is about to start
  107635. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  107636. */
  107637. onBeforeParticlesRenderingObservable: Observable<Scene>;
  107638. /**
  107639. * An event triggered when particles rendering is done
  107640. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  107641. */
  107642. onAfterParticlesRenderingObservable: Observable<Scene>;
  107643. /**
  107644. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  107645. */
  107646. onDataLoadedObservable: Observable<Scene>;
  107647. /**
  107648. * An event triggered when a camera is created
  107649. */
  107650. onNewCameraAddedObservable: Observable<Camera>;
  107651. /**
  107652. * An event triggered when a camera is removed
  107653. */
  107654. onCameraRemovedObservable: Observable<Camera>;
  107655. /**
  107656. * An event triggered when a light is created
  107657. */
  107658. onNewLightAddedObservable: Observable<Light>;
  107659. /**
  107660. * An event triggered when a light is removed
  107661. */
  107662. onLightRemovedObservable: Observable<Light>;
  107663. /**
  107664. * An event triggered when a geometry is created
  107665. */
  107666. onNewGeometryAddedObservable: Observable<Geometry>;
  107667. /**
  107668. * An event triggered when a geometry is removed
  107669. */
  107670. onGeometryRemovedObservable: Observable<Geometry>;
  107671. /**
  107672. * An event triggered when a transform node is created
  107673. */
  107674. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  107675. /**
  107676. * An event triggered when a transform node is removed
  107677. */
  107678. onTransformNodeRemovedObservable: Observable<TransformNode>;
  107679. /**
  107680. * An event triggered when a mesh is created
  107681. */
  107682. onNewMeshAddedObservable: Observable<AbstractMesh>;
  107683. /**
  107684. * An event triggered when a mesh is removed
  107685. */
  107686. onMeshRemovedObservable: Observable<AbstractMesh>;
  107687. /**
  107688. * An event triggered when a skeleton is created
  107689. */
  107690. onNewSkeletonAddedObservable: Observable<Skeleton>;
  107691. /**
  107692. * An event triggered when a skeleton is removed
  107693. */
  107694. onSkeletonRemovedObservable: Observable<Skeleton>;
  107695. /**
  107696. * An event triggered when a material is created
  107697. */
  107698. onNewMaterialAddedObservable: Observable<Material>;
  107699. /**
  107700. * An event triggered when a material is removed
  107701. */
  107702. onMaterialRemovedObservable: Observable<Material>;
  107703. /**
  107704. * An event triggered when a texture is created
  107705. */
  107706. onNewTextureAddedObservable: Observable<BaseTexture>;
  107707. /**
  107708. * An event triggered when a texture is removed
  107709. */
  107710. onTextureRemovedObservable: Observable<BaseTexture>;
  107711. /**
  107712. * An event triggered when render targets are about to be rendered
  107713. * Can happen multiple times per frame.
  107714. */
  107715. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  107716. /**
  107717. * An event triggered when render targets were rendered.
  107718. * Can happen multiple times per frame.
  107719. */
  107720. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  107721. /**
  107722. * An event triggered before calculating deterministic simulation step
  107723. */
  107724. onBeforeStepObservable: Observable<Scene>;
  107725. /**
  107726. * An event triggered after calculating deterministic simulation step
  107727. */
  107728. onAfterStepObservable: Observable<Scene>;
  107729. /**
  107730. * An event triggered when the activeCamera property is updated
  107731. */
  107732. onActiveCameraChanged: Observable<Scene>;
  107733. /**
  107734. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  107735. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  107736. * 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)
  107737. */
  107738. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  107739. /**
  107740. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  107741. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  107742. * 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)
  107743. */
  107744. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  107745. /**
  107746. * This Observable will when a mesh has been imported into the scene.
  107747. */
  107748. onMeshImportedObservable: Observable<AbstractMesh>;
  107749. /**
  107750. * This Observable will when an animation file has been imported into the scene.
  107751. */
  107752. onAnimationFileImportedObservable: Observable<Scene>;
  107753. /**
  107754. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  107755. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  107756. */
  107757. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  107758. /** @hidden */
  107759. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  107760. /**
  107761. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  107762. */
  107763. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  107764. /**
  107765. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  107766. */
  107767. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  107768. /**
  107769. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  107770. */
  107771. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  107772. /** Callback called when a pointer move is detected */
  107773. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  107774. /** Callback called when a pointer down is detected */
  107775. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  107776. /** Callback called when a pointer up is detected */
  107777. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  107778. /** Callback called when a pointer pick is detected */
  107779. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  107780. /**
  107781. * 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).
  107782. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  107783. */
  107784. onPrePointerObservable: Observable<PointerInfoPre>;
  107785. /**
  107786. * Observable event triggered each time an input event is received from the rendering canvas
  107787. */
  107788. onPointerObservable: Observable<PointerInfo>;
  107789. /**
  107790. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  107791. */
  107792. get unTranslatedPointer(): Vector2;
  107793. /**
  107794. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  107795. */
  107796. static get DragMovementThreshold(): number;
  107797. static set DragMovementThreshold(value: number);
  107798. /**
  107799. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  107800. */
  107801. static get LongPressDelay(): number;
  107802. static set LongPressDelay(value: number);
  107803. /**
  107804. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  107805. */
  107806. static get DoubleClickDelay(): number;
  107807. static set DoubleClickDelay(value: number);
  107808. /** If you need to check double click without raising a single click at first click, enable this flag */
  107809. static get ExclusiveDoubleClickMode(): boolean;
  107810. static set ExclusiveDoubleClickMode(value: boolean);
  107811. /** @hidden */
  107812. _mirroredCameraPosition: Nullable<Vector3>;
  107813. /**
  107814. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  107815. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  107816. */
  107817. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  107818. /**
  107819. * Observable event triggered each time an keyboard event is received from the hosting window
  107820. */
  107821. onKeyboardObservable: Observable<KeyboardInfo>;
  107822. private _useRightHandedSystem;
  107823. /**
  107824. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  107825. */
  107826. set useRightHandedSystem(value: boolean);
  107827. get useRightHandedSystem(): boolean;
  107828. private _timeAccumulator;
  107829. private _currentStepId;
  107830. private _currentInternalStep;
  107831. /**
  107832. * Sets the step Id used by deterministic lock step
  107833. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107834. * @param newStepId defines the step Id
  107835. */
  107836. setStepId(newStepId: number): void;
  107837. /**
  107838. * Gets the step Id used by deterministic lock step
  107839. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107840. * @returns the step Id
  107841. */
  107842. getStepId(): number;
  107843. /**
  107844. * Gets the internal step used by deterministic lock step
  107845. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107846. * @returns the internal step
  107847. */
  107848. getInternalStep(): number;
  107849. private _fogEnabled;
  107850. /**
  107851. * Gets or sets a boolean indicating if fog is enabled on this scene
  107852. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107853. * (Default is true)
  107854. */
  107855. set fogEnabled(value: boolean);
  107856. get fogEnabled(): boolean;
  107857. private _fogMode;
  107858. /**
  107859. * Gets or sets the fog mode to use
  107860. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107861. * | mode | value |
  107862. * | --- | --- |
  107863. * | FOGMODE_NONE | 0 |
  107864. * | FOGMODE_EXP | 1 |
  107865. * | FOGMODE_EXP2 | 2 |
  107866. * | FOGMODE_LINEAR | 3 |
  107867. */
  107868. set fogMode(value: number);
  107869. get fogMode(): number;
  107870. /**
  107871. * Gets or sets the fog color to use
  107872. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107873. * (Default is Color3(0.2, 0.2, 0.3))
  107874. */
  107875. fogColor: Color3;
  107876. /**
  107877. * Gets or sets the fog density to use
  107878. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107879. * (Default is 0.1)
  107880. */
  107881. fogDensity: number;
  107882. /**
  107883. * Gets or sets the fog start distance to use
  107884. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107885. * (Default is 0)
  107886. */
  107887. fogStart: number;
  107888. /**
  107889. * Gets or sets the fog end distance to use
  107890. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107891. * (Default is 1000)
  107892. */
  107893. fogEnd: number;
  107894. private _shadowsEnabled;
  107895. /**
  107896. * Gets or sets a boolean indicating if shadows are enabled on this scene
  107897. */
  107898. set shadowsEnabled(value: boolean);
  107899. get shadowsEnabled(): boolean;
  107900. private _lightsEnabled;
  107901. /**
  107902. * Gets or sets a boolean indicating if lights are enabled on this scene
  107903. */
  107904. set lightsEnabled(value: boolean);
  107905. get lightsEnabled(): boolean;
  107906. /** All of the active cameras added to this scene. */
  107907. activeCameras: Camera[];
  107908. /** @hidden */
  107909. _activeCamera: Nullable<Camera>;
  107910. /** Gets or sets the current active camera */
  107911. get activeCamera(): Nullable<Camera>;
  107912. set activeCamera(value: Nullable<Camera>);
  107913. private _defaultMaterial;
  107914. /** The default material used on meshes when no material is affected */
  107915. get defaultMaterial(): Material;
  107916. /** The default material used on meshes when no material is affected */
  107917. set defaultMaterial(value: Material);
  107918. private _texturesEnabled;
  107919. /**
  107920. * Gets or sets a boolean indicating if textures are enabled on this scene
  107921. */
  107922. set texturesEnabled(value: boolean);
  107923. get texturesEnabled(): boolean;
  107924. /**
  107925. * Gets or sets a boolean indicating if particles are enabled on this scene
  107926. */
  107927. particlesEnabled: boolean;
  107928. /**
  107929. * Gets or sets a boolean indicating if sprites are enabled on this scene
  107930. */
  107931. spritesEnabled: boolean;
  107932. private _skeletonsEnabled;
  107933. /**
  107934. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  107935. */
  107936. set skeletonsEnabled(value: boolean);
  107937. get skeletonsEnabled(): boolean;
  107938. /**
  107939. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  107940. */
  107941. lensFlaresEnabled: boolean;
  107942. /**
  107943. * Gets or sets a boolean indicating if collisions are enabled on this scene
  107944. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  107945. */
  107946. collisionsEnabled: boolean;
  107947. private _collisionCoordinator;
  107948. /** @hidden */
  107949. get collisionCoordinator(): ICollisionCoordinator;
  107950. /**
  107951. * Defines the gravity applied to this scene (used only for collisions)
  107952. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  107953. */
  107954. gravity: Vector3;
  107955. /**
  107956. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  107957. */
  107958. postProcessesEnabled: boolean;
  107959. /**
  107960. * The list of postprocesses added to the scene
  107961. */
  107962. postProcesses: PostProcess[];
  107963. /**
  107964. * Gets the current postprocess manager
  107965. */
  107966. postProcessManager: PostProcessManager;
  107967. /**
  107968. * Gets or sets a boolean indicating if render targets are enabled on this scene
  107969. */
  107970. renderTargetsEnabled: boolean;
  107971. /**
  107972. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  107973. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  107974. */
  107975. dumpNextRenderTargets: boolean;
  107976. /**
  107977. * The list of user defined render targets added to the scene
  107978. */
  107979. customRenderTargets: RenderTargetTexture[];
  107980. /**
  107981. * Defines if texture loading must be delayed
  107982. * If true, textures will only be loaded when they need to be rendered
  107983. */
  107984. useDelayedTextureLoading: boolean;
  107985. /**
  107986. * Gets the list of meshes imported to the scene through SceneLoader
  107987. */
  107988. importedMeshesFiles: String[];
  107989. /**
  107990. * Gets or sets a boolean indicating if probes are enabled on this scene
  107991. */
  107992. probesEnabled: boolean;
  107993. /**
  107994. * Gets or sets the current offline provider to use to store scene data
  107995. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  107996. */
  107997. offlineProvider: IOfflineProvider;
  107998. /**
  107999. * Gets or sets the action manager associated with the scene
  108000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108001. */
  108002. actionManager: AbstractActionManager;
  108003. private _meshesForIntersections;
  108004. /**
  108005. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108006. */
  108007. proceduralTexturesEnabled: boolean;
  108008. private _engine;
  108009. private _totalVertices;
  108010. /** @hidden */
  108011. _activeIndices: PerfCounter;
  108012. /** @hidden */
  108013. _activeParticles: PerfCounter;
  108014. /** @hidden */
  108015. _activeBones: PerfCounter;
  108016. private _animationRatio;
  108017. /** @hidden */
  108018. _animationTimeLast: number;
  108019. /** @hidden */
  108020. _animationTime: number;
  108021. /**
  108022. * Gets or sets a general scale for animation speed
  108023. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108024. */
  108025. animationTimeScale: number;
  108026. /** @hidden */
  108027. _cachedMaterial: Nullable<Material>;
  108028. /** @hidden */
  108029. _cachedEffect: Nullable<Effect>;
  108030. /** @hidden */
  108031. _cachedVisibility: Nullable<number>;
  108032. private _renderId;
  108033. private _frameId;
  108034. private _executeWhenReadyTimeoutId;
  108035. private _intermediateRendering;
  108036. private _viewUpdateFlag;
  108037. private _projectionUpdateFlag;
  108038. /** @hidden */
  108039. _toBeDisposed: Nullable<IDisposable>[];
  108040. private _activeRequests;
  108041. /** @hidden */
  108042. _pendingData: any[];
  108043. private _isDisposed;
  108044. /**
  108045. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108046. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108047. */
  108048. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108049. private _activeMeshes;
  108050. private _processedMaterials;
  108051. private _renderTargets;
  108052. /** @hidden */
  108053. _activeParticleSystems: SmartArray<IParticleSystem>;
  108054. private _activeSkeletons;
  108055. private _softwareSkinnedMeshes;
  108056. private _renderingManager;
  108057. /** @hidden */
  108058. _activeAnimatables: Animatable[];
  108059. private _transformMatrix;
  108060. private _sceneUbo;
  108061. /** @hidden */
  108062. _viewMatrix: Matrix;
  108063. private _projectionMatrix;
  108064. /** @hidden */
  108065. _forcedViewPosition: Nullable<Vector3>;
  108066. /** @hidden */
  108067. _frustumPlanes: Plane[];
  108068. /**
  108069. * Gets the list of frustum planes (built from the active camera)
  108070. */
  108071. get frustumPlanes(): Plane[];
  108072. /**
  108073. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108074. * This is useful if there are more lights that the maximum simulteanous authorized
  108075. */
  108076. requireLightSorting: boolean;
  108077. /** @hidden */
  108078. readonly useMaterialMeshMap: boolean;
  108079. /** @hidden */
  108080. readonly useClonedMeshMap: boolean;
  108081. private _externalData;
  108082. private _uid;
  108083. /**
  108084. * @hidden
  108085. * Backing store of defined scene components.
  108086. */
  108087. _components: ISceneComponent[];
  108088. /**
  108089. * @hidden
  108090. * Backing store of defined scene components.
  108091. */
  108092. _serializableComponents: ISceneSerializableComponent[];
  108093. /**
  108094. * List of components to register on the next registration step.
  108095. */
  108096. private _transientComponents;
  108097. /**
  108098. * Registers the transient components if needed.
  108099. */
  108100. private _registerTransientComponents;
  108101. /**
  108102. * @hidden
  108103. * Add a component to the scene.
  108104. * Note that the ccomponent could be registered on th next frame if this is called after
  108105. * the register component stage.
  108106. * @param component Defines the component to add to the scene
  108107. */
  108108. _addComponent(component: ISceneComponent): void;
  108109. /**
  108110. * @hidden
  108111. * Gets a component from the scene.
  108112. * @param name defines the name of the component to retrieve
  108113. * @returns the component or null if not present
  108114. */
  108115. _getComponent(name: string): Nullable<ISceneComponent>;
  108116. /**
  108117. * @hidden
  108118. * Defines the actions happening before camera updates.
  108119. */
  108120. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  108121. /**
  108122. * @hidden
  108123. * Defines the actions happening before clear the canvas.
  108124. */
  108125. _beforeClearStage: Stage<SimpleStageAction>;
  108126. /**
  108127. * @hidden
  108128. * Defines the actions when collecting render targets for the frame.
  108129. */
  108130. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108131. /**
  108132. * @hidden
  108133. * Defines the actions happening for one camera in the frame.
  108134. */
  108135. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108136. /**
  108137. * @hidden
  108138. * Defines the actions happening during the per mesh ready checks.
  108139. */
  108140. _isReadyForMeshStage: Stage<MeshStageAction>;
  108141. /**
  108142. * @hidden
  108143. * Defines the actions happening before evaluate active mesh checks.
  108144. */
  108145. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  108146. /**
  108147. * @hidden
  108148. * Defines the actions happening during the evaluate sub mesh checks.
  108149. */
  108150. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  108151. /**
  108152. * @hidden
  108153. * Defines the actions happening during the active mesh stage.
  108154. */
  108155. _activeMeshStage: Stage<ActiveMeshStageAction>;
  108156. /**
  108157. * @hidden
  108158. * Defines the actions happening during the per camera render target step.
  108159. */
  108160. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  108161. /**
  108162. * @hidden
  108163. * Defines the actions happening just before the active camera is drawing.
  108164. */
  108165. _beforeCameraDrawStage: Stage<CameraStageAction>;
  108166. /**
  108167. * @hidden
  108168. * Defines the actions happening just before a render target is drawing.
  108169. */
  108170. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108171. /**
  108172. * @hidden
  108173. * Defines the actions happening just before a rendering group is drawing.
  108174. */
  108175. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108176. /**
  108177. * @hidden
  108178. * Defines the actions happening just before a mesh is drawing.
  108179. */
  108180. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108181. /**
  108182. * @hidden
  108183. * Defines the actions happening just after a mesh has been drawn.
  108184. */
  108185. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108186. /**
  108187. * @hidden
  108188. * Defines the actions happening just after a rendering group has been drawn.
  108189. */
  108190. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108191. /**
  108192. * @hidden
  108193. * Defines the actions happening just after the active camera has been drawn.
  108194. */
  108195. _afterCameraDrawStage: Stage<CameraStageAction>;
  108196. /**
  108197. * @hidden
  108198. * Defines the actions happening just after a render target has been drawn.
  108199. */
  108200. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108201. /**
  108202. * @hidden
  108203. * Defines the actions happening just after rendering all cameras and computing intersections.
  108204. */
  108205. _afterRenderStage: Stage<SimpleStageAction>;
  108206. /**
  108207. * @hidden
  108208. * Defines the actions happening when a pointer move event happens.
  108209. */
  108210. _pointerMoveStage: Stage<PointerMoveStageAction>;
  108211. /**
  108212. * @hidden
  108213. * Defines the actions happening when a pointer down event happens.
  108214. */
  108215. _pointerDownStage: Stage<PointerUpDownStageAction>;
  108216. /**
  108217. * @hidden
  108218. * Defines the actions happening when a pointer up event happens.
  108219. */
  108220. _pointerUpStage: Stage<PointerUpDownStageAction>;
  108221. /**
  108222. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  108223. */
  108224. private geometriesByUniqueId;
  108225. /**
  108226. * Creates a new Scene
  108227. * @param engine defines the engine to use to render this scene
  108228. * @param options defines the scene options
  108229. */
  108230. constructor(engine: Engine, options?: SceneOptions);
  108231. /**
  108232. * Gets a string idenfifying the name of the class
  108233. * @returns "Scene" string
  108234. */
  108235. getClassName(): string;
  108236. private _defaultMeshCandidates;
  108237. /**
  108238. * @hidden
  108239. */
  108240. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108241. private _defaultSubMeshCandidates;
  108242. /**
  108243. * @hidden
  108244. */
  108245. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108246. /**
  108247. * Sets the default candidate providers for the scene.
  108248. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  108249. * and getCollidingSubMeshCandidates to their default function
  108250. */
  108251. setDefaultCandidateProviders(): void;
  108252. /**
  108253. * Gets the mesh that is currently under the pointer
  108254. */
  108255. get meshUnderPointer(): Nullable<AbstractMesh>;
  108256. /**
  108257. * Gets or sets the current on-screen X position of the pointer
  108258. */
  108259. get pointerX(): number;
  108260. set pointerX(value: number);
  108261. /**
  108262. * Gets or sets the current on-screen Y position of the pointer
  108263. */
  108264. get pointerY(): number;
  108265. set pointerY(value: number);
  108266. /**
  108267. * Gets the cached material (ie. the latest rendered one)
  108268. * @returns the cached material
  108269. */
  108270. getCachedMaterial(): Nullable<Material>;
  108271. /**
  108272. * Gets the cached effect (ie. the latest rendered one)
  108273. * @returns the cached effect
  108274. */
  108275. getCachedEffect(): Nullable<Effect>;
  108276. /**
  108277. * Gets the cached visibility state (ie. the latest rendered one)
  108278. * @returns the cached visibility state
  108279. */
  108280. getCachedVisibility(): Nullable<number>;
  108281. /**
  108282. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  108283. * @param material defines the current material
  108284. * @param effect defines the current effect
  108285. * @param visibility defines the current visibility state
  108286. * @returns true if one parameter is not cached
  108287. */
  108288. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  108289. /**
  108290. * Gets the engine associated with the scene
  108291. * @returns an Engine
  108292. */
  108293. getEngine(): Engine;
  108294. /**
  108295. * Gets the total number of vertices rendered per frame
  108296. * @returns the total number of vertices rendered per frame
  108297. */
  108298. getTotalVertices(): number;
  108299. /**
  108300. * Gets the performance counter for total vertices
  108301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108302. */
  108303. get totalVerticesPerfCounter(): PerfCounter;
  108304. /**
  108305. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  108306. * @returns the total number of active indices rendered per frame
  108307. */
  108308. getActiveIndices(): number;
  108309. /**
  108310. * Gets the performance counter for active indices
  108311. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108312. */
  108313. get totalActiveIndicesPerfCounter(): PerfCounter;
  108314. /**
  108315. * Gets the total number of active particles rendered per frame
  108316. * @returns the total number of active particles rendered per frame
  108317. */
  108318. getActiveParticles(): number;
  108319. /**
  108320. * Gets the performance counter for active particles
  108321. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108322. */
  108323. get activeParticlesPerfCounter(): PerfCounter;
  108324. /**
  108325. * Gets the total number of active bones rendered per frame
  108326. * @returns the total number of active bones rendered per frame
  108327. */
  108328. getActiveBones(): number;
  108329. /**
  108330. * Gets the performance counter for active bones
  108331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108332. */
  108333. get activeBonesPerfCounter(): PerfCounter;
  108334. /**
  108335. * Gets the array of active meshes
  108336. * @returns an array of AbstractMesh
  108337. */
  108338. getActiveMeshes(): SmartArray<AbstractMesh>;
  108339. /**
  108340. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  108341. * @returns a number
  108342. */
  108343. getAnimationRatio(): number;
  108344. /**
  108345. * Gets an unique Id for the current render phase
  108346. * @returns a number
  108347. */
  108348. getRenderId(): number;
  108349. /**
  108350. * Gets an unique Id for the current frame
  108351. * @returns a number
  108352. */
  108353. getFrameId(): number;
  108354. /** Call this function if you want to manually increment the render Id*/
  108355. incrementRenderId(): void;
  108356. private _createUbo;
  108357. /**
  108358. * Use this method to simulate a pointer move on a mesh
  108359. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108360. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108361. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108362. * @returns the current scene
  108363. */
  108364. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108365. /**
  108366. * Use this method to simulate a pointer down on a mesh
  108367. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108368. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108369. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108370. * @returns the current scene
  108371. */
  108372. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108373. /**
  108374. * Use this method to simulate a pointer up on a mesh
  108375. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108376. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108377. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108378. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108379. * @returns the current scene
  108380. */
  108381. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  108382. /**
  108383. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108384. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108385. * @returns true if the pointer was captured
  108386. */
  108387. isPointerCaptured(pointerId?: number): boolean;
  108388. /**
  108389. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108390. * @param attachUp defines if you want to attach events to pointerup
  108391. * @param attachDown defines if you want to attach events to pointerdown
  108392. * @param attachMove defines if you want to attach events to pointermove
  108393. */
  108394. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  108395. /** Detaches all event handlers*/
  108396. detachControl(): void;
  108397. /**
  108398. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  108399. * Delay loaded resources are not taking in account
  108400. * @return true if all required resources are ready
  108401. */
  108402. isReady(): boolean;
  108403. /** Resets all cached information relative to material (including effect and visibility) */
  108404. resetCachedMaterial(): void;
  108405. /**
  108406. * Registers a function to be called before every frame render
  108407. * @param func defines the function to register
  108408. */
  108409. registerBeforeRender(func: () => void): void;
  108410. /**
  108411. * Unregisters a function called before every frame render
  108412. * @param func defines the function to unregister
  108413. */
  108414. unregisterBeforeRender(func: () => void): void;
  108415. /**
  108416. * Registers a function to be called after every frame render
  108417. * @param func defines the function to register
  108418. */
  108419. registerAfterRender(func: () => void): void;
  108420. /**
  108421. * Unregisters a function called after every frame render
  108422. * @param func defines the function to unregister
  108423. */
  108424. unregisterAfterRender(func: () => void): void;
  108425. private _executeOnceBeforeRender;
  108426. /**
  108427. * The provided function will run before render once and will be disposed afterwards.
  108428. * A timeout delay can be provided so that the function will be executed in N ms.
  108429. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  108430. * @param func The function to be executed.
  108431. * @param timeout optional delay in ms
  108432. */
  108433. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  108434. /** @hidden */
  108435. _addPendingData(data: any): void;
  108436. /** @hidden */
  108437. _removePendingData(data: any): void;
  108438. /**
  108439. * Returns the number of items waiting to be loaded
  108440. * @returns the number of items waiting to be loaded
  108441. */
  108442. getWaitingItemsCount(): number;
  108443. /**
  108444. * Returns a boolean indicating if the scene is still loading data
  108445. */
  108446. get isLoading(): boolean;
  108447. /**
  108448. * Registers a function to be executed when the scene is ready
  108449. * @param {Function} func - the function to be executed
  108450. */
  108451. executeWhenReady(func: () => void): void;
  108452. /**
  108453. * Returns a promise that resolves when the scene is ready
  108454. * @returns A promise that resolves when the scene is ready
  108455. */
  108456. whenReadyAsync(): Promise<void>;
  108457. /** @hidden */
  108458. _checkIsReady(): void;
  108459. /**
  108460. * Gets all animatable attached to the scene
  108461. */
  108462. get animatables(): Animatable[];
  108463. /**
  108464. * Resets the last animation time frame.
  108465. * Useful to override when animations start running when loading a scene for the first time.
  108466. */
  108467. resetLastAnimationTimeFrame(): void;
  108468. /**
  108469. * Gets the current view matrix
  108470. * @returns a Matrix
  108471. */
  108472. getViewMatrix(): Matrix;
  108473. /**
  108474. * Gets the current projection matrix
  108475. * @returns a Matrix
  108476. */
  108477. getProjectionMatrix(): Matrix;
  108478. /**
  108479. * Gets the current transform matrix
  108480. * @returns a Matrix made of View * Projection
  108481. */
  108482. getTransformMatrix(): Matrix;
  108483. /**
  108484. * Sets the current transform matrix
  108485. * @param viewL defines the View matrix to use
  108486. * @param projectionL defines the Projection matrix to use
  108487. * @param viewR defines the right View matrix to use (if provided)
  108488. * @param projectionR defines the right Projection matrix to use (if provided)
  108489. */
  108490. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  108491. /**
  108492. * Gets the uniform buffer used to store scene data
  108493. * @returns a UniformBuffer
  108494. */
  108495. getSceneUniformBuffer(): UniformBuffer;
  108496. /**
  108497. * Gets an unique (relatively to the current scene) Id
  108498. * @returns an unique number for the scene
  108499. */
  108500. getUniqueId(): number;
  108501. /**
  108502. * Add a mesh to the list of scene's meshes
  108503. * @param newMesh defines the mesh to add
  108504. * @param recursive if all child meshes should also be added to the scene
  108505. */
  108506. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  108507. /**
  108508. * Remove a mesh for the list of scene's meshes
  108509. * @param toRemove defines the mesh to remove
  108510. * @param recursive if all child meshes should also be removed from the scene
  108511. * @returns the index where the mesh was in the mesh list
  108512. */
  108513. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  108514. /**
  108515. * Add a transform node to the list of scene's transform nodes
  108516. * @param newTransformNode defines the transform node to add
  108517. */
  108518. addTransformNode(newTransformNode: TransformNode): void;
  108519. /**
  108520. * Remove a transform node for the list of scene's transform nodes
  108521. * @param toRemove defines the transform node to remove
  108522. * @returns the index where the transform node was in the transform node list
  108523. */
  108524. removeTransformNode(toRemove: TransformNode): number;
  108525. /**
  108526. * Remove a skeleton for the list of scene's skeletons
  108527. * @param toRemove defines the skeleton to remove
  108528. * @returns the index where the skeleton was in the skeleton list
  108529. */
  108530. removeSkeleton(toRemove: Skeleton): number;
  108531. /**
  108532. * Remove a morph target for the list of scene's morph targets
  108533. * @param toRemove defines the morph target to remove
  108534. * @returns the index where the morph target was in the morph target list
  108535. */
  108536. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  108537. /**
  108538. * Remove a light for the list of scene's lights
  108539. * @param toRemove defines the light to remove
  108540. * @returns the index where the light was in the light list
  108541. */
  108542. removeLight(toRemove: Light): number;
  108543. /**
  108544. * Remove a camera for the list of scene's cameras
  108545. * @param toRemove defines the camera to remove
  108546. * @returns the index where the camera was in the camera list
  108547. */
  108548. removeCamera(toRemove: Camera): number;
  108549. /**
  108550. * Remove a particle system for the list of scene's particle systems
  108551. * @param toRemove defines the particle system to remove
  108552. * @returns the index where the particle system was in the particle system list
  108553. */
  108554. removeParticleSystem(toRemove: IParticleSystem): number;
  108555. /**
  108556. * Remove a animation for the list of scene's animations
  108557. * @param toRemove defines the animation to remove
  108558. * @returns the index where the animation was in the animation list
  108559. */
  108560. removeAnimation(toRemove: Animation): number;
  108561. /**
  108562. * Will stop the animation of the given target
  108563. * @param target - the target
  108564. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  108565. * @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)
  108566. */
  108567. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  108568. /**
  108569. * Removes the given animation group from this scene.
  108570. * @param toRemove The animation group to remove
  108571. * @returns The index of the removed animation group
  108572. */
  108573. removeAnimationGroup(toRemove: AnimationGroup): number;
  108574. /**
  108575. * Removes the given multi-material from this scene.
  108576. * @param toRemove The multi-material to remove
  108577. * @returns The index of the removed multi-material
  108578. */
  108579. removeMultiMaterial(toRemove: MultiMaterial): number;
  108580. /**
  108581. * Removes the given material from this scene.
  108582. * @param toRemove The material to remove
  108583. * @returns The index of the removed material
  108584. */
  108585. removeMaterial(toRemove: Material): number;
  108586. /**
  108587. * Removes the given action manager from this scene.
  108588. * @param toRemove The action manager to remove
  108589. * @returns The index of the removed action manager
  108590. */
  108591. removeActionManager(toRemove: AbstractActionManager): number;
  108592. /**
  108593. * Removes the given texture from this scene.
  108594. * @param toRemove The texture to remove
  108595. * @returns The index of the removed texture
  108596. */
  108597. removeTexture(toRemove: BaseTexture): number;
  108598. /**
  108599. * Adds the given light to this scene
  108600. * @param newLight The light to add
  108601. */
  108602. addLight(newLight: Light): void;
  108603. /**
  108604. * Sorts the list list based on light priorities
  108605. */
  108606. sortLightsByPriority(): void;
  108607. /**
  108608. * Adds the given camera to this scene
  108609. * @param newCamera The camera to add
  108610. */
  108611. addCamera(newCamera: Camera): void;
  108612. /**
  108613. * Adds the given skeleton to this scene
  108614. * @param newSkeleton The skeleton to add
  108615. */
  108616. addSkeleton(newSkeleton: Skeleton): void;
  108617. /**
  108618. * Adds the given particle system to this scene
  108619. * @param newParticleSystem The particle system to add
  108620. */
  108621. addParticleSystem(newParticleSystem: IParticleSystem): void;
  108622. /**
  108623. * Adds the given animation to this scene
  108624. * @param newAnimation The animation to add
  108625. */
  108626. addAnimation(newAnimation: Animation): void;
  108627. /**
  108628. * Adds the given animation group to this scene.
  108629. * @param newAnimationGroup The animation group to add
  108630. */
  108631. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  108632. /**
  108633. * Adds the given multi-material to this scene
  108634. * @param newMultiMaterial The multi-material to add
  108635. */
  108636. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  108637. /**
  108638. * Adds the given material to this scene
  108639. * @param newMaterial The material to add
  108640. */
  108641. addMaterial(newMaterial: Material): void;
  108642. /**
  108643. * Adds the given morph target to this scene
  108644. * @param newMorphTargetManager The morph target to add
  108645. */
  108646. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  108647. /**
  108648. * Adds the given geometry to this scene
  108649. * @param newGeometry The geometry to add
  108650. */
  108651. addGeometry(newGeometry: Geometry): void;
  108652. /**
  108653. * Adds the given action manager to this scene
  108654. * @param newActionManager The action manager to add
  108655. */
  108656. addActionManager(newActionManager: AbstractActionManager): void;
  108657. /**
  108658. * Adds the given texture to this scene.
  108659. * @param newTexture The texture to add
  108660. */
  108661. addTexture(newTexture: BaseTexture): void;
  108662. /**
  108663. * Switch active camera
  108664. * @param newCamera defines the new active camera
  108665. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  108666. */
  108667. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  108668. /**
  108669. * sets the active camera of the scene using its ID
  108670. * @param id defines the camera's ID
  108671. * @return the new active camera or null if none found.
  108672. */
  108673. setActiveCameraByID(id: string): Nullable<Camera>;
  108674. /**
  108675. * sets the active camera of the scene using its name
  108676. * @param name defines the camera's name
  108677. * @returns the new active camera or null if none found.
  108678. */
  108679. setActiveCameraByName(name: string): Nullable<Camera>;
  108680. /**
  108681. * get an animation group using its name
  108682. * @param name defines the material's name
  108683. * @return the animation group or null if none found.
  108684. */
  108685. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  108686. /**
  108687. * Get a material using its unique id
  108688. * @param uniqueId defines the material's unique id
  108689. * @return the material or null if none found.
  108690. */
  108691. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  108692. /**
  108693. * get a material using its id
  108694. * @param id defines the material's ID
  108695. * @return the material or null if none found.
  108696. */
  108697. getMaterialByID(id: string): Nullable<Material>;
  108698. /**
  108699. * Gets a the last added material using a given id
  108700. * @param id defines the material's ID
  108701. * @return the last material with the given id or null if none found.
  108702. */
  108703. getLastMaterialByID(id: string): Nullable<Material>;
  108704. /**
  108705. * Gets a material using its name
  108706. * @param name defines the material's name
  108707. * @return the material or null if none found.
  108708. */
  108709. getMaterialByName(name: string): Nullable<Material>;
  108710. /**
  108711. * Get a texture using its unique id
  108712. * @param uniqueId defines the texture's unique id
  108713. * @return the texture or null if none found.
  108714. */
  108715. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  108716. /**
  108717. * Gets a camera using its id
  108718. * @param id defines the id to look for
  108719. * @returns the camera or null if not found
  108720. */
  108721. getCameraByID(id: string): Nullable<Camera>;
  108722. /**
  108723. * Gets a camera using its unique id
  108724. * @param uniqueId defines the unique id to look for
  108725. * @returns the camera or null if not found
  108726. */
  108727. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  108728. /**
  108729. * Gets a camera using its name
  108730. * @param name defines the camera's name
  108731. * @return the camera or null if none found.
  108732. */
  108733. getCameraByName(name: string): Nullable<Camera>;
  108734. /**
  108735. * Gets a bone using its id
  108736. * @param id defines the bone's id
  108737. * @return the bone or null if not found
  108738. */
  108739. getBoneByID(id: string): Nullable<Bone>;
  108740. /**
  108741. * Gets a bone using its id
  108742. * @param name defines the bone's name
  108743. * @return the bone or null if not found
  108744. */
  108745. getBoneByName(name: string): Nullable<Bone>;
  108746. /**
  108747. * Gets a light node using its name
  108748. * @param name defines the the light's name
  108749. * @return the light or null if none found.
  108750. */
  108751. getLightByName(name: string): Nullable<Light>;
  108752. /**
  108753. * Gets a light node using its id
  108754. * @param id defines the light's id
  108755. * @return the light or null if none found.
  108756. */
  108757. getLightByID(id: string): Nullable<Light>;
  108758. /**
  108759. * Gets a light node using its scene-generated unique ID
  108760. * @param uniqueId defines the light's unique id
  108761. * @return the light or null if none found.
  108762. */
  108763. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  108764. /**
  108765. * Gets a particle system by id
  108766. * @param id defines the particle system id
  108767. * @return the corresponding system or null if none found
  108768. */
  108769. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  108770. /**
  108771. * Gets a geometry using its ID
  108772. * @param id defines the geometry's id
  108773. * @return the geometry or null if none found.
  108774. */
  108775. getGeometryByID(id: string): Nullable<Geometry>;
  108776. private _getGeometryByUniqueID;
  108777. /**
  108778. * Add a new geometry to this scene
  108779. * @param geometry defines the geometry to be added to the scene.
  108780. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  108781. * @return a boolean defining if the geometry was added or not
  108782. */
  108783. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  108784. /**
  108785. * Removes an existing geometry
  108786. * @param geometry defines the geometry to be removed from the scene
  108787. * @return a boolean defining if the geometry was removed or not
  108788. */
  108789. removeGeometry(geometry: Geometry): boolean;
  108790. /**
  108791. * Gets the list of geometries attached to the scene
  108792. * @returns an array of Geometry
  108793. */
  108794. getGeometries(): Geometry[];
  108795. /**
  108796. * Gets the first added mesh found of a given ID
  108797. * @param id defines the id to search for
  108798. * @return the mesh found or null if not found at all
  108799. */
  108800. getMeshByID(id: string): Nullable<AbstractMesh>;
  108801. /**
  108802. * Gets a list of meshes using their id
  108803. * @param id defines the id to search for
  108804. * @returns a list of meshes
  108805. */
  108806. getMeshesByID(id: string): Array<AbstractMesh>;
  108807. /**
  108808. * Gets the first added transform node found of a given ID
  108809. * @param id defines the id to search for
  108810. * @return the found transform node or null if not found at all.
  108811. */
  108812. getTransformNodeByID(id: string): Nullable<TransformNode>;
  108813. /**
  108814. * Gets a transform node with its auto-generated unique id
  108815. * @param uniqueId efines the unique id to search for
  108816. * @return the found transform node or null if not found at all.
  108817. */
  108818. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  108819. /**
  108820. * Gets a list of transform nodes using their id
  108821. * @param id defines the id to search for
  108822. * @returns a list of transform nodes
  108823. */
  108824. getTransformNodesByID(id: string): Array<TransformNode>;
  108825. /**
  108826. * Gets a mesh with its auto-generated unique id
  108827. * @param uniqueId defines the unique id to search for
  108828. * @return the found mesh or null if not found at all.
  108829. */
  108830. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  108831. /**
  108832. * Gets a the last added mesh using a given id
  108833. * @param id defines the id to search for
  108834. * @return the found mesh or null if not found at all.
  108835. */
  108836. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  108837. /**
  108838. * Gets a the last added node (Mesh, Camera, Light) using a given id
  108839. * @param id defines the id to search for
  108840. * @return the found node or null if not found at all
  108841. */
  108842. getLastEntryByID(id: string): Nullable<Node>;
  108843. /**
  108844. * Gets a node (Mesh, Camera, Light) using a given id
  108845. * @param id defines the id to search for
  108846. * @return the found node or null if not found at all
  108847. */
  108848. getNodeByID(id: string): Nullable<Node>;
  108849. /**
  108850. * Gets a node (Mesh, Camera, Light) using a given name
  108851. * @param name defines the name to search for
  108852. * @return the found node or null if not found at all.
  108853. */
  108854. getNodeByName(name: string): Nullable<Node>;
  108855. /**
  108856. * Gets a mesh using a given name
  108857. * @param name defines the name to search for
  108858. * @return the found mesh or null if not found at all.
  108859. */
  108860. getMeshByName(name: string): Nullable<AbstractMesh>;
  108861. /**
  108862. * Gets a transform node using a given name
  108863. * @param name defines the name to search for
  108864. * @return the found transform node or null if not found at all.
  108865. */
  108866. getTransformNodeByName(name: string): Nullable<TransformNode>;
  108867. /**
  108868. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  108869. * @param id defines the id to search for
  108870. * @return the found skeleton or null if not found at all.
  108871. */
  108872. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  108873. /**
  108874. * Gets a skeleton using a given auto generated unique id
  108875. * @param uniqueId defines the unique id to search for
  108876. * @return the found skeleton or null if not found at all.
  108877. */
  108878. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  108879. /**
  108880. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  108881. * @param id defines the id to search for
  108882. * @return the found skeleton or null if not found at all.
  108883. */
  108884. getSkeletonById(id: string): Nullable<Skeleton>;
  108885. /**
  108886. * Gets a skeleton using a given name
  108887. * @param name defines the name to search for
  108888. * @return the found skeleton or null if not found at all.
  108889. */
  108890. getSkeletonByName(name: string): Nullable<Skeleton>;
  108891. /**
  108892. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  108893. * @param id defines the id to search for
  108894. * @return the found morph target manager or null if not found at all.
  108895. */
  108896. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  108897. /**
  108898. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  108899. * @param id defines the id to search for
  108900. * @return the found morph target or null if not found at all.
  108901. */
  108902. getMorphTargetById(id: string): Nullable<MorphTarget>;
  108903. /**
  108904. * Gets a boolean indicating if the given mesh is active
  108905. * @param mesh defines the mesh to look for
  108906. * @returns true if the mesh is in the active list
  108907. */
  108908. isActiveMesh(mesh: AbstractMesh): boolean;
  108909. /**
  108910. * Return a unique id as a string which can serve as an identifier for the scene
  108911. */
  108912. get uid(): string;
  108913. /**
  108914. * Add an externaly attached data from its key.
  108915. * This method call will fail and return false, if such key already exists.
  108916. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  108917. * @param key the unique key that identifies the data
  108918. * @param data the data object to associate to the key for this Engine instance
  108919. * @return true if no such key were already present and the data was added successfully, false otherwise
  108920. */
  108921. addExternalData<T>(key: string, data: T): boolean;
  108922. /**
  108923. * Get an externaly attached data from its key
  108924. * @param key the unique key that identifies the data
  108925. * @return the associated data, if present (can be null), or undefined if not present
  108926. */
  108927. getExternalData<T>(key: string): Nullable<T>;
  108928. /**
  108929. * Get an externaly attached data from its key, create it using a factory if it's not already present
  108930. * @param key the unique key that identifies the data
  108931. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  108932. * @return the associated data, can be null if the factory returned null.
  108933. */
  108934. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  108935. /**
  108936. * Remove an externaly attached data from the Engine instance
  108937. * @param key the unique key that identifies the data
  108938. * @return true if the data was successfully removed, false if it doesn't exist
  108939. */
  108940. removeExternalData(key: string): boolean;
  108941. private _evaluateSubMesh;
  108942. /**
  108943. * Clear the processed materials smart array preventing retention point in material dispose.
  108944. */
  108945. freeProcessedMaterials(): void;
  108946. private _preventFreeActiveMeshesAndRenderingGroups;
  108947. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  108948. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  108949. * when disposing several meshes in a row or a hierarchy of meshes.
  108950. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  108951. */
  108952. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  108953. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  108954. /**
  108955. * Clear the active meshes smart array preventing retention point in mesh dispose.
  108956. */
  108957. freeActiveMeshes(): void;
  108958. /**
  108959. * Clear the info related to rendering groups preventing retention points during dispose.
  108960. */
  108961. freeRenderingGroups(): void;
  108962. /** @hidden */
  108963. _isInIntermediateRendering(): boolean;
  108964. /**
  108965. * Lambda returning the list of potentially active meshes.
  108966. */
  108967. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  108968. /**
  108969. * Lambda returning the list of potentially active sub meshes.
  108970. */
  108971. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  108972. /**
  108973. * Lambda returning the list of potentially intersecting sub meshes.
  108974. */
  108975. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  108976. /**
  108977. * Lambda returning the list of potentially colliding sub meshes.
  108978. */
  108979. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  108980. private _activeMeshesFrozen;
  108981. private _skipEvaluateActiveMeshesCompletely;
  108982. /**
  108983. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  108984. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  108985. * @returns the current scene
  108986. */
  108987. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  108988. /**
  108989. * Use this function to restart evaluating active meshes on every frame
  108990. * @returns the current scene
  108991. */
  108992. unfreezeActiveMeshes(): Scene;
  108993. private _evaluateActiveMeshes;
  108994. private _activeMesh;
  108995. /**
  108996. * Update the transform matrix to update from the current active camera
  108997. * @param force defines a boolean used to force the update even if cache is up to date
  108998. */
  108999. updateTransformMatrix(force?: boolean): void;
  109000. private _bindFrameBuffer;
  109001. /** @hidden */
  109002. _allowPostProcessClearColor: boolean;
  109003. /** @hidden */
  109004. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109005. private _processSubCameras;
  109006. private _checkIntersections;
  109007. /** @hidden */
  109008. _advancePhysicsEngineStep(step: number): void;
  109009. /**
  109010. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109011. */
  109012. getDeterministicFrameTime: () => number;
  109013. /** @hidden */
  109014. _animate(): void;
  109015. /** Execute all animations (for a frame) */
  109016. animate(): void;
  109017. /**
  109018. * Render the scene
  109019. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109020. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109021. */
  109022. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109023. /**
  109024. * Freeze all materials
  109025. * A frozen material will not be updatable but should be faster to render
  109026. */
  109027. freezeMaterials(): void;
  109028. /**
  109029. * Unfreeze all materials
  109030. * A frozen material will not be updatable but should be faster to render
  109031. */
  109032. unfreezeMaterials(): void;
  109033. /**
  109034. * Releases all held ressources
  109035. */
  109036. dispose(): void;
  109037. /**
  109038. * Gets if the scene is already disposed
  109039. */
  109040. get isDisposed(): boolean;
  109041. /**
  109042. * Call this function to reduce memory footprint of the scene.
  109043. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109044. */
  109045. clearCachedVertexData(): void;
  109046. /**
  109047. * This function will remove the local cached buffer data from texture.
  109048. * It will save memory but will prevent the texture from being rebuilt
  109049. */
  109050. cleanCachedTextureBuffer(): void;
  109051. /**
  109052. * Get the world extend vectors with an optional filter
  109053. *
  109054. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109055. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109056. */
  109057. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109058. min: Vector3;
  109059. max: Vector3;
  109060. };
  109061. /**
  109062. * Creates a ray that can be used to pick in the scene
  109063. * @param x defines the x coordinate of the origin (on-screen)
  109064. * @param y defines the y coordinate of the origin (on-screen)
  109065. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109066. * @param camera defines the camera to use for the picking
  109067. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109068. * @returns a Ray
  109069. */
  109070. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109071. /**
  109072. * Creates a ray that can be used to pick in the scene
  109073. * @param x defines the x coordinate of the origin (on-screen)
  109074. * @param y defines the y coordinate of the origin (on-screen)
  109075. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109076. * @param result defines the ray where to store the picking ray
  109077. * @param camera defines the camera to use for the picking
  109078. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109079. * @returns the current scene
  109080. */
  109081. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109082. /**
  109083. * Creates a ray that can be used to pick in the scene
  109084. * @param x defines the x coordinate of the origin (on-screen)
  109085. * @param y defines the y coordinate of the origin (on-screen)
  109086. * @param camera defines the camera to use for the picking
  109087. * @returns a Ray
  109088. */
  109089. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109090. /**
  109091. * Creates a ray that can be used to pick in the scene
  109092. * @param x defines the x coordinate of the origin (on-screen)
  109093. * @param y defines the y coordinate of the origin (on-screen)
  109094. * @param result defines the ray where to store the picking ray
  109095. * @param camera defines the camera to use for the picking
  109096. * @returns the current scene
  109097. */
  109098. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109099. /** Launch a ray to try to pick a mesh in the scene
  109100. * @param x position on screen
  109101. * @param y position on screen
  109102. * @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
  109103. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109104. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109105. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109106. * @returns a PickingInfo
  109107. */
  109108. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109109. /** Use the given ray to pick a mesh in the scene
  109110. * @param ray The ray to use to pick meshes
  109111. * @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
  109112. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  109113. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109114. * @returns a PickingInfo
  109115. */
  109116. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109117. /**
  109118. * Launch a ray to try to pick a mesh in the scene
  109119. * @param x X position on screen
  109120. * @param y Y position on screen
  109121. * @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
  109122. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109123. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109124. * @returns an array of PickingInfo
  109125. */
  109126. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109127. /**
  109128. * Launch a ray to try to pick a mesh in the scene
  109129. * @param ray Ray to use
  109130. * @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
  109131. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109132. * @returns an array of PickingInfo
  109133. */
  109134. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109135. /**
  109136. * Force the value of meshUnderPointer
  109137. * @param mesh defines the mesh to use
  109138. */
  109139. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109140. /**
  109141. * Gets the mesh under the pointer
  109142. * @returns a Mesh or null if no mesh is under the pointer
  109143. */
  109144. getPointerOverMesh(): Nullable<AbstractMesh>;
  109145. /** @hidden */
  109146. _rebuildGeometries(): void;
  109147. /** @hidden */
  109148. _rebuildTextures(): void;
  109149. private _getByTags;
  109150. /**
  109151. * Get a list of meshes by tags
  109152. * @param tagsQuery defines the tags query to use
  109153. * @param forEach defines a predicate used to filter results
  109154. * @returns an array of Mesh
  109155. */
  109156. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  109157. /**
  109158. * Get a list of cameras by tags
  109159. * @param tagsQuery defines the tags query to use
  109160. * @param forEach defines a predicate used to filter results
  109161. * @returns an array of Camera
  109162. */
  109163. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  109164. /**
  109165. * Get a list of lights by tags
  109166. * @param tagsQuery defines the tags query to use
  109167. * @param forEach defines a predicate used to filter results
  109168. * @returns an array of Light
  109169. */
  109170. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  109171. /**
  109172. * Get a list of materials by tags
  109173. * @param tagsQuery defines the tags query to use
  109174. * @param forEach defines a predicate used to filter results
  109175. * @returns an array of Material
  109176. */
  109177. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  109178. /**
  109179. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109180. * This allowed control for front to back rendering or reversly depending of the special needs.
  109181. *
  109182. * @param renderingGroupId The rendering group id corresponding to its index
  109183. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109184. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109185. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109186. */
  109187. 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;
  109188. /**
  109189. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109190. *
  109191. * @param renderingGroupId The rendering group id corresponding to its index
  109192. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109193. * @param depth Automatically clears depth between groups if true and autoClear is true.
  109194. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  109195. */
  109196. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  109197. /**
  109198. * Gets the current auto clear configuration for one rendering group of the rendering
  109199. * manager.
  109200. * @param index the rendering group index to get the information for
  109201. * @returns The auto clear setup for the requested rendering group
  109202. */
  109203. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  109204. private _blockMaterialDirtyMechanism;
  109205. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  109206. get blockMaterialDirtyMechanism(): boolean;
  109207. set blockMaterialDirtyMechanism(value: boolean);
  109208. /**
  109209. * Will flag all materials as dirty to trigger new shader compilation
  109210. * @param flag defines the flag used to specify which material part must be marked as dirty
  109211. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  109212. */
  109213. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109214. /** @hidden */
  109215. _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;
  109216. /** @hidden */
  109217. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109218. /** @hidden */
  109219. _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;
  109220. /** @hidden */
  109221. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  109222. /** @hidden */
  109223. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  109224. /** @hidden */
  109225. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109226. }
  109227. }
  109228. declare module BABYLON {
  109229. /**
  109230. * Set of assets to keep when moving a scene into an asset container.
  109231. */
  109232. export class KeepAssets extends AbstractScene {
  109233. }
  109234. /**
  109235. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  109236. */
  109237. export class InstantiatedEntries {
  109238. /**
  109239. * List of new root nodes (eg. nodes with no parent)
  109240. */
  109241. rootNodes: TransformNode[];
  109242. /**
  109243. * List of new skeletons
  109244. */
  109245. skeletons: Skeleton[];
  109246. /**
  109247. * List of new animation groups
  109248. */
  109249. animationGroups: AnimationGroup[];
  109250. }
  109251. /**
  109252. * Container with a set of assets that can be added or removed from a scene.
  109253. */
  109254. export class AssetContainer extends AbstractScene {
  109255. /**
  109256. * The scene the AssetContainer belongs to.
  109257. */
  109258. scene: Scene;
  109259. /**
  109260. * Instantiates an AssetContainer.
  109261. * @param scene The scene the AssetContainer belongs to.
  109262. */
  109263. constructor(scene: Scene);
  109264. /**
  109265. * Instantiate or clone all meshes and add the new ones to the scene.
  109266. * Skeletons and animation groups will all be cloned
  109267. * @param nameFunction defines an optional function used to get new names for clones
  109268. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  109269. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  109270. */
  109271. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  109272. /**
  109273. * Adds all the assets from the container to the scene.
  109274. */
  109275. addAllToScene(): void;
  109276. /**
  109277. * Removes all the assets in the container from the scene
  109278. */
  109279. removeAllFromScene(): void;
  109280. /**
  109281. * Disposes all the assets in the container
  109282. */
  109283. dispose(): void;
  109284. private _moveAssets;
  109285. /**
  109286. * Removes all the assets contained in the scene and adds them to the container.
  109287. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  109288. */
  109289. moveAllFromScene(keepAssets?: KeepAssets): void;
  109290. /**
  109291. * 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.
  109292. * @returns the root mesh
  109293. */
  109294. createRootMesh(): Mesh;
  109295. /**
  109296. * Merge animations from this asset container into a scene
  109297. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109298. * @param animatables set of animatables to retarget to a node from the scene
  109299. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  109300. */
  109301. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  109302. }
  109303. }
  109304. declare module BABYLON {
  109305. /**
  109306. * Defines how the parser contract is defined.
  109307. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  109308. */
  109309. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  109310. /**
  109311. * Defines how the individual parser contract is defined.
  109312. * These parser can parse an individual asset
  109313. */
  109314. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  109315. /**
  109316. * Base class of the scene acting as a container for the different elements composing a scene.
  109317. * This class is dynamically extended by the different components of the scene increasing
  109318. * flexibility and reducing coupling
  109319. */
  109320. export abstract class AbstractScene {
  109321. /**
  109322. * Stores the list of available parsers in the application.
  109323. */
  109324. private static _BabylonFileParsers;
  109325. /**
  109326. * Stores the list of available individual parsers in the application.
  109327. */
  109328. private static _IndividualBabylonFileParsers;
  109329. /**
  109330. * Adds a parser in the list of available ones
  109331. * @param name Defines the name of the parser
  109332. * @param parser Defines the parser to add
  109333. */
  109334. static AddParser(name: string, parser: BabylonFileParser): void;
  109335. /**
  109336. * Gets a general parser from the list of avaialble ones
  109337. * @param name Defines the name of the parser
  109338. * @returns the requested parser or null
  109339. */
  109340. static GetParser(name: string): Nullable<BabylonFileParser>;
  109341. /**
  109342. * Adds n individual parser in the list of available ones
  109343. * @param name Defines the name of the parser
  109344. * @param parser Defines the parser to add
  109345. */
  109346. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  109347. /**
  109348. * Gets an individual parser from the list of avaialble ones
  109349. * @param name Defines the name of the parser
  109350. * @returns the requested parser or null
  109351. */
  109352. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  109353. /**
  109354. * Parser json data and populate both a scene and its associated container object
  109355. * @param jsonData Defines the data to parse
  109356. * @param scene Defines the scene to parse the data for
  109357. * @param container Defines the container attached to the parsing sequence
  109358. * @param rootUrl Defines the root url of the data
  109359. */
  109360. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  109361. /**
  109362. * Gets the list of root nodes (ie. nodes with no parent)
  109363. */
  109364. rootNodes: Node[];
  109365. /** All of the cameras added to this scene
  109366. * @see http://doc.babylonjs.com/babylon101/cameras
  109367. */
  109368. cameras: Camera[];
  109369. /**
  109370. * All of the lights added to this scene
  109371. * @see http://doc.babylonjs.com/babylon101/lights
  109372. */
  109373. lights: Light[];
  109374. /**
  109375. * All of the (abstract) meshes added to this scene
  109376. */
  109377. meshes: AbstractMesh[];
  109378. /**
  109379. * The list of skeletons added to the scene
  109380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109381. */
  109382. skeletons: Skeleton[];
  109383. /**
  109384. * All of the particle systems added to this scene
  109385. * @see http://doc.babylonjs.com/babylon101/particles
  109386. */
  109387. particleSystems: IParticleSystem[];
  109388. /**
  109389. * Gets a list of Animations associated with the scene
  109390. */
  109391. animations: Animation[];
  109392. /**
  109393. * All of the animation groups added to this scene
  109394. * @see http://doc.babylonjs.com/how_to/group
  109395. */
  109396. animationGroups: AnimationGroup[];
  109397. /**
  109398. * All of the multi-materials added to this scene
  109399. * @see http://doc.babylonjs.com/how_to/multi_materials
  109400. */
  109401. multiMaterials: MultiMaterial[];
  109402. /**
  109403. * All of the materials added to this scene
  109404. * In the context of a Scene, it is not supposed to be modified manually.
  109405. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  109406. * Note also that the order of the Material within the array is not significant and might change.
  109407. * @see http://doc.babylonjs.com/babylon101/materials
  109408. */
  109409. materials: Material[];
  109410. /**
  109411. * The list of morph target managers added to the scene
  109412. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  109413. */
  109414. morphTargetManagers: MorphTargetManager[];
  109415. /**
  109416. * The list of geometries used in the scene.
  109417. */
  109418. geometries: Geometry[];
  109419. /**
  109420. * All of the tranform nodes added to this scene
  109421. * In the context of a Scene, it is not supposed to be modified manually.
  109422. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  109423. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  109424. * @see http://doc.babylonjs.com/how_to/transformnode
  109425. */
  109426. transformNodes: TransformNode[];
  109427. /**
  109428. * ActionManagers available on the scene.
  109429. */
  109430. actionManagers: AbstractActionManager[];
  109431. /**
  109432. * Textures to keep.
  109433. */
  109434. textures: BaseTexture[];
  109435. /**
  109436. * Environment texture for the scene
  109437. */
  109438. environmentTexture: Nullable<BaseTexture>;
  109439. /**
  109440. * @returns all meshes, lights, cameras, transformNodes and bones
  109441. */
  109442. getNodes(): Array<Node>;
  109443. }
  109444. }
  109445. declare module BABYLON {
  109446. /**
  109447. * Interface used to define options for Sound class
  109448. */
  109449. export interface ISoundOptions {
  109450. /**
  109451. * Does the sound autoplay once loaded.
  109452. */
  109453. autoplay?: boolean;
  109454. /**
  109455. * Does the sound loop after it finishes playing once.
  109456. */
  109457. loop?: boolean;
  109458. /**
  109459. * Sound's volume
  109460. */
  109461. volume?: number;
  109462. /**
  109463. * Is it a spatial sound?
  109464. */
  109465. spatialSound?: boolean;
  109466. /**
  109467. * Maximum distance to hear that sound
  109468. */
  109469. maxDistance?: number;
  109470. /**
  109471. * Uses user defined attenuation function
  109472. */
  109473. useCustomAttenuation?: boolean;
  109474. /**
  109475. * Define the roll off factor of spatial sounds.
  109476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109477. */
  109478. rolloffFactor?: number;
  109479. /**
  109480. * Define the reference distance the sound should be heard perfectly.
  109481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109482. */
  109483. refDistance?: number;
  109484. /**
  109485. * Define the distance attenuation model the sound will follow.
  109486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109487. */
  109488. distanceModel?: string;
  109489. /**
  109490. * Defines the playback speed (1 by default)
  109491. */
  109492. playbackRate?: number;
  109493. /**
  109494. * Defines if the sound is from a streaming source
  109495. */
  109496. streaming?: boolean;
  109497. /**
  109498. * Defines an optional length (in seconds) inside the sound file
  109499. */
  109500. length?: number;
  109501. /**
  109502. * Defines an optional offset (in seconds) inside the sound file
  109503. */
  109504. offset?: number;
  109505. /**
  109506. * If true, URLs will not be required to state the audio file codec to use.
  109507. */
  109508. skipCodecCheck?: boolean;
  109509. }
  109510. /**
  109511. * Defines a sound that can be played in the application.
  109512. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  109513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109514. */
  109515. export class Sound {
  109516. /**
  109517. * The name of the sound in the scene.
  109518. */
  109519. name: string;
  109520. /**
  109521. * Does the sound autoplay once loaded.
  109522. */
  109523. autoplay: boolean;
  109524. /**
  109525. * Does the sound loop after it finishes playing once.
  109526. */
  109527. loop: boolean;
  109528. /**
  109529. * Does the sound use a custom attenuation curve to simulate the falloff
  109530. * happening when the source gets further away from the camera.
  109531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  109532. */
  109533. useCustomAttenuation: boolean;
  109534. /**
  109535. * The sound track id this sound belongs to.
  109536. */
  109537. soundTrackId: number;
  109538. /**
  109539. * Is this sound currently played.
  109540. */
  109541. isPlaying: boolean;
  109542. /**
  109543. * Is this sound currently paused.
  109544. */
  109545. isPaused: boolean;
  109546. /**
  109547. * Does this sound enables spatial sound.
  109548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109549. */
  109550. spatialSound: boolean;
  109551. /**
  109552. * Define the reference distance the sound should be heard perfectly.
  109553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109554. */
  109555. refDistance: number;
  109556. /**
  109557. * Define the roll off factor of spatial sounds.
  109558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109559. */
  109560. rolloffFactor: number;
  109561. /**
  109562. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  109563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109564. */
  109565. maxDistance: number;
  109566. /**
  109567. * Define the distance attenuation model the sound will follow.
  109568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109569. */
  109570. distanceModel: string;
  109571. /**
  109572. * @hidden
  109573. * Back Compat
  109574. **/
  109575. onended: () => any;
  109576. /**
  109577. * Observable event when the current playing sound finishes.
  109578. */
  109579. onEndedObservable: Observable<Sound>;
  109580. private _panningModel;
  109581. private _playbackRate;
  109582. private _streaming;
  109583. private _startTime;
  109584. private _startOffset;
  109585. private _position;
  109586. /** @hidden */
  109587. _positionInEmitterSpace: boolean;
  109588. private _localDirection;
  109589. private _volume;
  109590. private _isReadyToPlay;
  109591. private _isDirectional;
  109592. private _readyToPlayCallback;
  109593. private _audioBuffer;
  109594. private _soundSource;
  109595. private _streamingSource;
  109596. private _soundPanner;
  109597. private _soundGain;
  109598. private _inputAudioNode;
  109599. private _outputAudioNode;
  109600. private _coneInnerAngle;
  109601. private _coneOuterAngle;
  109602. private _coneOuterGain;
  109603. private _scene;
  109604. private _connectedTransformNode;
  109605. private _customAttenuationFunction;
  109606. private _registerFunc;
  109607. private _isOutputConnected;
  109608. private _htmlAudioElement;
  109609. private _urlType;
  109610. private _length?;
  109611. private _offset?;
  109612. /** @hidden */
  109613. static _SceneComponentInitialization: (scene: Scene) => void;
  109614. /**
  109615. * Create a sound and attach it to a scene
  109616. * @param name Name of your sound
  109617. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  109618. * @param scene defines the scene the sound belongs to
  109619. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  109620. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  109621. */
  109622. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  109623. /**
  109624. * Release the sound and its associated resources
  109625. */
  109626. dispose(): void;
  109627. /**
  109628. * Gets if the sounds is ready to be played or not.
  109629. * @returns true if ready, otherwise false
  109630. */
  109631. isReady(): boolean;
  109632. private _soundLoaded;
  109633. /**
  109634. * Sets the data of the sound from an audiobuffer
  109635. * @param audioBuffer The audioBuffer containing the data
  109636. */
  109637. setAudioBuffer(audioBuffer: AudioBuffer): void;
  109638. /**
  109639. * Updates the current sounds options such as maxdistance, loop...
  109640. * @param options A JSON object containing values named as the object properties
  109641. */
  109642. updateOptions(options: ISoundOptions): void;
  109643. private _createSpatialParameters;
  109644. private _updateSpatialParameters;
  109645. /**
  109646. * Switch the panning model to HRTF:
  109647. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  109648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109649. */
  109650. switchPanningModelToHRTF(): void;
  109651. /**
  109652. * Switch the panning model to Equal Power:
  109653. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  109654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109655. */
  109656. switchPanningModelToEqualPower(): void;
  109657. private _switchPanningModel;
  109658. /**
  109659. * Connect this sound to a sound track audio node like gain...
  109660. * @param soundTrackAudioNode the sound track audio node to connect to
  109661. */
  109662. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  109663. /**
  109664. * Transform this sound into a directional source
  109665. * @param coneInnerAngle Size of the inner cone in degree
  109666. * @param coneOuterAngle Size of the outer cone in degree
  109667. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  109668. */
  109669. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  109670. /**
  109671. * Gets or sets the inner angle for the directional cone.
  109672. */
  109673. get directionalConeInnerAngle(): number;
  109674. /**
  109675. * Gets or sets the inner angle for the directional cone.
  109676. */
  109677. set directionalConeInnerAngle(value: number);
  109678. /**
  109679. * Gets or sets the outer angle for the directional cone.
  109680. */
  109681. get directionalConeOuterAngle(): number;
  109682. /**
  109683. * Gets or sets the outer angle for the directional cone.
  109684. */
  109685. set directionalConeOuterAngle(value: number);
  109686. /**
  109687. * Sets the position of the emitter if spatial sound is enabled
  109688. * @param newPosition Defines the new posisiton
  109689. */
  109690. setPosition(newPosition: Vector3): void;
  109691. /**
  109692. * Sets the local direction of the emitter if spatial sound is enabled
  109693. * @param newLocalDirection Defines the new local direction
  109694. */
  109695. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  109696. private _updateDirection;
  109697. /** @hidden */
  109698. updateDistanceFromListener(): void;
  109699. /**
  109700. * Sets a new custom attenuation function for the sound.
  109701. * @param callback Defines the function used for the attenuation
  109702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  109703. */
  109704. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  109705. /**
  109706. * Play the sound
  109707. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  109708. * @param offset (optional) Start the sound at a specific time in seconds
  109709. * @param length (optional) Sound duration (in seconds)
  109710. */
  109711. play(time?: number, offset?: number, length?: number): void;
  109712. private _onended;
  109713. /**
  109714. * Stop the sound
  109715. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  109716. */
  109717. stop(time?: number): void;
  109718. /**
  109719. * Put the sound in pause
  109720. */
  109721. pause(): void;
  109722. /**
  109723. * Sets a dedicated volume for this sounds
  109724. * @param newVolume Define the new volume of the sound
  109725. * @param time Define time for gradual change to new volume
  109726. */
  109727. setVolume(newVolume: number, time?: number): void;
  109728. /**
  109729. * Set the sound play back rate
  109730. * @param newPlaybackRate Define the playback rate the sound should be played at
  109731. */
  109732. setPlaybackRate(newPlaybackRate: number): void;
  109733. /**
  109734. * Gets the volume of the sound.
  109735. * @returns the volume of the sound
  109736. */
  109737. getVolume(): number;
  109738. /**
  109739. * Attach the sound to a dedicated mesh
  109740. * @param transformNode The transform node to connect the sound with
  109741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  109742. */
  109743. attachToMesh(transformNode: TransformNode): void;
  109744. /**
  109745. * Detach the sound from the previously attached mesh
  109746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  109747. */
  109748. detachFromMesh(): void;
  109749. private _onRegisterAfterWorldMatrixUpdate;
  109750. /**
  109751. * Clone the current sound in the scene.
  109752. * @returns the new sound clone
  109753. */
  109754. clone(): Nullable<Sound>;
  109755. /**
  109756. * Gets the current underlying audio buffer containing the data
  109757. * @returns the audio buffer
  109758. */
  109759. getAudioBuffer(): Nullable<AudioBuffer>;
  109760. /**
  109761. * Serializes the Sound in a JSON representation
  109762. * @returns the JSON representation of the sound
  109763. */
  109764. serialize(): any;
  109765. /**
  109766. * Parse a JSON representation of a sound to innstantiate in a given scene
  109767. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  109768. * @param scene Define the scene the new parsed sound should be created in
  109769. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  109770. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  109771. * @returns the newly parsed sound
  109772. */
  109773. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  109774. }
  109775. }
  109776. declare module BABYLON {
  109777. /**
  109778. * This defines an action helpful to play a defined sound on a triggered action.
  109779. */
  109780. export class PlaySoundAction extends Action {
  109781. private _sound;
  109782. /**
  109783. * Instantiate the action
  109784. * @param triggerOptions defines the trigger options
  109785. * @param sound defines the sound to play
  109786. * @param condition defines the trigger related conditions
  109787. */
  109788. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  109789. /** @hidden */
  109790. _prepare(): void;
  109791. /**
  109792. * Execute the action and play the sound.
  109793. */
  109794. execute(): void;
  109795. /**
  109796. * Serializes the actions and its related information.
  109797. * @param parent defines the object to serialize in
  109798. * @returns the serialized object
  109799. */
  109800. serialize(parent: any): any;
  109801. }
  109802. /**
  109803. * This defines an action helpful to stop a defined sound on a triggered action.
  109804. */
  109805. export class StopSoundAction extends Action {
  109806. private _sound;
  109807. /**
  109808. * Instantiate the action
  109809. * @param triggerOptions defines the trigger options
  109810. * @param sound defines the sound to stop
  109811. * @param condition defines the trigger related conditions
  109812. */
  109813. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  109814. /** @hidden */
  109815. _prepare(): void;
  109816. /**
  109817. * Execute the action and stop the sound.
  109818. */
  109819. execute(): void;
  109820. /**
  109821. * Serializes the actions and its related information.
  109822. * @param parent defines the object to serialize in
  109823. * @returns the serialized object
  109824. */
  109825. serialize(parent: any): any;
  109826. }
  109827. }
  109828. declare module BABYLON {
  109829. /**
  109830. * This defines an action responsible to change the value of a property
  109831. * by interpolating between its current value and the newly set one once triggered.
  109832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109833. */
  109834. export class InterpolateValueAction extends Action {
  109835. /**
  109836. * Defines the path of the property where the value should be interpolated
  109837. */
  109838. propertyPath: string;
  109839. /**
  109840. * Defines the target value at the end of the interpolation.
  109841. */
  109842. value: any;
  109843. /**
  109844. * Defines the time it will take for the property to interpolate to the value.
  109845. */
  109846. duration: number;
  109847. /**
  109848. * Defines if the other scene animations should be stopped when the action has been triggered
  109849. */
  109850. stopOtherAnimations?: boolean;
  109851. /**
  109852. * Defines a callback raised once the interpolation animation has been done.
  109853. */
  109854. onInterpolationDone?: () => void;
  109855. /**
  109856. * Observable triggered once the interpolation animation has been done.
  109857. */
  109858. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  109859. private _target;
  109860. private _effectiveTarget;
  109861. private _property;
  109862. /**
  109863. * Instantiate the action
  109864. * @param triggerOptions defines the trigger options
  109865. * @param target defines the object containing the value to interpolate
  109866. * @param propertyPath defines the path to the property in the target object
  109867. * @param value defines the target value at the end of the interpolation
  109868. * @param duration deines the time it will take for the property to interpolate to the value.
  109869. * @param condition defines the trigger related conditions
  109870. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  109871. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  109872. */
  109873. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  109874. /** @hidden */
  109875. _prepare(): void;
  109876. /**
  109877. * Execute the action starts the value interpolation.
  109878. */
  109879. execute(): void;
  109880. /**
  109881. * Serializes the actions and its related information.
  109882. * @param parent defines the object to serialize in
  109883. * @returns the serialized object
  109884. */
  109885. serialize(parent: any): any;
  109886. }
  109887. }
  109888. declare module BABYLON {
  109889. /**
  109890. * Options allowed during the creation of a sound track.
  109891. */
  109892. export interface ISoundTrackOptions {
  109893. /**
  109894. * The volume the sound track should take during creation
  109895. */
  109896. volume?: number;
  109897. /**
  109898. * Define if the sound track is the main sound track of the scene
  109899. */
  109900. mainTrack?: boolean;
  109901. }
  109902. /**
  109903. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  109904. * It will be also used in a future release to apply effects on a specific track.
  109905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  109906. */
  109907. export class SoundTrack {
  109908. /**
  109909. * The unique identifier of the sound track in the scene.
  109910. */
  109911. id: number;
  109912. /**
  109913. * The list of sounds included in the sound track.
  109914. */
  109915. soundCollection: Array<Sound>;
  109916. private _outputAudioNode;
  109917. private _scene;
  109918. private _connectedAnalyser;
  109919. private _options;
  109920. private _isInitialized;
  109921. /**
  109922. * Creates a new sound track.
  109923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  109924. * @param scene Define the scene the sound track belongs to
  109925. * @param options
  109926. */
  109927. constructor(scene: Scene, options?: ISoundTrackOptions);
  109928. private _initializeSoundTrackAudioGraph;
  109929. /**
  109930. * Release the sound track and its associated resources
  109931. */
  109932. dispose(): void;
  109933. /**
  109934. * Adds a sound to this sound track
  109935. * @param sound define the cound to add
  109936. * @ignoreNaming
  109937. */
  109938. AddSound(sound: Sound): void;
  109939. /**
  109940. * Removes a sound to this sound track
  109941. * @param sound define the cound to remove
  109942. * @ignoreNaming
  109943. */
  109944. RemoveSound(sound: Sound): void;
  109945. /**
  109946. * Set a global volume for the full sound track.
  109947. * @param newVolume Define the new volume of the sound track
  109948. */
  109949. setVolume(newVolume: number): void;
  109950. /**
  109951. * Switch the panning model to HRTF:
  109952. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  109953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109954. */
  109955. switchPanningModelToHRTF(): void;
  109956. /**
  109957. * Switch the panning model to Equal Power:
  109958. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  109959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109960. */
  109961. switchPanningModelToEqualPower(): void;
  109962. /**
  109963. * Connect the sound track to an audio analyser allowing some amazing
  109964. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109966. * @param analyser The analyser to connect to the engine
  109967. */
  109968. connectToAnalyser(analyser: Analyser): void;
  109969. }
  109970. }
  109971. declare module BABYLON {
  109972. interface AbstractScene {
  109973. /**
  109974. * The list of sounds used in the scene.
  109975. */
  109976. sounds: Nullable<Array<Sound>>;
  109977. }
  109978. interface Scene {
  109979. /**
  109980. * @hidden
  109981. * Backing field
  109982. */
  109983. _mainSoundTrack: SoundTrack;
  109984. /**
  109985. * The main sound track played by the scene.
  109986. * It cotains your primary collection of sounds.
  109987. */
  109988. mainSoundTrack: SoundTrack;
  109989. /**
  109990. * The list of sound tracks added to the scene
  109991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109992. */
  109993. soundTracks: Nullable<Array<SoundTrack>>;
  109994. /**
  109995. * Gets a sound using a given name
  109996. * @param name defines the name to search for
  109997. * @return the found sound or null if not found at all.
  109998. */
  109999. getSoundByName(name: string): Nullable<Sound>;
  110000. /**
  110001. * Gets or sets if audio support is enabled
  110002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110003. */
  110004. audioEnabled: boolean;
  110005. /**
  110006. * Gets or sets if audio will be output to headphones
  110007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110008. */
  110009. headphone: boolean;
  110010. /**
  110011. * Gets or sets custom audio listener position provider
  110012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110013. */
  110014. audioListenerPositionProvider: Nullable<() => Vector3>;
  110015. /**
  110016. * Gets or sets a refresh rate when using 3D audio positioning
  110017. */
  110018. audioPositioningRefreshRate: number;
  110019. }
  110020. /**
  110021. * Defines the sound scene component responsible to manage any sounds
  110022. * in a given scene.
  110023. */
  110024. export class AudioSceneComponent implements ISceneSerializableComponent {
  110025. /**
  110026. * The component name helpfull to identify the component in the list of scene components.
  110027. */
  110028. readonly name: string;
  110029. /**
  110030. * The scene the component belongs to.
  110031. */
  110032. scene: Scene;
  110033. private _audioEnabled;
  110034. /**
  110035. * Gets whether audio is enabled or not.
  110036. * Please use related enable/disable method to switch state.
  110037. */
  110038. get audioEnabled(): boolean;
  110039. private _headphone;
  110040. /**
  110041. * Gets whether audio is outputing to headphone or not.
  110042. * Please use the according Switch methods to change output.
  110043. */
  110044. get headphone(): boolean;
  110045. /**
  110046. * Gets or sets a refresh rate when using 3D audio positioning
  110047. */
  110048. audioPositioningRefreshRate: number;
  110049. private _audioListenerPositionProvider;
  110050. /**
  110051. * Gets the current audio listener position provider
  110052. */
  110053. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110054. /**
  110055. * Sets a custom listener position for all sounds in the scene
  110056. * By default, this is the position of the first active camera
  110057. */
  110058. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110059. /**
  110060. * Creates a new instance of the component for the given scene
  110061. * @param scene Defines the scene to register the component in
  110062. */
  110063. constructor(scene: Scene);
  110064. /**
  110065. * Registers the component in a given scene
  110066. */
  110067. register(): void;
  110068. /**
  110069. * Rebuilds the elements related to this component in case of
  110070. * context lost for instance.
  110071. */
  110072. rebuild(): void;
  110073. /**
  110074. * Serializes the component data to the specified json object
  110075. * @param serializationObject The object to serialize to
  110076. */
  110077. serialize(serializationObject: any): void;
  110078. /**
  110079. * Adds all the elements from the container to the scene
  110080. * @param container the container holding the elements
  110081. */
  110082. addFromContainer(container: AbstractScene): void;
  110083. /**
  110084. * Removes all the elements in the container from the scene
  110085. * @param container contains the elements to remove
  110086. * @param dispose if the removed element should be disposed (default: false)
  110087. */
  110088. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110089. /**
  110090. * Disposes the component and the associated ressources.
  110091. */
  110092. dispose(): void;
  110093. /**
  110094. * Disables audio in the associated scene.
  110095. */
  110096. disableAudio(): void;
  110097. /**
  110098. * Enables audio in the associated scene.
  110099. */
  110100. enableAudio(): void;
  110101. /**
  110102. * Switch audio to headphone output.
  110103. */
  110104. switchAudioModeForHeadphones(): void;
  110105. /**
  110106. * Switch audio to normal speakers.
  110107. */
  110108. switchAudioModeForNormalSpeakers(): void;
  110109. private _cachedCameraDirection;
  110110. private _cachedCameraPosition;
  110111. private _lastCheck;
  110112. private _afterRender;
  110113. }
  110114. }
  110115. declare module BABYLON {
  110116. /**
  110117. * Wraps one or more Sound objects and selects one with random weight for playback.
  110118. */
  110119. export class WeightedSound {
  110120. /** When true a Sound will be selected and played when the current playing Sound completes. */
  110121. loop: boolean;
  110122. private _coneInnerAngle;
  110123. private _coneOuterAngle;
  110124. private _volume;
  110125. /** A Sound is currently playing. */
  110126. isPlaying: boolean;
  110127. /** A Sound is currently paused. */
  110128. isPaused: boolean;
  110129. private _sounds;
  110130. private _weights;
  110131. private _currentIndex?;
  110132. /**
  110133. * Creates a new WeightedSound from the list of sounds given.
  110134. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  110135. * @param sounds Array of Sounds that will be selected from.
  110136. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  110137. */
  110138. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  110139. /**
  110140. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  110141. */
  110142. get directionalConeInnerAngle(): number;
  110143. /**
  110144. * The size of cone in degress for a directional sound in which there will be no attenuation.
  110145. */
  110146. set directionalConeInnerAngle(value: number);
  110147. /**
  110148. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110149. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110150. */
  110151. get directionalConeOuterAngle(): number;
  110152. /**
  110153. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110154. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110155. */
  110156. set directionalConeOuterAngle(value: number);
  110157. /**
  110158. * Playback volume.
  110159. */
  110160. get volume(): number;
  110161. /**
  110162. * Playback volume.
  110163. */
  110164. set volume(value: number);
  110165. private _onended;
  110166. /**
  110167. * Suspend playback
  110168. */
  110169. pause(): void;
  110170. /**
  110171. * Stop playback
  110172. */
  110173. stop(): void;
  110174. /**
  110175. * Start playback.
  110176. * @param startOffset Position the clip head at a specific time in seconds.
  110177. */
  110178. play(startOffset?: number): void;
  110179. }
  110180. }
  110181. declare module BABYLON {
  110182. /**
  110183. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  110184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  110185. */
  110186. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  110187. /**
  110188. * Gets the name of the behavior.
  110189. */
  110190. get name(): string;
  110191. /**
  110192. * The easing function used by animations
  110193. */
  110194. static EasingFunction: BackEase;
  110195. /**
  110196. * The easing mode used by animations
  110197. */
  110198. static EasingMode: number;
  110199. /**
  110200. * The duration of the animation, in milliseconds
  110201. */
  110202. transitionDuration: number;
  110203. /**
  110204. * Length of the distance animated by the transition when lower radius is reached
  110205. */
  110206. lowerRadiusTransitionRange: number;
  110207. /**
  110208. * Length of the distance animated by the transition when upper radius is reached
  110209. */
  110210. upperRadiusTransitionRange: number;
  110211. private _autoTransitionRange;
  110212. /**
  110213. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110214. */
  110215. get autoTransitionRange(): boolean;
  110216. /**
  110217. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110218. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  110219. */
  110220. set autoTransitionRange(value: boolean);
  110221. private _attachedCamera;
  110222. private _onAfterCheckInputsObserver;
  110223. private _onMeshTargetChangedObserver;
  110224. /**
  110225. * Initializes the behavior.
  110226. */
  110227. init(): void;
  110228. /**
  110229. * Attaches the behavior to its arc rotate camera.
  110230. * @param camera Defines the camera to attach the behavior to
  110231. */
  110232. attach(camera: ArcRotateCamera): void;
  110233. /**
  110234. * Detaches the behavior from its current arc rotate camera.
  110235. */
  110236. detach(): void;
  110237. private _radiusIsAnimating;
  110238. private _radiusBounceTransition;
  110239. private _animatables;
  110240. private _cachedWheelPrecision;
  110241. /**
  110242. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  110243. * @param radiusLimit The limit to check against.
  110244. * @return Bool to indicate if at limit.
  110245. */
  110246. private _isRadiusAtLimit;
  110247. /**
  110248. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  110249. * @param radiusDelta The delta by which to animate to. Can be negative.
  110250. */
  110251. private _applyBoundRadiusAnimation;
  110252. /**
  110253. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  110254. */
  110255. protected _clearAnimationLocks(): void;
  110256. /**
  110257. * Stops and removes all animations that have been applied to the camera
  110258. */
  110259. stopAllAnimations(): void;
  110260. }
  110261. }
  110262. declare module BABYLON {
  110263. /**
  110264. * 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.
  110265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  110266. */
  110267. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  110268. /**
  110269. * Gets the name of the behavior.
  110270. */
  110271. get name(): string;
  110272. private _mode;
  110273. private _radiusScale;
  110274. private _positionScale;
  110275. private _defaultElevation;
  110276. private _elevationReturnTime;
  110277. private _elevationReturnWaitTime;
  110278. private _zoomStopsAnimation;
  110279. private _framingTime;
  110280. /**
  110281. * The easing function used by animations
  110282. */
  110283. static EasingFunction: ExponentialEase;
  110284. /**
  110285. * The easing mode used by animations
  110286. */
  110287. static EasingMode: number;
  110288. /**
  110289. * Sets the current mode used by the behavior
  110290. */
  110291. set mode(mode: number);
  110292. /**
  110293. * Gets current mode used by the behavior.
  110294. */
  110295. get mode(): number;
  110296. /**
  110297. * Sets the scale applied to the radius (1 by default)
  110298. */
  110299. set radiusScale(radius: number);
  110300. /**
  110301. * Gets the scale applied to the radius
  110302. */
  110303. get radiusScale(): number;
  110304. /**
  110305. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110306. */
  110307. set positionScale(scale: number);
  110308. /**
  110309. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110310. */
  110311. get positionScale(): number;
  110312. /**
  110313. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110314. * behaviour is triggered, in radians.
  110315. */
  110316. set defaultElevation(elevation: number);
  110317. /**
  110318. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110319. * behaviour is triggered, in radians.
  110320. */
  110321. get defaultElevation(): number;
  110322. /**
  110323. * Sets the time (in milliseconds) taken to return to the default beta position.
  110324. * Negative value indicates camera should not return to default.
  110325. */
  110326. set elevationReturnTime(speed: number);
  110327. /**
  110328. * Gets the time (in milliseconds) taken to return to the default beta position.
  110329. * Negative value indicates camera should not return to default.
  110330. */
  110331. get elevationReturnTime(): number;
  110332. /**
  110333. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110334. */
  110335. set elevationReturnWaitTime(time: number);
  110336. /**
  110337. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110338. */
  110339. get elevationReturnWaitTime(): number;
  110340. /**
  110341. * Sets the flag that indicates if user zooming should stop animation.
  110342. */
  110343. set zoomStopsAnimation(flag: boolean);
  110344. /**
  110345. * Gets the flag that indicates if user zooming should stop animation.
  110346. */
  110347. get zoomStopsAnimation(): boolean;
  110348. /**
  110349. * Sets the transition time when framing the mesh, in milliseconds
  110350. */
  110351. set framingTime(time: number);
  110352. /**
  110353. * Gets the transition time when framing the mesh, in milliseconds
  110354. */
  110355. get framingTime(): number;
  110356. /**
  110357. * Define if the behavior should automatically change the configured
  110358. * camera limits and sensibilities.
  110359. */
  110360. autoCorrectCameraLimitsAndSensibility: boolean;
  110361. private _onPrePointerObservableObserver;
  110362. private _onAfterCheckInputsObserver;
  110363. private _onMeshTargetChangedObserver;
  110364. private _attachedCamera;
  110365. private _isPointerDown;
  110366. private _lastInteractionTime;
  110367. /**
  110368. * Initializes the behavior.
  110369. */
  110370. init(): void;
  110371. /**
  110372. * Attaches the behavior to its arc rotate camera.
  110373. * @param camera Defines the camera to attach the behavior to
  110374. */
  110375. attach(camera: ArcRotateCamera): void;
  110376. /**
  110377. * Detaches the behavior from its current arc rotate camera.
  110378. */
  110379. detach(): void;
  110380. private _animatables;
  110381. private _betaIsAnimating;
  110382. private _betaTransition;
  110383. private _radiusTransition;
  110384. private _vectorTransition;
  110385. /**
  110386. * Targets the given mesh and updates zoom level accordingly.
  110387. * @param mesh The mesh to target.
  110388. * @param radius Optional. If a cached radius position already exists, overrides default.
  110389. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110390. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110391. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110392. */
  110393. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110394. /**
  110395. * Targets the given mesh with its children and updates zoom level accordingly.
  110396. * @param mesh The mesh to target.
  110397. * @param radius Optional. If a cached radius position already exists, overrides default.
  110398. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110399. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110400. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110401. */
  110402. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110403. /**
  110404. * Targets the given meshes with their children and updates zoom level accordingly.
  110405. * @param meshes The mesh to target.
  110406. * @param radius Optional. If a cached radius position already exists, overrides default.
  110407. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110408. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110409. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110410. */
  110411. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110412. /**
  110413. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  110414. * @param minimumWorld Determines the smaller position of the bounding box extend
  110415. * @param maximumWorld Determines the bigger position of the bounding box extend
  110416. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110417. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110418. */
  110419. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110420. /**
  110421. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  110422. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  110423. * frustum width.
  110424. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  110425. * to fully enclose the mesh in the viewing frustum.
  110426. */
  110427. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  110428. /**
  110429. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  110430. * is automatically returned to its default position (expected to be above ground plane).
  110431. */
  110432. private _maintainCameraAboveGround;
  110433. /**
  110434. * Returns the frustum slope based on the canvas ratio and camera FOV
  110435. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  110436. */
  110437. private _getFrustumSlope;
  110438. /**
  110439. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  110440. */
  110441. private _clearAnimationLocks;
  110442. /**
  110443. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110444. */
  110445. private _applyUserInteraction;
  110446. /**
  110447. * Stops and removes all animations that have been applied to the camera
  110448. */
  110449. stopAllAnimations(): void;
  110450. /**
  110451. * Gets a value indicating if the user is moving the camera
  110452. */
  110453. get isUserIsMoving(): boolean;
  110454. /**
  110455. * The camera can move all the way towards the mesh.
  110456. */
  110457. static IgnoreBoundsSizeMode: number;
  110458. /**
  110459. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  110460. */
  110461. static FitFrustumSidesMode: number;
  110462. }
  110463. }
  110464. declare module BABYLON {
  110465. /**
  110466. * Base class for Camera Pointer Inputs.
  110467. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  110468. * for example usage.
  110469. */
  110470. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  110471. /**
  110472. * Defines the camera the input is attached to.
  110473. */
  110474. abstract camera: Camera;
  110475. /**
  110476. * Whether keyboard modifier keys are pressed at time of last mouse event.
  110477. */
  110478. protected _altKey: boolean;
  110479. protected _ctrlKey: boolean;
  110480. protected _metaKey: boolean;
  110481. protected _shiftKey: boolean;
  110482. /**
  110483. * Which mouse buttons were pressed at time of last mouse event.
  110484. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  110485. */
  110486. protected _buttonsPressed: number;
  110487. /**
  110488. * Defines the buttons associated with the input to handle camera move.
  110489. */
  110490. buttons: number[];
  110491. /**
  110492. * Attach the input controls to a specific dom element to get the input from.
  110493. * @param element Defines the element the controls should be listened from
  110494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110495. */
  110496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110497. /**
  110498. * Detach the current controls from the specified dom element.
  110499. * @param element Defines the element to stop listening the inputs from
  110500. */
  110501. detachControl(element: Nullable<HTMLElement>): void;
  110502. /**
  110503. * Gets the class name of the current input.
  110504. * @returns the class name
  110505. */
  110506. getClassName(): string;
  110507. /**
  110508. * Get the friendly name associated with the input class.
  110509. * @returns the input friendly name
  110510. */
  110511. getSimpleName(): string;
  110512. /**
  110513. * Called on pointer POINTERDOUBLETAP event.
  110514. * Override this method to provide functionality on POINTERDOUBLETAP event.
  110515. */
  110516. protected onDoubleTap(type: string): void;
  110517. /**
  110518. * Called on pointer POINTERMOVE event if only a single touch is active.
  110519. * Override this method to provide functionality.
  110520. */
  110521. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110522. /**
  110523. * Called on pointer POINTERMOVE event if multiple touches are active.
  110524. * Override this method to provide functionality.
  110525. */
  110526. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110527. /**
  110528. * Called on JS contextmenu event.
  110529. * Override this method to provide functionality.
  110530. */
  110531. protected onContextMenu(evt: PointerEvent): void;
  110532. /**
  110533. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  110534. * press.
  110535. * Override this method to provide functionality.
  110536. */
  110537. protected onButtonDown(evt: PointerEvent): void;
  110538. /**
  110539. * Called each time a new POINTERUP event occurs. Ie, for each button
  110540. * release.
  110541. * Override this method to provide functionality.
  110542. */
  110543. protected onButtonUp(evt: PointerEvent): void;
  110544. /**
  110545. * Called when window becomes inactive.
  110546. * Override this method to provide functionality.
  110547. */
  110548. protected onLostFocus(): void;
  110549. private _pointerInput;
  110550. private _observer;
  110551. private _onLostFocus;
  110552. private pointA;
  110553. private pointB;
  110554. }
  110555. }
  110556. declare module BABYLON {
  110557. /**
  110558. * Manage the pointers inputs to control an arc rotate camera.
  110559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110560. */
  110561. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  110562. /**
  110563. * Defines the camera the input is attached to.
  110564. */
  110565. camera: ArcRotateCamera;
  110566. /**
  110567. * Gets the class name of the current input.
  110568. * @returns the class name
  110569. */
  110570. getClassName(): string;
  110571. /**
  110572. * Defines the buttons associated with the input to handle camera move.
  110573. */
  110574. buttons: number[];
  110575. /**
  110576. * Defines the pointer angular sensibility along the X axis or how fast is
  110577. * the camera rotating.
  110578. */
  110579. angularSensibilityX: number;
  110580. /**
  110581. * Defines the pointer angular sensibility along the Y axis or how fast is
  110582. * the camera rotating.
  110583. */
  110584. angularSensibilityY: number;
  110585. /**
  110586. * Defines the pointer pinch precision or how fast is the camera zooming.
  110587. */
  110588. pinchPrecision: number;
  110589. /**
  110590. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110591. * from 0.
  110592. * It defines the percentage of current camera.radius to use as delta when
  110593. * pinch zoom is used.
  110594. */
  110595. pinchDeltaPercentage: number;
  110596. /**
  110597. * Defines the pointer panning sensibility or how fast is the camera moving.
  110598. */
  110599. panningSensibility: number;
  110600. /**
  110601. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  110602. */
  110603. multiTouchPanning: boolean;
  110604. /**
  110605. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  110606. * zoom (pinch) through multitouch.
  110607. */
  110608. multiTouchPanAndZoom: boolean;
  110609. /**
  110610. * Revers pinch action direction.
  110611. */
  110612. pinchInwards: boolean;
  110613. private _isPanClick;
  110614. private _twoFingerActivityCount;
  110615. private _isPinching;
  110616. /**
  110617. * Called on pointer POINTERMOVE event if only a single touch is active.
  110618. */
  110619. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110620. /**
  110621. * Called on pointer POINTERDOUBLETAP event.
  110622. */
  110623. protected onDoubleTap(type: string): void;
  110624. /**
  110625. * Called on pointer POINTERMOVE event if multiple touches are active.
  110626. */
  110627. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110628. /**
  110629. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  110630. * press.
  110631. */
  110632. protected onButtonDown(evt: PointerEvent): void;
  110633. /**
  110634. * Called each time a new POINTERUP event occurs. Ie, for each button
  110635. * release.
  110636. */
  110637. protected onButtonUp(evt: PointerEvent): void;
  110638. /**
  110639. * Called when window becomes inactive.
  110640. */
  110641. protected onLostFocus(): void;
  110642. }
  110643. }
  110644. declare module BABYLON {
  110645. /**
  110646. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  110647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110648. */
  110649. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  110650. /**
  110651. * Defines the camera the input is attached to.
  110652. */
  110653. camera: ArcRotateCamera;
  110654. /**
  110655. * Defines the list of key codes associated with the up action (increase alpha)
  110656. */
  110657. keysUp: number[];
  110658. /**
  110659. * Defines the list of key codes associated with the down action (decrease alpha)
  110660. */
  110661. keysDown: number[];
  110662. /**
  110663. * Defines the list of key codes associated with the left action (increase beta)
  110664. */
  110665. keysLeft: number[];
  110666. /**
  110667. * Defines the list of key codes associated with the right action (decrease beta)
  110668. */
  110669. keysRight: number[];
  110670. /**
  110671. * Defines the list of key codes associated with the reset action.
  110672. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  110673. */
  110674. keysReset: number[];
  110675. /**
  110676. * Defines the panning sensibility of the inputs.
  110677. * (How fast is the camera paning)
  110678. */
  110679. panningSensibility: number;
  110680. /**
  110681. * Defines the zooming sensibility of the inputs.
  110682. * (How fast is the camera zooming)
  110683. */
  110684. zoomingSensibility: number;
  110685. /**
  110686. * Defines wether maintaining the alt key down switch the movement mode from
  110687. * orientation to zoom.
  110688. */
  110689. useAltToZoom: boolean;
  110690. /**
  110691. * Rotation speed of the camera
  110692. */
  110693. angularSpeed: number;
  110694. private _keys;
  110695. private _ctrlPressed;
  110696. private _altPressed;
  110697. private _onCanvasBlurObserver;
  110698. private _onKeyboardObserver;
  110699. private _engine;
  110700. private _scene;
  110701. /**
  110702. * Attach the input controls to a specific dom element to get the input from.
  110703. * @param element Defines the element the controls should be listened from
  110704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110705. */
  110706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110707. /**
  110708. * Detach the current controls from the specified dom element.
  110709. * @param element Defines the element to stop listening the inputs from
  110710. */
  110711. detachControl(element: Nullable<HTMLElement>): void;
  110712. /**
  110713. * Update the current camera state depending on the inputs that have been used this frame.
  110714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110715. */
  110716. checkInputs(): void;
  110717. /**
  110718. * Gets the class name of the current intput.
  110719. * @returns the class name
  110720. */
  110721. getClassName(): string;
  110722. /**
  110723. * Get the friendly name associated with the input class.
  110724. * @returns the input friendly name
  110725. */
  110726. getSimpleName(): string;
  110727. }
  110728. }
  110729. declare module BABYLON {
  110730. /**
  110731. * Manage the mouse wheel inputs to control an arc rotate camera.
  110732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110733. */
  110734. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  110735. /**
  110736. * Defines the camera the input is attached to.
  110737. */
  110738. camera: ArcRotateCamera;
  110739. /**
  110740. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  110741. */
  110742. wheelPrecision: number;
  110743. /**
  110744. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110745. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110746. */
  110747. wheelDeltaPercentage: number;
  110748. private _wheel;
  110749. private _observer;
  110750. private computeDeltaFromMouseWheelLegacyEvent;
  110751. /**
  110752. * Attach the input controls to a specific dom element to get the input from.
  110753. * @param element Defines the element the controls should be listened from
  110754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110755. */
  110756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110757. /**
  110758. * Detach the current controls from the specified dom element.
  110759. * @param element Defines the element to stop listening the inputs from
  110760. */
  110761. detachControl(element: Nullable<HTMLElement>): void;
  110762. /**
  110763. * Gets the class name of the current intput.
  110764. * @returns the class name
  110765. */
  110766. getClassName(): string;
  110767. /**
  110768. * Get the friendly name associated with the input class.
  110769. * @returns the input friendly name
  110770. */
  110771. getSimpleName(): string;
  110772. }
  110773. }
  110774. declare module BABYLON {
  110775. /**
  110776. * Default Inputs manager for the ArcRotateCamera.
  110777. * It groups all the default supported inputs for ease of use.
  110778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110779. */
  110780. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  110781. /**
  110782. * Instantiates a new ArcRotateCameraInputsManager.
  110783. * @param camera Defines the camera the inputs belong to
  110784. */
  110785. constructor(camera: ArcRotateCamera);
  110786. /**
  110787. * Add mouse wheel input support to the input manager.
  110788. * @returns the current input manager
  110789. */
  110790. addMouseWheel(): ArcRotateCameraInputsManager;
  110791. /**
  110792. * Add pointers input support to the input manager.
  110793. * @returns the current input manager
  110794. */
  110795. addPointers(): ArcRotateCameraInputsManager;
  110796. /**
  110797. * Add keyboard input support to the input manager.
  110798. * @returns the current input manager
  110799. */
  110800. addKeyboard(): ArcRotateCameraInputsManager;
  110801. }
  110802. }
  110803. declare module BABYLON {
  110804. /**
  110805. * This represents an orbital type of camera.
  110806. *
  110807. * 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.
  110808. * 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.
  110809. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  110810. */
  110811. export class ArcRotateCamera extends TargetCamera {
  110812. /**
  110813. * Defines the rotation angle of the camera along the longitudinal axis.
  110814. */
  110815. alpha: number;
  110816. /**
  110817. * Defines the rotation angle of the camera along the latitudinal axis.
  110818. */
  110819. beta: number;
  110820. /**
  110821. * Defines the radius of the camera from it s target point.
  110822. */
  110823. radius: number;
  110824. protected _target: Vector3;
  110825. protected _targetHost: Nullable<AbstractMesh>;
  110826. /**
  110827. * Defines the target point of the camera.
  110828. * The camera looks towards it form the radius distance.
  110829. */
  110830. get target(): Vector3;
  110831. set target(value: Vector3);
  110832. /**
  110833. * Define the current local position of the camera in the scene
  110834. */
  110835. get position(): Vector3;
  110836. set position(newPosition: Vector3);
  110837. protected _upVector: Vector3;
  110838. protected _upToYMatrix: Matrix;
  110839. protected _YToUpMatrix: Matrix;
  110840. /**
  110841. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  110842. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  110843. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  110844. */
  110845. set upVector(vec: Vector3);
  110846. get upVector(): Vector3;
  110847. /**
  110848. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  110849. */
  110850. setMatUp(): void;
  110851. /**
  110852. * Current inertia value on the longitudinal axis.
  110853. * The bigger this number the longer it will take for the camera to stop.
  110854. */
  110855. inertialAlphaOffset: number;
  110856. /**
  110857. * Current inertia value on the latitudinal axis.
  110858. * The bigger this number the longer it will take for the camera to stop.
  110859. */
  110860. inertialBetaOffset: number;
  110861. /**
  110862. * Current inertia value on the radius axis.
  110863. * The bigger this number the longer it will take for the camera to stop.
  110864. */
  110865. inertialRadiusOffset: number;
  110866. /**
  110867. * Minimum allowed angle on the longitudinal axis.
  110868. * This can help limiting how the Camera is able to move in the scene.
  110869. */
  110870. lowerAlphaLimit: Nullable<number>;
  110871. /**
  110872. * Maximum allowed angle on the longitudinal axis.
  110873. * This can help limiting how the Camera is able to move in the scene.
  110874. */
  110875. upperAlphaLimit: Nullable<number>;
  110876. /**
  110877. * Minimum allowed angle on the latitudinal axis.
  110878. * This can help limiting how the Camera is able to move in the scene.
  110879. */
  110880. lowerBetaLimit: number;
  110881. /**
  110882. * Maximum allowed angle on the latitudinal axis.
  110883. * This can help limiting how the Camera is able to move in the scene.
  110884. */
  110885. upperBetaLimit: number;
  110886. /**
  110887. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  110888. * This can help limiting how the Camera is able to move in the scene.
  110889. */
  110890. lowerRadiusLimit: Nullable<number>;
  110891. /**
  110892. * Maximum allowed distance of the camera to the target (The camera can not get further).
  110893. * This can help limiting how the Camera is able to move in the scene.
  110894. */
  110895. upperRadiusLimit: Nullable<number>;
  110896. /**
  110897. * Defines the current inertia value used during panning of the camera along the X axis.
  110898. */
  110899. inertialPanningX: number;
  110900. /**
  110901. * Defines the current inertia value used during panning of the camera along the Y axis.
  110902. */
  110903. inertialPanningY: number;
  110904. /**
  110905. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  110906. * Basically if your fingers moves away from more than this distance you will be considered
  110907. * in pinch mode.
  110908. */
  110909. pinchToPanMaxDistance: number;
  110910. /**
  110911. * Defines the maximum distance the camera can pan.
  110912. * This could help keeping the cammera always in your scene.
  110913. */
  110914. panningDistanceLimit: Nullable<number>;
  110915. /**
  110916. * Defines the target of the camera before paning.
  110917. */
  110918. panningOriginTarget: Vector3;
  110919. /**
  110920. * Defines the value of the inertia used during panning.
  110921. * 0 would mean stop inertia and one would mean no decelleration at all.
  110922. */
  110923. panningInertia: number;
  110924. /**
  110925. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  110926. */
  110927. get angularSensibilityX(): number;
  110928. set angularSensibilityX(value: number);
  110929. /**
  110930. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  110931. */
  110932. get angularSensibilityY(): number;
  110933. set angularSensibilityY(value: number);
  110934. /**
  110935. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  110936. */
  110937. get pinchPrecision(): number;
  110938. set pinchPrecision(value: number);
  110939. /**
  110940. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  110941. * It will be used instead of pinchDeltaPrecision if different from 0.
  110942. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  110943. */
  110944. get pinchDeltaPercentage(): number;
  110945. set pinchDeltaPercentage(value: number);
  110946. /**
  110947. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  110948. */
  110949. get panningSensibility(): number;
  110950. set panningSensibility(value: number);
  110951. /**
  110952. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  110953. */
  110954. get keysUp(): number[];
  110955. set keysUp(value: number[]);
  110956. /**
  110957. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  110958. */
  110959. get keysDown(): number[];
  110960. set keysDown(value: number[]);
  110961. /**
  110962. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  110963. */
  110964. get keysLeft(): number[];
  110965. set keysLeft(value: number[]);
  110966. /**
  110967. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  110968. */
  110969. get keysRight(): number[];
  110970. set keysRight(value: number[]);
  110971. /**
  110972. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  110973. */
  110974. get wheelPrecision(): number;
  110975. set wheelPrecision(value: number);
  110976. /**
  110977. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  110978. * It will be used instead of pinchDeltaPrecision if different from 0.
  110979. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  110980. */
  110981. get wheelDeltaPercentage(): number;
  110982. set wheelDeltaPercentage(value: number);
  110983. /**
  110984. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  110985. */
  110986. zoomOnFactor: number;
  110987. /**
  110988. * Defines a screen offset for the camera position.
  110989. */
  110990. targetScreenOffset: Vector2;
  110991. /**
  110992. * Allows the camera to be completely reversed.
  110993. * If false the camera can not arrive upside down.
  110994. */
  110995. allowUpsideDown: boolean;
  110996. /**
  110997. * Define if double tap/click is used to restore the previously saved state of the camera.
  110998. */
  110999. useInputToRestoreState: boolean;
  111000. /** @hidden */
  111001. _viewMatrix: Matrix;
  111002. /** @hidden */
  111003. _useCtrlForPanning: boolean;
  111004. /** @hidden */
  111005. _panningMouseButton: number;
  111006. /**
  111007. * Defines the input associated to the camera.
  111008. */
  111009. inputs: ArcRotateCameraInputsManager;
  111010. /** @hidden */
  111011. _reset: () => void;
  111012. /**
  111013. * Defines the allowed panning axis.
  111014. */
  111015. panningAxis: Vector3;
  111016. protected _localDirection: Vector3;
  111017. protected _transformedDirection: Vector3;
  111018. private _bouncingBehavior;
  111019. /**
  111020. * Gets the bouncing behavior of the camera if it has been enabled.
  111021. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111022. */
  111023. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111024. /**
  111025. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111026. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111027. */
  111028. get useBouncingBehavior(): boolean;
  111029. set useBouncingBehavior(value: boolean);
  111030. private _framingBehavior;
  111031. /**
  111032. * Gets the framing behavior of the camera if it has been enabled.
  111033. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111034. */
  111035. get framingBehavior(): Nullable<FramingBehavior>;
  111036. /**
  111037. * Defines if the framing behavior of the camera is enabled on the camera.
  111038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111039. */
  111040. get useFramingBehavior(): boolean;
  111041. set useFramingBehavior(value: boolean);
  111042. private _autoRotationBehavior;
  111043. /**
  111044. * Gets the auto rotation behavior of the camera if it has been enabled.
  111045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111046. */
  111047. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111048. /**
  111049. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111051. */
  111052. get useAutoRotationBehavior(): boolean;
  111053. set useAutoRotationBehavior(value: boolean);
  111054. /**
  111055. * Observable triggered when the mesh target has been changed on the camera.
  111056. */
  111057. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111058. /**
  111059. * Event raised when the camera is colliding with a mesh.
  111060. */
  111061. onCollide: (collidedMesh: AbstractMesh) => void;
  111062. /**
  111063. * Defines whether the camera should check collision with the objects oh the scene.
  111064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111065. */
  111066. checkCollisions: boolean;
  111067. /**
  111068. * Defines the collision radius of the camera.
  111069. * This simulates a sphere around the camera.
  111070. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111071. */
  111072. collisionRadius: Vector3;
  111073. protected _collider: Collider;
  111074. protected _previousPosition: Vector3;
  111075. protected _collisionVelocity: Vector3;
  111076. protected _newPosition: Vector3;
  111077. protected _previousAlpha: number;
  111078. protected _previousBeta: number;
  111079. protected _previousRadius: number;
  111080. protected _collisionTriggered: boolean;
  111081. protected _targetBoundingCenter: Nullable<Vector3>;
  111082. private _computationVector;
  111083. /**
  111084. * Instantiates a new ArcRotateCamera in a given scene
  111085. * @param name Defines the name of the camera
  111086. * @param alpha Defines the camera rotation along the logitudinal axis
  111087. * @param beta Defines the camera rotation along the latitudinal axis
  111088. * @param radius Defines the camera distance from its target
  111089. * @param target Defines the camera target
  111090. * @param scene Defines the scene the camera belongs to
  111091. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111092. */
  111093. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111094. /** @hidden */
  111095. _initCache(): void;
  111096. /** @hidden */
  111097. _updateCache(ignoreParentClass?: boolean): void;
  111098. protected _getTargetPosition(): Vector3;
  111099. private _storedAlpha;
  111100. private _storedBeta;
  111101. private _storedRadius;
  111102. private _storedTarget;
  111103. private _storedTargetScreenOffset;
  111104. /**
  111105. * Stores the current state of the camera (alpha, beta, radius and target)
  111106. * @returns the camera itself
  111107. */
  111108. storeState(): Camera;
  111109. /**
  111110. * @hidden
  111111. * Restored camera state. You must call storeState() first
  111112. */
  111113. _restoreStateValues(): boolean;
  111114. /** @hidden */
  111115. _isSynchronizedViewMatrix(): boolean;
  111116. /**
  111117. * Attached controls to the current camera.
  111118. * @param element Defines the element the controls should be listened from
  111119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111120. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  111121. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  111122. */
  111123. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  111124. /**
  111125. * Detach the current controls from the camera.
  111126. * The camera will stop reacting to inputs.
  111127. * @param element Defines the element to stop listening the inputs from
  111128. */
  111129. detachControl(element: HTMLElement): void;
  111130. /** @hidden */
  111131. _checkInputs(): void;
  111132. protected _checkLimits(): void;
  111133. /**
  111134. * Rebuilds angles (alpha, beta) and radius from the give position and target
  111135. */
  111136. rebuildAnglesAndRadius(): void;
  111137. /**
  111138. * Use a position to define the current camera related information like alpha, beta and radius
  111139. * @param position Defines the position to set the camera at
  111140. */
  111141. setPosition(position: Vector3): void;
  111142. /**
  111143. * Defines the target the camera should look at.
  111144. * This will automatically adapt alpha beta and radius to fit within the new target.
  111145. * @param target Defines the new target as a Vector or a mesh
  111146. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  111147. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  111148. */
  111149. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  111150. /** @hidden */
  111151. _getViewMatrix(): Matrix;
  111152. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  111153. /**
  111154. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  111155. * @param meshes Defines the mesh to zoom on
  111156. * @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)
  111157. */
  111158. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  111159. /**
  111160. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  111161. * The target will be changed but the radius
  111162. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  111163. * @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)
  111164. */
  111165. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  111166. min: Vector3;
  111167. max: Vector3;
  111168. distance: number;
  111169. }, doNotUpdateMaxZ?: boolean): void;
  111170. /**
  111171. * @override
  111172. * Override Camera.createRigCamera
  111173. */
  111174. createRigCamera(name: string, cameraIndex: number): Camera;
  111175. /**
  111176. * @hidden
  111177. * @override
  111178. * Override Camera._updateRigCameras
  111179. */
  111180. _updateRigCameras(): void;
  111181. /**
  111182. * Destroy the camera and release the current resources hold by it.
  111183. */
  111184. dispose(): void;
  111185. /**
  111186. * Gets the current object class name.
  111187. * @return the class name
  111188. */
  111189. getClassName(): string;
  111190. }
  111191. }
  111192. declare module BABYLON {
  111193. /**
  111194. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  111195. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111196. */
  111197. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  111198. /**
  111199. * Gets the name of the behavior.
  111200. */
  111201. get name(): string;
  111202. private _zoomStopsAnimation;
  111203. private _idleRotationSpeed;
  111204. private _idleRotationWaitTime;
  111205. private _idleRotationSpinupTime;
  111206. /**
  111207. * Sets the flag that indicates if user zooming should stop animation.
  111208. */
  111209. set zoomStopsAnimation(flag: boolean);
  111210. /**
  111211. * Gets the flag that indicates if user zooming should stop animation.
  111212. */
  111213. get zoomStopsAnimation(): boolean;
  111214. /**
  111215. * Sets the default speed at which the camera rotates around the model.
  111216. */
  111217. set idleRotationSpeed(speed: number);
  111218. /**
  111219. * Gets the default speed at which the camera rotates around the model.
  111220. */
  111221. get idleRotationSpeed(): number;
  111222. /**
  111223. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  111224. */
  111225. set idleRotationWaitTime(time: number);
  111226. /**
  111227. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  111228. */
  111229. get idleRotationWaitTime(): number;
  111230. /**
  111231. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111232. */
  111233. set idleRotationSpinupTime(time: number);
  111234. /**
  111235. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111236. */
  111237. get idleRotationSpinupTime(): number;
  111238. /**
  111239. * Gets a value indicating if the camera is currently rotating because of this behavior
  111240. */
  111241. get rotationInProgress(): boolean;
  111242. private _onPrePointerObservableObserver;
  111243. private _onAfterCheckInputsObserver;
  111244. private _attachedCamera;
  111245. private _isPointerDown;
  111246. private _lastFrameTime;
  111247. private _lastInteractionTime;
  111248. private _cameraRotationSpeed;
  111249. /**
  111250. * Initializes the behavior.
  111251. */
  111252. init(): void;
  111253. /**
  111254. * Attaches the behavior to its arc rotate camera.
  111255. * @param camera Defines the camera to attach the behavior to
  111256. */
  111257. attach(camera: ArcRotateCamera): void;
  111258. /**
  111259. * Detaches the behavior from its current arc rotate camera.
  111260. */
  111261. detach(): void;
  111262. /**
  111263. * Returns true if user is scrolling.
  111264. * @return true if user is scrolling.
  111265. */
  111266. private _userIsZooming;
  111267. private _lastFrameRadius;
  111268. private _shouldAnimationStopForInteraction;
  111269. /**
  111270. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111271. */
  111272. private _applyUserInteraction;
  111273. private _userIsMoving;
  111274. }
  111275. }
  111276. declare module BABYLON {
  111277. /**
  111278. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  111279. */
  111280. export class AttachToBoxBehavior implements Behavior<Mesh> {
  111281. private ui;
  111282. /**
  111283. * The name of the behavior
  111284. */
  111285. name: string;
  111286. /**
  111287. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  111288. */
  111289. distanceAwayFromFace: number;
  111290. /**
  111291. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  111292. */
  111293. distanceAwayFromBottomOfFace: number;
  111294. private _faceVectors;
  111295. private _target;
  111296. private _scene;
  111297. private _onRenderObserver;
  111298. private _tmpMatrix;
  111299. private _tmpVector;
  111300. /**
  111301. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  111302. * @param ui The transform node that should be attched to the mesh
  111303. */
  111304. constructor(ui: TransformNode);
  111305. /**
  111306. * Initializes the behavior
  111307. */
  111308. init(): void;
  111309. private _closestFace;
  111310. private _zeroVector;
  111311. private _lookAtTmpMatrix;
  111312. private _lookAtToRef;
  111313. /**
  111314. * Attaches the AttachToBoxBehavior to the passed in mesh
  111315. * @param target The mesh that the specified node will be attached to
  111316. */
  111317. attach(target: Mesh): void;
  111318. /**
  111319. * Detaches the behavior from the mesh
  111320. */
  111321. detach(): void;
  111322. }
  111323. }
  111324. declare module BABYLON {
  111325. /**
  111326. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  111327. */
  111328. export class FadeInOutBehavior implements Behavior<Mesh> {
  111329. /**
  111330. * Time in milliseconds to delay before fading in (Default: 0)
  111331. */
  111332. delay: number;
  111333. /**
  111334. * Time in milliseconds for the mesh to fade in (Default: 300)
  111335. */
  111336. fadeInTime: number;
  111337. private _millisecondsPerFrame;
  111338. private _hovered;
  111339. private _hoverValue;
  111340. private _ownerNode;
  111341. /**
  111342. * Instatiates the FadeInOutBehavior
  111343. */
  111344. constructor();
  111345. /**
  111346. * The name of the behavior
  111347. */
  111348. get name(): string;
  111349. /**
  111350. * Initializes the behavior
  111351. */
  111352. init(): void;
  111353. /**
  111354. * Attaches the fade behavior on the passed in mesh
  111355. * @param ownerNode The mesh that will be faded in/out once attached
  111356. */
  111357. attach(ownerNode: Mesh): void;
  111358. /**
  111359. * Detaches the behavior from the mesh
  111360. */
  111361. detach(): void;
  111362. /**
  111363. * Triggers the mesh to begin fading in or out
  111364. * @param value if the object should fade in or out (true to fade in)
  111365. */
  111366. fadeIn(value: boolean): void;
  111367. private _update;
  111368. private _setAllVisibility;
  111369. }
  111370. }
  111371. declare module BABYLON {
  111372. /**
  111373. * Class containing a set of static utilities functions for managing Pivots
  111374. * @hidden
  111375. */
  111376. export class PivotTools {
  111377. private static _PivotCached;
  111378. private static _OldPivotPoint;
  111379. private static _PivotTranslation;
  111380. private static _PivotTmpVector;
  111381. /** @hidden */
  111382. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  111383. /** @hidden */
  111384. static _RestorePivotPoint(mesh: AbstractMesh): void;
  111385. }
  111386. }
  111387. declare module BABYLON {
  111388. /**
  111389. * Class containing static functions to help procedurally build meshes
  111390. */
  111391. export class PlaneBuilder {
  111392. /**
  111393. * Creates a plane mesh
  111394. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  111395. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  111396. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  111397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111400. * @param name defines the name of the mesh
  111401. * @param options defines the options used to create the mesh
  111402. * @param scene defines the hosting scene
  111403. * @returns the plane mesh
  111404. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  111405. */
  111406. static CreatePlane(name: string, options: {
  111407. size?: number;
  111408. width?: number;
  111409. height?: number;
  111410. sideOrientation?: number;
  111411. frontUVs?: Vector4;
  111412. backUVs?: Vector4;
  111413. updatable?: boolean;
  111414. sourcePlane?: Plane;
  111415. }, scene?: Nullable<Scene>): Mesh;
  111416. }
  111417. }
  111418. declare module BABYLON {
  111419. /**
  111420. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  111421. */
  111422. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  111423. private static _AnyMouseID;
  111424. /**
  111425. * Abstract mesh the behavior is set on
  111426. */
  111427. attachedNode: AbstractMesh;
  111428. private _dragPlane;
  111429. private _scene;
  111430. private _pointerObserver;
  111431. private _beforeRenderObserver;
  111432. private static _planeScene;
  111433. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  111434. /**
  111435. * 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)
  111436. */
  111437. maxDragAngle: number;
  111438. /**
  111439. * @hidden
  111440. */
  111441. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  111442. /**
  111443. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111444. */
  111445. currentDraggingPointerID: number;
  111446. /**
  111447. * The last position where the pointer hit the drag plane in world space
  111448. */
  111449. lastDragPosition: Vector3;
  111450. /**
  111451. * If the behavior is currently in a dragging state
  111452. */
  111453. dragging: boolean;
  111454. /**
  111455. * 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)
  111456. */
  111457. dragDeltaRatio: number;
  111458. /**
  111459. * If the drag plane orientation should be updated during the dragging (Default: true)
  111460. */
  111461. updateDragPlane: boolean;
  111462. private _debugMode;
  111463. private _moving;
  111464. /**
  111465. * Fires each time the attached mesh is dragged with the pointer
  111466. * * delta between last drag position and current drag position in world space
  111467. * * dragDistance along the drag axis
  111468. * * dragPlaneNormal normal of the current drag plane used during the drag
  111469. * * dragPlanePoint in world space where the drag intersects the drag plane
  111470. */
  111471. onDragObservable: Observable<{
  111472. delta: Vector3;
  111473. dragPlanePoint: Vector3;
  111474. dragPlaneNormal: Vector3;
  111475. dragDistance: number;
  111476. pointerId: number;
  111477. }>;
  111478. /**
  111479. * Fires each time a drag begins (eg. mouse down on mesh)
  111480. */
  111481. onDragStartObservable: Observable<{
  111482. dragPlanePoint: Vector3;
  111483. pointerId: number;
  111484. }>;
  111485. /**
  111486. * Fires each time a drag ends (eg. mouse release after drag)
  111487. */
  111488. onDragEndObservable: Observable<{
  111489. dragPlanePoint: Vector3;
  111490. pointerId: number;
  111491. }>;
  111492. /**
  111493. * If the attached mesh should be moved when dragged
  111494. */
  111495. moveAttached: boolean;
  111496. /**
  111497. * If the drag behavior will react to drag events (Default: true)
  111498. */
  111499. enabled: boolean;
  111500. /**
  111501. * If pointer events should start and release the drag (Default: true)
  111502. */
  111503. startAndReleaseDragOnPointerEvents: boolean;
  111504. /**
  111505. * If camera controls should be detached during the drag
  111506. */
  111507. detachCameraControls: boolean;
  111508. /**
  111509. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  111510. */
  111511. useObjectOrientationForDragging: boolean;
  111512. private _options;
  111513. /**
  111514. * Gets the options used by the behavior
  111515. */
  111516. get options(): {
  111517. dragAxis?: Vector3;
  111518. dragPlaneNormal?: Vector3;
  111519. };
  111520. /**
  111521. * Sets the options used by the behavior
  111522. */
  111523. set options(options: {
  111524. dragAxis?: Vector3;
  111525. dragPlaneNormal?: Vector3;
  111526. });
  111527. /**
  111528. * Creates a pointer drag behavior that can be attached to a mesh
  111529. * @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)
  111530. */
  111531. constructor(options?: {
  111532. dragAxis?: Vector3;
  111533. dragPlaneNormal?: Vector3;
  111534. });
  111535. /**
  111536. * Predicate to determine if it is valid to move the object to a new position when it is moved
  111537. */
  111538. validateDrag: (targetPosition: Vector3) => boolean;
  111539. /**
  111540. * The name of the behavior
  111541. */
  111542. get name(): string;
  111543. /**
  111544. * Initializes the behavior
  111545. */
  111546. init(): void;
  111547. private _tmpVector;
  111548. private _alternatePickedPoint;
  111549. private _worldDragAxis;
  111550. private _targetPosition;
  111551. private _attachedElement;
  111552. /**
  111553. * Attaches the drag behavior the passed in mesh
  111554. * @param ownerNode The mesh that will be dragged around once attached
  111555. * @param predicate Predicate to use for pick filtering
  111556. */
  111557. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  111558. /**
  111559. * Force relase the drag action by code.
  111560. */
  111561. releaseDrag(): void;
  111562. private _startDragRay;
  111563. private _lastPointerRay;
  111564. /**
  111565. * Simulates the start of a pointer drag event on the behavior
  111566. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  111567. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  111568. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  111569. */
  111570. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  111571. private _startDrag;
  111572. private _dragDelta;
  111573. private _moveDrag;
  111574. private _pickWithRayOnDragPlane;
  111575. private _pointA;
  111576. private _pointB;
  111577. private _pointC;
  111578. private _lineA;
  111579. private _lineB;
  111580. private _localAxis;
  111581. private _lookAt;
  111582. private _updateDragPlanePosition;
  111583. /**
  111584. * Detaches the behavior from the mesh
  111585. */
  111586. detach(): void;
  111587. }
  111588. }
  111589. declare module BABYLON {
  111590. /**
  111591. * A behavior that when attached to a mesh will allow the mesh to be scaled
  111592. */
  111593. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  111594. private _dragBehaviorA;
  111595. private _dragBehaviorB;
  111596. private _startDistance;
  111597. private _initialScale;
  111598. private _targetScale;
  111599. private _ownerNode;
  111600. private _sceneRenderObserver;
  111601. /**
  111602. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  111603. */
  111604. constructor();
  111605. /**
  111606. * The name of the behavior
  111607. */
  111608. get name(): string;
  111609. /**
  111610. * Initializes the behavior
  111611. */
  111612. init(): void;
  111613. private _getCurrentDistance;
  111614. /**
  111615. * Attaches the scale behavior the passed in mesh
  111616. * @param ownerNode The mesh that will be scaled around once attached
  111617. */
  111618. attach(ownerNode: Mesh): void;
  111619. /**
  111620. * Detaches the behavior from the mesh
  111621. */
  111622. detach(): void;
  111623. }
  111624. }
  111625. declare module BABYLON {
  111626. /**
  111627. * 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
  111628. */
  111629. export class SixDofDragBehavior implements Behavior<Mesh> {
  111630. private static _virtualScene;
  111631. private _ownerNode;
  111632. private _sceneRenderObserver;
  111633. private _scene;
  111634. private _targetPosition;
  111635. private _virtualOriginMesh;
  111636. private _virtualDragMesh;
  111637. private _pointerObserver;
  111638. private _moving;
  111639. private _startingOrientation;
  111640. /**
  111641. * 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)
  111642. */
  111643. private zDragFactor;
  111644. /**
  111645. * If the object should rotate to face the drag origin
  111646. */
  111647. rotateDraggedObject: boolean;
  111648. /**
  111649. * If the behavior is currently in a dragging state
  111650. */
  111651. dragging: boolean;
  111652. /**
  111653. * 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)
  111654. */
  111655. dragDeltaRatio: number;
  111656. /**
  111657. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111658. */
  111659. currentDraggingPointerID: number;
  111660. /**
  111661. * If camera controls should be detached during the drag
  111662. */
  111663. detachCameraControls: boolean;
  111664. /**
  111665. * Fires each time a drag starts
  111666. */
  111667. onDragStartObservable: Observable<{}>;
  111668. /**
  111669. * Fires each time a drag ends (eg. mouse release after drag)
  111670. */
  111671. onDragEndObservable: Observable<{}>;
  111672. /**
  111673. * 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
  111674. */
  111675. constructor();
  111676. /**
  111677. * The name of the behavior
  111678. */
  111679. get name(): string;
  111680. /**
  111681. * Initializes the behavior
  111682. */
  111683. init(): void;
  111684. /**
  111685. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  111686. */
  111687. private get _pointerCamera();
  111688. /**
  111689. * Attaches the scale behavior the passed in mesh
  111690. * @param ownerNode The mesh that will be scaled around once attached
  111691. */
  111692. attach(ownerNode: Mesh): void;
  111693. /**
  111694. * Detaches the behavior from the mesh
  111695. */
  111696. detach(): void;
  111697. }
  111698. }
  111699. declare module BABYLON {
  111700. /**
  111701. * Class used to apply inverse kinematics to bones
  111702. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  111703. */
  111704. export class BoneIKController {
  111705. private static _tmpVecs;
  111706. private static _tmpQuat;
  111707. private static _tmpMats;
  111708. /**
  111709. * Gets or sets the target mesh
  111710. */
  111711. targetMesh: AbstractMesh;
  111712. /** Gets or sets the mesh used as pole */
  111713. poleTargetMesh: AbstractMesh;
  111714. /**
  111715. * Gets or sets the bone used as pole
  111716. */
  111717. poleTargetBone: Nullable<Bone>;
  111718. /**
  111719. * Gets or sets the target position
  111720. */
  111721. targetPosition: Vector3;
  111722. /**
  111723. * Gets or sets the pole target position
  111724. */
  111725. poleTargetPosition: Vector3;
  111726. /**
  111727. * Gets or sets the pole target local offset
  111728. */
  111729. poleTargetLocalOffset: Vector3;
  111730. /**
  111731. * Gets or sets the pole angle
  111732. */
  111733. poleAngle: number;
  111734. /**
  111735. * Gets or sets the mesh associated with the controller
  111736. */
  111737. mesh: AbstractMesh;
  111738. /**
  111739. * 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)
  111740. */
  111741. slerpAmount: number;
  111742. private _bone1Quat;
  111743. private _bone1Mat;
  111744. private _bone2Ang;
  111745. private _bone1;
  111746. private _bone2;
  111747. private _bone1Length;
  111748. private _bone2Length;
  111749. private _maxAngle;
  111750. private _maxReach;
  111751. private _rightHandedSystem;
  111752. private _bendAxis;
  111753. private _slerping;
  111754. private _adjustRoll;
  111755. /**
  111756. * Gets or sets maximum allowed angle
  111757. */
  111758. get maxAngle(): number;
  111759. set maxAngle(value: number);
  111760. /**
  111761. * Creates a new BoneIKController
  111762. * @param mesh defines the mesh to control
  111763. * @param bone defines the bone to control
  111764. * @param options defines options to set up the controller
  111765. */
  111766. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  111767. targetMesh?: AbstractMesh;
  111768. poleTargetMesh?: AbstractMesh;
  111769. poleTargetBone?: Bone;
  111770. poleTargetLocalOffset?: Vector3;
  111771. poleAngle?: number;
  111772. bendAxis?: Vector3;
  111773. maxAngle?: number;
  111774. slerpAmount?: number;
  111775. });
  111776. private _setMaxAngle;
  111777. /**
  111778. * Force the controller to update the bones
  111779. */
  111780. update(): void;
  111781. }
  111782. }
  111783. declare module BABYLON {
  111784. /**
  111785. * Class used to make a bone look toward a point in space
  111786. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  111787. */
  111788. export class BoneLookController {
  111789. private static _tmpVecs;
  111790. private static _tmpQuat;
  111791. private static _tmpMats;
  111792. /**
  111793. * The target Vector3 that the bone will look at
  111794. */
  111795. target: Vector3;
  111796. /**
  111797. * The mesh that the bone is attached to
  111798. */
  111799. mesh: AbstractMesh;
  111800. /**
  111801. * The bone that will be looking to the target
  111802. */
  111803. bone: Bone;
  111804. /**
  111805. * The up axis of the coordinate system that is used when the bone is rotated
  111806. */
  111807. upAxis: Vector3;
  111808. /**
  111809. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  111810. */
  111811. upAxisSpace: Space;
  111812. /**
  111813. * Used to make an adjustment to the yaw of the bone
  111814. */
  111815. adjustYaw: number;
  111816. /**
  111817. * Used to make an adjustment to the pitch of the bone
  111818. */
  111819. adjustPitch: number;
  111820. /**
  111821. * Used to make an adjustment to the roll of the bone
  111822. */
  111823. adjustRoll: number;
  111824. /**
  111825. * 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)
  111826. */
  111827. slerpAmount: number;
  111828. private _minYaw;
  111829. private _maxYaw;
  111830. private _minPitch;
  111831. private _maxPitch;
  111832. private _minYawSin;
  111833. private _minYawCos;
  111834. private _maxYawSin;
  111835. private _maxYawCos;
  111836. private _midYawConstraint;
  111837. private _minPitchTan;
  111838. private _maxPitchTan;
  111839. private _boneQuat;
  111840. private _slerping;
  111841. private _transformYawPitch;
  111842. private _transformYawPitchInv;
  111843. private _firstFrameSkipped;
  111844. private _yawRange;
  111845. private _fowardAxis;
  111846. /**
  111847. * Gets or sets the minimum yaw angle that the bone can look to
  111848. */
  111849. get minYaw(): number;
  111850. set minYaw(value: number);
  111851. /**
  111852. * Gets or sets the maximum yaw angle that the bone can look to
  111853. */
  111854. get maxYaw(): number;
  111855. set maxYaw(value: number);
  111856. /**
  111857. * Gets or sets the minimum pitch angle that the bone can look to
  111858. */
  111859. get minPitch(): number;
  111860. set minPitch(value: number);
  111861. /**
  111862. * Gets or sets the maximum pitch angle that the bone can look to
  111863. */
  111864. get maxPitch(): number;
  111865. set maxPitch(value: number);
  111866. /**
  111867. * Create a BoneLookController
  111868. * @param mesh the mesh that the bone belongs to
  111869. * @param bone the bone that will be looking to the target
  111870. * @param target the target Vector3 to look at
  111871. * @param options optional settings:
  111872. * * maxYaw: the maximum angle the bone will yaw to
  111873. * * minYaw: the minimum angle the bone will yaw to
  111874. * * maxPitch: the maximum angle the bone will pitch to
  111875. * * minPitch: the minimum angle the bone will yaw to
  111876. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  111877. * * upAxis: the up axis of the coordinate system
  111878. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  111879. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  111880. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  111881. * * adjustYaw: used to make an adjustment to the yaw of the bone
  111882. * * adjustPitch: used to make an adjustment to the pitch of the bone
  111883. * * adjustRoll: used to make an adjustment to the roll of the bone
  111884. **/
  111885. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  111886. maxYaw?: number;
  111887. minYaw?: number;
  111888. maxPitch?: number;
  111889. minPitch?: number;
  111890. slerpAmount?: number;
  111891. upAxis?: Vector3;
  111892. upAxisSpace?: Space;
  111893. yawAxis?: Vector3;
  111894. pitchAxis?: Vector3;
  111895. adjustYaw?: number;
  111896. adjustPitch?: number;
  111897. adjustRoll?: number;
  111898. });
  111899. /**
  111900. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  111901. */
  111902. update(): void;
  111903. private _getAngleDiff;
  111904. private _getAngleBetween;
  111905. private _isAngleBetween;
  111906. }
  111907. }
  111908. declare module BABYLON {
  111909. /**
  111910. * Manage the gamepad inputs to control an arc rotate camera.
  111911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111912. */
  111913. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  111914. /**
  111915. * Defines the camera the input is attached to.
  111916. */
  111917. camera: ArcRotateCamera;
  111918. /**
  111919. * Defines the gamepad the input is gathering event from.
  111920. */
  111921. gamepad: Nullable<Gamepad>;
  111922. /**
  111923. * Defines the gamepad rotation sensiblity.
  111924. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111925. */
  111926. gamepadRotationSensibility: number;
  111927. /**
  111928. * Defines the gamepad move sensiblity.
  111929. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111930. */
  111931. gamepadMoveSensibility: number;
  111932. private _yAxisScale;
  111933. /**
  111934. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111935. */
  111936. get invertYAxis(): boolean;
  111937. set invertYAxis(value: boolean);
  111938. private _onGamepadConnectedObserver;
  111939. private _onGamepadDisconnectedObserver;
  111940. /**
  111941. * Attach the input controls to a specific dom element to get the input from.
  111942. * @param element Defines the element the controls should be listened from
  111943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111944. */
  111945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111946. /**
  111947. * Detach the current controls from the specified dom element.
  111948. * @param element Defines the element to stop listening the inputs from
  111949. */
  111950. detachControl(element: Nullable<HTMLElement>): void;
  111951. /**
  111952. * Update the current camera state depending on the inputs that have been used this frame.
  111953. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111954. */
  111955. checkInputs(): void;
  111956. /**
  111957. * Gets the class name of the current intput.
  111958. * @returns the class name
  111959. */
  111960. getClassName(): string;
  111961. /**
  111962. * Get the friendly name associated with the input class.
  111963. * @returns the input friendly name
  111964. */
  111965. getSimpleName(): string;
  111966. }
  111967. }
  111968. declare module BABYLON {
  111969. interface ArcRotateCameraInputsManager {
  111970. /**
  111971. * Add orientation input support to the input manager.
  111972. * @returns the current input manager
  111973. */
  111974. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  111975. }
  111976. /**
  111977. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  111978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111979. */
  111980. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  111981. /**
  111982. * Defines the camera the input is attached to.
  111983. */
  111984. camera: ArcRotateCamera;
  111985. /**
  111986. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  111987. */
  111988. alphaCorrection: number;
  111989. /**
  111990. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  111991. */
  111992. gammaCorrection: number;
  111993. private _alpha;
  111994. private _gamma;
  111995. private _dirty;
  111996. private _deviceOrientationHandler;
  111997. /**
  111998. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  111999. */
  112000. constructor();
  112001. /**
  112002. * Attach the input controls to a specific dom element to get the input from.
  112003. * @param element Defines the element the controls should be listened from
  112004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112005. */
  112006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112007. /** @hidden */
  112008. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112009. /**
  112010. * Update the current camera state depending on the inputs that have been used this frame.
  112011. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112012. */
  112013. checkInputs(): void;
  112014. /**
  112015. * Detach the current controls from the specified dom element.
  112016. * @param element Defines the element to stop listening the inputs from
  112017. */
  112018. detachControl(element: Nullable<HTMLElement>): void;
  112019. /**
  112020. * Gets the class name of the current intput.
  112021. * @returns the class name
  112022. */
  112023. getClassName(): string;
  112024. /**
  112025. * Get the friendly name associated with the input class.
  112026. * @returns the input friendly name
  112027. */
  112028. getSimpleName(): string;
  112029. }
  112030. }
  112031. declare module BABYLON {
  112032. /**
  112033. * Listen to mouse events to control the camera.
  112034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112035. */
  112036. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112037. /**
  112038. * Defines the camera the input is attached to.
  112039. */
  112040. camera: FlyCamera;
  112041. /**
  112042. * Defines if touch is enabled. (Default is true.)
  112043. */
  112044. touchEnabled: boolean;
  112045. /**
  112046. * Defines the buttons associated with the input to handle camera rotation.
  112047. */
  112048. buttons: number[];
  112049. /**
  112050. * Assign buttons for Yaw control.
  112051. */
  112052. buttonsYaw: number[];
  112053. /**
  112054. * Assign buttons for Pitch control.
  112055. */
  112056. buttonsPitch: number[];
  112057. /**
  112058. * Assign buttons for Roll control.
  112059. */
  112060. buttonsRoll: number[];
  112061. /**
  112062. * Detect if any button is being pressed while mouse is moved.
  112063. * -1 = Mouse locked.
  112064. * 0 = Left button.
  112065. * 1 = Middle Button.
  112066. * 2 = Right Button.
  112067. */
  112068. activeButton: number;
  112069. /**
  112070. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112071. * Higher values reduce its sensitivity.
  112072. */
  112073. angularSensibility: number;
  112074. private _mousemoveCallback;
  112075. private _observer;
  112076. private _rollObserver;
  112077. private previousPosition;
  112078. private noPreventDefault;
  112079. private element;
  112080. /**
  112081. * Listen to mouse events to control the camera.
  112082. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112084. */
  112085. constructor(touchEnabled?: boolean);
  112086. /**
  112087. * Attach the mouse control to the HTML DOM element.
  112088. * @param element Defines the element that listens to the input events.
  112089. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112090. */
  112091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112092. /**
  112093. * Detach the current controls from the specified dom element.
  112094. * @param element Defines the element to stop listening the inputs from
  112095. */
  112096. detachControl(element: Nullable<HTMLElement>): void;
  112097. /**
  112098. * Gets the class name of the current input.
  112099. * @returns the class name.
  112100. */
  112101. getClassName(): string;
  112102. /**
  112103. * Get the friendly name associated with the input class.
  112104. * @returns the input's friendly name.
  112105. */
  112106. getSimpleName(): string;
  112107. private _pointerInput;
  112108. private _onMouseMove;
  112109. /**
  112110. * Rotate camera by mouse offset.
  112111. */
  112112. private rotateCamera;
  112113. }
  112114. }
  112115. declare module BABYLON {
  112116. /**
  112117. * Default Inputs manager for the FlyCamera.
  112118. * It groups all the default supported inputs for ease of use.
  112119. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112120. */
  112121. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  112122. /**
  112123. * Instantiates a new FlyCameraInputsManager.
  112124. * @param camera Defines the camera the inputs belong to.
  112125. */
  112126. constructor(camera: FlyCamera);
  112127. /**
  112128. * Add keyboard input support to the input manager.
  112129. * @returns the new FlyCameraKeyboardMoveInput().
  112130. */
  112131. addKeyboard(): FlyCameraInputsManager;
  112132. /**
  112133. * Add mouse input support to the input manager.
  112134. * @param touchEnabled Enable touch screen support.
  112135. * @returns the new FlyCameraMouseInput().
  112136. */
  112137. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  112138. }
  112139. }
  112140. declare module BABYLON {
  112141. /**
  112142. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112143. * such as in a 3D Space Shooter or a Flight Simulator.
  112144. */
  112145. export class FlyCamera extends TargetCamera {
  112146. /**
  112147. * Define the collision ellipsoid of the camera.
  112148. * This is helpful for simulating a camera body, like a player's body.
  112149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112150. */
  112151. ellipsoid: Vector3;
  112152. /**
  112153. * Define an offset for the position of the ellipsoid around the camera.
  112154. * This can be helpful if the camera is attached away from the player's body center,
  112155. * such as at its head.
  112156. */
  112157. ellipsoidOffset: Vector3;
  112158. /**
  112159. * Enable or disable collisions of the camera with the rest of the scene objects.
  112160. */
  112161. checkCollisions: boolean;
  112162. /**
  112163. * Enable or disable gravity on the camera.
  112164. */
  112165. applyGravity: boolean;
  112166. /**
  112167. * Define the current direction the camera is moving to.
  112168. */
  112169. cameraDirection: Vector3;
  112170. /**
  112171. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  112172. * This overrides and empties cameraRotation.
  112173. */
  112174. rotationQuaternion: Quaternion;
  112175. /**
  112176. * Track Roll to maintain the wanted Rolling when looking around.
  112177. */
  112178. _trackRoll: number;
  112179. /**
  112180. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  112181. */
  112182. rollCorrect: number;
  112183. /**
  112184. * Mimic a banked turn, Rolling the camera when Yawing.
  112185. * It's recommended to use rollCorrect = 10 for faster banking correction.
  112186. */
  112187. bankedTurn: boolean;
  112188. /**
  112189. * Limit in radians for how much Roll banking will add. (Default: 90°)
  112190. */
  112191. bankedTurnLimit: number;
  112192. /**
  112193. * Value of 0 disables the banked Roll.
  112194. * Value of 1 is equal to the Yaw angle in radians.
  112195. */
  112196. bankedTurnMultiplier: number;
  112197. /**
  112198. * The inputs manager loads all the input sources, such as keyboard and mouse.
  112199. */
  112200. inputs: FlyCameraInputsManager;
  112201. /**
  112202. * Gets the input sensibility for mouse input.
  112203. * Higher values reduce sensitivity.
  112204. */
  112205. get angularSensibility(): number;
  112206. /**
  112207. * Sets the input sensibility for a mouse input.
  112208. * Higher values reduce sensitivity.
  112209. */
  112210. set angularSensibility(value: number);
  112211. /**
  112212. * Get the keys for camera movement forward.
  112213. */
  112214. get keysForward(): number[];
  112215. /**
  112216. * Set the keys for camera movement forward.
  112217. */
  112218. set keysForward(value: number[]);
  112219. /**
  112220. * Get the keys for camera movement backward.
  112221. */
  112222. get keysBackward(): number[];
  112223. set keysBackward(value: number[]);
  112224. /**
  112225. * Get the keys for camera movement up.
  112226. */
  112227. get keysUp(): number[];
  112228. /**
  112229. * Set the keys for camera movement up.
  112230. */
  112231. set keysUp(value: number[]);
  112232. /**
  112233. * Get the keys for camera movement down.
  112234. */
  112235. get keysDown(): number[];
  112236. /**
  112237. * Set the keys for camera movement down.
  112238. */
  112239. set keysDown(value: number[]);
  112240. /**
  112241. * Get the keys for camera movement left.
  112242. */
  112243. get keysLeft(): number[];
  112244. /**
  112245. * Set the keys for camera movement left.
  112246. */
  112247. set keysLeft(value: number[]);
  112248. /**
  112249. * Set the keys for camera movement right.
  112250. */
  112251. get keysRight(): number[];
  112252. /**
  112253. * Set the keys for camera movement right.
  112254. */
  112255. set keysRight(value: number[]);
  112256. /**
  112257. * Event raised when the camera collides with a mesh in the scene.
  112258. */
  112259. onCollide: (collidedMesh: AbstractMesh) => void;
  112260. private _collider;
  112261. private _needMoveForGravity;
  112262. private _oldPosition;
  112263. private _diffPosition;
  112264. private _newPosition;
  112265. /** @hidden */
  112266. _localDirection: Vector3;
  112267. /** @hidden */
  112268. _transformedDirection: Vector3;
  112269. /**
  112270. * Instantiates a FlyCamera.
  112271. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112272. * such as in a 3D Space Shooter or a Flight Simulator.
  112273. * @param name Define the name of the camera in the scene.
  112274. * @param position Define the starting position of the camera in the scene.
  112275. * @param scene Define the scene the camera belongs to.
  112276. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  112277. */
  112278. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112279. /**
  112280. * Attach a control to the HTML DOM element.
  112281. * @param element Defines the element that listens to the input events.
  112282. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  112283. */
  112284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112285. /**
  112286. * Detach a control from the HTML DOM element.
  112287. * The camera will stop reacting to that input.
  112288. * @param element Defines the element that listens to the input events.
  112289. */
  112290. detachControl(element: HTMLElement): void;
  112291. private _collisionMask;
  112292. /**
  112293. * Get the mask that the camera ignores in collision events.
  112294. */
  112295. get collisionMask(): number;
  112296. /**
  112297. * Set the mask that the camera ignores in collision events.
  112298. */
  112299. set collisionMask(mask: number);
  112300. /** @hidden */
  112301. _collideWithWorld(displacement: Vector3): void;
  112302. /** @hidden */
  112303. private _onCollisionPositionChange;
  112304. /** @hidden */
  112305. _checkInputs(): void;
  112306. /** @hidden */
  112307. _decideIfNeedsToMove(): boolean;
  112308. /** @hidden */
  112309. _updatePosition(): void;
  112310. /**
  112311. * Restore the Roll to its target value at the rate specified.
  112312. * @param rate - Higher means slower restoring.
  112313. * @hidden
  112314. */
  112315. restoreRoll(rate: number): void;
  112316. /**
  112317. * Destroy the camera and release the current resources held by it.
  112318. */
  112319. dispose(): void;
  112320. /**
  112321. * Get the current object class name.
  112322. * @returns the class name.
  112323. */
  112324. getClassName(): string;
  112325. }
  112326. }
  112327. declare module BABYLON {
  112328. /**
  112329. * Listen to keyboard events to control the camera.
  112330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112331. */
  112332. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  112333. /**
  112334. * Defines the camera the input is attached to.
  112335. */
  112336. camera: FlyCamera;
  112337. /**
  112338. * The list of keyboard keys used to control the forward move of the camera.
  112339. */
  112340. keysForward: number[];
  112341. /**
  112342. * The list of keyboard keys used to control the backward move of the camera.
  112343. */
  112344. keysBackward: number[];
  112345. /**
  112346. * The list of keyboard keys used to control the forward move of the camera.
  112347. */
  112348. keysUp: number[];
  112349. /**
  112350. * The list of keyboard keys used to control the backward move of the camera.
  112351. */
  112352. keysDown: number[];
  112353. /**
  112354. * The list of keyboard keys used to control the right strafe move of the camera.
  112355. */
  112356. keysRight: number[];
  112357. /**
  112358. * The list of keyboard keys used to control the left strafe move of the camera.
  112359. */
  112360. keysLeft: number[];
  112361. private _keys;
  112362. private _onCanvasBlurObserver;
  112363. private _onKeyboardObserver;
  112364. private _engine;
  112365. private _scene;
  112366. /**
  112367. * Attach the input controls to a specific dom element to get the input from.
  112368. * @param element Defines the element the controls should be listened from
  112369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112370. */
  112371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112372. /**
  112373. * Detach the current controls from the specified dom element.
  112374. * @param element Defines the element to stop listening the inputs from
  112375. */
  112376. detachControl(element: Nullable<HTMLElement>): void;
  112377. /**
  112378. * Gets the class name of the current intput.
  112379. * @returns the class name
  112380. */
  112381. getClassName(): string;
  112382. /** @hidden */
  112383. _onLostFocus(e: FocusEvent): void;
  112384. /**
  112385. * Get the friendly name associated with the input class.
  112386. * @returns the input friendly name
  112387. */
  112388. getSimpleName(): string;
  112389. /**
  112390. * Update the current camera state depending on the inputs that have been used this frame.
  112391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112392. */
  112393. checkInputs(): void;
  112394. }
  112395. }
  112396. declare module BABYLON {
  112397. /**
  112398. * Manage the mouse wheel inputs to control a follow camera.
  112399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112400. */
  112401. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  112402. /**
  112403. * Defines the camera the input is attached to.
  112404. */
  112405. camera: FollowCamera;
  112406. /**
  112407. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  112408. */
  112409. axisControlRadius: boolean;
  112410. /**
  112411. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  112412. */
  112413. axisControlHeight: boolean;
  112414. /**
  112415. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  112416. */
  112417. axisControlRotation: boolean;
  112418. /**
  112419. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  112420. * relation to mouseWheel events.
  112421. */
  112422. wheelPrecision: number;
  112423. /**
  112424. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112425. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112426. */
  112427. wheelDeltaPercentage: number;
  112428. private _wheel;
  112429. private _observer;
  112430. /**
  112431. * Attach the input controls to a specific dom element to get the input from.
  112432. * @param element Defines the element the controls should be listened from
  112433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112434. */
  112435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112436. /**
  112437. * Detach the current controls from the specified dom element.
  112438. * @param element Defines the element to stop listening the inputs from
  112439. */
  112440. detachControl(element: Nullable<HTMLElement>): void;
  112441. /**
  112442. * Gets the class name of the current intput.
  112443. * @returns the class name
  112444. */
  112445. getClassName(): string;
  112446. /**
  112447. * Get the friendly name associated with the input class.
  112448. * @returns the input friendly name
  112449. */
  112450. getSimpleName(): string;
  112451. }
  112452. }
  112453. declare module BABYLON {
  112454. /**
  112455. * Manage the pointers inputs to control an follow camera.
  112456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112457. */
  112458. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  112459. /**
  112460. * Defines the camera the input is attached to.
  112461. */
  112462. camera: FollowCamera;
  112463. /**
  112464. * Gets the class name of the current input.
  112465. * @returns the class name
  112466. */
  112467. getClassName(): string;
  112468. /**
  112469. * Defines the pointer angular sensibility along the X axis or how fast is
  112470. * the camera rotating.
  112471. * A negative number will reverse the axis direction.
  112472. */
  112473. angularSensibilityX: number;
  112474. /**
  112475. * Defines the pointer angular sensibility along the Y axis or how fast is
  112476. * the camera rotating.
  112477. * A negative number will reverse the axis direction.
  112478. */
  112479. angularSensibilityY: number;
  112480. /**
  112481. * Defines the pointer pinch precision or how fast is the camera zooming.
  112482. * A negative number will reverse the axis direction.
  112483. */
  112484. pinchPrecision: number;
  112485. /**
  112486. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112487. * from 0.
  112488. * It defines the percentage of current camera.radius to use as delta when
  112489. * pinch zoom is used.
  112490. */
  112491. pinchDeltaPercentage: number;
  112492. /**
  112493. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  112494. */
  112495. axisXControlRadius: boolean;
  112496. /**
  112497. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  112498. */
  112499. axisXControlHeight: boolean;
  112500. /**
  112501. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  112502. */
  112503. axisXControlRotation: boolean;
  112504. /**
  112505. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  112506. */
  112507. axisYControlRadius: boolean;
  112508. /**
  112509. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  112510. */
  112511. axisYControlHeight: boolean;
  112512. /**
  112513. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  112514. */
  112515. axisYControlRotation: boolean;
  112516. /**
  112517. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  112518. */
  112519. axisPinchControlRadius: boolean;
  112520. /**
  112521. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  112522. */
  112523. axisPinchControlHeight: boolean;
  112524. /**
  112525. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  112526. */
  112527. axisPinchControlRotation: boolean;
  112528. /**
  112529. * Log error messages if basic misconfiguration has occurred.
  112530. */
  112531. warningEnable: boolean;
  112532. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112533. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112534. private _warningCounter;
  112535. private _warning;
  112536. }
  112537. }
  112538. declare module BABYLON {
  112539. /**
  112540. * Default Inputs manager for the FollowCamera.
  112541. * It groups all the default supported inputs for ease of use.
  112542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112543. */
  112544. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  112545. /**
  112546. * Instantiates a new FollowCameraInputsManager.
  112547. * @param camera Defines the camera the inputs belong to
  112548. */
  112549. constructor(camera: FollowCamera);
  112550. /**
  112551. * Add keyboard input support to the input manager.
  112552. * @returns the current input manager
  112553. */
  112554. addKeyboard(): FollowCameraInputsManager;
  112555. /**
  112556. * Add mouse wheel input support to the input manager.
  112557. * @returns the current input manager
  112558. */
  112559. addMouseWheel(): FollowCameraInputsManager;
  112560. /**
  112561. * Add pointers input support to the input manager.
  112562. * @returns the current input manager
  112563. */
  112564. addPointers(): FollowCameraInputsManager;
  112565. /**
  112566. * Add orientation input support to the input manager.
  112567. * @returns the current input manager
  112568. */
  112569. addVRDeviceOrientation(): FollowCameraInputsManager;
  112570. }
  112571. }
  112572. declare module BABYLON {
  112573. /**
  112574. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  112575. * an arc rotate version arcFollowCamera are available.
  112576. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112577. */
  112578. export class FollowCamera extends TargetCamera {
  112579. /**
  112580. * Distance the follow camera should follow an object at
  112581. */
  112582. radius: number;
  112583. /**
  112584. * Minimum allowed distance of the camera to the axis of rotation
  112585. * (The camera can not get closer).
  112586. * This can help limiting how the Camera is able to move in the scene.
  112587. */
  112588. lowerRadiusLimit: Nullable<number>;
  112589. /**
  112590. * Maximum allowed distance of the camera to the axis of rotation
  112591. * (The camera can not get further).
  112592. * This can help limiting how the Camera is able to move in the scene.
  112593. */
  112594. upperRadiusLimit: Nullable<number>;
  112595. /**
  112596. * Define a rotation offset between the camera and the object it follows
  112597. */
  112598. rotationOffset: number;
  112599. /**
  112600. * Minimum allowed angle to camera position relative to target object.
  112601. * This can help limiting how the Camera is able to move in the scene.
  112602. */
  112603. lowerRotationOffsetLimit: Nullable<number>;
  112604. /**
  112605. * Maximum allowed angle to camera position relative to target object.
  112606. * This can help limiting how the Camera is able to move in the scene.
  112607. */
  112608. upperRotationOffsetLimit: Nullable<number>;
  112609. /**
  112610. * Define a height offset between the camera and the object it follows.
  112611. * It can help following an object from the top (like a car chaing a plane)
  112612. */
  112613. heightOffset: number;
  112614. /**
  112615. * Minimum allowed height of camera position relative to target object.
  112616. * This can help limiting how the Camera is able to move in the scene.
  112617. */
  112618. lowerHeightOffsetLimit: Nullable<number>;
  112619. /**
  112620. * Maximum allowed height of camera position relative to target object.
  112621. * This can help limiting how the Camera is able to move in the scene.
  112622. */
  112623. upperHeightOffsetLimit: Nullable<number>;
  112624. /**
  112625. * Define how fast the camera can accelerate to follow it s target.
  112626. */
  112627. cameraAcceleration: number;
  112628. /**
  112629. * Define the speed limit of the camera following an object.
  112630. */
  112631. maxCameraSpeed: number;
  112632. /**
  112633. * Define the target of the camera.
  112634. */
  112635. lockedTarget: Nullable<AbstractMesh>;
  112636. /**
  112637. * Defines the input associated with the camera.
  112638. */
  112639. inputs: FollowCameraInputsManager;
  112640. /**
  112641. * Instantiates the follow camera.
  112642. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112643. * @param name Define the name of the camera in the scene
  112644. * @param position Define the position of the camera
  112645. * @param scene Define the scene the camera belong to
  112646. * @param lockedTarget Define the target of the camera
  112647. */
  112648. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  112649. private _follow;
  112650. /**
  112651. * Attached controls to the current camera.
  112652. * @param element Defines the element the controls should be listened from
  112653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112654. */
  112655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112656. /**
  112657. * Detach the current controls from the camera.
  112658. * The camera will stop reacting to inputs.
  112659. * @param element Defines the element to stop listening the inputs from
  112660. */
  112661. detachControl(element: HTMLElement): void;
  112662. /** @hidden */
  112663. _checkInputs(): void;
  112664. private _checkLimits;
  112665. /**
  112666. * Gets the camera class name.
  112667. * @returns the class name
  112668. */
  112669. getClassName(): string;
  112670. }
  112671. /**
  112672. * Arc Rotate version of the follow camera.
  112673. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  112674. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112675. */
  112676. export class ArcFollowCamera extends TargetCamera {
  112677. /** The longitudinal angle of the camera */
  112678. alpha: number;
  112679. /** The latitudinal angle of the camera */
  112680. beta: number;
  112681. /** The radius of the camera from its target */
  112682. radius: number;
  112683. /** Define the camera target (the messh it should follow) */
  112684. target: Nullable<AbstractMesh>;
  112685. private _cartesianCoordinates;
  112686. /**
  112687. * Instantiates a new ArcFollowCamera
  112688. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112689. * @param name Define the name of the camera
  112690. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  112691. * @param beta Define the rotation angle of the camera around the elevation axis
  112692. * @param radius Define the radius of the camera from its target point
  112693. * @param target Define the target of the camera
  112694. * @param scene Define the scene the camera belongs to
  112695. */
  112696. constructor(name: string,
  112697. /** The longitudinal angle of the camera */
  112698. alpha: number,
  112699. /** The latitudinal angle of the camera */
  112700. beta: number,
  112701. /** The radius of the camera from its target */
  112702. radius: number,
  112703. /** Define the camera target (the messh it should follow) */
  112704. target: Nullable<AbstractMesh>, scene: Scene);
  112705. private _follow;
  112706. /** @hidden */
  112707. _checkInputs(): void;
  112708. /**
  112709. * Returns the class name of the object.
  112710. * It is mostly used internally for serialization purposes.
  112711. */
  112712. getClassName(): string;
  112713. }
  112714. }
  112715. declare module BABYLON {
  112716. /**
  112717. * Manage the keyboard inputs to control the movement of a follow camera.
  112718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112719. */
  112720. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  112721. /**
  112722. * Defines the camera the input is attached to.
  112723. */
  112724. camera: FollowCamera;
  112725. /**
  112726. * Defines the list of key codes associated with the up action (increase heightOffset)
  112727. */
  112728. keysHeightOffsetIncr: number[];
  112729. /**
  112730. * Defines the list of key codes associated with the down action (decrease heightOffset)
  112731. */
  112732. keysHeightOffsetDecr: number[];
  112733. /**
  112734. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  112735. */
  112736. keysHeightOffsetModifierAlt: boolean;
  112737. /**
  112738. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  112739. */
  112740. keysHeightOffsetModifierCtrl: boolean;
  112741. /**
  112742. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  112743. */
  112744. keysHeightOffsetModifierShift: boolean;
  112745. /**
  112746. * Defines the list of key codes associated with the left action (increase rotationOffset)
  112747. */
  112748. keysRotationOffsetIncr: number[];
  112749. /**
  112750. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  112751. */
  112752. keysRotationOffsetDecr: number[];
  112753. /**
  112754. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  112755. */
  112756. keysRotationOffsetModifierAlt: boolean;
  112757. /**
  112758. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  112759. */
  112760. keysRotationOffsetModifierCtrl: boolean;
  112761. /**
  112762. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  112763. */
  112764. keysRotationOffsetModifierShift: boolean;
  112765. /**
  112766. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  112767. */
  112768. keysRadiusIncr: number[];
  112769. /**
  112770. * Defines the list of key codes associated with the zoom-out action (increase radius)
  112771. */
  112772. keysRadiusDecr: number[];
  112773. /**
  112774. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  112775. */
  112776. keysRadiusModifierAlt: boolean;
  112777. /**
  112778. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  112779. */
  112780. keysRadiusModifierCtrl: boolean;
  112781. /**
  112782. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  112783. */
  112784. keysRadiusModifierShift: boolean;
  112785. /**
  112786. * Defines the rate of change of heightOffset.
  112787. */
  112788. heightSensibility: number;
  112789. /**
  112790. * Defines the rate of change of rotationOffset.
  112791. */
  112792. rotationSensibility: number;
  112793. /**
  112794. * Defines the rate of change of radius.
  112795. */
  112796. radiusSensibility: number;
  112797. private _keys;
  112798. private _ctrlPressed;
  112799. private _altPressed;
  112800. private _shiftPressed;
  112801. private _onCanvasBlurObserver;
  112802. private _onKeyboardObserver;
  112803. private _engine;
  112804. private _scene;
  112805. /**
  112806. * Attach the input controls to a specific dom element to get the input from.
  112807. * @param element Defines the element the controls should be listened from
  112808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112809. */
  112810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112811. /**
  112812. * Detach the current controls from the specified dom element.
  112813. * @param element Defines the element to stop listening the inputs from
  112814. */
  112815. detachControl(element: Nullable<HTMLElement>): void;
  112816. /**
  112817. * Update the current camera state depending on the inputs that have been used this frame.
  112818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112819. */
  112820. checkInputs(): void;
  112821. /**
  112822. * Gets the class name of the current input.
  112823. * @returns the class name
  112824. */
  112825. getClassName(): string;
  112826. /**
  112827. * Get the friendly name associated with the input class.
  112828. * @returns the input friendly name
  112829. */
  112830. getSimpleName(): string;
  112831. /**
  112832. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112833. * allow modification of the heightOffset value.
  112834. */
  112835. private _modifierHeightOffset;
  112836. /**
  112837. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112838. * allow modification of the rotationOffset value.
  112839. */
  112840. private _modifierRotationOffset;
  112841. /**
  112842. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112843. * allow modification of the radius value.
  112844. */
  112845. private _modifierRadius;
  112846. }
  112847. }
  112848. declare module BABYLON {
  112849. interface FreeCameraInputsManager {
  112850. /**
  112851. * @hidden
  112852. */
  112853. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  112854. /**
  112855. * Add orientation input support to the input manager.
  112856. * @returns the current input manager
  112857. */
  112858. addDeviceOrientation(): FreeCameraInputsManager;
  112859. }
  112860. /**
  112861. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  112862. * Screen rotation is taken into account.
  112863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112864. */
  112865. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  112866. private _camera;
  112867. private _screenOrientationAngle;
  112868. private _constantTranform;
  112869. private _screenQuaternion;
  112870. private _alpha;
  112871. private _beta;
  112872. private _gamma;
  112873. /**
  112874. * Can be used to detect if a device orientation sensor is available on a device
  112875. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  112876. * @returns a promise that will resolve on orientation change
  112877. */
  112878. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  112879. /**
  112880. * @hidden
  112881. */
  112882. _onDeviceOrientationChangedObservable: Observable<void>;
  112883. /**
  112884. * Instantiates a new input
  112885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112886. */
  112887. constructor();
  112888. /**
  112889. * Define the camera controlled by the input.
  112890. */
  112891. get camera(): FreeCamera;
  112892. set camera(camera: FreeCamera);
  112893. /**
  112894. * Attach the input controls to a specific dom element to get the input from.
  112895. * @param element Defines the element the controls should be listened from
  112896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112897. */
  112898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112899. private _orientationChanged;
  112900. private _deviceOrientation;
  112901. /**
  112902. * Detach the current controls from the specified dom element.
  112903. * @param element Defines the element to stop listening the inputs from
  112904. */
  112905. detachControl(element: Nullable<HTMLElement>): void;
  112906. /**
  112907. * Update the current camera state depending on the inputs that have been used this frame.
  112908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112909. */
  112910. checkInputs(): void;
  112911. /**
  112912. * Gets the class name of the current intput.
  112913. * @returns the class name
  112914. */
  112915. getClassName(): string;
  112916. /**
  112917. * Get the friendly name associated with the input class.
  112918. * @returns the input friendly name
  112919. */
  112920. getSimpleName(): string;
  112921. }
  112922. }
  112923. declare module BABYLON {
  112924. /**
  112925. * Manage the gamepad inputs to control a free camera.
  112926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112927. */
  112928. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  112929. /**
  112930. * Define the camera the input is attached to.
  112931. */
  112932. camera: FreeCamera;
  112933. /**
  112934. * Define the Gamepad controlling the input
  112935. */
  112936. gamepad: Nullable<Gamepad>;
  112937. /**
  112938. * Defines the gamepad rotation sensiblity.
  112939. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112940. */
  112941. gamepadAngularSensibility: number;
  112942. /**
  112943. * Defines the gamepad move sensiblity.
  112944. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112945. */
  112946. gamepadMoveSensibility: number;
  112947. private _yAxisScale;
  112948. /**
  112949. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112950. */
  112951. get invertYAxis(): boolean;
  112952. set invertYAxis(value: boolean);
  112953. private _onGamepadConnectedObserver;
  112954. private _onGamepadDisconnectedObserver;
  112955. private _cameraTransform;
  112956. private _deltaTransform;
  112957. private _vector3;
  112958. private _vector2;
  112959. /**
  112960. * Attach the input controls to a specific dom element to get the input from.
  112961. * @param element Defines the element the controls should be listened from
  112962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112963. */
  112964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112965. /**
  112966. * Detach the current controls from the specified dom element.
  112967. * @param element Defines the element to stop listening the inputs from
  112968. */
  112969. detachControl(element: Nullable<HTMLElement>): void;
  112970. /**
  112971. * Update the current camera state depending on the inputs that have been used this frame.
  112972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112973. */
  112974. checkInputs(): void;
  112975. /**
  112976. * Gets the class name of the current intput.
  112977. * @returns the class name
  112978. */
  112979. getClassName(): string;
  112980. /**
  112981. * Get the friendly name associated with the input class.
  112982. * @returns the input friendly name
  112983. */
  112984. getSimpleName(): string;
  112985. }
  112986. }
  112987. declare module BABYLON {
  112988. /**
  112989. * Defines the potential axis of a Joystick
  112990. */
  112991. export enum JoystickAxis {
  112992. /** X axis */
  112993. X = 0,
  112994. /** Y axis */
  112995. Y = 1,
  112996. /** Z axis */
  112997. Z = 2
  112998. }
  112999. /**
  113000. * Class used to define virtual joystick (used in touch mode)
  113001. */
  113002. export class VirtualJoystick {
  113003. /**
  113004. * Gets or sets a boolean indicating that left and right values must be inverted
  113005. */
  113006. reverseLeftRight: boolean;
  113007. /**
  113008. * Gets or sets a boolean indicating that up and down values must be inverted
  113009. */
  113010. reverseUpDown: boolean;
  113011. /**
  113012. * Gets the offset value for the position (ie. the change of the position value)
  113013. */
  113014. deltaPosition: Vector3;
  113015. /**
  113016. * Gets a boolean indicating if the virtual joystick was pressed
  113017. */
  113018. pressed: boolean;
  113019. /**
  113020. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113021. */
  113022. static Canvas: Nullable<HTMLCanvasElement>;
  113023. private static _globalJoystickIndex;
  113024. private static vjCanvasContext;
  113025. private static vjCanvasWidth;
  113026. private static vjCanvasHeight;
  113027. private static halfWidth;
  113028. private _action;
  113029. private _axisTargetedByLeftAndRight;
  113030. private _axisTargetedByUpAndDown;
  113031. private _joystickSensibility;
  113032. private _inversedSensibility;
  113033. private _joystickPointerID;
  113034. private _joystickColor;
  113035. private _joystickPointerPos;
  113036. private _joystickPreviousPointerPos;
  113037. private _joystickPointerStartPos;
  113038. private _deltaJoystickVector;
  113039. private _leftJoystick;
  113040. private _touches;
  113041. private _onPointerDownHandlerRef;
  113042. private _onPointerMoveHandlerRef;
  113043. private _onPointerUpHandlerRef;
  113044. private _onResize;
  113045. /**
  113046. * Creates a new virtual joystick
  113047. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113048. */
  113049. constructor(leftJoystick?: boolean);
  113050. /**
  113051. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113052. * @param newJoystickSensibility defines the new sensibility
  113053. */
  113054. setJoystickSensibility(newJoystickSensibility: number): void;
  113055. private _onPointerDown;
  113056. private _onPointerMove;
  113057. private _onPointerUp;
  113058. /**
  113059. * Change the color of the virtual joystick
  113060. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113061. */
  113062. setJoystickColor(newColor: string): void;
  113063. /**
  113064. * Defines a callback to call when the joystick is touched
  113065. * @param action defines the callback
  113066. */
  113067. setActionOnTouch(action: () => any): void;
  113068. /**
  113069. * Defines which axis you'd like to control for left & right
  113070. * @param axis defines the axis to use
  113071. */
  113072. setAxisForLeftRight(axis: JoystickAxis): void;
  113073. /**
  113074. * Defines which axis you'd like to control for up & down
  113075. * @param axis defines the axis to use
  113076. */
  113077. setAxisForUpDown(axis: JoystickAxis): void;
  113078. private _drawVirtualJoystick;
  113079. /**
  113080. * Release internal HTML canvas
  113081. */
  113082. releaseCanvas(): void;
  113083. }
  113084. }
  113085. declare module BABYLON {
  113086. interface FreeCameraInputsManager {
  113087. /**
  113088. * Add virtual joystick input support to the input manager.
  113089. * @returns the current input manager
  113090. */
  113091. addVirtualJoystick(): FreeCameraInputsManager;
  113092. }
  113093. /**
  113094. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113096. */
  113097. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113098. /**
  113099. * Defines the camera the input is attached to.
  113100. */
  113101. camera: FreeCamera;
  113102. private _leftjoystick;
  113103. private _rightjoystick;
  113104. /**
  113105. * Gets the left stick of the virtual joystick.
  113106. * @returns The virtual Joystick
  113107. */
  113108. getLeftJoystick(): VirtualJoystick;
  113109. /**
  113110. * Gets the right stick of the virtual joystick.
  113111. * @returns The virtual Joystick
  113112. */
  113113. getRightJoystick(): VirtualJoystick;
  113114. /**
  113115. * Update the current camera state depending on the inputs that have been used this frame.
  113116. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113117. */
  113118. checkInputs(): void;
  113119. /**
  113120. * Attach the input controls to a specific dom element to get the input from.
  113121. * @param element Defines the element the controls should be listened from
  113122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113123. */
  113124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113125. /**
  113126. * Detach the current controls from the specified dom element.
  113127. * @param element Defines the element to stop listening the inputs from
  113128. */
  113129. detachControl(element: Nullable<HTMLElement>): void;
  113130. /**
  113131. * Gets the class name of the current intput.
  113132. * @returns the class name
  113133. */
  113134. getClassName(): string;
  113135. /**
  113136. * Get the friendly name associated with the input class.
  113137. * @returns the input friendly name
  113138. */
  113139. getSimpleName(): string;
  113140. }
  113141. }
  113142. declare module BABYLON {
  113143. /**
  113144. * This represents a FPS type of camera controlled by touch.
  113145. * This is like a universal camera minus the Gamepad controls.
  113146. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113147. */
  113148. export class TouchCamera extends FreeCamera {
  113149. /**
  113150. * Defines the touch sensibility for rotation.
  113151. * The higher the faster.
  113152. */
  113153. get touchAngularSensibility(): number;
  113154. set touchAngularSensibility(value: number);
  113155. /**
  113156. * Defines the touch sensibility for move.
  113157. * The higher the faster.
  113158. */
  113159. get touchMoveSensibility(): number;
  113160. set touchMoveSensibility(value: number);
  113161. /**
  113162. * Instantiates a new touch camera.
  113163. * This represents a FPS type of camera controlled by touch.
  113164. * This is like a universal camera minus the Gamepad controls.
  113165. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113166. * @param name Define the name of the camera in the scene
  113167. * @param position Define the start position of the camera in the scene
  113168. * @param scene Define the scene the camera belongs to
  113169. */
  113170. constructor(name: string, position: Vector3, scene: Scene);
  113171. /**
  113172. * Gets the current object class name.
  113173. * @return the class name
  113174. */
  113175. getClassName(): string;
  113176. /** @hidden */
  113177. _setupInputs(): void;
  113178. }
  113179. }
  113180. declare module BABYLON {
  113181. /**
  113182. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  113183. * being tilted forward or back and left or right.
  113184. */
  113185. export class DeviceOrientationCamera extends FreeCamera {
  113186. private _initialQuaternion;
  113187. private _quaternionCache;
  113188. private _tmpDragQuaternion;
  113189. private _disablePointerInputWhenUsingDeviceOrientation;
  113190. /**
  113191. * Creates a new device orientation camera
  113192. * @param name The name of the camera
  113193. * @param position The start position camera
  113194. * @param scene The scene the camera belongs to
  113195. */
  113196. constructor(name: string, position: Vector3, scene: Scene);
  113197. /**
  113198. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  113199. */
  113200. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  113201. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  113202. private _dragFactor;
  113203. /**
  113204. * Enabled turning on the y axis when the orientation sensor is active
  113205. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  113206. */
  113207. enableHorizontalDragging(dragFactor?: number): void;
  113208. /**
  113209. * Gets the current instance class name ("DeviceOrientationCamera").
  113210. * This helps avoiding instanceof at run time.
  113211. * @returns the class name
  113212. */
  113213. getClassName(): string;
  113214. /**
  113215. * @hidden
  113216. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  113217. */
  113218. _checkInputs(): void;
  113219. /**
  113220. * Reset the camera to its default orientation on the specified axis only.
  113221. * @param axis The axis to reset
  113222. */
  113223. resetToCurrentRotation(axis?: Axis): void;
  113224. }
  113225. }
  113226. declare module BABYLON {
  113227. /**
  113228. * Defines supported buttons for XBox360 compatible gamepads
  113229. */
  113230. export enum Xbox360Button {
  113231. /** A */
  113232. A = 0,
  113233. /** B */
  113234. B = 1,
  113235. /** X */
  113236. X = 2,
  113237. /** Y */
  113238. Y = 3,
  113239. /** Start */
  113240. Start = 4,
  113241. /** Back */
  113242. Back = 5,
  113243. /** Left button */
  113244. LB = 6,
  113245. /** Right button */
  113246. RB = 7,
  113247. /** Left stick */
  113248. LeftStick = 8,
  113249. /** Right stick */
  113250. RightStick = 9
  113251. }
  113252. /** Defines values for XBox360 DPad */
  113253. export enum Xbox360Dpad {
  113254. /** Up */
  113255. Up = 0,
  113256. /** Down */
  113257. Down = 1,
  113258. /** Left */
  113259. Left = 2,
  113260. /** Right */
  113261. Right = 3
  113262. }
  113263. /**
  113264. * Defines a XBox360 gamepad
  113265. */
  113266. export class Xbox360Pad extends Gamepad {
  113267. private _leftTrigger;
  113268. private _rightTrigger;
  113269. private _onlefttriggerchanged;
  113270. private _onrighttriggerchanged;
  113271. private _onbuttondown;
  113272. private _onbuttonup;
  113273. private _ondpaddown;
  113274. private _ondpadup;
  113275. /** Observable raised when a button is pressed */
  113276. onButtonDownObservable: Observable<Xbox360Button>;
  113277. /** Observable raised when a button is released */
  113278. onButtonUpObservable: Observable<Xbox360Button>;
  113279. /** Observable raised when a pad is pressed */
  113280. onPadDownObservable: Observable<Xbox360Dpad>;
  113281. /** Observable raised when a pad is released */
  113282. onPadUpObservable: Observable<Xbox360Dpad>;
  113283. private _buttonA;
  113284. private _buttonB;
  113285. private _buttonX;
  113286. private _buttonY;
  113287. private _buttonBack;
  113288. private _buttonStart;
  113289. private _buttonLB;
  113290. private _buttonRB;
  113291. private _buttonLeftStick;
  113292. private _buttonRightStick;
  113293. private _dPadUp;
  113294. private _dPadDown;
  113295. private _dPadLeft;
  113296. private _dPadRight;
  113297. private _isXboxOnePad;
  113298. /**
  113299. * Creates a new XBox360 gamepad object
  113300. * @param id defines the id of this gamepad
  113301. * @param index defines its index
  113302. * @param gamepad defines the internal HTML gamepad object
  113303. * @param xboxOne defines if it is a XBox One gamepad
  113304. */
  113305. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  113306. /**
  113307. * Defines the callback to call when left trigger is pressed
  113308. * @param callback defines the callback to use
  113309. */
  113310. onlefttriggerchanged(callback: (value: number) => void): void;
  113311. /**
  113312. * Defines the callback to call when right trigger is pressed
  113313. * @param callback defines the callback to use
  113314. */
  113315. onrighttriggerchanged(callback: (value: number) => void): void;
  113316. /**
  113317. * Gets the left trigger value
  113318. */
  113319. get leftTrigger(): number;
  113320. /**
  113321. * Sets the left trigger value
  113322. */
  113323. set leftTrigger(newValue: number);
  113324. /**
  113325. * Gets the right trigger value
  113326. */
  113327. get rightTrigger(): number;
  113328. /**
  113329. * Sets the right trigger value
  113330. */
  113331. set rightTrigger(newValue: number);
  113332. /**
  113333. * Defines the callback to call when a button is pressed
  113334. * @param callback defines the callback to use
  113335. */
  113336. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  113337. /**
  113338. * Defines the callback to call when a button is released
  113339. * @param callback defines the callback to use
  113340. */
  113341. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  113342. /**
  113343. * Defines the callback to call when a pad is pressed
  113344. * @param callback defines the callback to use
  113345. */
  113346. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  113347. /**
  113348. * Defines the callback to call when a pad is released
  113349. * @param callback defines the callback to use
  113350. */
  113351. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  113352. private _setButtonValue;
  113353. private _setDPadValue;
  113354. /**
  113355. * Gets the value of the `A` button
  113356. */
  113357. get buttonA(): number;
  113358. /**
  113359. * Sets the value of the `A` button
  113360. */
  113361. set buttonA(value: number);
  113362. /**
  113363. * Gets the value of the `B` button
  113364. */
  113365. get buttonB(): number;
  113366. /**
  113367. * Sets the value of the `B` button
  113368. */
  113369. set buttonB(value: number);
  113370. /**
  113371. * Gets the value of the `X` button
  113372. */
  113373. get buttonX(): number;
  113374. /**
  113375. * Sets the value of the `X` button
  113376. */
  113377. set buttonX(value: number);
  113378. /**
  113379. * Gets the value of the `Y` button
  113380. */
  113381. get buttonY(): number;
  113382. /**
  113383. * Sets the value of the `Y` button
  113384. */
  113385. set buttonY(value: number);
  113386. /**
  113387. * Gets the value of the `Start` button
  113388. */
  113389. get buttonStart(): number;
  113390. /**
  113391. * Sets the value of the `Start` button
  113392. */
  113393. set buttonStart(value: number);
  113394. /**
  113395. * Gets the value of the `Back` button
  113396. */
  113397. get buttonBack(): number;
  113398. /**
  113399. * Sets the value of the `Back` button
  113400. */
  113401. set buttonBack(value: number);
  113402. /**
  113403. * Gets the value of the `Left` button
  113404. */
  113405. get buttonLB(): number;
  113406. /**
  113407. * Sets the value of the `Left` button
  113408. */
  113409. set buttonLB(value: number);
  113410. /**
  113411. * Gets the value of the `Right` button
  113412. */
  113413. get buttonRB(): number;
  113414. /**
  113415. * Sets the value of the `Right` button
  113416. */
  113417. set buttonRB(value: number);
  113418. /**
  113419. * Gets the value of the Left joystick
  113420. */
  113421. get buttonLeftStick(): number;
  113422. /**
  113423. * Sets the value of the Left joystick
  113424. */
  113425. set buttonLeftStick(value: number);
  113426. /**
  113427. * Gets the value of the Right joystick
  113428. */
  113429. get buttonRightStick(): number;
  113430. /**
  113431. * Sets the value of the Right joystick
  113432. */
  113433. set buttonRightStick(value: number);
  113434. /**
  113435. * Gets the value of D-pad up
  113436. */
  113437. get dPadUp(): number;
  113438. /**
  113439. * Sets the value of D-pad up
  113440. */
  113441. set dPadUp(value: number);
  113442. /**
  113443. * Gets the value of D-pad down
  113444. */
  113445. get dPadDown(): number;
  113446. /**
  113447. * Sets the value of D-pad down
  113448. */
  113449. set dPadDown(value: number);
  113450. /**
  113451. * Gets the value of D-pad left
  113452. */
  113453. get dPadLeft(): number;
  113454. /**
  113455. * Sets the value of D-pad left
  113456. */
  113457. set dPadLeft(value: number);
  113458. /**
  113459. * Gets the value of D-pad right
  113460. */
  113461. get dPadRight(): number;
  113462. /**
  113463. * Sets the value of D-pad right
  113464. */
  113465. set dPadRight(value: number);
  113466. /**
  113467. * Force the gamepad to synchronize with device values
  113468. */
  113469. update(): void;
  113470. /**
  113471. * Disposes the gamepad
  113472. */
  113473. dispose(): void;
  113474. }
  113475. }
  113476. declare module BABYLON {
  113477. /**
  113478. * Defines supported buttons for DualShock compatible gamepads
  113479. */
  113480. export enum DualShockButton {
  113481. /** Cross */
  113482. Cross = 0,
  113483. /** Circle */
  113484. Circle = 1,
  113485. /** Square */
  113486. Square = 2,
  113487. /** Triangle */
  113488. Triangle = 3,
  113489. /** Options */
  113490. Options = 4,
  113491. /** Share */
  113492. Share = 5,
  113493. /** L1 */
  113494. L1 = 6,
  113495. /** R1 */
  113496. R1 = 7,
  113497. /** Left stick */
  113498. LeftStick = 8,
  113499. /** Right stick */
  113500. RightStick = 9
  113501. }
  113502. /** Defines values for DualShock DPad */
  113503. export enum DualShockDpad {
  113504. /** Up */
  113505. Up = 0,
  113506. /** Down */
  113507. Down = 1,
  113508. /** Left */
  113509. Left = 2,
  113510. /** Right */
  113511. Right = 3
  113512. }
  113513. /**
  113514. * Defines a DualShock gamepad
  113515. */
  113516. export class DualShockPad extends Gamepad {
  113517. private _leftTrigger;
  113518. private _rightTrigger;
  113519. private _onlefttriggerchanged;
  113520. private _onrighttriggerchanged;
  113521. private _onbuttondown;
  113522. private _onbuttonup;
  113523. private _ondpaddown;
  113524. private _ondpadup;
  113525. /** Observable raised when a button is pressed */
  113526. onButtonDownObservable: Observable<DualShockButton>;
  113527. /** Observable raised when a button is released */
  113528. onButtonUpObservable: Observable<DualShockButton>;
  113529. /** Observable raised when a pad is pressed */
  113530. onPadDownObservable: Observable<DualShockDpad>;
  113531. /** Observable raised when a pad is released */
  113532. onPadUpObservable: Observable<DualShockDpad>;
  113533. private _buttonCross;
  113534. private _buttonCircle;
  113535. private _buttonSquare;
  113536. private _buttonTriangle;
  113537. private _buttonShare;
  113538. private _buttonOptions;
  113539. private _buttonL1;
  113540. private _buttonR1;
  113541. private _buttonLeftStick;
  113542. private _buttonRightStick;
  113543. private _dPadUp;
  113544. private _dPadDown;
  113545. private _dPadLeft;
  113546. private _dPadRight;
  113547. /**
  113548. * Creates a new DualShock gamepad object
  113549. * @param id defines the id of this gamepad
  113550. * @param index defines its index
  113551. * @param gamepad defines the internal HTML gamepad object
  113552. */
  113553. constructor(id: string, index: number, gamepad: any);
  113554. /**
  113555. * Defines the callback to call when left trigger is pressed
  113556. * @param callback defines the callback to use
  113557. */
  113558. onlefttriggerchanged(callback: (value: number) => void): void;
  113559. /**
  113560. * Defines the callback to call when right trigger is pressed
  113561. * @param callback defines the callback to use
  113562. */
  113563. onrighttriggerchanged(callback: (value: number) => void): void;
  113564. /**
  113565. * Gets the left trigger value
  113566. */
  113567. get leftTrigger(): number;
  113568. /**
  113569. * Sets the left trigger value
  113570. */
  113571. set leftTrigger(newValue: number);
  113572. /**
  113573. * Gets the right trigger value
  113574. */
  113575. get rightTrigger(): number;
  113576. /**
  113577. * Sets the right trigger value
  113578. */
  113579. set rightTrigger(newValue: number);
  113580. /**
  113581. * Defines the callback to call when a button is pressed
  113582. * @param callback defines the callback to use
  113583. */
  113584. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  113585. /**
  113586. * Defines the callback to call when a button is released
  113587. * @param callback defines the callback to use
  113588. */
  113589. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  113590. /**
  113591. * Defines the callback to call when a pad is pressed
  113592. * @param callback defines the callback to use
  113593. */
  113594. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  113595. /**
  113596. * Defines the callback to call when a pad is released
  113597. * @param callback defines the callback to use
  113598. */
  113599. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  113600. private _setButtonValue;
  113601. private _setDPadValue;
  113602. /**
  113603. * Gets the value of the `Cross` button
  113604. */
  113605. get buttonCross(): number;
  113606. /**
  113607. * Sets the value of the `Cross` button
  113608. */
  113609. set buttonCross(value: number);
  113610. /**
  113611. * Gets the value of the `Circle` button
  113612. */
  113613. get buttonCircle(): number;
  113614. /**
  113615. * Sets the value of the `Circle` button
  113616. */
  113617. set buttonCircle(value: number);
  113618. /**
  113619. * Gets the value of the `Square` button
  113620. */
  113621. get buttonSquare(): number;
  113622. /**
  113623. * Sets the value of the `Square` button
  113624. */
  113625. set buttonSquare(value: number);
  113626. /**
  113627. * Gets the value of the `Triangle` button
  113628. */
  113629. get buttonTriangle(): number;
  113630. /**
  113631. * Sets the value of the `Triangle` button
  113632. */
  113633. set buttonTriangle(value: number);
  113634. /**
  113635. * Gets the value of the `Options` button
  113636. */
  113637. get buttonOptions(): number;
  113638. /**
  113639. * Sets the value of the `Options` button
  113640. */
  113641. set buttonOptions(value: number);
  113642. /**
  113643. * Gets the value of the `Share` button
  113644. */
  113645. get buttonShare(): number;
  113646. /**
  113647. * Sets the value of the `Share` button
  113648. */
  113649. set buttonShare(value: number);
  113650. /**
  113651. * Gets the value of the `L1` button
  113652. */
  113653. get buttonL1(): number;
  113654. /**
  113655. * Sets the value of the `L1` button
  113656. */
  113657. set buttonL1(value: number);
  113658. /**
  113659. * Gets the value of the `R1` button
  113660. */
  113661. get buttonR1(): number;
  113662. /**
  113663. * Sets the value of the `R1` button
  113664. */
  113665. set buttonR1(value: number);
  113666. /**
  113667. * Gets the value of the Left joystick
  113668. */
  113669. get buttonLeftStick(): number;
  113670. /**
  113671. * Sets the value of the Left joystick
  113672. */
  113673. set buttonLeftStick(value: number);
  113674. /**
  113675. * Gets the value of the Right joystick
  113676. */
  113677. get buttonRightStick(): number;
  113678. /**
  113679. * Sets the value of the Right joystick
  113680. */
  113681. set buttonRightStick(value: number);
  113682. /**
  113683. * Gets the value of D-pad up
  113684. */
  113685. get dPadUp(): number;
  113686. /**
  113687. * Sets the value of D-pad up
  113688. */
  113689. set dPadUp(value: number);
  113690. /**
  113691. * Gets the value of D-pad down
  113692. */
  113693. get dPadDown(): number;
  113694. /**
  113695. * Sets the value of D-pad down
  113696. */
  113697. set dPadDown(value: number);
  113698. /**
  113699. * Gets the value of D-pad left
  113700. */
  113701. get dPadLeft(): number;
  113702. /**
  113703. * Sets the value of D-pad left
  113704. */
  113705. set dPadLeft(value: number);
  113706. /**
  113707. * Gets the value of D-pad right
  113708. */
  113709. get dPadRight(): number;
  113710. /**
  113711. * Sets the value of D-pad right
  113712. */
  113713. set dPadRight(value: number);
  113714. /**
  113715. * Force the gamepad to synchronize with device values
  113716. */
  113717. update(): void;
  113718. /**
  113719. * Disposes the gamepad
  113720. */
  113721. dispose(): void;
  113722. }
  113723. }
  113724. declare module BABYLON {
  113725. /**
  113726. * Manager for handling gamepads
  113727. */
  113728. export class GamepadManager {
  113729. private _scene?;
  113730. private _babylonGamepads;
  113731. private _oneGamepadConnected;
  113732. /** @hidden */
  113733. _isMonitoring: boolean;
  113734. private _gamepadEventSupported;
  113735. private _gamepadSupport?;
  113736. /**
  113737. * observable to be triggered when the gamepad controller has been connected
  113738. */
  113739. onGamepadConnectedObservable: Observable<Gamepad>;
  113740. /**
  113741. * observable to be triggered when the gamepad controller has been disconnected
  113742. */
  113743. onGamepadDisconnectedObservable: Observable<Gamepad>;
  113744. private _onGamepadConnectedEvent;
  113745. private _onGamepadDisconnectedEvent;
  113746. /**
  113747. * Initializes the gamepad manager
  113748. * @param _scene BabylonJS scene
  113749. */
  113750. constructor(_scene?: Scene | undefined);
  113751. /**
  113752. * The gamepads in the game pad manager
  113753. */
  113754. get gamepads(): Gamepad[];
  113755. /**
  113756. * Get the gamepad controllers based on type
  113757. * @param type The type of gamepad controller
  113758. * @returns Nullable gamepad
  113759. */
  113760. getGamepadByType(type?: number): Nullable<Gamepad>;
  113761. /**
  113762. * Disposes the gamepad manager
  113763. */
  113764. dispose(): void;
  113765. private _addNewGamepad;
  113766. private _startMonitoringGamepads;
  113767. private _stopMonitoringGamepads;
  113768. /** @hidden */
  113769. _checkGamepadsStatus(): void;
  113770. private _updateGamepadObjects;
  113771. }
  113772. }
  113773. declare module BABYLON {
  113774. interface Scene {
  113775. /** @hidden */
  113776. _gamepadManager: Nullable<GamepadManager>;
  113777. /**
  113778. * Gets the gamepad manager associated with the scene
  113779. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  113780. */
  113781. gamepadManager: GamepadManager;
  113782. }
  113783. /**
  113784. * Interface representing a free camera inputs manager
  113785. */
  113786. interface FreeCameraInputsManager {
  113787. /**
  113788. * Adds gamepad input support to the FreeCameraInputsManager.
  113789. * @returns the FreeCameraInputsManager
  113790. */
  113791. addGamepad(): FreeCameraInputsManager;
  113792. }
  113793. /**
  113794. * Interface representing an arc rotate camera inputs manager
  113795. */
  113796. interface ArcRotateCameraInputsManager {
  113797. /**
  113798. * Adds gamepad input support to the ArcRotateCamera InputManager.
  113799. * @returns the camera inputs manager
  113800. */
  113801. addGamepad(): ArcRotateCameraInputsManager;
  113802. }
  113803. /**
  113804. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  113805. */
  113806. export class GamepadSystemSceneComponent implements ISceneComponent {
  113807. /**
  113808. * The component name helpfull to identify the component in the list of scene components.
  113809. */
  113810. readonly name: string;
  113811. /**
  113812. * The scene the component belongs to.
  113813. */
  113814. scene: Scene;
  113815. /**
  113816. * Creates a new instance of the component for the given scene
  113817. * @param scene Defines the scene to register the component in
  113818. */
  113819. constructor(scene: Scene);
  113820. /**
  113821. * Registers the component in a given scene
  113822. */
  113823. register(): void;
  113824. /**
  113825. * Rebuilds the elements related to this component in case of
  113826. * context lost for instance.
  113827. */
  113828. rebuild(): void;
  113829. /**
  113830. * Disposes the component and the associated ressources
  113831. */
  113832. dispose(): void;
  113833. private _beforeCameraUpdate;
  113834. }
  113835. }
  113836. declare module BABYLON {
  113837. /**
  113838. * 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,
  113839. * which still works and will still be found in many Playgrounds.
  113840. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113841. */
  113842. export class UniversalCamera extends TouchCamera {
  113843. /**
  113844. * Defines the gamepad rotation sensiblity.
  113845. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113846. */
  113847. get gamepadAngularSensibility(): number;
  113848. set gamepadAngularSensibility(value: number);
  113849. /**
  113850. * Defines the gamepad move sensiblity.
  113851. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113852. */
  113853. get gamepadMoveSensibility(): number;
  113854. set gamepadMoveSensibility(value: number);
  113855. /**
  113856. * 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,
  113857. * which still works and will still be found in many Playgrounds.
  113858. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113859. * @param name Define the name of the camera in the scene
  113860. * @param position Define the start position of the camera in the scene
  113861. * @param scene Define the scene the camera belongs to
  113862. */
  113863. constructor(name: string, position: Vector3, scene: Scene);
  113864. /**
  113865. * Gets the current object class name.
  113866. * @return the class name
  113867. */
  113868. getClassName(): string;
  113869. }
  113870. }
  113871. declare module BABYLON {
  113872. /**
  113873. * This represents a FPS type of camera. This is only here for back compat purpose.
  113874. * Please use the UniversalCamera instead as both are identical.
  113875. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113876. */
  113877. export class GamepadCamera extends UniversalCamera {
  113878. /**
  113879. * Instantiates a new Gamepad Camera
  113880. * This represents a FPS type of camera. This is only here for back compat purpose.
  113881. * Please use the UniversalCamera instead as both are identical.
  113882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113883. * @param name Define the name of the camera in the scene
  113884. * @param position Define the start position of the camera in the scene
  113885. * @param scene Define the scene the camera belongs to
  113886. */
  113887. constructor(name: string, position: Vector3, scene: Scene);
  113888. /**
  113889. * Gets the current object class name.
  113890. * @return the class name
  113891. */
  113892. getClassName(): string;
  113893. }
  113894. }
  113895. declare module BABYLON {
  113896. /** @hidden */
  113897. export var passPixelShader: {
  113898. name: string;
  113899. shader: string;
  113900. };
  113901. }
  113902. declare module BABYLON {
  113903. /** @hidden */
  113904. export var passCubePixelShader: {
  113905. name: string;
  113906. shader: string;
  113907. };
  113908. }
  113909. declare module BABYLON {
  113910. /**
  113911. * PassPostProcess which produces an output the same as it's input
  113912. */
  113913. export class PassPostProcess extends PostProcess {
  113914. /**
  113915. * Creates the PassPostProcess
  113916. * @param name The name of the effect.
  113917. * @param options The required width/height ratio to downsize to before computing the render pass.
  113918. * @param camera The camera to apply the render pass to.
  113919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113920. * @param engine The engine which the post process will be applied. (default: current engine)
  113921. * @param reusable If the post process can be reused on the same frame. (default: false)
  113922. * @param textureType The type of texture to be used when performing the post processing.
  113923. * @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)
  113924. */
  113925. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113926. }
  113927. /**
  113928. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  113929. */
  113930. export class PassCubePostProcess extends PostProcess {
  113931. private _face;
  113932. /**
  113933. * Gets or sets the cube face to display.
  113934. * * 0 is +X
  113935. * * 1 is -X
  113936. * * 2 is +Y
  113937. * * 3 is -Y
  113938. * * 4 is +Z
  113939. * * 5 is -Z
  113940. */
  113941. get face(): number;
  113942. set face(value: number);
  113943. /**
  113944. * Creates the PassCubePostProcess
  113945. * @param name The name of the effect.
  113946. * @param options The required width/height ratio to downsize to before computing the render pass.
  113947. * @param camera The camera to apply the render pass to.
  113948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113949. * @param engine The engine which the post process will be applied. (default: current engine)
  113950. * @param reusable If the post process can be reused on the same frame. (default: false)
  113951. * @param textureType The type of texture to be used when performing the post processing.
  113952. * @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)
  113953. */
  113954. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113955. }
  113956. }
  113957. declare module BABYLON {
  113958. /** @hidden */
  113959. export var anaglyphPixelShader: {
  113960. name: string;
  113961. shader: string;
  113962. };
  113963. }
  113964. declare module BABYLON {
  113965. /**
  113966. * Postprocess used to generate anaglyphic rendering
  113967. */
  113968. export class AnaglyphPostProcess extends PostProcess {
  113969. private _passedProcess;
  113970. /**
  113971. * Creates a new AnaglyphPostProcess
  113972. * @param name defines postprocess name
  113973. * @param options defines creation options or target ratio scale
  113974. * @param rigCameras defines cameras using this postprocess
  113975. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  113976. * @param engine defines hosting engine
  113977. * @param reusable defines if the postprocess will be reused multiple times per frame
  113978. */
  113979. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  113980. }
  113981. }
  113982. declare module BABYLON {
  113983. /**
  113984. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  113985. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  113986. */
  113987. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  113988. /**
  113989. * Creates a new AnaglyphArcRotateCamera
  113990. * @param name defines camera name
  113991. * @param alpha defines alpha angle (in radians)
  113992. * @param beta defines beta angle (in radians)
  113993. * @param radius defines radius
  113994. * @param target defines camera target
  113995. * @param interaxialDistance defines distance between each color axis
  113996. * @param scene defines the hosting scene
  113997. */
  113998. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  113999. /**
  114000. * Gets camera class name
  114001. * @returns AnaglyphArcRotateCamera
  114002. */
  114003. getClassName(): string;
  114004. }
  114005. }
  114006. declare module BABYLON {
  114007. /**
  114008. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114009. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114010. */
  114011. export class AnaglyphFreeCamera extends FreeCamera {
  114012. /**
  114013. * Creates a new AnaglyphFreeCamera
  114014. * @param name defines camera name
  114015. * @param position defines initial position
  114016. * @param interaxialDistance defines distance between each color axis
  114017. * @param scene defines the hosting scene
  114018. */
  114019. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114020. /**
  114021. * Gets camera class name
  114022. * @returns AnaglyphFreeCamera
  114023. */
  114024. getClassName(): string;
  114025. }
  114026. }
  114027. declare module BABYLON {
  114028. /**
  114029. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114030. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114031. */
  114032. export class AnaglyphGamepadCamera extends GamepadCamera {
  114033. /**
  114034. * Creates a new AnaglyphGamepadCamera
  114035. * @param name defines camera name
  114036. * @param position defines initial position
  114037. * @param interaxialDistance defines distance between each color axis
  114038. * @param scene defines the hosting scene
  114039. */
  114040. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114041. /**
  114042. * Gets camera class name
  114043. * @returns AnaglyphGamepadCamera
  114044. */
  114045. getClassName(): string;
  114046. }
  114047. }
  114048. declare module BABYLON {
  114049. /**
  114050. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114051. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114052. */
  114053. export class AnaglyphUniversalCamera extends UniversalCamera {
  114054. /**
  114055. * Creates a new AnaglyphUniversalCamera
  114056. * @param name defines camera name
  114057. * @param position defines initial position
  114058. * @param interaxialDistance defines distance between each color axis
  114059. * @param scene defines the hosting scene
  114060. */
  114061. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114062. /**
  114063. * Gets camera class name
  114064. * @returns AnaglyphUniversalCamera
  114065. */
  114066. getClassName(): string;
  114067. }
  114068. }
  114069. declare module BABYLON {
  114070. /** @hidden */
  114071. export var stereoscopicInterlacePixelShader: {
  114072. name: string;
  114073. shader: string;
  114074. };
  114075. }
  114076. declare module BABYLON {
  114077. /**
  114078. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114079. */
  114080. export class StereoscopicInterlacePostProcess extends PostProcess {
  114081. private _stepSize;
  114082. private _passedProcess;
  114083. /**
  114084. * Initializes a StereoscopicInterlacePostProcess
  114085. * @param name The name of the effect.
  114086. * @param rigCameras The rig cameras to be appled to the post process
  114087. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  114088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114089. * @param engine The engine which the post process will be applied. (default: current engine)
  114090. * @param reusable If the post process can be reused on the same frame. (default: false)
  114091. */
  114092. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114093. }
  114094. }
  114095. declare module BABYLON {
  114096. /**
  114097. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  114098. * @see http://doc.babylonjs.com/features/cameras
  114099. */
  114100. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  114101. /**
  114102. * Creates a new StereoscopicArcRotateCamera
  114103. * @param name defines camera name
  114104. * @param alpha defines alpha angle (in radians)
  114105. * @param beta defines beta angle (in radians)
  114106. * @param radius defines radius
  114107. * @param target defines camera target
  114108. * @param interaxialDistance defines distance between each color axis
  114109. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114110. * @param scene defines the hosting scene
  114111. */
  114112. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114113. /**
  114114. * Gets camera class name
  114115. * @returns StereoscopicArcRotateCamera
  114116. */
  114117. getClassName(): string;
  114118. }
  114119. }
  114120. declare module BABYLON {
  114121. /**
  114122. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  114123. * @see http://doc.babylonjs.com/features/cameras
  114124. */
  114125. export class StereoscopicFreeCamera extends FreeCamera {
  114126. /**
  114127. * Creates a new StereoscopicFreeCamera
  114128. * @param name defines camera name
  114129. * @param position defines initial position
  114130. * @param interaxialDistance defines distance between each color axis
  114131. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114132. * @param scene defines the hosting scene
  114133. */
  114134. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114135. /**
  114136. * Gets camera class name
  114137. * @returns StereoscopicFreeCamera
  114138. */
  114139. getClassName(): string;
  114140. }
  114141. }
  114142. declare module BABYLON {
  114143. /**
  114144. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  114145. * @see http://doc.babylonjs.com/features/cameras
  114146. */
  114147. export class StereoscopicGamepadCamera extends GamepadCamera {
  114148. /**
  114149. * Creates a new StereoscopicGamepadCamera
  114150. * @param name defines camera name
  114151. * @param position defines initial position
  114152. * @param interaxialDistance defines distance between each color axis
  114153. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114154. * @param scene defines the hosting scene
  114155. */
  114156. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114157. /**
  114158. * Gets camera class name
  114159. * @returns StereoscopicGamepadCamera
  114160. */
  114161. getClassName(): string;
  114162. }
  114163. }
  114164. declare module BABYLON {
  114165. /**
  114166. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  114167. * @see http://doc.babylonjs.com/features/cameras
  114168. */
  114169. export class StereoscopicUniversalCamera extends UniversalCamera {
  114170. /**
  114171. * Creates a new StereoscopicUniversalCamera
  114172. * @param name defines camera name
  114173. * @param position defines initial position
  114174. * @param interaxialDistance defines distance between each color axis
  114175. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114176. * @param scene defines the hosting scene
  114177. */
  114178. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114179. /**
  114180. * Gets camera class name
  114181. * @returns StereoscopicUniversalCamera
  114182. */
  114183. getClassName(): string;
  114184. }
  114185. }
  114186. declare module BABYLON {
  114187. /**
  114188. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  114189. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114190. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114191. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114192. */
  114193. export class VirtualJoysticksCamera extends FreeCamera {
  114194. /**
  114195. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  114196. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114197. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114198. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114199. * @param name Define the name of the camera in the scene
  114200. * @param position Define the start position of the camera in the scene
  114201. * @param scene Define the scene the camera belongs to
  114202. */
  114203. constructor(name: string, position: Vector3, scene: Scene);
  114204. /**
  114205. * Gets the current object class name.
  114206. * @return the class name
  114207. */
  114208. getClassName(): string;
  114209. }
  114210. }
  114211. declare module BABYLON {
  114212. /**
  114213. * This represents all the required metrics to create a VR camera.
  114214. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  114215. */
  114216. export class VRCameraMetrics {
  114217. /**
  114218. * Define the horizontal resolution off the screen.
  114219. */
  114220. hResolution: number;
  114221. /**
  114222. * Define the vertical resolution off the screen.
  114223. */
  114224. vResolution: number;
  114225. /**
  114226. * Define the horizontal screen size.
  114227. */
  114228. hScreenSize: number;
  114229. /**
  114230. * Define the vertical screen size.
  114231. */
  114232. vScreenSize: number;
  114233. /**
  114234. * Define the vertical screen center position.
  114235. */
  114236. vScreenCenter: number;
  114237. /**
  114238. * Define the distance of the eyes to the screen.
  114239. */
  114240. eyeToScreenDistance: number;
  114241. /**
  114242. * Define the distance between both lenses
  114243. */
  114244. lensSeparationDistance: number;
  114245. /**
  114246. * Define the distance between both viewer's eyes.
  114247. */
  114248. interpupillaryDistance: number;
  114249. /**
  114250. * Define the distortion factor of the VR postprocess.
  114251. * Please, touch with care.
  114252. */
  114253. distortionK: number[];
  114254. /**
  114255. * Define the chromatic aberration correction factors for the VR post process.
  114256. */
  114257. chromaAbCorrection: number[];
  114258. /**
  114259. * Define the scale factor of the post process.
  114260. * The smaller the better but the slower.
  114261. */
  114262. postProcessScaleFactor: number;
  114263. /**
  114264. * Define an offset for the lens center.
  114265. */
  114266. lensCenterOffset: number;
  114267. /**
  114268. * Define if the current vr camera should compensate the distortion of the lense or not.
  114269. */
  114270. compensateDistortion: boolean;
  114271. /**
  114272. * Defines if multiview should be enabled when rendering (Default: false)
  114273. */
  114274. multiviewEnabled: boolean;
  114275. /**
  114276. * Gets the rendering aspect ratio based on the provided resolutions.
  114277. */
  114278. get aspectRatio(): number;
  114279. /**
  114280. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  114281. */
  114282. get aspectRatioFov(): number;
  114283. /**
  114284. * @hidden
  114285. */
  114286. get leftHMatrix(): Matrix;
  114287. /**
  114288. * @hidden
  114289. */
  114290. get rightHMatrix(): Matrix;
  114291. /**
  114292. * @hidden
  114293. */
  114294. get leftPreViewMatrix(): Matrix;
  114295. /**
  114296. * @hidden
  114297. */
  114298. get rightPreViewMatrix(): Matrix;
  114299. /**
  114300. * Get the default VRMetrics based on the most generic setup.
  114301. * @returns the default vr metrics
  114302. */
  114303. static GetDefault(): VRCameraMetrics;
  114304. }
  114305. }
  114306. declare module BABYLON {
  114307. /** @hidden */
  114308. export var vrDistortionCorrectionPixelShader: {
  114309. name: string;
  114310. shader: string;
  114311. };
  114312. }
  114313. declare module BABYLON {
  114314. /**
  114315. * VRDistortionCorrectionPostProcess used for mobile VR
  114316. */
  114317. export class VRDistortionCorrectionPostProcess extends PostProcess {
  114318. private _isRightEye;
  114319. private _distortionFactors;
  114320. private _postProcessScaleFactor;
  114321. private _lensCenterOffset;
  114322. private _scaleIn;
  114323. private _scaleFactor;
  114324. private _lensCenter;
  114325. /**
  114326. * Initializes the VRDistortionCorrectionPostProcess
  114327. * @param name The name of the effect.
  114328. * @param camera The camera to apply the render pass to.
  114329. * @param isRightEye If this is for the right eye distortion
  114330. * @param vrMetrics All the required metrics for the VR camera
  114331. */
  114332. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  114333. }
  114334. }
  114335. declare module BABYLON {
  114336. /**
  114337. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  114338. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114339. */
  114340. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  114341. /**
  114342. * Creates a new VRDeviceOrientationArcRotateCamera
  114343. * @param name defines camera name
  114344. * @param alpha defines the camera rotation along the logitudinal axis
  114345. * @param beta defines the camera rotation along the latitudinal axis
  114346. * @param radius defines the camera distance from its target
  114347. * @param target defines the camera target
  114348. * @param scene defines the scene the camera belongs to
  114349. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114350. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114351. */
  114352. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114353. /**
  114354. * Gets camera class name
  114355. * @returns VRDeviceOrientationArcRotateCamera
  114356. */
  114357. getClassName(): string;
  114358. }
  114359. }
  114360. declare module BABYLON {
  114361. /**
  114362. * Camera used to simulate VR rendering (based on FreeCamera)
  114363. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114364. */
  114365. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  114366. /**
  114367. * Creates a new VRDeviceOrientationFreeCamera
  114368. * @param name defines camera name
  114369. * @param position defines the start position of the camera
  114370. * @param scene defines the scene the camera belongs to
  114371. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114372. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114373. */
  114374. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114375. /**
  114376. * Gets camera class name
  114377. * @returns VRDeviceOrientationFreeCamera
  114378. */
  114379. getClassName(): string;
  114380. }
  114381. }
  114382. declare module BABYLON {
  114383. /**
  114384. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  114385. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114386. */
  114387. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  114388. /**
  114389. * Creates a new VRDeviceOrientationGamepadCamera
  114390. * @param name defines camera name
  114391. * @param position defines the start position of the camera
  114392. * @param scene defines the scene the camera belongs to
  114393. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114394. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114395. */
  114396. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114397. /**
  114398. * Gets camera class name
  114399. * @returns VRDeviceOrientationGamepadCamera
  114400. */
  114401. getClassName(): string;
  114402. }
  114403. }
  114404. declare module BABYLON {
  114405. /** @hidden */
  114406. export var imageProcessingPixelShader: {
  114407. name: string;
  114408. shader: string;
  114409. };
  114410. }
  114411. declare module BABYLON {
  114412. /**
  114413. * ImageProcessingPostProcess
  114414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  114415. */
  114416. export class ImageProcessingPostProcess extends PostProcess {
  114417. /**
  114418. * Default configuration related to image processing available in the PBR Material.
  114419. */
  114420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114421. /**
  114422. * Gets the image processing configuration used either in this material.
  114423. */
  114424. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  114425. /**
  114426. * Sets the Default image processing configuration used either in the this material.
  114427. *
  114428. * If sets to null, the scene one is in use.
  114429. */
  114430. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  114431. /**
  114432. * Keep track of the image processing observer to allow dispose and replace.
  114433. */
  114434. private _imageProcessingObserver;
  114435. /**
  114436. * Attaches a new image processing configuration to the PBR Material.
  114437. * @param configuration
  114438. */
  114439. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  114440. /**
  114441. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114442. */
  114443. get colorCurves(): Nullable<ColorCurves>;
  114444. /**
  114445. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114446. */
  114447. set colorCurves(value: Nullable<ColorCurves>);
  114448. /**
  114449. * Gets wether the color curves effect is enabled.
  114450. */
  114451. get colorCurvesEnabled(): boolean;
  114452. /**
  114453. * Sets wether the color curves effect is enabled.
  114454. */
  114455. set colorCurvesEnabled(value: boolean);
  114456. /**
  114457. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114458. */
  114459. get colorGradingTexture(): Nullable<BaseTexture>;
  114460. /**
  114461. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114462. */
  114463. set colorGradingTexture(value: Nullable<BaseTexture>);
  114464. /**
  114465. * Gets wether the color grading effect is enabled.
  114466. */
  114467. get colorGradingEnabled(): boolean;
  114468. /**
  114469. * Gets wether the color grading effect is enabled.
  114470. */
  114471. set colorGradingEnabled(value: boolean);
  114472. /**
  114473. * Gets exposure used in the effect.
  114474. */
  114475. get exposure(): number;
  114476. /**
  114477. * Sets exposure used in the effect.
  114478. */
  114479. set exposure(value: number);
  114480. /**
  114481. * Gets wether tonemapping is enabled or not.
  114482. */
  114483. get toneMappingEnabled(): boolean;
  114484. /**
  114485. * Sets wether tonemapping is enabled or not
  114486. */
  114487. set toneMappingEnabled(value: boolean);
  114488. /**
  114489. * Gets the type of tone mapping effect.
  114490. */
  114491. get toneMappingType(): number;
  114492. /**
  114493. * Sets the type of tone mapping effect.
  114494. */
  114495. set toneMappingType(value: number);
  114496. /**
  114497. * Gets contrast used in the effect.
  114498. */
  114499. get contrast(): number;
  114500. /**
  114501. * Sets contrast used in the effect.
  114502. */
  114503. set contrast(value: number);
  114504. /**
  114505. * Gets Vignette stretch size.
  114506. */
  114507. get vignetteStretch(): number;
  114508. /**
  114509. * Sets Vignette stretch size.
  114510. */
  114511. set vignetteStretch(value: number);
  114512. /**
  114513. * Gets Vignette centre X Offset.
  114514. */
  114515. get vignetteCentreX(): number;
  114516. /**
  114517. * Sets Vignette centre X Offset.
  114518. */
  114519. set vignetteCentreX(value: number);
  114520. /**
  114521. * Gets Vignette centre Y Offset.
  114522. */
  114523. get vignetteCentreY(): number;
  114524. /**
  114525. * Sets Vignette centre Y Offset.
  114526. */
  114527. set vignetteCentreY(value: number);
  114528. /**
  114529. * Gets Vignette weight or intensity of the vignette effect.
  114530. */
  114531. get vignetteWeight(): number;
  114532. /**
  114533. * Sets Vignette weight or intensity of the vignette effect.
  114534. */
  114535. set vignetteWeight(value: number);
  114536. /**
  114537. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  114538. * if vignetteEnabled is set to true.
  114539. */
  114540. get vignetteColor(): Color4;
  114541. /**
  114542. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  114543. * if vignetteEnabled is set to true.
  114544. */
  114545. set vignetteColor(value: Color4);
  114546. /**
  114547. * Gets Camera field of view used by the Vignette effect.
  114548. */
  114549. get vignetteCameraFov(): number;
  114550. /**
  114551. * Sets Camera field of view used by the Vignette effect.
  114552. */
  114553. set vignetteCameraFov(value: number);
  114554. /**
  114555. * Gets the vignette blend mode allowing different kind of effect.
  114556. */
  114557. get vignetteBlendMode(): number;
  114558. /**
  114559. * Sets the vignette blend mode allowing different kind of effect.
  114560. */
  114561. set vignetteBlendMode(value: number);
  114562. /**
  114563. * Gets wether the vignette effect is enabled.
  114564. */
  114565. get vignetteEnabled(): boolean;
  114566. /**
  114567. * Sets wether the vignette effect is enabled.
  114568. */
  114569. set vignetteEnabled(value: boolean);
  114570. private _fromLinearSpace;
  114571. /**
  114572. * Gets wether the input of the processing is in Gamma or Linear Space.
  114573. */
  114574. get fromLinearSpace(): boolean;
  114575. /**
  114576. * Sets wether the input of the processing is in Gamma or Linear Space.
  114577. */
  114578. set fromLinearSpace(value: boolean);
  114579. /**
  114580. * Defines cache preventing GC.
  114581. */
  114582. private _defines;
  114583. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  114584. /**
  114585. * "ImageProcessingPostProcess"
  114586. * @returns "ImageProcessingPostProcess"
  114587. */
  114588. getClassName(): string;
  114589. protected _updateParameters(): void;
  114590. dispose(camera?: Camera): void;
  114591. }
  114592. }
  114593. declare module BABYLON {
  114594. /**
  114595. * Class containing static functions to help procedurally build meshes
  114596. */
  114597. export class GroundBuilder {
  114598. /**
  114599. * Creates a ground mesh
  114600. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  114601. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  114602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114603. * @param name defines the name of the mesh
  114604. * @param options defines the options used to create the mesh
  114605. * @param scene defines the hosting scene
  114606. * @returns the ground mesh
  114607. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  114608. */
  114609. static CreateGround(name: string, options: {
  114610. width?: number;
  114611. height?: number;
  114612. subdivisions?: number;
  114613. subdivisionsX?: number;
  114614. subdivisionsY?: number;
  114615. updatable?: boolean;
  114616. }, scene: any): Mesh;
  114617. /**
  114618. * Creates a tiled ground mesh
  114619. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  114620. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  114621. * * 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
  114622. * * 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
  114623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114624. * @param name defines the name of the mesh
  114625. * @param options defines the options used to create the mesh
  114626. * @param scene defines the hosting scene
  114627. * @returns the tiled ground mesh
  114628. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  114629. */
  114630. static CreateTiledGround(name: string, options: {
  114631. xmin: number;
  114632. zmin: number;
  114633. xmax: number;
  114634. zmax: number;
  114635. subdivisions?: {
  114636. w: number;
  114637. h: number;
  114638. };
  114639. precision?: {
  114640. w: number;
  114641. h: number;
  114642. };
  114643. updatable?: boolean;
  114644. }, scene?: Nullable<Scene>): Mesh;
  114645. /**
  114646. * Creates a ground mesh from a height map
  114647. * * The parameter `url` sets the URL of the height map image resource.
  114648. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  114649. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  114650. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  114651. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  114652. * * 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.
  114653. * * 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).
  114654. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114656. * @param name defines the name of the mesh
  114657. * @param url defines the url to the height map
  114658. * @param options defines the options used to create the mesh
  114659. * @param scene defines the hosting scene
  114660. * @returns the ground mesh
  114661. * @see https://doc.babylonjs.com/babylon101/height_map
  114662. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  114663. */
  114664. static CreateGroundFromHeightMap(name: string, url: string, options: {
  114665. width?: number;
  114666. height?: number;
  114667. subdivisions?: number;
  114668. minHeight?: number;
  114669. maxHeight?: number;
  114670. colorFilter?: Color3;
  114671. alphaFilter?: number;
  114672. updatable?: boolean;
  114673. onReady?: (mesh: GroundMesh) => void;
  114674. }, scene?: Nullable<Scene>): GroundMesh;
  114675. }
  114676. }
  114677. declare module BABYLON {
  114678. /**
  114679. * Class containing static functions to help procedurally build meshes
  114680. */
  114681. export class TorusBuilder {
  114682. /**
  114683. * Creates a torus mesh
  114684. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  114685. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  114686. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  114687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114690. * @param name defines the name of the mesh
  114691. * @param options defines the options used to create the mesh
  114692. * @param scene defines the hosting scene
  114693. * @returns the torus mesh
  114694. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  114695. */
  114696. static CreateTorus(name: string, options: {
  114697. diameter?: number;
  114698. thickness?: number;
  114699. tessellation?: number;
  114700. updatable?: boolean;
  114701. sideOrientation?: number;
  114702. frontUVs?: Vector4;
  114703. backUVs?: Vector4;
  114704. }, scene: any): Mesh;
  114705. }
  114706. }
  114707. declare module BABYLON {
  114708. /**
  114709. * Class containing static functions to help procedurally build meshes
  114710. */
  114711. export class CylinderBuilder {
  114712. /**
  114713. * Creates a cylinder or a cone mesh
  114714. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  114715. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  114716. * * 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.
  114717. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  114718. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  114719. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  114720. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  114721. * * 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).
  114722. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  114723. * * 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).
  114724. * * 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
  114725. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  114726. * * 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
  114727. * * 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.
  114728. * * If `enclose` is false, a ring surface is one element.
  114729. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  114730. * * 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
  114731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114734. * @param name defines the name of the mesh
  114735. * @param options defines the options used to create the mesh
  114736. * @param scene defines the hosting scene
  114737. * @returns the cylinder mesh
  114738. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  114739. */
  114740. static CreateCylinder(name: string, options: {
  114741. height?: number;
  114742. diameterTop?: number;
  114743. diameterBottom?: number;
  114744. diameter?: number;
  114745. tessellation?: number;
  114746. subdivisions?: number;
  114747. arc?: number;
  114748. faceColors?: Color4[];
  114749. faceUV?: Vector4[];
  114750. updatable?: boolean;
  114751. hasRings?: boolean;
  114752. enclose?: boolean;
  114753. cap?: number;
  114754. sideOrientation?: number;
  114755. frontUVs?: Vector4;
  114756. backUVs?: Vector4;
  114757. }, scene: any): Mesh;
  114758. }
  114759. }
  114760. declare module BABYLON {
  114761. /**
  114762. * States of the webXR experience
  114763. */
  114764. export enum WebXRState {
  114765. /**
  114766. * Transitioning to being in XR mode
  114767. */
  114768. ENTERING_XR = 0,
  114769. /**
  114770. * Transitioning to non XR mode
  114771. */
  114772. EXITING_XR = 1,
  114773. /**
  114774. * In XR mode and presenting
  114775. */
  114776. IN_XR = 2,
  114777. /**
  114778. * Not entered XR mode
  114779. */
  114780. NOT_IN_XR = 3
  114781. }
  114782. /**
  114783. * Abstraction of the XR render target
  114784. */
  114785. export interface WebXRRenderTarget extends IDisposable {
  114786. /**
  114787. * xrpresent context of the canvas which can be used to display/mirror xr content
  114788. */
  114789. canvasContext: WebGLRenderingContext;
  114790. /**
  114791. * xr layer for the canvas
  114792. */
  114793. xrLayer: Nullable<XRWebGLLayer>;
  114794. /**
  114795. * Initializes the xr layer for the session
  114796. * @param xrSession xr session
  114797. * @returns a promise that will resolve once the XR Layer has been created
  114798. */
  114799. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  114800. }
  114801. }
  114802. declare module BABYLON {
  114803. /**
  114804. * COnfiguration object for WebXR output canvas
  114805. */
  114806. export class WebXRManagedOutputCanvasOptions {
  114807. /**
  114808. * Options for this XR Layer output
  114809. */
  114810. canvasOptions: XRWebGLLayerOptions;
  114811. /**
  114812. * CSS styling for a newly created canvas (if not provided)
  114813. */
  114814. newCanvasCssStyle?: string;
  114815. /**
  114816. * Get the default values of the configuration object
  114817. * @returns default values of this configuration object
  114818. */
  114819. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  114820. }
  114821. /**
  114822. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  114823. */
  114824. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  114825. private configuration;
  114826. private _engine;
  114827. private _canvas;
  114828. /**
  114829. * xrpresent context of the canvas which can be used to display/mirror xr content
  114830. */
  114831. canvasContext: WebGLRenderingContext;
  114832. /**
  114833. * xr layer for the canvas
  114834. */
  114835. xrLayer: Nullable<XRWebGLLayer>;
  114836. /**
  114837. * Initializes the xr layer for the session
  114838. * @param xrSession xr session
  114839. * @returns a promise that will resolve once the XR Layer has been created
  114840. */
  114841. initializeXRLayerAsync(xrSession: any): any;
  114842. /**
  114843. * Initializes the canvas to be added/removed upon entering/exiting xr
  114844. * @param engine the Babylon engine
  114845. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  114846. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  114847. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  114848. */
  114849. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  114850. /**
  114851. * Disposes of the object
  114852. */
  114853. dispose(): void;
  114854. private _setManagedOutputCanvas;
  114855. private _addCanvas;
  114856. private _removeCanvas;
  114857. }
  114858. }
  114859. declare module BABYLON {
  114860. /**
  114861. * Manages an XRSession to work with Babylon's engine
  114862. * @see https://doc.babylonjs.com/how_to/webxr
  114863. */
  114864. export class WebXRSessionManager implements IDisposable {
  114865. /** The scene which the session should be created for */
  114866. scene: Scene;
  114867. /**
  114868. * Fires every time a new xrFrame arrives which can be used to update the camera
  114869. */
  114870. onXRFrameObservable: Observable<XRFrame>;
  114871. /**
  114872. * Fires when the xr session is ended either by the device or manually done
  114873. */
  114874. onXRSessionEnded: Observable<any>;
  114875. /**
  114876. * Fires when the xr session is ended either by the device or manually done
  114877. */
  114878. onXRSessionInit: Observable<XRSession>;
  114879. /**
  114880. * Fires when the reference space changed
  114881. */
  114882. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  114883. /**
  114884. * Underlying xr session
  114885. */
  114886. session: XRSession;
  114887. /**
  114888. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  114889. * or get the offset the player is currently at.
  114890. */
  114891. viewerReferenceSpace: XRReferenceSpace;
  114892. private _referenceSpace;
  114893. /**
  114894. * The current reference space used in this session. This reference space can constantly change!
  114895. * It is mainly used to offset the camera's position.
  114896. */
  114897. get referenceSpace(): XRReferenceSpace;
  114898. /**
  114899. * Set a new reference space and triggers the observable
  114900. */
  114901. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  114902. /**
  114903. * The base reference space from which the session started. good if you want to reset your
  114904. * reference space
  114905. */
  114906. baseReferenceSpace: XRReferenceSpace;
  114907. /**
  114908. * Used just in case of a failure to initialize an immersive session.
  114909. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  114910. */
  114911. defaultHeightCompensation: number;
  114912. /**
  114913. * Current XR frame
  114914. */
  114915. currentFrame: Nullable<XRFrame>;
  114916. /** WebXR timestamp updated every frame */
  114917. currentTimestamp: number;
  114918. private _xrNavigator;
  114919. private baseLayer;
  114920. private _rttProvider;
  114921. private _sessionEnded;
  114922. /**
  114923. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  114924. * @param scene The scene which the session should be created for
  114925. */
  114926. constructor(
  114927. /** The scene which the session should be created for */
  114928. scene: Scene);
  114929. /**
  114930. * Initializes the manager
  114931. * After initialization enterXR can be called to start an XR session
  114932. * @returns Promise which resolves after it is initialized
  114933. */
  114934. initializeAsync(): Promise<void>;
  114935. /**
  114936. * Initializes an xr session
  114937. * @param xrSessionMode mode to initialize
  114938. * @param optionalFeatures defines optional values to pass to the session builder
  114939. * @returns a promise which will resolve once the session has been initialized
  114940. */
  114941. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  114942. /**
  114943. * Sets the reference space on the xr session
  114944. * @param referenceSpace space to set
  114945. * @returns a promise that will resolve once the reference space has been set
  114946. */
  114947. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  114948. /**
  114949. * Updates the render state of the session
  114950. * @param state state to set
  114951. * @returns a promise that resolves once the render state has been updated
  114952. */
  114953. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  114954. /**
  114955. * Starts rendering to the xr layer
  114956. * @returns a promise that will resolve once rendering has started
  114957. */
  114958. startRenderingToXRAsync(): Promise<void>;
  114959. /**
  114960. * Gets the correct render target texture to be rendered this frame for this eye
  114961. * @param eye the eye for which to get the render target
  114962. * @returns the render target for the specified eye
  114963. */
  114964. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  114965. /**
  114966. * Stops the xrSession and restores the renderloop
  114967. * @returns Promise which resolves after it exits XR
  114968. */
  114969. exitXRAsync(): Promise<void>;
  114970. /**
  114971. * Checks if a session would be supported for the creation options specified
  114972. * @param sessionMode session mode to check if supported eg. immersive-vr
  114973. * @returns true if supported
  114974. */
  114975. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  114976. /**
  114977. * Creates a WebXRRenderTarget object for the XR session
  114978. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  114979. * @param options optional options to provide when creating a new render target
  114980. * @returns a WebXR render target to which the session can render
  114981. */
  114982. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  114983. /**
  114984. * @hidden
  114985. * Converts the render layer of xrSession to a render target
  114986. * @param session session to create render target for
  114987. * @param scene scene the new render target should be created for
  114988. * @param baseLayer the webgl layer to create the render target for
  114989. */
  114990. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  114991. /**
  114992. * Disposes of the session manager
  114993. */
  114994. dispose(): void;
  114995. /**
  114996. * Gets a promise returning true when fullfiled if the given session mode is supported
  114997. * @param sessionMode defines the session to test
  114998. * @returns a promise
  114999. */
  115000. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115001. }
  115002. }
  115003. declare module BABYLON {
  115004. /**
  115005. * WebXR Camera which holds the views for the xrSession
  115006. * @see https://doc.babylonjs.com/how_to/webxr
  115007. */
  115008. export class WebXRCamera extends FreeCamera {
  115009. private _xrSessionManager;
  115010. /**
  115011. * Is the camera in debug mode. Used when using an emulator
  115012. */
  115013. debugMode: boolean;
  115014. private _firstFrame;
  115015. private _referencedPosition;
  115016. private _referenceQuaternion;
  115017. private _xrInvPositionCache;
  115018. private _xrInvQuaternionCache;
  115019. /**
  115020. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115021. * @param name the name of the camera
  115022. * @param scene the scene to add the camera to
  115023. */
  115024. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115025. private _updateNumberOfRigCameras;
  115026. /** @hidden */
  115027. _updateForDualEyeDebugging(): void;
  115028. private _updateReferenceSpace;
  115029. private _updateReferenceSpaceOffset;
  115030. private _updateFromXRSession;
  115031. }
  115032. }
  115033. declare module BABYLON {
  115034. /**
  115035. * Defining the interface required for a (webxr) feature
  115036. */
  115037. export interface IWebXRFeature extends IDisposable {
  115038. /**
  115039. * Is this feature attached
  115040. */
  115041. attached: boolean;
  115042. /**
  115043. * Attach the feature to the session
  115044. * Will usually be called by the features manager
  115045. *
  115046. * @returns true if successful.
  115047. */
  115048. attach(): boolean;
  115049. /**
  115050. * Detach the feature from the session
  115051. * Will usually be called by the features manager
  115052. *
  115053. * @returns true if successful.
  115054. */
  115055. detach(): boolean;
  115056. }
  115057. /**
  115058. * Defining the constructor of a feature. Used to register the modules.
  115059. */
  115060. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  115061. /**
  115062. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  115063. * It is mainly used in AR sessions.
  115064. *
  115065. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  115066. */
  115067. export class WebXRFeaturesManager implements IDisposable {
  115068. private _xrSessionManager;
  115069. private static readonly _AvailableFeatures;
  115070. /**
  115071. * Used to register a module. After calling this function a developer can use this feature in the scene.
  115072. * Mainly used internally.
  115073. *
  115074. * @param featureName the name of the feature to register
  115075. * @param constructorFunction the function used to construct the module
  115076. * @param version the (babylon) version of the module
  115077. * @param stable is that a stable version of this module
  115078. */
  115079. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  115080. /**
  115081. * Returns a constructor of a specific feature.
  115082. *
  115083. * @param featureName the name of the feature to construct
  115084. * @param version the version of the feature to load
  115085. * @param xrSessionManager the xrSessionManager. Used to construct the module
  115086. * @param options optional options provided to the module.
  115087. * @returns a function that, when called, will return a new instance of this feature
  115088. */
  115089. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  115090. /**
  115091. * Return the latest unstable version of this feature
  115092. * @param featureName the name of the feature to search
  115093. * @returns the version number. if not found will return -1
  115094. */
  115095. static GetLatestVersionOfFeature(featureName: string): number;
  115096. /**
  115097. * Return the latest stable version of this feature
  115098. * @param featureName the name of the feature to search
  115099. * @returns the version number. if not found will return -1
  115100. */
  115101. static GetStableVersionOfFeature(featureName: string): number;
  115102. /**
  115103. * Can be used to return the list of features currently registered
  115104. *
  115105. * @returns an Array of available features
  115106. */
  115107. static GetAvailableFeatures(): string[];
  115108. /**
  115109. * Gets the versions available for a specific feature
  115110. * @param featureName the name of the feature
  115111. * @returns an array with the available versions
  115112. */
  115113. static GetAvailableVersions(featureName: string): string[];
  115114. private _features;
  115115. /**
  115116. * constructs a new features manages.
  115117. *
  115118. * @param _xrSessionManager an instance of WebXRSessionManager
  115119. */
  115120. constructor(_xrSessionManager: WebXRSessionManager);
  115121. /**
  115122. * 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.
  115123. *
  115124. * @param featureName the name of the feature to load or the class of the feature
  115125. * @param version optional version to load. if not provided the latest version will be enabled
  115126. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  115127. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  115128. * @returns a new constructed feature or throws an error if feature not found.
  115129. */
  115130. enableFeature(featureName: string | {
  115131. Name: string;
  115132. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  115133. /**
  115134. * Used to disable an already-enabled feature
  115135. * @param featureName the feature to disable
  115136. * @returns true if disable was successful
  115137. */
  115138. disableFeature(featureName: string | {
  115139. Name: string;
  115140. }): boolean;
  115141. /**
  115142. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  115143. * Can be used during a session to start a feature
  115144. * @param featureName the name of feature to attach
  115145. */
  115146. attachFeature(featureName: string): void;
  115147. /**
  115148. * Can be used inside a session or when the session ends to detach a specific feature
  115149. * @param featureName the name of the feature to detach
  115150. */
  115151. detachFeature(featureName: string): void;
  115152. /**
  115153. * Get the list of enabled features
  115154. * @returns an array of enabled features
  115155. */
  115156. getEnabledFeatures(): string[];
  115157. /**
  115158. * get the implementation of an enabled feature.
  115159. * @param featureName the name of the feature to load
  115160. * @returns the feature class, if found
  115161. */
  115162. getEnabledFeature(featureName: string): IWebXRFeature;
  115163. /**
  115164. * dispose this features manager
  115165. */
  115166. dispose(): void;
  115167. }
  115168. }
  115169. declare module BABYLON {
  115170. /**
  115171. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  115172. * @see https://doc.babylonjs.com/how_to/webxr
  115173. */
  115174. export class WebXRExperienceHelper implements IDisposable {
  115175. private scene;
  115176. /**
  115177. * Camera used to render xr content
  115178. */
  115179. camera: WebXRCamera;
  115180. /**
  115181. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  115182. */
  115183. state: WebXRState;
  115184. private _setState;
  115185. /**
  115186. * Fires when the state of the experience helper has changed
  115187. */
  115188. onStateChangedObservable: Observable<WebXRState>;
  115189. /**
  115190. * Observers registered here will be triggered after the camera's initial transformation is set
  115191. * This can be used to set a different ground level or an extra rotation.
  115192. *
  115193. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  115194. * to the position set after this observable is done executing.
  115195. */
  115196. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  115197. /** Session manager used to keep track of xr session */
  115198. sessionManager: WebXRSessionManager;
  115199. /** A features manager for this xr session */
  115200. featuresManager: WebXRFeaturesManager;
  115201. private _nonVRCamera;
  115202. private _originalSceneAutoClear;
  115203. private _supported;
  115204. /**
  115205. * Creates the experience helper
  115206. * @param scene the scene to attach the experience helper to
  115207. * @returns a promise for the experience helper
  115208. */
  115209. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  115210. /**
  115211. * Creates a WebXRExperienceHelper
  115212. * @param scene The scene the helper should be created in
  115213. */
  115214. private constructor();
  115215. /**
  115216. * Exits XR mode and returns the scene to its original state
  115217. * @returns promise that resolves after xr mode has exited
  115218. */
  115219. exitXRAsync(): Promise<void>;
  115220. /**
  115221. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  115222. * @param sessionMode options for the XR session
  115223. * @param referenceSpaceType frame of reference of the XR session
  115224. * @param renderTarget the output canvas that will be used to enter XR mode
  115225. * @returns promise that resolves after xr mode has entered
  115226. */
  115227. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  115228. /**
  115229. * Disposes of the experience helper
  115230. */
  115231. dispose(): void;
  115232. private _nonXRToXRCamera;
  115233. }
  115234. }
  115235. declare module BABYLON {
  115236. /**
  115237. * X-Y values for axes in WebXR
  115238. */
  115239. export interface IWebXRMotionControllerAxesValue {
  115240. /**
  115241. * The value of the x axis
  115242. */
  115243. x: number;
  115244. /**
  115245. * The value of the y-axis
  115246. */
  115247. y: number;
  115248. }
  115249. /**
  115250. * changed / previous values for the values of this component
  115251. */
  115252. export interface IWebXRMotionControllerComponentChangesValues<T> {
  115253. /**
  115254. * current (this frame) value
  115255. */
  115256. current: T;
  115257. /**
  115258. * previous (last change) value
  115259. */
  115260. previous: T;
  115261. }
  115262. /**
  115263. * Represents changes in the component between current frame and last values recorded
  115264. */
  115265. export interface IWebXRMotionControllerComponentChanges {
  115266. /**
  115267. * will be populated with previous and current values if touched changed
  115268. */
  115269. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115270. /**
  115271. * will be populated with previous and current values if pressed changed
  115272. */
  115273. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115274. /**
  115275. * will be populated with previous and current values if value changed
  115276. */
  115277. value?: IWebXRMotionControllerComponentChangesValues<number>;
  115278. /**
  115279. * will be populated with previous and current values if axes changed
  115280. */
  115281. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  115282. }
  115283. /**
  115284. * This class represents a single component (for example button or thumbstick) of a motion controller
  115285. */
  115286. export class WebXRControllerComponent implements IDisposable {
  115287. /**
  115288. * the id of this component
  115289. */
  115290. id: string;
  115291. /**
  115292. * the type of the component
  115293. */
  115294. type: MotionControllerComponentType;
  115295. private _buttonIndex;
  115296. private _axesIndices;
  115297. /**
  115298. * Thumbstick component type
  115299. */
  115300. static THUMBSTICK: string;
  115301. /**
  115302. * Touchpad component type
  115303. */
  115304. static TOUCHPAD: string;
  115305. /**
  115306. * trigger component type
  115307. */
  115308. static TRIGGER: string;
  115309. /**
  115310. * squeeze component type
  115311. */
  115312. static SQUEEZE: string;
  115313. /**
  115314. * Observers registered here will be triggered when the state of a button changes
  115315. * State change is either pressed / touched / value
  115316. */
  115317. onButtonStateChanged: Observable<WebXRControllerComponent>;
  115318. /**
  115319. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  115320. * the axes data changes
  115321. */
  115322. onAxisValueChanged: Observable<{
  115323. x: number;
  115324. y: number;
  115325. }>;
  115326. private _currentValue;
  115327. private _touched;
  115328. private _pressed;
  115329. private _axes;
  115330. private _changes;
  115331. /**
  115332. * Creates a new component for a motion controller.
  115333. * It is created by the motion controller itself
  115334. *
  115335. * @param id the id of this component
  115336. * @param type the type of the component
  115337. * @param _buttonIndex index in the buttons array of the gamepad
  115338. * @param _axesIndices indices of the values in the axes array of the gamepad
  115339. */
  115340. constructor(
  115341. /**
  115342. * the id of this component
  115343. */
  115344. id: string,
  115345. /**
  115346. * the type of the component
  115347. */
  115348. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  115349. /**
  115350. * Get the current value of this component
  115351. */
  115352. get value(): number;
  115353. /**
  115354. * is the button currently pressed
  115355. */
  115356. get pressed(): boolean;
  115357. /**
  115358. * is the button currently touched
  115359. */
  115360. get touched(): boolean;
  115361. /**
  115362. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  115363. */
  115364. get axes(): IWebXRMotionControllerAxesValue;
  115365. /**
  115366. * Get the changes. Elements will be populated only if they changed with their previous and current value
  115367. */
  115368. get changes(): IWebXRMotionControllerComponentChanges;
  115369. /**
  115370. * Is this component a button (hence - pressable)
  115371. * @returns true if can be pressed
  115372. */
  115373. isButton(): boolean;
  115374. /**
  115375. * Are there axes correlating to this component
  115376. * @return true is axes data is available
  115377. */
  115378. isAxes(): boolean;
  115379. /**
  115380. * update this component using the gamepad object it is in. Called on every frame
  115381. * @param nativeController the native gamepad controller object
  115382. */
  115383. update(nativeController: IMinimalMotionControllerObject): void;
  115384. /**
  115385. * Dispose this component
  115386. */
  115387. dispose(): void;
  115388. }
  115389. }
  115390. declare module BABYLON {
  115391. /**
  115392. * Class used to represent data loading progression
  115393. */
  115394. export class SceneLoaderProgressEvent {
  115395. /** defines if data length to load can be evaluated */
  115396. readonly lengthComputable: boolean;
  115397. /** defines the loaded data length */
  115398. readonly loaded: number;
  115399. /** defines the data length to load */
  115400. readonly total: number;
  115401. /**
  115402. * Create a new progress event
  115403. * @param lengthComputable defines if data length to load can be evaluated
  115404. * @param loaded defines the loaded data length
  115405. * @param total defines the data length to load
  115406. */
  115407. constructor(
  115408. /** defines if data length to load can be evaluated */
  115409. lengthComputable: boolean,
  115410. /** defines the loaded data length */
  115411. loaded: number,
  115412. /** defines the data length to load */
  115413. total: number);
  115414. /**
  115415. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  115416. * @param event defines the source event
  115417. * @returns a new SceneLoaderProgressEvent
  115418. */
  115419. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  115420. }
  115421. /**
  115422. * Interface used by SceneLoader plugins to define supported file extensions
  115423. */
  115424. export interface ISceneLoaderPluginExtensions {
  115425. /**
  115426. * Defines the list of supported extensions
  115427. */
  115428. [extension: string]: {
  115429. isBinary: boolean;
  115430. };
  115431. }
  115432. /**
  115433. * Interface used by SceneLoader plugin factory
  115434. */
  115435. export interface ISceneLoaderPluginFactory {
  115436. /**
  115437. * Defines the name of the factory
  115438. */
  115439. name: string;
  115440. /**
  115441. * Function called to create a new plugin
  115442. * @return the new plugin
  115443. */
  115444. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  115445. /**
  115446. * The callback that returns true if the data can be directly loaded.
  115447. * @param data string containing the file data
  115448. * @returns if the data can be loaded directly
  115449. */
  115450. canDirectLoad?(data: string): boolean;
  115451. }
  115452. /**
  115453. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  115454. */
  115455. export interface ISceneLoaderPluginBase {
  115456. /**
  115457. * The friendly name of this plugin.
  115458. */
  115459. name: string;
  115460. /**
  115461. * The file extensions supported by this plugin.
  115462. */
  115463. extensions: string | ISceneLoaderPluginExtensions;
  115464. /**
  115465. * The callback called when loading from a url.
  115466. * @param scene scene loading this url
  115467. * @param url url to load
  115468. * @param onSuccess callback called when the file successfully loads
  115469. * @param onProgress callback called while file is loading (if the server supports this mode)
  115470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115471. * @param onError callback called when the file fails to load
  115472. * @returns a file request object
  115473. */
  115474. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  115475. /**
  115476. * The callback called when loading from a file object.
  115477. * @param scene scene loading this file
  115478. * @param file defines the file to load
  115479. * @param onSuccess defines the callback to call when data is loaded
  115480. * @param onProgress defines the callback to call during loading process
  115481. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115482. * @param onError defines the callback to call when an error occurs
  115483. * @returns a file request object
  115484. */
  115485. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  115486. /**
  115487. * The callback that returns true if the data can be directly loaded.
  115488. * @param data string containing the file data
  115489. * @returns if the data can be loaded directly
  115490. */
  115491. canDirectLoad?(data: string): boolean;
  115492. /**
  115493. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  115494. * @param scene scene loading this data
  115495. * @param data string containing the data
  115496. * @returns data to pass to the plugin
  115497. */
  115498. directLoad?(scene: Scene, data: string): any;
  115499. /**
  115500. * The callback that allows custom handling of the root url based on the response url.
  115501. * @param rootUrl the original root url
  115502. * @param responseURL the response url if available
  115503. * @returns the new root url
  115504. */
  115505. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  115506. }
  115507. /**
  115508. * Interface used to define a SceneLoader plugin
  115509. */
  115510. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  115511. /**
  115512. * Import meshes into a scene.
  115513. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115514. * @param scene The scene to import into
  115515. * @param data The data to import
  115516. * @param rootUrl The root url for scene and resources
  115517. * @param meshes The meshes array to import into
  115518. * @param particleSystems The particle systems array to import into
  115519. * @param skeletons The skeletons array to import into
  115520. * @param onError The callback when import fails
  115521. * @returns True if successful or false otherwise
  115522. */
  115523. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  115524. /**
  115525. * Load into a scene.
  115526. * @param scene The scene to load into
  115527. * @param data The data to import
  115528. * @param rootUrl The root url for scene and resources
  115529. * @param onError The callback when import fails
  115530. * @returns True if successful or false otherwise
  115531. */
  115532. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  115533. /**
  115534. * Load into an asset container.
  115535. * @param scene The scene to load into
  115536. * @param data The data to import
  115537. * @param rootUrl The root url for scene and resources
  115538. * @param onError The callback when import fails
  115539. * @returns The loaded asset container
  115540. */
  115541. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  115542. }
  115543. /**
  115544. * Interface used to define an async SceneLoader plugin
  115545. */
  115546. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  115547. /**
  115548. * Import meshes into a scene.
  115549. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115550. * @param scene The scene to import into
  115551. * @param data The data to import
  115552. * @param rootUrl The root url for scene and resources
  115553. * @param onProgress The callback when the load progresses
  115554. * @param fileName Defines the name of the file to load
  115555. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  115556. */
  115557. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  115558. meshes: AbstractMesh[];
  115559. particleSystems: IParticleSystem[];
  115560. skeletons: Skeleton[];
  115561. animationGroups: AnimationGroup[];
  115562. }>;
  115563. /**
  115564. * Load into a scene.
  115565. * @param scene The scene to load into
  115566. * @param data The data to import
  115567. * @param rootUrl The root url for scene and resources
  115568. * @param onProgress The callback when the load progresses
  115569. * @param fileName Defines the name of the file to load
  115570. * @returns Nothing
  115571. */
  115572. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  115573. /**
  115574. * Load into an asset container.
  115575. * @param scene The scene to load into
  115576. * @param data The data to import
  115577. * @param rootUrl The root url for scene and resources
  115578. * @param onProgress The callback when the load progresses
  115579. * @param fileName Defines the name of the file to load
  115580. * @returns The loaded asset container
  115581. */
  115582. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  115583. }
  115584. /**
  115585. * Mode that determines how to handle old animation groups before loading new ones.
  115586. */
  115587. export enum SceneLoaderAnimationGroupLoadingMode {
  115588. /**
  115589. * Reset all old animations to initial state then dispose them.
  115590. */
  115591. Clean = 0,
  115592. /**
  115593. * Stop all old animations.
  115594. */
  115595. Stop = 1,
  115596. /**
  115597. * Restart old animations from first frame.
  115598. */
  115599. Sync = 2,
  115600. /**
  115601. * Old animations remains untouched.
  115602. */
  115603. NoSync = 3
  115604. }
  115605. /**
  115606. * Class used to load scene from various file formats using registered plugins
  115607. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  115608. */
  115609. export class SceneLoader {
  115610. /**
  115611. * No logging while loading
  115612. */
  115613. static readonly NO_LOGGING: number;
  115614. /**
  115615. * Minimal logging while loading
  115616. */
  115617. static readonly MINIMAL_LOGGING: number;
  115618. /**
  115619. * Summary logging while loading
  115620. */
  115621. static readonly SUMMARY_LOGGING: number;
  115622. /**
  115623. * Detailled logging while loading
  115624. */
  115625. static readonly DETAILED_LOGGING: number;
  115626. /**
  115627. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  115628. */
  115629. static get ForceFullSceneLoadingForIncremental(): boolean;
  115630. static set ForceFullSceneLoadingForIncremental(value: boolean);
  115631. /**
  115632. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  115633. */
  115634. static get ShowLoadingScreen(): boolean;
  115635. static set ShowLoadingScreen(value: boolean);
  115636. /**
  115637. * Defines the current logging level (while loading the scene)
  115638. * @ignorenaming
  115639. */
  115640. static get loggingLevel(): number;
  115641. static set loggingLevel(value: number);
  115642. /**
  115643. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  115644. */
  115645. static get CleanBoneMatrixWeights(): boolean;
  115646. static set CleanBoneMatrixWeights(value: boolean);
  115647. /**
  115648. * Event raised when a plugin is used to load a scene
  115649. */
  115650. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  115651. private static _registeredPlugins;
  115652. private static _getDefaultPlugin;
  115653. private static _getPluginForExtension;
  115654. private static _getPluginForDirectLoad;
  115655. private static _getPluginForFilename;
  115656. private static _getDirectLoad;
  115657. private static _loadData;
  115658. private static _getFileInfo;
  115659. /**
  115660. * Gets a plugin that can load the given extension
  115661. * @param extension defines the extension to load
  115662. * @returns a plugin or null if none works
  115663. */
  115664. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  115665. /**
  115666. * Gets a boolean indicating that the given extension can be loaded
  115667. * @param extension defines the extension to load
  115668. * @returns true if the extension is supported
  115669. */
  115670. static IsPluginForExtensionAvailable(extension: string): boolean;
  115671. /**
  115672. * Adds a new plugin to the list of registered plugins
  115673. * @param plugin defines the plugin to add
  115674. */
  115675. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  115676. /**
  115677. * Import meshes into a scene
  115678. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115679. * @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)
  115680. * @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)
  115681. * @param scene the instance of BABYLON.Scene to append to
  115682. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  115683. * @param onProgress a callback with a progress event for each file being loaded
  115684. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115685. * @param pluginExtension the extension used to determine the plugin
  115686. * @returns The loaded plugin
  115687. */
  115688. 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>;
  115689. /**
  115690. * Import meshes into a scene
  115691. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115692. * @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)
  115693. * @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)
  115694. * @param scene the instance of BABYLON.Scene to append to
  115695. * @param onProgress a callback with a progress event for each file being loaded
  115696. * @param pluginExtension the extension used to determine the plugin
  115697. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  115698. */
  115699. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  115700. meshes: AbstractMesh[];
  115701. particleSystems: IParticleSystem[];
  115702. skeletons: Skeleton[];
  115703. animationGroups: AnimationGroup[];
  115704. }>;
  115705. /**
  115706. * Load a scene
  115707. * @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)
  115708. * @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)
  115709. * @param engine is the instance of BABYLON.Engine to use to create the scene
  115710. * @param onSuccess a callback with the scene when import succeeds
  115711. * @param onProgress a callback with a progress event for each file being loaded
  115712. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115713. * @param pluginExtension the extension used to determine the plugin
  115714. * @returns The loaded plugin
  115715. */
  115716. 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>;
  115717. /**
  115718. * Load a scene
  115719. * @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)
  115720. * @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)
  115721. * @param engine is the instance of BABYLON.Engine to use to create the scene
  115722. * @param onProgress a callback with a progress event for each file being loaded
  115723. * @param pluginExtension the extension used to determine the plugin
  115724. * @returns The loaded scene
  115725. */
  115726. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  115727. /**
  115728. * Append a scene
  115729. * @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)
  115730. * @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)
  115731. * @param scene is the instance of BABYLON.Scene to append to
  115732. * @param onSuccess a callback with the scene when import succeeds
  115733. * @param onProgress a callback with a progress event for each file being loaded
  115734. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115735. * @param pluginExtension the extension used to determine the plugin
  115736. * @returns The loaded plugin
  115737. */
  115738. 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>;
  115739. /**
  115740. * Append a scene
  115741. * @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)
  115742. * @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)
  115743. * @param scene is the instance of BABYLON.Scene to append to
  115744. * @param onProgress a callback with a progress event for each file being loaded
  115745. * @param pluginExtension the extension used to determine the plugin
  115746. * @returns The given scene
  115747. */
  115748. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  115749. /**
  115750. * Load a scene into an asset container
  115751. * @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)
  115752. * @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)
  115753. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115754. * @param onSuccess a callback with the scene when import succeeds
  115755. * @param onProgress a callback with a progress event for each file being loaded
  115756. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115757. * @param pluginExtension the extension used to determine the plugin
  115758. * @returns The loaded plugin
  115759. */
  115760. 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>;
  115761. /**
  115762. * Load a scene into an asset container
  115763. * @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)
  115764. * @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)
  115765. * @param scene is the instance of Scene to append to
  115766. * @param onProgress a callback with a progress event for each file being loaded
  115767. * @param pluginExtension the extension used to determine the plugin
  115768. * @returns The loaded asset container
  115769. */
  115770. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  115771. /**
  115772. * Import animations from a file into a scene
  115773. * @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)
  115774. * @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)
  115775. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115776. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  115777. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  115778. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  115779. * @param onSuccess a callback with the scene when import succeeds
  115780. * @param onProgress a callback with a progress event for each file being loaded
  115781. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115782. */
  115783. 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;
  115784. /**
  115785. * Import animations from a file into a scene
  115786. * @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)
  115787. * @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)
  115788. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115789. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  115790. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  115791. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  115792. * @param onSuccess a callback with the scene when import succeeds
  115793. * @param onProgress a callback with a progress event for each file being loaded
  115794. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115795. * @returns the updated scene with imported animations
  115796. */
  115797. 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>;
  115798. }
  115799. }
  115800. declare module BABYLON {
  115801. /**
  115802. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  115803. */
  115804. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  115805. /**
  115806. * The type of components available in motion controllers.
  115807. * This is not the name of the component.
  115808. */
  115809. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  115810. /**
  115811. * The schema of motion controller layout.
  115812. * No object will be initialized using this interface
  115813. * This is used just to define the profile.
  115814. */
  115815. export interface IMotionControllerLayout {
  115816. /**
  115817. * Defines the main button component id
  115818. */
  115819. selectComponentId: string;
  115820. /**
  115821. * Available components (unsorted)
  115822. */
  115823. components: {
  115824. /**
  115825. * A map of component Ids
  115826. */
  115827. [componentId: string]: {
  115828. /**
  115829. * The type of input the component outputs
  115830. */
  115831. type: MotionControllerComponentType;
  115832. };
  115833. };
  115834. /**
  115835. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  115836. */
  115837. gamepad?: {
  115838. /**
  115839. * Is the mapping based on the xr-standard defined here:
  115840. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  115841. */
  115842. mapping: "" | "xr-standard";
  115843. /**
  115844. * The buttons available in this input in the right order
  115845. * index of this button will be the index in the gamepadObject.buttons array
  115846. * correlates to the componentId in components
  115847. */
  115848. buttons: Array<string | null>;
  115849. /**
  115850. * Definition of the axes of the gamepad input, sorted
  115851. * Correlates to componentIds in the components map
  115852. */
  115853. axes: Array<{
  115854. /**
  115855. * The component id that the axis correlates to
  115856. */
  115857. componentId: string;
  115858. /**
  115859. * X or Y Axis
  115860. */
  115861. axis: "x-axis" | "y-axis";
  115862. } | null>;
  115863. };
  115864. }
  115865. /**
  115866. * A definition for the layout map in the input profile
  115867. */
  115868. export interface IMotionControllerLayoutMap {
  115869. /**
  115870. * Layouts with handness type as a key
  115871. */
  115872. [handness: string]: IMotionControllerLayout;
  115873. }
  115874. /**
  115875. * The XR Input profile schema
  115876. * Profiles can be found here:
  115877. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  115878. */
  115879. export interface IMotionControllerProfile {
  115880. /**
  115881. * The id of this profile
  115882. * correlates to the profile(s) in the xrInput.profiles array
  115883. */
  115884. profileId: string;
  115885. /**
  115886. * fallback profiles for this profileId
  115887. */
  115888. fallbackProfileIds: string[];
  115889. /**
  115890. * The layout map, with handness as key
  115891. */
  115892. layouts: IMotionControllerLayoutMap;
  115893. }
  115894. /**
  115895. * A helper-interface for the 3 meshes needed for controller button animation
  115896. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  115897. */
  115898. export interface IMotionControllerButtonMeshMap {
  115899. /**
  115900. * The mesh that will be changed when value changes
  115901. */
  115902. valueMesh: AbstractMesh;
  115903. /**
  115904. * the mesh that defines the pressed value mesh position.
  115905. * This is used to find the max-position of this button
  115906. */
  115907. pressedMesh: AbstractMesh;
  115908. /**
  115909. * the mesh that defines the unpressed value mesh position.
  115910. * This is used to find the min (or initial) position of this button
  115911. */
  115912. unpressedMesh: AbstractMesh;
  115913. }
  115914. /**
  115915. * A helper-interface for the 3 meshes needed for controller axis animation.
  115916. * This will be expanded when touchpad animations are fully supported
  115917. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  115918. */
  115919. export interface IMotionControllerAxisMeshMap {
  115920. /**
  115921. * The mesh that will be changed when axis value changes
  115922. */
  115923. valueMesh: AbstractMesh;
  115924. /**
  115925. * the mesh that defines the minimum value mesh position.
  115926. */
  115927. minMesh: AbstractMesh;
  115928. /**
  115929. * the mesh that defines the maximum value mesh position.
  115930. */
  115931. maxMesh: AbstractMesh;
  115932. }
  115933. /**
  115934. * The elements needed for change-detection of the gamepad objects in motion controllers
  115935. */
  115936. export interface IMinimalMotionControllerObject {
  115937. /**
  115938. * An array of available buttons
  115939. */
  115940. buttons: Array<{
  115941. /**
  115942. * Value of the button/trigger
  115943. */
  115944. value: number;
  115945. /**
  115946. * If the button/trigger is currently touched
  115947. */
  115948. touched: boolean;
  115949. /**
  115950. * If the button/trigger is currently pressed
  115951. */
  115952. pressed: boolean;
  115953. }>;
  115954. /**
  115955. * Available axes of this controller
  115956. */
  115957. axes: number[];
  115958. }
  115959. /**
  115960. * An Abstract Motion controller
  115961. * This class receives an xrInput and a profile layout and uses those to initialize the components
  115962. * Each component has an observable to check for changes in value and state
  115963. */
  115964. export abstract class WebXRAbstractMotionController implements IDisposable {
  115965. protected scene: Scene;
  115966. protected layout: IMotionControllerLayout;
  115967. /**
  115968. * The gamepad object correlating to this controller
  115969. */
  115970. gamepadObject: IMinimalMotionControllerObject;
  115971. /**
  115972. * handness (left/right/none) of this controller
  115973. */
  115974. handness: MotionControllerHandness;
  115975. /**
  115976. * Component type map
  115977. */
  115978. static ComponentType: {
  115979. TRIGGER: string;
  115980. SQUEEZE: string;
  115981. TOUCHPAD: string;
  115982. THUMBSTICK: string;
  115983. BUTTON: string;
  115984. };
  115985. /**
  115986. * The profile id of this motion controller
  115987. */
  115988. abstract profileId: string;
  115989. /**
  115990. * A map of components (WebXRControllerComponent) in this motion controller
  115991. * Components have a ComponentType and can also have both button and axis definitions
  115992. */
  115993. readonly components: {
  115994. [id: string]: WebXRControllerComponent;
  115995. };
  115996. /**
  115997. * Observers registered here will be triggered when the model of this controller is done loading
  115998. */
  115999. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  116000. /**
  116001. * The root mesh of the model. It is null if the model was not yet initialized
  116002. */
  116003. rootMesh: Nullable<AbstractMesh>;
  116004. private _modelReady;
  116005. /**
  116006. * constructs a new abstract motion controller
  116007. * @param scene the scene to which the model of the controller will be added
  116008. * @param layout The profile layout to load
  116009. * @param gamepadObject The gamepad object correlating to this controller
  116010. * @param handness handness (left/right/none) of this controller
  116011. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  116012. */
  116013. constructor(scene: Scene, layout: IMotionControllerLayout,
  116014. /**
  116015. * The gamepad object correlating to this controller
  116016. */
  116017. gamepadObject: IMinimalMotionControllerObject,
  116018. /**
  116019. * handness (left/right/none) of this controller
  116020. */
  116021. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  116022. private _initComponent;
  116023. /**
  116024. * Update this model using the current XRFrame
  116025. * @param xrFrame the current xr frame to use and update the model
  116026. */
  116027. updateFromXRFrame(xrFrame: XRFrame): void;
  116028. /**
  116029. * Get the list of components available in this motion controller
  116030. * @returns an array of strings correlating to available components
  116031. */
  116032. getComponentTypes(): string[];
  116033. /**
  116034. * Get the main (Select) component of this controller as defined in the layout
  116035. * @returns the main component of this controller
  116036. */
  116037. getMainComponent(): WebXRControllerComponent;
  116038. /**
  116039. * get a component based an its component id as defined in layout.components
  116040. * @param id the id of the component
  116041. * @returns the component correlates to the id or undefined if not found
  116042. */
  116043. getComponent(id: string): WebXRControllerComponent;
  116044. /**
  116045. * Loads the model correlating to this controller
  116046. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  116047. * @returns A promise fulfilled with the result of the model loading
  116048. */
  116049. loadModel(): Promise<boolean>;
  116050. /**
  116051. * Update the model itself with the current frame data
  116052. * @param xrFrame the frame to use for updating the model mesh
  116053. */
  116054. protected updateModel(xrFrame: XRFrame): void;
  116055. /**
  116056. * Moves the axis on the controller mesh based on its current state
  116057. * @param axis the index of the axis
  116058. * @param axisValue the value of the axis which determines the meshes new position
  116059. * @hidden
  116060. */
  116061. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  116062. /**
  116063. * Moves the buttons on the controller mesh based on their current state
  116064. * @param buttonName the name of the button to move
  116065. * @param buttonValue the value of the button which determines the buttons new position
  116066. */
  116067. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  116068. private _getGenericFilenameAndPath;
  116069. private _getGenericParentMesh;
  116070. /**
  116071. * Get the filename and path for this controller's model
  116072. * @returns a map of filename and path
  116073. */
  116074. protected abstract _getFilenameAndPath(): {
  116075. filename: string;
  116076. path: string;
  116077. };
  116078. /**
  116079. * This function will be called after the model was successfully loaded and can be used
  116080. * for mesh transformations before it is available for the user
  116081. * @param meshes the loaded meshes
  116082. */
  116083. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  116084. /**
  116085. * Set the root mesh for this controller. Important for the WebXR controller class
  116086. * @param meshes the loaded meshes
  116087. */
  116088. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  116089. /**
  116090. * A function executed each frame that updates the mesh (if needed)
  116091. * @param xrFrame the current xrFrame
  116092. */
  116093. protected abstract _updateModel(xrFrame: XRFrame): void;
  116094. /**
  116095. * This function is called before the mesh is loaded. It checks for loading constraints.
  116096. * For example, this function can check if the GLB loader is available
  116097. * If this function returns false, the generic controller will be loaded instead
  116098. * @returns Is the client ready to load the mesh
  116099. */
  116100. protected abstract _getModelLoadingConstraints(): boolean;
  116101. /**
  116102. * Dispose this controller, the model mesh and all its components
  116103. */
  116104. dispose(): void;
  116105. }
  116106. }
  116107. declare module BABYLON {
  116108. /**
  116109. * A generic trigger-only motion controller for WebXR
  116110. */
  116111. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  116112. /**
  116113. * Static version of the profile id of this controller
  116114. */
  116115. static ProfileId: string;
  116116. profileId: string;
  116117. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116118. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  116119. protected _updateModel(): void;
  116120. protected _getFilenameAndPath(): {
  116121. filename: string;
  116122. path: string;
  116123. };
  116124. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116125. protected _getModelLoadingConstraints(): boolean;
  116126. }
  116127. }
  116128. declare module BABYLON {
  116129. /**
  116130. * A construction function type to create a new controller based on an xrInput object
  116131. */
  116132. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  116133. /**
  116134. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  116135. *
  116136. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  116137. * it should be replaced with auto-loaded controllers.
  116138. *
  116139. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  116140. */
  116141. export class WebXRMotionControllerManager {
  116142. private static _AvailableControllers;
  116143. private static _Fallbacks;
  116144. /**
  116145. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  116146. *
  116147. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  116148. *
  116149. * @param type the profile type to register
  116150. * @param constructFunction the function to be called when loading this profile
  116151. */
  116152. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  116153. /**
  116154. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  116155. * The order of search:
  116156. *
  116157. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  116158. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  116159. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  116160. * 4) return the generic trigger controller if none were found
  116161. *
  116162. * @param xrInput the xrInput to which a new controller is initialized
  116163. * @param scene the scene to which the model will be added
  116164. * @param forceProfile force a certain profile for this controller
  116165. * @return the motion controller class for this profile id or the generic standard class if none was found
  116166. */
  116167. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  116168. /**
  116169. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  116170. * @param profileId the profile to which a fallback needs to be found
  116171. * @return an array with corresponding fallback profiles
  116172. */
  116173. static FindFallbackWithProfileId(profileId: string): string[];
  116174. /**
  116175. * Register a fallback to a specific profile.
  116176. * @param profileId the profileId that will receive the fallbacks
  116177. * @param fallbacks A list of fallback profiles
  116178. */
  116179. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  116180. /**
  116181. * Register the default fallbacks.
  116182. * This function is called automatically when this file is imported.
  116183. */
  116184. static DefaultFallbacks(): void;
  116185. }
  116186. }
  116187. declare module BABYLON {
  116188. /**
  116189. * Represents an XR controller
  116190. */
  116191. export class WebXRController {
  116192. private scene;
  116193. /** The underlying input source for the controller */
  116194. inputSource: XRInputSource;
  116195. /**
  116196. * 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
  116197. */
  116198. grip?: AbstractMesh;
  116199. /**
  116200. * Pointer which can be used to select objects or attach a visible laser to
  116201. */
  116202. pointer: AbstractMesh;
  116203. /**
  116204. * If available, this is the gamepad object related to this controller.
  116205. * Using this object it is possible to get click events and trackpad changes of the
  116206. * webxr controller that is currently being used.
  116207. */
  116208. gamepadController?: WebXRAbstractMotionController;
  116209. /**
  116210. * Event that fires when the controller is removed/disposed
  116211. */
  116212. onDisposeObservable: Observable<{}>;
  116213. private _tmpQuaternion;
  116214. private _tmpVector;
  116215. private _uniqueId;
  116216. /**
  116217. * Creates the controller
  116218. * @see https://doc.babylonjs.com/how_to/webxr
  116219. * @param scene the scene which the controller should be associated to
  116220. * @param inputSource the underlying input source for the controller
  116221. * @param controllerProfile An optional controller profile for this input. This will override the xrInput profile.
  116222. */
  116223. constructor(scene: Scene,
  116224. /** The underlying input source for the controller */
  116225. inputSource: XRInputSource, controllerProfile?: string);
  116226. /**
  116227. * Get this controllers unique id
  116228. */
  116229. get uniqueId(): string;
  116230. /**
  116231. * Updates the controller pose based on the given XRFrame
  116232. * @param xrFrame xr frame to update the pose with
  116233. * @param referenceSpace reference space to use
  116234. */
  116235. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  116236. /**
  116237. * Gets a world space ray coming from the controller
  116238. * @param result the resulting ray
  116239. */
  116240. getWorldPointerRayToRef(result: Ray): void;
  116241. /**
  116242. * Get the scene associated with this controller
  116243. * @returns the scene object
  116244. */
  116245. getScene(): Scene;
  116246. /**
  116247. * Disposes of the object
  116248. */
  116249. dispose(): void;
  116250. }
  116251. }
  116252. declare module BABYLON {
  116253. /**
  116254. * The schema for initialization options of the XR Input class
  116255. */
  116256. export interface IWebXRInputOptions {
  116257. /**
  116258. * If set to true no model will be automatically loaded
  116259. */
  116260. doNotLoadControllerMeshes?: boolean;
  116261. /**
  116262. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  116263. * If not found, the xr input profile data will be used.
  116264. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  116265. */
  116266. forceInputProfile?: string;
  116267. }
  116268. /**
  116269. * XR input used to track XR inputs such as controllers/rays
  116270. */
  116271. export class WebXRInput implements IDisposable {
  116272. /**
  116273. * the xr session manager for this session
  116274. */
  116275. xrSessionManager: WebXRSessionManager;
  116276. /**
  116277. * the WebXR camera for this session. Mainly used for teleportation
  116278. */
  116279. xrCamera: WebXRCamera;
  116280. private readonly options;
  116281. /**
  116282. * XR controllers being tracked
  116283. */
  116284. controllers: Array<WebXRController>;
  116285. private _frameObserver;
  116286. private _sessionEndedObserver;
  116287. private _sessionInitObserver;
  116288. /**
  116289. * Event when a controller has been connected/added
  116290. */
  116291. onControllerAddedObservable: Observable<WebXRController>;
  116292. /**
  116293. * Event when a controller has been removed/disconnected
  116294. */
  116295. onControllerRemovedObservable: Observable<WebXRController>;
  116296. /**
  116297. * Initializes the WebXRInput
  116298. * @param xrSessionManager the xr session manager for this session
  116299. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  116300. * @param options = initialization options for this xr input
  116301. */
  116302. constructor(
  116303. /**
  116304. * the xr session manager for this session
  116305. */
  116306. xrSessionManager: WebXRSessionManager,
  116307. /**
  116308. * the WebXR camera for this session. Mainly used for teleportation
  116309. */
  116310. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  116311. private _onInputSourcesChange;
  116312. private _addAndRemoveControllers;
  116313. /**
  116314. * Disposes of the object
  116315. */
  116316. dispose(): void;
  116317. }
  116318. }
  116319. declare module BABYLON {
  116320. /**
  116321. * Options interface for the pointer selection module
  116322. */
  116323. export interface IWebXRControllerPointerSelectionOptions {
  116324. /**
  116325. * the xr input to use with this pointer selection
  116326. */
  116327. xrInput: WebXRInput;
  116328. /**
  116329. * Different button type to use instead of the main component
  116330. */
  116331. overrideButtonId?: string;
  116332. /**
  116333. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  116334. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  116335. * 3000 means 3 seconds between pointing at something and selecting it
  116336. */
  116337. timeToSelect?: number;
  116338. /**
  116339. * 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)
  116340. * If not disabled, the last picked point will be used to execute a pointer up event
  116341. * If disabled, pointer up event will be triggered right after the pointer down event.
  116342. * Used in screen and gaze target ray mode only
  116343. */
  116344. disablePointerUpOnTouchOut: boolean;
  116345. /**
  116346. * For gaze mode (time to select instead of press)
  116347. */
  116348. forceGazeMode: boolean;
  116349. /**
  116350. * 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
  116351. * to start a new countdown to the pointer down event.
  116352. * Defaults to 1.
  116353. */
  116354. gazeModePointerMovedFactor?: number;
  116355. }
  116356. /**
  116357. * A module that will enable pointer selection for motion controllers of XR Input Sources
  116358. */
  116359. export class WebXRControllerPointerSelection implements IWebXRFeature {
  116360. private _xrSessionManager;
  116361. private readonly _options;
  116362. /**
  116363. * The module's name
  116364. */
  116365. static readonly Name: string;
  116366. /**
  116367. * The (Babylon) version of this module.
  116368. * This is an integer representing the implementation version.
  116369. * This number does not correspond to the webxr specs version
  116370. */
  116371. static readonly Version: number;
  116372. /**
  116373. * This color will be set to the laser pointer when selection is triggered
  116374. */
  116375. laserPointerPickedColor: Color3;
  116376. /**
  116377. * This color will be applied to the selection ring when selection is triggered
  116378. */
  116379. selectionMeshPickedColor: Color3;
  116380. /**
  116381. * default color of the selection ring
  116382. */
  116383. selectionMeshDefaultColor: Color3;
  116384. /**
  116385. * Default color of the laser pointer
  116386. */
  116387. lasterPointerDefaultColor: Color3;
  116388. private static _idCounter;
  116389. private _observerTracked;
  116390. private _attached;
  116391. private _tmpRay;
  116392. private _controllers;
  116393. /**
  116394. * Is this feature attached
  116395. */
  116396. get attached(): boolean;
  116397. private _scene;
  116398. /**
  116399. * constructs a new background remover module
  116400. * @param _xrSessionManager the session manager for this module
  116401. * @param _options read-only options to be used in this module
  116402. */
  116403. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  116404. /**
  116405. * attach this feature
  116406. * Will usually be called by the features manager
  116407. *
  116408. * @returns true if successful.
  116409. */
  116410. attach(): boolean;
  116411. /**
  116412. * detach this feature.
  116413. * Will usually be called by the features manager
  116414. *
  116415. * @returns true if successful.
  116416. */
  116417. detach(): boolean;
  116418. /**
  116419. * Get the xr controller that correlates to the pointer id in the pointer event
  116420. *
  116421. * @param id the pointer id to search for
  116422. * @returns the controller that correlates to this id or null if not found
  116423. */
  116424. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  116425. private _attachController;
  116426. private _attachScreenRayMode;
  116427. private _attachGazeMode;
  116428. private _tmpVectorForPickCompare;
  116429. private _pickingMoved;
  116430. private _attachTrackedPointerRayMode;
  116431. private _detachController;
  116432. private _generateNewMeshPair;
  116433. private _convertNormalToDirectionOfRay;
  116434. private _updatePointerDistance;
  116435. /**
  116436. * Dispose this feature and all of the resources attached
  116437. */
  116438. dispose(): void;
  116439. }
  116440. }
  116441. declare module BABYLON {
  116442. /**
  116443. * Button which can be used to enter a different mode of XR
  116444. */
  116445. export class WebXREnterExitUIButton {
  116446. /** button element */
  116447. element: HTMLElement;
  116448. /** XR initialization options for the button */
  116449. sessionMode: XRSessionMode;
  116450. /** Reference space type */
  116451. referenceSpaceType: XRReferenceSpaceType;
  116452. /**
  116453. * Creates a WebXREnterExitUIButton
  116454. * @param element button element
  116455. * @param sessionMode XR initialization session mode
  116456. * @param referenceSpaceType the type of reference space to be used
  116457. */
  116458. constructor(
  116459. /** button element */
  116460. element: HTMLElement,
  116461. /** XR initialization options for the button */
  116462. sessionMode: XRSessionMode,
  116463. /** Reference space type */
  116464. referenceSpaceType: XRReferenceSpaceType);
  116465. /**
  116466. * Overwritable function which can be used to update the button's visuals when the state changes
  116467. * @param activeButton the current active button in the UI
  116468. */
  116469. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  116470. }
  116471. /**
  116472. * Options to create the webXR UI
  116473. */
  116474. export class WebXREnterExitUIOptions {
  116475. /**
  116476. * Context to enter xr with
  116477. */
  116478. renderTarget?: Nullable<WebXRRenderTarget>;
  116479. /**
  116480. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  116481. */
  116482. customButtons?: Array<WebXREnterExitUIButton>;
  116483. /**
  116484. * A session mode to use when creating the default button.
  116485. * Default is immersive-vr
  116486. */
  116487. sessionMode?: XRSessionMode;
  116488. /**
  116489. * A reference space type to use when creating the default button.
  116490. * Default is local-floor
  116491. */
  116492. referenceSpaceType?: XRReferenceSpaceType;
  116493. }
  116494. /**
  116495. * UI to allow the user to enter/exit XR mode
  116496. */
  116497. export class WebXREnterExitUI implements IDisposable {
  116498. private scene;
  116499. /** version of the options passed to this UI */
  116500. options: WebXREnterExitUIOptions;
  116501. private _overlay;
  116502. private _buttons;
  116503. private _activeButton;
  116504. /**
  116505. * Fired every time the active button is changed.
  116506. *
  116507. * When xr is entered via a button that launches xr that button will be the callback parameter
  116508. *
  116509. * When exiting xr the callback parameter will be null)
  116510. */
  116511. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  116512. /**
  116513. * Creates UI to allow the user to enter/exit XR mode
  116514. * @param scene the scene to add the ui to
  116515. * @param helper the xr experience helper to enter/exit xr with
  116516. * @param options options to configure the UI
  116517. * @returns the created ui
  116518. */
  116519. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  116520. /**
  116521. *
  116522. * @param scene babylon scene object to use
  116523. * @param options (read-only) version of the options passed to this UI
  116524. */
  116525. private constructor();
  116526. private _updateButtons;
  116527. /**
  116528. * Disposes of the object
  116529. */
  116530. dispose(): void;
  116531. }
  116532. }
  116533. declare module BABYLON {
  116534. /**
  116535. * Class containing static functions to help procedurally build meshes
  116536. */
  116537. export class LinesBuilder {
  116538. /**
  116539. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116540. * * 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
  116541. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116542. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116543. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116544. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116545. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116546. * * 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
  116547. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116550. * @param name defines the name of the new line system
  116551. * @param options defines the options used to create the line system
  116552. * @param scene defines the hosting scene
  116553. * @returns a new line system mesh
  116554. */
  116555. static CreateLineSystem(name: string, options: {
  116556. lines: Vector3[][];
  116557. updatable?: boolean;
  116558. instance?: Nullable<LinesMesh>;
  116559. colors?: Nullable<Color4[][]>;
  116560. useVertexAlpha?: boolean;
  116561. }, scene: Nullable<Scene>): LinesMesh;
  116562. /**
  116563. * Creates a line mesh
  116564. * 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
  116565. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116566. * * The parameter `points` is an array successive Vector3
  116567. * * 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
  116568. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116569. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116570. * * When updating an instance, remember that only point positions can change, not the number of points
  116571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116573. * @param name defines the name of the new line system
  116574. * @param options defines the options used to create the line system
  116575. * @param scene defines the hosting scene
  116576. * @returns a new line mesh
  116577. */
  116578. static CreateLines(name: string, options: {
  116579. points: Vector3[];
  116580. updatable?: boolean;
  116581. instance?: Nullable<LinesMesh>;
  116582. colors?: Color4[];
  116583. useVertexAlpha?: boolean;
  116584. }, scene?: Nullable<Scene>): LinesMesh;
  116585. /**
  116586. * Creates a dashed line mesh
  116587. * * 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
  116588. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116589. * * The parameter `points` is an array successive Vector3
  116590. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116591. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116592. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116593. * * 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
  116594. * * When updating an instance, remember that only point positions can change, not the number of points
  116595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116596. * @param name defines the name of the mesh
  116597. * @param options defines the options used to create the mesh
  116598. * @param scene defines the hosting scene
  116599. * @returns the dashed line mesh
  116600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116601. */
  116602. static CreateDashedLines(name: string, options: {
  116603. points: Vector3[];
  116604. dashSize?: number;
  116605. gapSize?: number;
  116606. dashNb?: number;
  116607. updatable?: boolean;
  116608. instance?: LinesMesh;
  116609. }, scene?: Nullable<Scene>): LinesMesh;
  116610. }
  116611. }
  116612. declare module BABYLON {
  116613. /**
  116614. * The options container for the teleportation module
  116615. */
  116616. export interface IWebXRTeleportationOptions {
  116617. /**
  116618. * Babylon XR Input class for controller
  116619. */
  116620. xrInput: WebXRInput;
  116621. /**
  116622. * A list of meshes to use as floor meshes.
  116623. * Meshes can be added and removed after initializing the feature using the
  116624. * addFloorMesh and removeFloorMesh functions
  116625. */
  116626. floorMeshes: AbstractMesh[];
  116627. /**
  116628. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  116629. * If you want to support rotation, make sure your mesh has a direction indicator.
  116630. *
  116631. * When left untouched, the default mesh will be initialized.
  116632. */
  116633. teleportationTargetMesh?: AbstractMesh;
  116634. /**
  116635. * Values to configure the default target mesh
  116636. */
  116637. defaultTargetMeshOptions?: {
  116638. /**
  116639. * Fill color of the teleportation area
  116640. */
  116641. teleportationFillColor?: string;
  116642. /**
  116643. * Border color for the teleportation area
  116644. */
  116645. teleportationBorderColor?: string;
  116646. /**
  116647. * Override the default material of the torus and arrow
  116648. */
  116649. torusArrowMaterial?: Material;
  116650. /**
  116651. * Disable the mesh's animation sequence
  116652. */
  116653. disableAnimation?: boolean;
  116654. };
  116655. /**
  116656. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  116657. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  116658. */
  116659. useMainComponentOnly?: boolean;
  116660. /**
  116661. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  116662. */
  116663. timeToTeleport?: number;
  116664. }
  116665. /**
  116666. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  116667. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  116668. * the input of the attached controllers.
  116669. */
  116670. export class WebXRMotionControllerTeleportation implements IWebXRFeature {
  116671. private _xrSessionManager;
  116672. private _options;
  116673. /**
  116674. * The module's name
  116675. */
  116676. static readonly Name: string;
  116677. /**
  116678. * The (Babylon) version of this module.
  116679. * This is an integer representing the implementation version.
  116680. * This number does not correspond to the webxr specs version
  116681. */
  116682. static readonly Version: number;
  116683. /**
  116684. * Is rotation enabled when moving forward?
  116685. * Disabling this feature will prevent the user from deciding the direction when teleporting
  116686. */
  116687. rotationEnabled: boolean;
  116688. /**
  116689. * Should the module support parabolic ray on top of direct ray
  116690. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  116691. * Very helpful when moving between floors / different heights
  116692. */
  116693. parabolicRayEnabled: boolean;
  116694. /**
  116695. * The distance from the user to the inspection point in the direction of the controller
  116696. * A higher number will allow the user to move further
  116697. * defaults to 5 (meters, in xr units)
  116698. */
  116699. parabolicCheckRadius: number;
  116700. /**
  116701. * How much rotation should be applied when rotating right and left
  116702. */
  116703. rotationAngle: number;
  116704. /**
  116705. * Distance to travel when moving backwards
  116706. */
  116707. backwardsTeleportationDistance: number;
  116708. private _observerTracked;
  116709. private _attached;
  116710. /**
  116711. * Is this feature attached
  116712. */
  116713. get attached(): boolean;
  116714. /**
  116715. * Add a new mesh to the floor meshes array
  116716. * @param mesh the mesh to use as floor mesh
  116717. */
  116718. addFloorMesh(mesh: AbstractMesh): void;
  116719. /**
  116720. * Remove a mesh from the floor meshes array
  116721. * @param mesh the mesh to remove
  116722. */
  116723. removeFloorMesh(mesh: AbstractMesh): void;
  116724. /**
  116725. * Remove a mesh from the floor meshes array using its name
  116726. * @param name the mesh name to remove
  116727. */
  116728. removeFloorMeshByName(name: string): void;
  116729. private _tmpRay;
  116730. private _tmpVector;
  116731. private _controllers;
  116732. /**
  116733. * constructs a new anchor system
  116734. * @param _xrSessionManager an instance of WebXRSessionManager
  116735. * @param _options configuration object for this feature
  116736. */
  116737. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  116738. private _selectionFeature;
  116739. /**
  116740. * This function sets a selection feature that will be disabled when
  116741. * the forward ray is shown and will be reattached when hidden.
  116742. * This is used to remove the selection rays when moving.
  116743. * @param selectionFeature the feature to disable when forward movement is enabled
  116744. */
  116745. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  116746. /**
  116747. * attach this feature
  116748. * Will usually be called by the features manager
  116749. *
  116750. * @returns true if successful.
  116751. */
  116752. attach(): boolean;
  116753. /**
  116754. * detach this feature.
  116755. * Will usually be called by the features manager
  116756. *
  116757. * @returns true if successful.
  116758. */
  116759. detach(): boolean;
  116760. /**
  116761. * Dispose this feature and all of the resources attached
  116762. */
  116763. dispose(): void;
  116764. private _currentTeleportationControllerId;
  116765. private _attachController;
  116766. private _teleportForward;
  116767. private _detachController;
  116768. private createDefaultTargetMesh;
  116769. private setTargetMeshVisibility;
  116770. private setTargetMeshPosition;
  116771. private _quadraticBezierCurve;
  116772. private showParabolicPath;
  116773. }
  116774. }
  116775. declare module BABYLON {
  116776. /**
  116777. * Options for the default xr helper
  116778. */
  116779. export class WebXRDefaultExperienceOptions {
  116780. /**
  116781. * Floor meshes that should be used for teleporting
  116782. */
  116783. floorMeshes?: Array<AbstractMesh>;
  116784. /**
  116785. * Enable or disable default UI to enter XR
  116786. */
  116787. disableDefaultUI?: boolean;
  116788. /**
  116789. * optional configuration for the output canvas
  116790. */
  116791. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  116792. /**
  116793. * optional UI options. This can be used among other to change session mode and reference space type
  116794. */
  116795. uiOptions?: WebXREnterExitUIOptions;
  116796. /**
  116797. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  116798. */
  116799. inputOptions?: IWebXRInputOptions;
  116800. }
  116801. /**
  116802. * Default experience which provides a similar setup to the previous webVRExperience
  116803. */
  116804. export class WebXRDefaultExperience {
  116805. /**
  116806. * Base experience
  116807. */
  116808. baseExperience: WebXRExperienceHelper;
  116809. /**
  116810. * Input experience extension
  116811. */
  116812. input: WebXRInput;
  116813. /**
  116814. * Enables laser pointer and selection
  116815. */
  116816. pointerSelection: WebXRControllerPointerSelection;
  116817. /**
  116818. * Enables teleportation
  116819. */
  116820. teleportation: WebXRMotionControllerTeleportation;
  116821. /**
  116822. * Enables ui for entering/exiting xr
  116823. */
  116824. enterExitUI: WebXREnterExitUI;
  116825. /**
  116826. * Default target xr should render to
  116827. */
  116828. renderTarget: WebXRRenderTarget;
  116829. /**
  116830. * Creates the default xr experience
  116831. * @param scene scene
  116832. * @param options options for basic configuration
  116833. * @returns resulting WebXRDefaultExperience
  116834. */
  116835. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116836. private constructor();
  116837. /**
  116838. * DIsposes of the experience helper
  116839. */
  116840. dispose(): void;
  116841. }
  116842. }
  116843. declare module BABYLON {
  116844. /**
  116845. * Options to modify the vr teleportation behavior.
  116846. */
  116847. export interface VRTeleportationOptions {
  116848. /**
  116849. * The name of the mesh which should be used as the teleportation floor. (default: null)
  116850. */
  116851. floorMeshName?: string;
  116852. /**
  116853. * A list of meshes to be used as the teleportation floor. (default: empty)
  116854. */
  116855. floorMeshes?: Mesh[];
  116856. /**
  116857. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  116858. */
  116859. teleportationMode?: number;
  116860. /**
  116861. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  116862. */
  116863. teleportationTime?: number;
  116864. /**
  116865. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  116866. */
  116867. teleportationSpeed?: number;
  116868. /**
  116869. * The easing function used in the animation or null for Linear. (default CircleEase)
  116870. */
  116871. easingFunction?: EasingFunction;
  116872. }
  116873. /**
  116874. * Options to modify the vr experience helper's behavior.
  116875. */
  116876. export interface VRExperienceHelperOptions extends WebVROptions {
  116877. /**
  116878. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  116879. */
  116880. createDeviceOrientationCamera?: boolean;
  116881. /**
  116882. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  116883. */
  116884. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  116885. /**
  116886. * Uses the main button on the controller to toggle the laser casted. (default: true)
  116887. */
  116888. laserToggle?: boolean;
  116889. /**
  116890. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  116891. */
  116892. floorMeshes?: Mesh[];
  116893. /**
  116894. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  116895. */
  116896. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  116897. /**
  116898. * Defines if WebXR should be used instead of WebVR (if available)
  116899. */
  116900. useXR?: boolean;
  116901. }
  116902. /**
  116903. * Event containing information after VR has been entered
  116904. */
  116905. export class OnAfterEnteringVRObservableEvent {
  116906. /**
  116907. * If entering vr was successful
  116908. */
  116909. success: boolean;
  116910. }
  116911. /**
  116912. * Helps to quickly add VR support to an existing scene.
  116913. * See http://doc.babylonjs.com/how_to/webvr_helper
  116914. */
  116915. export class VRExperienceHelper {
  116916. /** Options to modify the vr experience helper's behavior. */
  116917. webVROptions: VRExperienceHelperOptions;
  116918. private _scene;
  116919. private _position;
  116920. private _btnVR;
  116921. private _btnVRDisplayed;
  116922. private _webVRsupported;
  116923. private _webVRready;
  116924. private _webVRrequesting;
  116925. private _webVRpresenting;
  116926. private _hasEnteredVR;
  116927. private _fullscreenVRpresenting;
  116928. private _inputElement;
  116929. private _webVRCamera;
  116930. private _vrDeviceOrientationCamera;
  116931. private _deviceOrientationCamera;
  116932. private _existingCamera;
  116933. private _onKeyDown;
  116934. private _onVrDisplayPresentChange;
  116935. private _onVRDisplayChanged;
  116936. private _onVRRequestPresentStart;
  116937. private _onVRRequestPresentComplete;
  116938. /**
  116939. * 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)
  116940. */
  116941. enableGazeEvenWhenNoPointerLock: boolean;
  116942. /**
  116943. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  116944. */
  116945. exitVROnDoubleTap: boolean;
  116946. /**
  116947. * Observable raised right before entering VR.
  116948. */
  116949. onEnteringVRObservable: Observable<VRExperienceHelper>;
  116950. /**
  116951. * Observable raised when entering VR has completed.
  116952. */
  116953. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  116954. /**
  116955. * Observable raised when exiting VR.
  116956. */
  116957. onExitingVRObservable: Observable<VRExperienceHelper>;
  116958. /**
  116959. * Observable raised when controller mesh is loaded.
  116960. */
  116961. onControllerMeshLoadedObservable: Observable<WebVRController>;
  116962. /** Return this.onEnteringVRObservable
  116963. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  116964. */
  116965. get onEnteringVR(): Observable<VRExperienceHelper>;
  116966. /** Return this.onExitingVRObservable
  116967. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  116968. */
  116969. get onExitingVR(): Observable<VRExperienceHelper>;
  116970. /** Return this.onControllerMeshLoadedObservable
  116971. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  116972. */
  116973. get onControllerMeshLoaded(): Observable<WebVRController>;
  116974. private _rayLength;
  116975. private _useCustomVRButton;
  116976. private _teleportationRequested;
  116977. private _teleportActive;
  116978. private _floorMeshName;
  116979. private _floorMeshesCollection;
  116980. private _teleportationMode;
  116981. private _teleportationTime;
  116982. private _teleportationSpeed;
  116983. private _teleportationEasing;
  116984. private _rotationAllowed;
  116985. private _teleportBackwardsVector;
  116986. private _teleportationTarget;
  116987. private _isDefaultTeleportationTarget;
  116988. private _postProcessMove;
  116989. private _teleportationFillColor;
  116990. private _teleportationBorderColor;
  116991. private _rotationAngle;
  116992. private _haloCenter;
  116993. private _cameraGazer;
  116994. private _padSensibilityUp;
  116995. private _padSensibilityDown;
  116996. private _leftController;
  116997. private _rightController;
  116998. private _gazeColor;
  116999. private _laserColor;
  117000. private _pickedLaserColor;
  117001. private _pickedGazeColor;
  117002. /**
  117003. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  117004. */
  117005. onNewMeshSelected: Observable<AbstractMesh>;
  117006. /**
  117007. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  117008. * This observable will provide the mesh and the controller used to select the mesh
  117009. */
  117010. onMeshSelectedWithController: Observable<{
  117011. mesh: AbstractMesh;
  117012. controller: WebVRController;
  117013. }>;
  117014. /**
  117015. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  117016. */
  117017. onNewMeshPicked: Observable<PickingInfo>;
  117018. private _circleEase;
  117019. /**
  117020. * Observable raised before camera teleportation
  117021. */
  117022. onBeforeCameraTeleport: Observable<Vector3>;
  117023. /**
  117024. * Observable raised after camera teleportation
  117025. */
  117026. onAfterCameraTeleport: Observable<Vector3>;
  117027. /**
  117028. * Observable raised when current selected mesh gets unselected
  117029. */
  117030. onSelectedMeshUnselected: Observable<AbstractMesh>;
  117031. private _raySelectionPredicate;
  117032. /**
  117033. * To be optionaly changed by user to define custom ray selection
  117034. */
  117035. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  117036. /**
  117037. * To be optionaly changed by user to define custom selection logic (after ray selection)
  117038. */
  117039. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117040. /**
  117041. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  117042. */
  117043. teleportationEnabled: boolean;
  117044. private _defaultHeight;
  117045. private _teleportationInitialized;
  117046. private _interactionsEnabled;
  117047. private _interactionsRequested;
  117048. private _displayGaze;
  117049. private _displayLaserPointer;
  117050. /**
  117051. * The mesh used to display where the user is going to teleport.
  117052. */
  117053. get teleportationTarget(): Mesh;
  117054. /**
  117055. * Sets the mesh to be used to display where the user is going to teleport.
  117056. */
  117057. set teleportationTarget(value: Mesh);
  117058. /**
  117059. * 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
  117060. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  117061. * See http://doc.babylonjs.com/resources/baking_transformations
  117062. */
  117063. get gazeTrackerMesh(): Mesh;
  117064. set gazeTrackerMesh(value: Mesh);
  117065. /**
  117066. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  117067. */
  117068. updateGazeTrackerScale: boolean;
  117069. /**
  117070. * If the gaze trackers color should be updated when selecting meshes
  117071. */
  117072. updateGazeTrackerColor: boolean;
  117073. /**
  117074. * If the controller laser color should be updated when selecting meshes
  117075. */
  117076. updateControllerLaserColor: boolean;
  117077. /**
  117078. * The gaze tracking mesh corresponding to the left controller
  117079. */
  117080. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  117081. /**
  117082. * The gaze tracking mesh corresponding to the right controller
  117083. */
  117084. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  117085. /**
  117086. * If the ray of the gaze should be displayed.
  117087. */
  117088. get displayGaze(): boolean;
  117089. /**
  117090. * Sets if the ray of the gaze should be displayed.
  117091. */
  117092. set displayGaze(value: boolean);
  117093. /**
  117094. * If the ray of the LaserPointer should be displayed.
  117095. */
  117096. get displayLaserPointer(): boolean;
  117097. /**
  117098. * Sets if the ray of the LaserPointer should be displayed.
  117099. */
  117100. set displayLaserPointer(value: boolean);
  117101. /**
  117102. * The deviceOrientationCamera used as the camera when not in VR.
  117103. */
  117104. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  117105. /**
  117106. * Based on the current WebVR support, returns the current VR camera used.
  117107. */
  117108. get currentVRCamera(): Nullable<Camera>;
  117109. /**
  117110. * The webVRCamera which is used when in VR.
  117111. */
  117112. get webVRCamera(): WebVRFreeCamera;
  117113. /**
  117114. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  117115. */
  117116. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  117117. /**
  117118. * The html button that is used to trigger entering into VR.
  117119. */
  117120. get vrButton(): Nullable<HTMLButtonElement>;
  117121. private get _teleportationRequestInitiated();
  117122. /**
  117123. * Defines wether or not Pointer lock should be requested when switching to
  117124. * full screen.
  117125. */
  117126. requestPointerLockOnFullScreen: boolean;
  117127. /**
  117128. * If asking to force XR, this will be populated with the default xr experience
  117129. */
  117130. xr: WebXRDefaultExperience;
  117131. /**
  117132. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  117133. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  117134. */
  117135. xrTestDone: boolean;
  117136. /**
  117137. * Instantiates a VRExperienceHelper.
  117138. * Helps to quickly add VR support to an existing scene.
  117139. * @param scene The scene the VRExperienceHelper belongs to.
  117140. * @param webVROptions Options to modify the vr experience helper's behavior.
  117141. */
  117142. constructor(scene: Scene,
  117143. /** Options to modify the vr experience helper's behavior. */
  117144. webVROptions?: VRExperienceHelperOptions);
  117145. private completeVRInit;
  117146. private _onDefaultMeshLoaded;
  117147. private _onResize;
  117148. private _onFullscreenChange;
  117149. /**
  117150. * Gets a value indicating if we are currently in VR mode.
  117151. */
  117152. get isInVRMode(): boolean;
  117153. private onVrDisplayPresentChange;
  117154. private onVRDisplayChanged;
  117155. private moveButtonToBottomRight;
  117156. private displayVRButton;
  117157. private updateButtonVisibility;
  117158. private _cachedAngularSensibility;
  117159. /**
  117160. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  117161. * Otherwise, will use the fullscreen API.
  117162. */
  117163. enterVR(): void;
  117164. /**
  117165. * Attempt to exit VR, or fullscreen.
  117166. */
  117167. exitVR(): void;
  117168. /**
  117169. * The position of the vr experience helper.
  117170. */
  117171. get position(): Vector3;
  117172. /**
  117173. * Sets the position of the vr experience helper.
  117174. */
  117175. set position(value: Vector3);
  117176. /**
  117177. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  117178. */
  117179. enableInteractions(): void;
  117180. private get _noControllerIsActive();
  117181. private beforeRender;
  117182. private _isTeleportationFloor;
  117183. /**
  117184. * Adds a floor mesh to be used for teleportation.
  117185. * @param floorMesh the mesh to be used for teleportation.
  117186. */
  117187. addFloorMesh(floorMesh: Mesh): void;
  117188. /**
  117189. * Removes a floor mesh from being used for teleportation.
  117190. * @param floorMesh the mesh to be removed.
  117191. */
  117192. removeFloorMesh(floorMesh: Mesh): void;
  117193. /**
  117194. * Enables interactions and teleportation using the VR controllers and gaze.
  117195. * @param vrTeleportationOptions options to modify teleportation behavior.
  117196. */
  117197. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  117198. private _onNewGamepadConnected;
  117199. private _tryEnableInteractionOnController;
  117200. private _onNewGamepadDisconnected;
  117201. private _enableInteractionOnController;
  117202. private _checkTeleportWithRay;
  117203. private _checkRotate;
  117204. private _checkTeleportBackwards;
  117205. private _enableTeleportationOnController;
  117206. private _createTeleportationCircles;
  117207. private _displayTeleportationTarget;
  117208. private _hideTeleportationTarget;
  117209. private _rotateCamera;
  117210. private _moveTeleportationSelectorTo;
  117211. private _workingVector;
  117212. private _workingQuaternion;
  117213. private _workingMatrix;
  117214. /**
  117215. * Time Constant Teleportation Mode
  117216. */
  117217. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  117218. /**
  117219. * Speed Constant Teleportation Mode
  117220. */
  117221. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  117222. /**
  117223. * Teleports the users feet to the desired location
  117224. * @param location The location where the user's feet should be placed
  117225. */
  117226. teleportCamera(location: Vector3): void;
  117227. private _convertNormalToDirectionOfRay;
  117228. private _castRayAndSelectObject;
  117229. private _notifySelectedMeshUnselected;
  117230. /**
  117231. * Permanently set new colors for the laser pointer
  117232. * @param color the new laser color
  117233. * @param pickedColor the new laser color when picked mesh detected
  117234. */
  117235. setLaserColor(color: Color3, pickedColor?: Color3): void;
  117236. /**
  117237. * Permanently set new colors for the gaze pointer
  117238. * @param color the new gaze color
  117239. * @param pickedColor the new gaze color when picked mesh detected
  117240. */
  117241. setGazeColor(color: Color3, pickedColor?: Color3): void;
  117242. /**
  117243. * Sets the color of the laser ray from the vr controllers.
  117244. * @param color new color for the ray.
  117245. */
  117246. changeLaserColor(color: Color3): void;
  117247. /**
  117248. * Sets the color of the ray from the vr headsets gaze.
  117249. * @param color new color for the ray.
  117250. */
  117251. changeGazeColor(color: Color3): void;
  117252. /**
  117253. * Exits VR and disposes of the vr experience helper
  117254. */
  117255. dispose(): void;
  117256. /**
  117257. * Gets the name of the VRExperienceHelper class
  117258. * @returns "VRExperienceHelper"
  117259. */
  117260. getClassName(): string;
  117261. }
  117262. }
  117263. declare module BABYLON {
  117264. /**
  117265. * Options used for hit testing
  117266. */
  117267. export interface IWebXRHitTestOptions {
  117268. /**
  117269. * Only test when user interacted with the scene. Default - hit test every frame
  117270. */
  117271. testOnPointerDownOnly?: boolean;
  117272. /**
  117273. * The node to use to transform the local results to world coordinates
  117274. */
  117275. worldParentNode?: TransformNode;
  117276. }
  117277. /**
  117278. * Interface defining the babylon result of raycasting/hit-test
  117279. */
  117280. export interface IWebXRHitResult {
  117281. /**
  117282. * The native hit test result
  117283. */
  117284. xrHitResult: XRHitResult;
  117285. /**
  117286. * Transformation matrix that can be applied to a node that will put it in the hit point location
  117287. */
  117288. transformationMatrix: Matrix;
  117289. }
  117290. /**
  117291. * The currently-working hit-test module.
  117292. * Hit test (or raycasting) is used to interact with the real world.
  117293. * For further information read here - https://github.com/immersive-web/hit-test
  117294. */
  117295. export class WebXRHitTestLegacy implements IWebXRFeature {
  117296. private _xrSessionManager;
  117297. /**
  117298. * options to use when constructing this feature
  117299. */
  117300. readonly options: IWebXRHitTestOptions;
  117301. /**
  117302. * The module's name
  117303. */
  117304. static readonly Name: string;
  117305. /**
  117306. * The (Babylon) version of this module.
  117307. * This is an integer representing the implementation version.
  117308. * This number does not correspond to the webxr specs version
  117309. */
  117310. static readonly Version: number;
  117311. private _attached;
  117312. /**
  117313. * Is this feature attached
  117314. */
  117315. get attached(): boolean;
  117316. /**
  117317. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  117318. * @param event the (select) event to use to select with
  117319. * @param referenceSpace the reference space to use for this hit test
  117320. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  117321. */
  117322. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  117323. /**
  117324. * execute a hit test with an XR Ray
  117325. *
  117326. * @param xrSession a native xrSession that will execute this hit test
  117327. * @param xrRay the ray (position and direction) to use for raycasting
  117328. * @param referenceSpace native XR reference space to use for the hit-test
  117329. * @param filter filter function that will filter the results
  117330. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  117331. */
  117332. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  117333. /**
  117334. * Triggered when new babylon (transformed) hit test results are available
  117335. */
  117336. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  117337. private _onSelectEnabled;
  117338. private _xrFrameObserver;
  117339. /**
  117340. * Creates a new instance of the (legacy version) hit test feature
  117341. * @param _xrSessionManager an instance of WebXRSessionManager
  117342. * @param options options to use when constructing this feature
  117343. */
  117344. constructor(_xrSessionManager: WebXRSessionManager,
  117345. /**
  117346. * options to use when constructing this feature
  117347. */
  117348. options?: IWebXRHitTestOptions);
  117349. /**
  117350. * Populated with the last native XR Hit Results
  117351. */
  117352. lastNativeXRHitResults: XRHitResult[];
  117353. /**
  117354. * attach this feature
  117355. * Will usually be called by the features manager
  117356. *
  117357. * @returns true if successful.
  117358. */
  117359. attach(): boolean;
  117360. /**
  117361. * detach this feature.
  117362. * Will usually be called by the features manager
  117363. *
  117364. * @returns true if successful.
  117365. */
  117366. detach(): boolean;
  117367. private _onHitTestResults;
  117368. private _onSelect;
  117369. /**
  117370. * Dispose this feature and all of the resources attached
  117371. */
  117372. dispose(): void;
  117373. }
  117374. }
  117375. declare module BABYLON {
  117376. /**
  117377. * Options used in the plane detector module
  117378. */
  117379. export interface IWebXRPlaneDetectorOptions {
  117380. /**
  117381. * The node to use to transform the local results to world coordinates
  117382. */
  117383. worldParentNode?: TransformNode;
  117384. }
  117385. /**
  117386. * A babylon interface for a webxr plane.
  117387. * A Plane is actually a polygon, built from N points in space
  117388. */
  117389. export interface IWebXRPlane {
  117390. /**
  117391. * a babylon-assigned ID for this polygon
  117392. */
  117393. id: number;
  117394. /**
  117395. * the native xr-plane object
  117396. */
  117397. xrPlane: XRPlane;
  117398. /**
  117399. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  117400. */
  117401. polygonDefinition: Array<Vector3>;
  117402. /**
  117403. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  117404. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  117405. */
  117406. transformationMatrix: Matrix;
  117407. }
  117408. /**
  117409. * The plane detector is used to detect planes in the real world when in AR
  117410. * For more information see https://github.com/immersive-web/real-world-geometry/
  117411. */
  117412. export class WebXRPlaneDetector implements IWebXRFeature {
  117413. private _xrSessionManager;
  117414. private _options;
  117415. /**
  117416. * The module's name
  117417. */
  117418. static readonly Name: string;
  117419. /**
  117420. * The (Babylon) version of this module.
  117421. * This is an integer representing the implementation version.
  117422. * This number does not correspond to the webxr specs version
  117423. */
  117424. static readonly Version: number;
  117425. /**
  117426. * Observers registered here will be executed when a new plane was added to the session
  117427. */
  117428. onPlaneAddedObservable: Observable<IWebXRPlane>;
  117429. /**
  117430. * Observers registered here will be executed when a plane is no longer detected in the session
  117431. */
  117432. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  117433. /**
  117434. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  117435. * This can execute N times every frame
  117436. */
  117437. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  117438. private _attached;
  117439. /**
  117440. * Is this feature attached
  117441. */
  117442. get attached(): boolean;
  117443. private _enabled;
  117444. private _detectedPlanes;
  117445. private _lastFrameDetected;
  117446. private _observerTracked;
  117447. /**
  117448. * construct a new Plane Detector
  117449. * @param _xrSessionManager an instance of xr Session manager
  117450. * @param _options configuration to use when constructing this feature
  117451. */
  117452. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  117453. /**
  117454. * attach this feature
  117455. * Will usually be called by the features manager
  117456. *
  117457. * @returns true if successful.
  117458. */
  117459. attach(): boolean;
  117460. /**
  117461. * detach this feature.
  117462. * Will usually be called by the features manager
  117463. *
  117464. * @returns true if successful.
  117465. */
  117466. detach(): boolean;
  117467. /**
  117468. * Dispose this feature and all of the resources attached
  117469. */
  117470. dispose(): void;
  117471. private _updatePlaneWithXRPlane;
  117472. /**
  117473. * avoiding using Array.find for global support.
  117474. * @param xrPlane the plane to find in the array
  117475. */
  117476. private findIndexInPlaneArray;
  117477. }
  117478. }
  117479. declare module BABYLON {
  117480. /**
  117481. * Configuration options of the anchor system
  117482. */
  117483. export interface IWebXRAnchorSystemOptions {
  117484. /**
  117485. * a node that will be used to convert local to world coordinates
  117486. */
  117487. worldParentNode?: TransformNode;
  117488. /**
  117489. * should the anchor system use plane detection.
  117490. * If set to true, the plane-detection feature should be set using setPlaneDetector
  117491. */
  117492. usePlaneDetection?: boolean;
  117493. /**
  117494. * Should a new anchor be added every time a select event is triggered
  117495. */
  117496. addAnchorOnSelect?: boolean;
  117497. }
  117498. /**
  117499. * A babylon container for an XR Anchor
  117500. */
  117501. export interface IWebXRAnchor {
  117502. /**
  117503. * A babylon-assigned ID for this anchor
  117504. */
  117505. id: number;
  117506. /**
  117507. * The native anchor object
  117508. */
  117509. xrAnchor: XRAnchor;
  117510. /**
  117511. * Transformation matrix to apply to an object attached to this anchor
  117512. */
  117513. transformationMatrix: Matrix;
  117514. }
  117515. /**
  117516. * An implementation of the anchor system of WebXR.
  117517. * Note that the current documented implementation is not available in any browser. Future implementations
  117518. * will use the frame to create an anchor and not the session or a detected plane
  117519. * For further information see https://github.com/immersive-web/anchors/
  117520. */
  117521. export class WebXRAnchorSystem implements IWebXRFeature {
  117522. private _xrSessionManager;
  117523. private _options;
  117524. /**
  117525. * The module's name
  117526. */
  117527. static readonly Name: string;
  117528. /**
  117529. * The (Babylon) version of this module.
  117530. * This is an integer representing the implementation version.
  117531. * This number does not correspond to the webxr specs version
  117532. */
  117533. static readonly Version: number;
  117534. /**
  117535. * Observers registered here will be executed when a new anchor was added to the session
  117536. */
  117537. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  117538. /**
  117539. * Observers registered here will be executed when an existing anchor updates
  117540. * This can execute N times every frame
  117541. */
  117542. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  117543. /**
  117544. * Observers registered here will be executed when an anchor was removed from the session
  117545. */
  117546. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  117547. private _attached;
  117548. /**
  117549. * Is this feature attached
  117550. */
  117551. get attached(): boolean;
  117552. private _planeDetector;
  117553. private _hitTestModule;
  117554. private _enabled;
  117555. private _trackedAnchors;
  117556. private _lastFrameDetected;
  117557. private _observerTracked;
  117558. /**
  117559. * constructs a new anchor system
  117560. * @param _xrSessionManager an instance of WebXRSessionManager
  117561. * @param _options configuration object for this feature
  117562. */
  117563. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  117564. /**
  117565. * set the plane detector to use in order to create anchors from frames
  117566. * @param planeDetector the plane-detector module to use
  117567. * @param enable enable plane-anchors. default is true
  117568. */
  117569. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  117570. /**
  117571. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  117572. * @param hitTestModule the hit-test module to use.
  117573. */
  117574. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  117575. /**
  117576. * attach this feature
  117577. * Will usually be called by the features manager
  117578. *
  117579. * @returns true if successful.
  117580. */
  117581. attach(): boolean;
  117582. /**
  117583. * detach this feature.
  117584. * Will usually be called by the features manager
  117585. *
  117586. * @returns true if successful.
  117587. */
  117588. detach(): boolean;
  117589. /**
  117590. * Dispose this feature and all of the resources attached
  117591. */
  117592. dispose(): void;
  117593. private _onSelect;
  117594. /**
  117595. * Add anchor at a specific XR point.
  117596. *
  117597. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  117598. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  117599. * @returns a promise the fulfills when the anchor was created
  117600. */
  117601. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  117602. private _updateAnchorWithXRFrame;
  117603. /**
  117604. * avoiding using Array.find for global support.
  117605. * @param xrAnchor the plane to find in the array
  117606. */
  117607. private _findIndexInAnchorArray;
  117608. }
  117609. }
  117610. declare module BABYLON {
  117611. /**
  117612. * Options interface for the background remover plugin
  117613. */
  117614. export interface IWebXRBackgroundRemoverOptions {
  117615. /**
  117616. * don't disable the environment helper
  117617. */
  117618. ignoreEnvironmentHelper?: boolean;
  117619. /**
  117620. * flags to configure the removal of the environment helper.
  117621. * If not set, the entire background will be removed. If set, flags should be set as well.
  117622. */
  117623. environmentHelperRemovalFlags?: {
  117624. /**
  117625. * Should the skybox be removed (default false)
  117626. */
  117627. skyBox?: boolean;
  117628. /**
  117629. * Should the ground be removed (default false)
  117630. */
  117631. ground?: boolean;
  117632. };
  117633. /**
  117634. * Further background meshes to disable when entering AR
  117635. */
  117636. backgroundMeshes?: AbstractMesh[];
  117637. }
  117638. /**
  117639. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  117640. */
  117641. export class WebXRBackgroundRemover implements IWebXRFeature {
  117642. private _xrSessionManager;
  117643. /**
  117644. * read-only options to be used in this module
  117645. */
  117646. readonly options: IWebXRBackgroundRemoverOptions;
  117647. /**
  117648. * The module's name
  117649. */
  117650. static readonly Name: string;
  117651. /**
  117652. * The (Babylon) version of this module.
  117653. * This is an integer representing the implementation version.
  117654. * This number does not correspond to the webxr specs version
  117655. */
  117656. static readonly Version: number;
  117657. /**
  117658. * registered observers will be triggered when the background state changes
  117659. */
  117660. onBackgroundStateChangedObservable: Observable<boolean>;
  117661. private _attached;
  117662. /**
  117663. * Is this feature attached
  117664. */
  117665. get attached(): boolean;
  117666. /**
  117667. * constructs a new background remover module
  117668. * @param _xrSessionManager the session manager for this module
  117669. * @param options read-only options to be used in this module
  117670. */
  117671. constructor(_xrSessionManager: WebXRSessionManager,
  117672. /**
  117673. * read-only options to be used in this module
  117674. */
  117675. options?: IWebXRBackgroundRemoverOptions);
  117676. /**
  117677. * attach this feature
  117678. * Will usually be called by the features manager
  117679. *
  117680. * @returns true if successful.
  117681. */
  117682. attach(): boolean;
  117683. /**
  117684. * detach this feature.
  117685. * Will usually be called by the features manager
  117686. *
  117687. * @returns true if successful.
  117688. */
  117689. detach(): boolean;
  117690. private _setBackgroundState;
  117691. /**
  117692. * Dispose this feature and all of the resources attached
  117693. */
  117694. dispose(): void;
  117695. }
  117696. }
  117697. declare module BABYLON {
  117698. /**
  117699. * The motion controller class for all microsoft mixed reality controllers
  117700. */
  117701. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  117702. /**
  117703. * The base url used to load the left and right controller models
  117704. */
  117705. static MODEL_BASE_URL: string;
  117706. /**
  117707. * The name of the left controller model file
  117708. */
  117709. static MODEL_LEFT_FILENAME: string;
  117710. /**
  117711. * The name of the right controller model file
  117712. */
  117713. static MODEL_RIGHT_FILENAME: string;
  117714. profileId: string;
  117715. protected readonly _mapping: {
  117716. defaultButton: {
  117717. "valueNodeName": string;
  117718. "unpressedNodeName": string;
  117719. "pressedNodeName": string;
  117720. };
  117721. defaultAxis: {
  117722. "valueNodeName": string;
  117723. "minNodeName": string;
  117724. "maxNodeName": string;
  117725. };
  117726. buttons: {
  117727. "xr-standard-trigger": {
  117728. "rootNodeName": string;
  117729. "componentProperty": string;
  117730. "states": string[];
  117731. };
  117732. "xr-standard-squeeze": {
  117733. "rootNodeName": string;
  117734. "componentProperty": string;
  117735. "states": string[];
  117736. };
  117737. "xr-standard-touchpad": {
  117738. "rootNodeName": string;
  117739. "labelAnchorNodeName": string;
  117740. "touchPointNodeName": string;
  117741. };
  117742. "xr-standard-thumbstick": {
  117743. "rootNodeName": string;
  117744. "componentProperty": string;
  117745. "states": string[];
  117746. };
  117747. };
  117748. axes: {
  117749. "xr-standard-touchpad": {
  117750. "x-axis": {
  117751. "rootNodeName": string;
  117752. };
  117753. "y-axis": {
  117754. "rootNodeName": string;
  117755. };
  117756. };
  117757. "xr-standard-thumbstick": {
  117758. "x-axis": {
  117759. "rootNodeName": string;
  117760. };
  117761. "y-axis": {
  117762. "rootNodeName": string;
  117763. };
  117764. };
  117765. };
  117766. };
  117767. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117768. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117769. private _getChildByName;
  117770. private _getImmediateChildByName;
  117771. protected _getFilenameAndPath(): {
  117772. filename: string;
  117773. path: string;
  117774. };
  117775. protected _updateModel(): void;
  117776. protected _getModelLoadingConstraints(): boolean;
  117777. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117778. }
  117779. }
  117780. declare module BABYLON {
  117781. /**
  117782. * The motion controller class for oculus touch (quest, rift).
  117783. * This class supports legacy mapping as well the standard xr mapping
  117784. */
  117785. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  117786. private _forceLegacyControllers;
  117787. /**
  117788. * The base url used to load the left and right controller models
  117789. */
  117790. static MODEL_BASE_URL: string;
  117791. /**
  117792. * The name of the left controller model file
  117793. */
  117794. static MODEL_LEFT_FILENAME: string;
  117795. /**
  117796. * The name of the right controller model file
  117797. */
  117798. static MODEL_RIGHT_FILENAME: string;
  117799. /**
  117800. * Base Url for the Quest controller model.
  117801. */
  117802. static QUEST_MODEL_BASE_URL: string;
  117803. profileId: string;
  117804. private _modelRootNode;
  117805. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  117806. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117807. protected _getFilenameAndPath(): {
  117808. filename: string;
  117809. path: string;
  117810. };
  117811. /**
  117812. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  117813. * between the touch and touch 2.
  117814. */
  117815. private _isQuest;
  117816. protected _updateModel(): void;
  117817. protected _getModelLoadingConstraints(): boolean;
  117818. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117819. }
  117820. }
  117821. declare module BABYLON {
  117822. /**
  117823. * The motion controller class for the standard HTC-Vive controllers
  117824. */
  117825. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  117826. /**
  117827. * The base url used to load the left and right controller models
  117828. */
  117829. static MODEL_BASE_URL: string;
  117830. /**
  117831. * File name for the controller model.
  117832. */
  117833. static MODEL_FILENAME: string;
  117834. profileId: string;
  117835. private _modelRootNode;
  117836. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  117837. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117838. protected _getFilenameAndPath(): {
  117839. filename: string;
  117840. path: string;
  117841. };
  117842. protected _updateModel(): void;
  117843. protected _getModelLoadingConstraints(): boolean;
  117844. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117845. }
  117846. }
  117847. declare module BABYLON {
  117848. /**
  117849. * Contains an array of blocks representing the octree
  117850. */
  117851. export interface IOctreeContainer<T> {
  117852. /**
  117853. * Blocks within the octree
  117854. */
  117855. blocks: Array<OctreeBlock<T>>;
  117856. }
  117857. /**
  117858. * Class used to store a cell in an octree
  117859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  117860. */
  117861. export class OctreeBlock<T> {
  117862. /**
  117863. * Gets the content of the current block
  117864. */
  117865. entries: T[];
  117866. /**
  117867. * Gets the list of block children
  117868. */
  117869. blocks: Array<OctreeBlock<T>>;
  117870. private _depth;
  117871. private _maxDepth;
  117872. private _capacity;
  117873. private _minPoint;
  117874. private _maxPoint;
  117875. private _boundingVectors;
  117876. private _creationFunc;
  117877. /**
  117878. * Creates a new block
  117879. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  117880. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  117881. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  117882. * @param depth defines the current depth of this block in the octree
  117883. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  117884. * @param creationFunc defines a callback to call when an element is added to the block
  117885. */
  117886. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  117887. /**
  117888. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  117889. */
  117890. get capacity(): number;
  117891. /**
  117892. * Gets the minimum vector (in world space) of the block's bounding box
  117893. */
  117894. get minPoint(): Vector3;
  117895. /**
  117896. * Gets the maximum vector (in world space) of the block's bounding box
  117897. */
  117898. get maxPoint(): Vector3;
  117899. /**
  117900. * Add a new element to this block
  117901. * @param entry defines the element to add
  117902. */
  117903. addEntry(entry: T): void;
  117904. /**
  117905. * Remove an element from this block
  117906. * @param entry defines the element to remove
  117907. */
  117908. removeEntry(entry: T): void;
  117909. /**
  117910. * Add an array of elements to this block
  117911. * @param entries defines the array of elements to add
  117912. */
  117913. addEntries(entries: T[]): void;
  117914. /**
  117915. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  117916. * @param frustumPlanes defines the frustum planes to test
  117917. * @param selection defines the array to store current content if selection is positive
  117918. * @param allowDuplicate defines if the selection array can contains duplicated entries
  117919. */
  117920. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  117921. /**
  117922. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  117923. * @param sphereCenter defines the bounding sphere center
  117924. * @param sphereRadius defines the bounding sphere radius
  117925. * @param selection defines the array to store current content if selection is positive
  117926. * @param allowDuplicate defines if the selection array can contains duplicated entries
  117927. */
  117928. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  117929. /**
  117930. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  117931. * @param ray defines the ray to test with
  117932. * @param selection defines the array to store current content if selection is positive
  117933. */
  117934. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  117935. /**
  117936. * Subdivide the content into child blocks (this block will then be empty)
  117937. */
  117938. createInnerBlocks(): void;
  117939. /**
  117940. * @hidden
  117941. */
  117942. 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;
  117943. }
  117944. }
  117945. declare module BABYLON {
  117946. /**
  117947. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  117948. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  117949. */
  117950. export class Octree<T> {
  117951. /** 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.) */
  117952. maxDepth: number;
  117953. /**
  117954. * Blocks within the octree containing objects
  117955. */
  117956. blocks: Array<OctreeBlock<T>>;
  117957. /**
  117958. * Content stored in the octree
  117959. */
  117960. dynamicContent: T[];
  117961. private _maxBlockCapacity;
  117962. private _selectionContent;
  117963. private _creationFunc;
  117964. /**
  117965. * Creates a octree
  117966. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  117967. * @param creationFunc function to be used to instatiate the octree
  117968. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  117969. * @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.)
  117970. */
  117971. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  117972. /** 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.) */
  117973. maxDepth?: number);
  117974. /**
  117975. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  117976. * @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);
  117977. * @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);
  117978. * @param entries meshes to be added to the octree blocks
  117979. */
  117980. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  117981. /**
  117982. * Adds a mesh to the octree
  117983. * @param entry Mesh to add to the octree
  117984. */
  117985. addMesh(entry: T): void;
  117986. /**
  117987. * Remove an element from the octree
  117988. * @param entry defines the element to remove
  117989. */
  117990. removeMesh(entry: T): void;
  117991. /**
  117992. * Selects an array of meshes within the frustum
  117993. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  117994. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  117995. * @returns array of meshes within the frustum
  117996. */
  117997. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  117998. /**
  117999. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118000. * @param sphereCenter defines the bounding sphere center
  118001. * @param sphereRadius defines the bounding sphere radius
  118002. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118003. * @returns an array of objects that intersect the sphere
  118004. */
  118005. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118006. /**
  118007. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118008. * @param ray defines the ray to test with
  118009. * @returns array of intersected objects
  118010. */
  118011. intersectsRay(ray: Ray): SmartArray<T>;
  118012. /**
  118013. * Adds a mesh into the octree block if it intersects the block
  118014. */
  118015. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118016. /**
  118017. * Adds a submesh into the octree block if it intersects the block
  118018. */
  118019. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118020. }
  118021. }
  118022. declare module BABYLON {
  118023. interface Scene {
  118024. /**
  118025. * @hidden
  118026. * Backing Filed
  118027. */
  118028. _selectionOctree: Octree<AbstractMesh>;
  118029. /**
  118030. * Gets the octree used to boost mesh selection (picking)
  118031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118032. */
  118033. selectionOctree: Octree<AbstractMesh>;
  118034. /**
  118035. * Creates or updates the octree used to boost selection (picking)
  118036. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118037. * @param maxCapacity defines the maximum capacity per leaf
  118038. * @param maxDepth defines the maximum depth of the octree
  118039. * @returns an octree of AbstractMesh
  118040. */
  118041. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118042. }
  118043. interface AbstractMesh {
  118044. /**
  118045. * @hidden
  118046. * Backing Field
  118047. */
  118048. _submeshesOctree: Octree<SubMesh>;
  118049. /**
  118050. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118051. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118052. * @param maxCapacity defines the maximum size of each block (64 by default)
  118053. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118054. * @returns the new octree
  118055. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118057. */
  118058. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118059. }
  118060. /**
  118061. * Defines the octree scene component responsible to manage any octrees
  118062. * in a given scene.
  118063. */
  118064. export class OctreeSceneComponent {
  118065. /**
  118066. * The component name help to identify the component in the list of scene components.
  118067. */
  118068. readonly name: string;
  118069. /**
  118070. * The scene the component belongs to.
  118071. */
  118072. scene: Scene;
  118073. /**
  118074. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118075. */
  118076. readonly checksIsEnabled: boolean;
  118077. /**
  118078. * Creates a new instance of the component for the given scene
  118079. * @param scene Defines the scene to register the component in
  118080. */
  118081. constructor(scene: Scene);
  118082. /**
  118083. * Registers the component in a given scene
  118084. */
  118085. register(): void;
  118086. /**
  118087. * Return the list of active meshes
  118088. * @returns the list of active meshes
  118089. */
  118090. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118091. /**
  118092. * Return the list of active sub meshes
  118093. * @param mesh The mesh to get the candidates sub meshes from
  118094. * @returns the list of active sub meshes
  118095. */
  118096. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118097. private _tempRay;
  118098. /**
  118099. * Return the list of sub meshes intersecting with a given local ray
  118100. * @param mesh defines the mesh to find the submesh for
  118101. * @param localRay defines the ray in local space
  118102. * @returns the list of intersecting sub meshes
  118103. */
  118104. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118105. /**
  118106. * Return the list of sub meshes colliding with a collider
  118107. * @param mesh defines the mesh to find the submesh for
  118108. * @param collider defines the collider to evaluate the collision against
  118109. * @returns the list of colliding sub meshes
  118110. */
  118111. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118112. /**
  118113. * Rebuilds the elements related to this component in case of
  118114. * context lost for instance.
  118115. */
  118116. rebuild(): void;
  118117. /**
  118118. * Disposes the component and the associated ressources.
  118119. */
  118120. dispose(): void;
  118121. }
  118122. }
  118123. declare module BABYLON {
  118124. /**
  118125. * Renders a layer on top of an existing scene
  118126. */
  118127. export class UtilityLayerRenderer implements IDisposable {
  118128. /** the original scene that will be rendered on top of */
  118129. originalScene: Scene;
  118130. private _pointerCaptures;
  118131. private _lastPointerEvents;
  118132. private static _DefaultUtilityLayer;
  118133. private static _DefaultKeepDepthUtilityLayer;
  118134. private _sharedGizmoLight;
  118135. private _renderCamera;
  118136. /**
  118137. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118138. * @returns the camera that is used when rendering the utility layer
  118139. */
  118140. getRenderCamera(): Nullable<Camera>;
  118141. /**
  118142. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118143. * @param cam the camera that should be used when rendering the utility layer
  118144. */
  118145. setRenderCamera(cam: Nullable<Camera>): void;
  118146. /**
  118147. * @hidden
  118148. * Light which used by gizmos to get light shading
  118149. */
  118150. _getSharedGizmoLight(): HemisphericLight;
  118151. /**
  118152. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118153. */
  118154. pickUtilitySceneFirst: boolean;
  118155. /**
  118156. * 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)
  118157. */
  118158. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118159. /**
  118160. * 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)
  118161. */
  118162. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118163. /**
  118164. * The scene that is rendered on top of the original scene
  118165. */
  118166. utilityLayerScene: Scene;
  118167. /**
  118168. * If the utility layer should automatically be rendered on top of existing scene
  118169. */
  118170. shouldRender: boolean;
  118171. /**
  118172. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118173. */
  118174. onlyCheckPointerDownEvents: boolean;
  118175. /**
  118176. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118177. */
  118178. processAllEvents: boolean;
  118179. /**
  118180. * Observable raised when the pointer move from the utility layer scene to the main scene
  118181. */
  118182. onPointerOutObservable: Observable<number>;
  118183. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118184. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118185. private _afterRenderObserver;
  118186. private _sceneDisposeObserver;
  118187. private _originalPointerObserver;
  118188. /**
  118189. * Instantiates a UtilityLayerRenderer
  118190. * @param originalScene the original scene that will be rendered on top of
  118191. * @param handleEvents boolean indicating if the utility layer should handle events
  118192. */
  118193. constructor(
  118194. /** the original scene that will be rendered on top of */
  118195. originalScene: Scene, handleEvents?: boolean);
  118196. private _notifyObservers;
  118197. /**
  118198. * Renders the utility layers scene on top of the original scene
  118199. */
  118200. render(): void;
  118201. /**
  118202. * Disposes of the renderer
  118203. */
  118204. dispose(): void;
  118205. private _updateCamera;
  118206. }
  118207. }
  118208. declare module BABYLON {
  118209. /**
  118210. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118211. */
  118212. export class Gizmo implements IDisposable {
  118213. /** The utility layer the gizmo will be added to */
  118214. gizmoLayer: UtilityLayerRenderer;
  118215. /**
  118216. * The root mesh of the gizmo
  118217. */
  118218. _rootMesh: Mesh;
  118219. private _attachedMesh;
  118220. /**
  118221. * Ratio for the scale of the gizmo (Default: 1)
  118222. */
  118223. scaleRatio: number;
  118224. /**
  118225. * If a custom mesh has been set (Default: false)
  118226. */
  118227. protected _customMeshSet: boolean;
  118228. /**
  118229. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118230. * * When set, interactions will be enabled
  118231. */
  118232. get attachedMesh(): Nullable<AbstractMesh>;
  118233. set attachedMesh(value: Nullable<AbstractMesh>);
  118234. /**
  118235. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118236. * @param mesh The mesh to replace the default mesh of the gizmo
  118237. */
  118238. setCustomMesh(mesh: Mesh): void;
  118239. /**
  118240. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118241. */
  118242. updateGizmoRotationToMatchAttachedMesh: boolean;
  118243. /**
  118244. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118245. */
  118246. updateGizmoPositionToMatchAttachedMesh: boolean;
  118247. /**
  118248. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118249. */
  118250. updateScale: boolean;
  118251. protected _interactionsEnabled: boolean;
  118252. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118253. private _beforeRenderObserver;
  118254. private _tempVector;
  118255. /**
  118256. * Creates a gizmo
  118257. * @param gizmoLayer The utility layer the gizmo will be added to
  118258. */
  118259. constructor(
  118260. /** The utility layer the gizmo will be added to */
  118261. gizmoLayer?: UtilityLayerRenderer);
  118262. /**
  118263. * Updates the gizmo to match the attached mesh's position/rotation
  118264. */
  118265. protected _update(): void;
  118266. /**
  118267. * Disposes of the gizmo
  118268. */
  118269. dispose(): void;
  118270. }
  118271. }
  118272. declare module BABYLON {
  118273. /**
  118274. * Single plane drag gizmo
  118275. */
  118276. export class PlaneDragGizmo extends Gizmo {
  118277. /**
  118278. * Drag behavior responsible for the gizmos dragging interactions
  118279. */
  118280. dragBehavior: PointerDragBehavior;
  118281. private _pointerObserver;
  118282. /**
  118283. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118284. */
  118285. snapDistance: number;
  118286. /**
  118287. * Event that fires each time the gizmo snaps to a new location.
  118288. * * snapDistance is the the change in distance
  118289. */
  118290. onSnapObservable: Observable<{
  118291. snapDistance: number;
  118292. }>;
  118293. private _plane;
  118294. private _coloredMaterial;
  118295. private _hoverMaterial;
  118296. private _isEnabled;
  118297. private _parent;
  118298. /** @hidden */
  118299. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  118300. /** @hidden */
  118301. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118302. /**
  118303. * Creates a PlaneDragGizmo
  118304. * @param gizmoLayer The utility layer the gizmo will be added to
  118305. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  118306. * @param color The color of the gizmo
  118307. */
  118308. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118309. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118310. /**
  118311. * If the gizmo is enabled
  118312. */
  118313. set isEnabled(value: boolean);
  118314. get isEnabled(): boolean;
  118315. /**
  118316. * Disposes of the gizmo
  118317. */
  118318. dispose(): void;
  118319. }
  118320. }
  118321. declare module BABYLON {
  118322. /**
  118323. * Gizmo that enables dragging a mesh along 3 axis
  118324. */
  118325. export class PositionGizmo extends Gizmo {
  118326. /**
  118327. * Internal gizmo used for interactions on the x axis
  118328. */
  118329. xGizmo: AxisDragGizmo;
  118330. /**
  118331. * Internal gizmo used for interactions on the y axis
  118332. */
  118333. yGizmo: AxisDragGizmo;
  118334. /**
  118335. * Internal gizmo used for interactions on the z axis
  118336. */
  118337. zGizmo: AxisDragGizmo;
  118338. /**
  118339. * Internal gizmo used for interactions on the yz plane
  118340. */
  118341. xPlaneGizmo: PlaneDragGizmo;
  118342. /**
  118343. * Internal gizmo used for interactions on the xz plane
  118344. */
  118345. yPlaneGizmo: PlaneDragGizmo;
  118346. /**
  118347. * Internal gizmo used for interactions on the xy plane
  118348. */
  118349. zPlaneGizmo: PlaneDragGizmo;
  118350. /**
  118351. * private variables
  118352. */
  118353. private _meshAttached;
  118354. private _updateGizmoRotationToMatchAttachedMesh;
  118355. private _snapDistance;
  118356. private _scaleRatio;
  118357. /** Fires an event when any of it's sub gizmos are dragged */
  118358. onDragStartObservable: Observable<unknown>;
  118359. /** Fires an event when any of it's sub gizmos are released from dragging */
  118360. onDragEndObservable: Observable<unknown>;
  118361. /**
  118362. * If set to true, planar drag is enabled
  118363. */
  118364. private _planarGizmoEnabled;
  118365. get attachedMesh(): Nullable<AbstractMesh>;
  118366. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118367. /**
  118368. * Creates a PositionGizmo
  118369. * @param gizmoLayer The utility layer the gizmo will be added to
  118370. */
  118371. constructor(gizmoLayer?: UtilityLayerRenderer);
  118372. /**
  118373. * If the planar drag gizmo is enabled
  118374. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  118375. */
  118376. set planarGizmoEnabled(value: boolean);
  118377. get planarGizmoEnabled(): boolean;
  118378. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118379. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118380. /**
  118381. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118382. */
  118383. set snapDistance(value: number);
  118384. get snapDistance(): number;
  118385. /**
  118386. * Ratio for the scale of the gizmo (Default: 1)
  118387. */
  118388. set scaleRatio(value: number);
  118389. get scaleRatio(): number;
  118390. /**
  118391. * Disposes of the gizmo
  118392. */
  118393. dispose(): void;
  118394. /**
  118395. * CustomMeshes are not supported by this gizmo
  118396. * @param mesh The mesh to replace the default mesh of the gizmo
  118397. */
  118398. setCustomMesh(mesh: Mesh): void;
  118399. }
  118400. }
  118401. declare module BABYLON {
  118402. /**
  118403. * Single axis drag gizmo
  118404. */
  118405. export class AxisDragGizmo extends Gizmo {
  118406. /**
  118407. * Drag behavior responsible for the gizmos dragging interactions
  118408. */
  118409. dragBehavior: PointerDragBehavior;
  118410. private _pointerObserver;
  118411. /**
  118412. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118413. */
  118414. snapDistance: number;
  118415. /**
  118416. * Event that fires each time the gizmo snaps to a new location.
  118417. * * snapDistance is the the change in distance
  118418. */
  118419. onSnapObservable: Observable<{
  118420. snapDistance: number;
  118421. }>;
  118422. private _isEnabled;
  118423. private _parent;
  118424. private _arrow;
  118425. private _coloredMaterial;
  118426. private _hoverMaterial;
  118427. /** @hidden */
  118428. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  118429. /** @hidden */
  118430. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118431. /**
  118432. * Creates an AxisDragGizmo
  118433. * @param gizmoLayer The utility layer the gizmo will be added to
  118434. * @param dragAxis The axis which the gizmo will be able to drag on
  118435. * @param color The color of the gizmo
  118436. */
  118437. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118438. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118439. /**
  118440. * If the gizmo is enabled
  118441. */
  118442. set isEnabled(value: boolean);
  118443. get isEnabled(): boolean;
  118444. /**
  118445. * Disposes of the gizmo
  118446. */
  118447. dispose(): void;
  118448. }
  118449. }
  118450. declare module BABYLON.Debug {
  118451. /**
  118452. * The Axes viewer will show 3 axes in a specific point in space
  118453. */
  118454. export class AxesViewer {
  118455. private _xAxis;
  118456. private _yAxis;
  118457. private _zAxis;
  118458. private _scaleLinesFactor;
  118459. private _instanced;
  118460. /**
  118461. * Gets the hosting scene
  118462. */
  118463. scene: Scene;
  118464. /**
  118465. * Gets or sets a number used to scale line length
  118466. */
  118467. scaleLines: number;
  118468. /** Gets the node hierarchy used to render x-axis */
  118469. get xAxis(): TransformNode;
  118470. /** Gets the node hierarchy used to render y-axis */
  118471. get yAxis(): TransformNode;
  118472. /** Gets the node hierarchy used to render z-axis */
  118473. get zAxis(): TransformNode;
  118474. /**
  118475. * Creates a new AxesViewer
  118476. * @param scene defines the hosting scene
  118477. * @param scaleLines defines a number used to scale line length (1 by default)
  118478. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  118479. * @param xAxis defines the node hierarchy used to render the x-axis
  118480. * @param yAxis defines the node hierarchy used to render the y-axis
  118481. * @param zAxis defines the node hierarchy used to render the z-axis
  118482. */
  118483. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  118484. /**
  118485. * Force the viewer to update
  118486. * @param position defines the position of the viewer
  118487. * @param xaxis defines the x axis of the viewer
  118488. * @param yaxis defines the y axis of the viewer
  118489. * @param zaxis defines the z axis of the viewer
  118490. */
  118491. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  118492. /**
  118493. * Creates an instance of this axes viewer.
  118494. * @returns a new axes viewer with instanced meshes
  118495. */
  118496. createInstance(): AxesViewer;
  118497. /** Releases resources */
  118498. dispose(): void;
  118499. private static _SetRenderingGroupId;
  118500. }
  118501. }
  118502. declare module BABYLON.Debug {
  118503. /**
  118504. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  118505. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  118506. */
  118507. export class BoneAxesViewer extends AxesViewer {
  118508. /**
  118509. * Gets or sets the target mesh where to display the axes viewer
  118510. */
  118511. mesh: Nullable<Mesh>;
  118512. /**
  118513. * Gets or sets the target bone where to display the axes viewer
  118514. */
  118515. bone: Nullable<Bone>;
  118516. /** Gets current position */
  118517. pos: Vector3;
  118518. /** Gets direction of X axis */
  118519. xaxis: Vector3;
  118520. /** Gets direction of Y axis */
  118521. yaxis: Vector3;
  118522. /** Gets direction of Z axis */
  118523. zaxis: Vector3;
  118524. /**
  118525. * Creates a new BoneAxesViewer
  118526. * @param scene defines the hosting scene
  118527. * @param bone defines the target bone
  118528. * @param mesh defines the target mesh
  118529. * @param scaleLines defines a scaling factor for line length (1 by default)
  118530. */
  118531. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  118532. /**
  118533. * Force the viewer to update
  118534. */
  118535. update(): void;
  118536. /** Releases resources */
  118537. dispose(): void;
  118538. }
  118539. }
  118540. declare module BABYLON {
  118541. /**
  118542. * Interface used to define scene explorer extensibility option
  118543. */
  118544. export interface IExplorerExtensibilityOption {
  118545. /**
  118546. * Define the option label
  118547. */
  118548. label: string;
  118549. /**
  118550. * Defines the action to execute on click
  118551. */
  118552. action: (entity: any) => void;
  118553. }
  118554. /**
  118555. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  118556. */
  118557. export interface IExplorerExtensibilityGroup {
  118558. /**
  118559. * Defines a predicate to test if a given type mut be extended
  118560. */
  118561. predicate: (entity: any) => boolean;
  118562. /**
  118563. * Gets the list of options added to a type
  118564. */
  118565. entries: IExplorerExtensibilityOption[];
  118566. }
  118567. /**
  118568. * Interface used to define the options to use to create the Inspector
  118569. */
  118570. export interface IInspectorOptions {
  118571. /**
  118572. * Display in overlay mode (default: false)
  118573. */
  118574. overlay?: boolean;
  118575. /**
  118576. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  118577. */
  118578. globalRoot?: HTMLElement;
  118579. /**
  118580. * Display the Scene explorer
  118581. */
  118582. showExplorer?: boolean;
  118583. /**
  118584. * Display the property inspector
  118585. */
  118586. showInspector?: boolean;
  118587. /**
  118588. * Display in embed mode (both panes on the right)
  118589. */
  118590. embedMode?: boolean;
  118591. /**
  118592. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  118593. */
  118594. handleResize?: boolean;
  118595. /**
  118596. * Allow the panes to popup (default: true)
  118597. */
  118598. enablePopup?: boolean;
  118599. /**
  118600. * Allow the panes to be closed by users (default: true)
  118601. */
  118602. enableClose?: boolean;
  118603. /**
  118604. * Optional list of extensibility entries
  118605. */
  118606. explorerExtensibility?: IExplorerExtensibilityGroup[];
  118607. /**
  118608. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  118609. */
  118610. inspectorURL?: string;
  118611. /**
  118612. * Optional initial tab (default to DebugLayerTab.Properties)
  118613. */
  118614. initialTab?: DebugLayerTab;
  118615. }
  118616. interface Scene {
  118617. /**
  118618. * @hidden
  118619. * Backing field
  118620. */
  118621. _debugLayer: DebugLayer;
  118622. /**
  118623. * Gets the debug layer (aka Inspector) associated with the scene
  118624. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118625. */
  118626. debugLayer: DebugLayer;
  118627. }
  118628. /**
  118629. * Enum of inspector action tab
  118630. */
  118631. export enum DebugLayerTab {
  118632. /**
  118633. * Properties tag (default)
  118634. */
  118635. Properties = 0,
  118636. /**
  118637. * Debug tab
  118638. */
  118639. Debug = 1,
  118640. /**
  118641. * Statistics tab
  118642. */
  118643. Statistics = 2,
  118644. /**
  118645. * Tools tab
  118646. */
  118647. Tools = 3,
  118648. /**
  118649. * Settings tab
  118650. */
  118651. Settings = 4
  118652. }
  118653. /**
  118654. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118655. * what is happening in your scene
  118656. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118657. */
  118658. export class DebugLayer {
  118659. /**
  118660. * Define the url to get the inspector script from.
  118661. * By default it uses the babylonjs CDN.
  118662. * @ignoreNaming
  118663. */
  118664. static InspectorURL: string;
  118665. private _scene;
  118666. private BJSINSPECTOR;
  118667. private _onPropertyChangedObservable?;
  118668. /**
  118669. * Observable triggered when a property is changed through the inspector.
  118670. */
  118671. get onPropertyChangedObservable(): any;
  118672. /**
  118673. * Instantiates a new debug layer.
  118674. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118675. * what is happening in your scene
  118676. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118677. * @param scene Defines the scene to inspect
  118678. */
  118679. constructor(scene: Scene);
  118680. /** Creates the inspector window. */
  118681. private _createInspector;
  118682. /**
  118683. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  118684. * @param entity defines the entity to select
  118685. * @param lineContainerTitle defines the specific block to highlight
  118686. */
  118687. select(entity: any, lineContainerTitle?: string): void;
  118688. /** Get the inspector from bundle or global */
  118689. private _getGlobalInspector;
  118690. /**
  118691. * Get if the inspector is visible or not.
  118692. * @returns true if visible otherwise, false
  118693. */
  118694. isVisible(): boolean;
  118695. /**
  118696. * Hide the inspector and close its window.
  118697. */
  118698. hide(): void;
  118699. /**
  118700. * Launch the debugLayer.
  118701. * @param config Define the configuration of the inspector
  118702. * @return a promise fulfilled when the debug layer is visible
  118703. */
  118704. show(config?: IInspectorOptions): Promise<DebugLayer>;
  118705. }
  118706. }
  118707. declare module BABYLON {
  118708. /**
  118709. * Class containing static functions to help procedurally build meshes
  118710. */
  118711. export class BoxBuilder {
  118712. /**
  118713. * Creates a box mesh
  118714. * * The parameter `size` sets the size (float) of each box side (default 1)
  118715. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118716. * * 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)
  118717. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118721. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118722. * @param name defines the name of the mesh
  118723. * @param options defines the options used to create the mesh
  118724. * @param scene defines the hosting scene
  118725. * @returns the box mesh
  118726. */
  118727. static CreateBox(name: string, options: {
  118728. size?: number;
  118729. width?: number;
  118730. height?: number;
  118731. depth?: number;
  118732. faceUV?: Vector4[];
  118733. faceColors?: Color4[];
  118734. sideOrientation?: number;
  118735. frontUVs?: Vector4;
  118736. backUVs?: Vector4;
  118737. wrap?: boolean;
  118738. topBaseAt?: number;
  118739. bottomBaseAt?: number;
  118740. updatable?: boolean;
  118741. }, scene?: Nullable<Scene>): Mesh;
  118742. }
  118743. }
  118744. declare module BABYLON {
  118745. /**
  118746. * Class containing static functions to help procedurally build meshes
  118747. */
  118748. export class SphereBuilder {
  118749. /**
  118750. * Creates a sphere mesh
  118751. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118752. * * 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`)
  118753. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118754. * * 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
  118755. * * 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)
  118756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118759. * @param name defines the name of the mesh
  118760. * @param options defines the options used to create the mesh
  118761. * @param scene defines the hosting scene
  118762. * @returns the sphere mesh
  118763. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118764. */
  118765. static CreateSphere(name: string, options: {
  118766. segments?: number;
  118767. diameter?: number;
  118768. diameterX?: number;
  118769. diameterY?: number;
  118770. diameterZ?: number;
  118771. arc?: number;
  118772. slice?: number;
  118773. sideOrientation?: number;
  118774. frontUVs?: Vector4;
  118775. backUVs?: Vector4;
  118776. updatable?: boolean;
  118777. }, scene?: Nullable<Scene>): Mesh;
  118778. }
  118779. }
  118780. declare module BABYLON.Debug {
  118781. /**
  118782. * Used to show the physics impostor around the specific mesh
  118783. */
  118784. export class PhysicsViewer {
  118785. /** @hidden */
  118786. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  118787. /** @hidden */
  118788. protected _meshes: Array<Nullable<AbstractMesh>>;
  118789. /** @hidden */
  118790. protected _scene: Nullable<Scene>;
  118791. /** @hidden */
  118792. protected _numMeshes: number;
  118793. /** @hidden */
  118794. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  118795. private _renderFunction;
  118796. private _utilityLayer;
  118797. private _debugBoxMesh;
  118798. private _debugSphereMesh;
  118799. private _debugCylinderMesh;
  118800. private _debugMaterial;
  118801. private _debugMeshMeshes;
  118802. /**
  118803. * Creates a new PhysicsViewer
  118804. * @param scene defines the hosting scene
  118805. */
  118806. constructor(scene: Scene);
  118807. /** @hidden */
  118808. protected _updateDebugMeshes(): void;
  118809. /**
  118810. * Renders a specified physic impostor
  118811. * @param impostor defines the impostor to render
  118812. * @param targetMesh defines the mesh represented by the impostor
  118813. * @returns the new debug mesh used to render the impostor
  118814. */
  118815. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  118816. /**
  118817. * Hides a specified physic impostor
  118818. * @param impostor defines the impostor to hide
  118819. */
  118820. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  118821. private _getDebugMaterial;
  118822. private _getDebugBoxMesh;
  118823. private _getDebugSphereMesh;
  118824. private _getDebugCylinderMesh;
  118825. private _getDebugMeshMesh;
  118826. private _getDebugMesh;
  118827. /** Releases all resources */
  118828. dispose(): void;
  118829. }
  118830. }
  118831. declare module BABYLON {
  118832. /**
  118833. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  118834. * in order to better appreciate the issue one might have.
  118835. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  118836. */
  118837. export class RayHelper {
  118838. /**
  118839. * Defines the ray we are currently tryin to visualize.
  118840. */
  118841. ray: Nullable<Ray>;
  118842. private _renderPoints;
  118843. private _renderLine;
  118844. private _renderFunction;
  118845. private _scene;
  118846. private _updateToMeshFunction;
  118847. private _attachedToMesh;
  118848. private _meshSpaceDirection;
  118849. private _meshSpaceOrigin;
  118850. /**
  118851. * Helper function to create a colored helper in a scene in one line.
  118852. * @param ray Defines the ray we are currently tryin to visualize
  118853. * @param scene Defines the scene the ray is used in
  118854. * @param color Defines the color we want to see the ray in
  118855. * @returns The newly created ray helper.
  118856. */
  118857. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  118858. /**
  118859. * Instantiate a new ray helper.
  118860. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  118861. * in order to better appreciate the issue one might have.
  118862. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  118863. * @param ray Defines the ray we are currently tryin to visualize
  118864. */
  118865. constructor(ray: Ray);
  118866. /**
  118867. * Shows the ray we are willing to debug.
  118868. * @param scene Defines the scene the ray needs to be rendered in
  118869. * @param color Defines the color the ray needs to be rendered in
  118870. */
  118871. show(scene: Scene, color?: Color3): void;
  118872. /**
  118873. * Hides the ray we are debugging.
  118874. */
  118875. hide(): void;
  118876. private _render;
  118877. /**
  118878. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  118879. * @param mesh Defines the mesh we want the helper attached to
  118880. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  118881. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  118882. * @param length Defines the length of the ray
  118883. */
  118884. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  118885. /**
  118886. * Detach the ray helper from the mesh it has previously been attached to.
  118887. */
  118888. detachFromMesh(): void;
  118889. private _updateToMesh;
  118890. /**
  118891. * Dispose the helper and release its associated resources.
  118892. */
  118893. dispose(): void;
  118894. }
  118895. }
  118896. declare module BABYLON.Debug {
  118897. /**
  118898. * Class used to render a debug view of a given skeleton
  118899. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  118900. */
  118901. export class SkeletonViewer {
  118902. /** defines the skeleton to render */
  118903. skeleton: Skeleton;
  118904. /** defines the mesh attached to the skeleton */
  118905. mesh: AbstractMesh;
  118906. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  118907. autoUpdateBonesMatrices: boolean;
  118908. /** defines the rendering group id to use with the viewer */
  118909. renderingGroupId: number;
  118910. /** Gets or sets the color used to render the skeleton */
  118911. color: Color3;
  118912. private _scene;
  118913. private _debugLines;
  118914. private _debugMesh;
  118915. private _isEnabled;
  118916. private _renderFunction;
  118917. private _utilityLayer;
  118918. /**
  118919. * Returns the mesh used to render the bones
  118920. */
  118921. get debugMesh(): Nullable<LinesMesh>;
  118922. /**
  118923. * Creates a new SkeletonViewer
  118924. * @param skeleton defines the skeleton to render
  118925. * @param mesh defines the mesh attached to the skeleton
  118926. * @param scene defines the hosting scene
  118927. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  118928. * @param renderingGroupId defines the rendering group id to use with the viewer
  118929. */
  118930. constructor(
  118931. /** defines the skeleton to render */
  118932. skeleton: Skeleton,
  118933. /** defines the mesh attached to the skeleton */
  118934. mesh: AbstractMesh, scene: Scene,
  118935. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  118936. autoUpdateBonesMatrices?: boolean,
  118937. /** defines the rendering group id to use with the viewer */
  118938. renderingGroupId?: number);
  118939. /** Gets or sets a boolean indicating if the viewer is enabled */
  118940. set isEnabled(value: boolean);
  118941. get isEnabled(): boolean;
  118942. private _getBonePosition;
  118943. private _getLinesForBonesWithLength;
  118944. private _getLinesForBonesNoLength;
  118945. /** Update the viewer to sync with current skeleton state */
  118946. update(): void;
  118947. /** Release associated resources */
  118948. dispose(): void;
  118949. }
  118950. }
  118951. declare module BABYLON {
  118952. /**
  118953. * Options to create the null engine
  118954. */
  118955. export class NullEngineOptions {
  118956. /**
  118957. * Render width (Default: 512)
  118958. */
  118959. renderWidth: number;
  118960. /**
  118961. * Render height (Default: 256)
  118962. */
  118963. renderHeight: number;
  118964. /**
  118965. * Texture size (Default: 512)
  118966. */
  118967. textureSize: number;
  118968. /**
  118969. * If delta time between frames should be constant
  118970. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118971. */
  118972. deterministicLockstep: boolean;
  118973. /**
  118974. * Maximum about of steps between frames (Default: 4)
  118975. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118976. */
  118977. lockstepMaxSteps: number;
  118978. }
  118979. /**
  118980. * The null engine class provides support for headless version of babylon.js.
  118981. * This can be used in server side scenario or for testing purposes
  118982. */
  118983. export class NullEngine extends Engine {
  118984. private _options;
  118985. /**
  118986. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118987. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118988. * @returns true if engine is in deterministic lock step mode
  118989. */
  118990. isDeterministicLockStep(): boolean;
  118991. /**
  118992. * Gets the max steps when engine is running in deterministic lock step
  118993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118994. * @returns the max steps
  118995. */
  118996. getLockstepMaxSteps(): number;
  118997. /**
  118998. * Gets the current hardware scaling level.
  118999. * By default the hardware scaling level is computed from the window device ratio.
  119000. * 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.
  119001. * @returns a number indicating the current hardware scaling level
  119002. */
  119003. getHardwareScalingLevel(): number;
  119004. constructor(options?: NullEngineOptions);
  119005. /**
  119006. * Creates a vertex buffer
  119007. * @param vertices the data for the vertex buffer
  119008. * @returns the new WebGL static buffer
  119009. */
  119010. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119011. /**
  119012. * Creates a new index buffer
  119013. * @param indices defines the content of the index buffer
  119014. * @param updatable defines if the index buffer must be updatable
  119015. * @returns a new webGL buffer
  119016. */
  119017. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119018. /**
  119019. * Clear the current render buffer or the current render target (if any is set up)
  119020. * @param color defines the color to use
  119021. * @param backBuffer defines if the back buffer must be cleared
  119022. * @param depth defines if the depth buffer must be cleared
  119023. * @param stencil defines if the stencil buffer must be cleared
  119024. */
  119025. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119026. /**
  119027. * Gets the current render width
  119028. * @param useScreen defines if screen size must be used (or the current render target if any)
  119029. * @returns a number defining the current render width
  119030. */
  119031. getRenderWidth(useScreen?: boolean): number;
  119032. /**
  119033. * Gets the current render height
  119034. * @param useScreen defines if screen size must be used (or the current render target if any)
  119035. * @returns a number defining the current render height
  119036. */
  119037. getRenderHeight(useScreen?: boolean): number;
  119038. /**
  119039. * Set the WebGL's viewport
  119040. * @param viewport defines the viewport element to be used
  119041. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119042. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119043. */
  119044. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119045. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119046. /**
  119047. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119048. * @param pipelineContext defines the pipeline context to use
  119049. * @param uniformsNames defines the list of uniform names
  119050. * @returns an array of webGL uniform locations
  119051. */
  119052. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119053. /**
  119054. * Gets the lsit of active attributes for a given webGL program
  119055. * @param pipelineContext defines the pipeline context to use
  119056. * @param attributesNames defines the list of attribute names to get
  119057. * @returns an array of indices indicating the offset of each attribute
  119058. */
  119059. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119060. /**
  119061. * Binds an effect to the webGL context
  119062. * @param effect defines the effect to bind
  119063. */
  119064. bindSamplers(effect: Effect): void;
  119065. /**
  119066. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119067. * @param effect defines the effect to activate
  119068. */
  119069. enableEffect(effect: Effect): void;
  119070. /**
  119071. * Set various states to the webGL context
  119072. * @param culling defines backface culling state
  119073. * @param zOffset defines the value to apply to zOffset (0 by default)
  119074. * @param force defines if states must be applied even if cache is up to date
  119075. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119076. */
  119077. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119078. /**
  119079. * Set the value of an uniform to an array of int32
  119080. * @param uniform defines the webGL uniform location where to store the value
  119081. * @param array defines the array of int32 to store
  119082. */
  119083. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119084. /**
  119085. * Set the value of an uniform to an array of int32 (stored as vec2)
  119086. * @param uniform defines the webGL uniform location where to store the value
  119087. * @param array defines the array of int32 to store
  119088. */
  119089. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119090. /**
  119091. * Set the value of an uniform to an array of int32 (stored as vec3)
  119092. * @param uniform defines the webGL uniform location where to store the value
  119093. * @param array defines the array of int32 to store
  119094. */
  119095. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119096. /**
  119097. * Set the value of an uniform to an array of int32 (stored as vec4)
  119098. * @param uniform defines the webGL uniform location where to store the value
  119099. * @param array defines the array of int32 to store
  119100. */
  119101. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119102. /**
  119103. * Set the value of an uniform to an array of float32
  119104. * @param uniform defines the webGL uniform location where to store the value
  119105. * @param array defines the array of float32 to store
  119106. */
  119107. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119108. /**
  119109. * Set the value of an uniform to an array of float32 (stored as vec2)
  119110. * @param uniform defines the webGL uniform location where to store the value
  119111. * @param array defines the array of float32 to store
  119112. */
  119113. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119114. /**
  119115. * Set the value of an uniform to an array of float32 (stored as vec3)
  119116. * @param uniform defines the webGL uniform location where to store the value
  119117. * @param array defines the array of float32 to store
  119118. */
  119119. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119120. /**
  119121. * Set the value of an uniform to an array of float32 (stored as vec4)
  119122. * @param uniform defines the webGL uniform location where to store the value
  119123. * @param array defines the array of float32 to store
  119124. */
  119125. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119126. /**
  119127. * Set the value of an uniform to an array of number
  119128. * @param uniform defines the webGL uniform location where to store the value
  119129. * @param array defines the array of number to store
  119130. */
  119131. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119132. /**
  119133. * Set the value of an uniform to an array of number (stored as vec2)
  119134. * @param uniform defines the webGL uniform location where to store the value
  119135. * @param array defines the array of number to store
  119136. */
  119137. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119138. /**
  119139. * Set the value of an uniform to an array of number (stored as vec3)
  119140. * @param uniform defines the webGL uniform location where to store the value
  119141. * @param array defines the array of number to store
  119142. */
  119143. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119144. /**
  119145. * Set the value of an uniform to an array of number (stored as vec4)
  119146. * @param uniform defines the webGL uniform location where to store the value
  119147. * @param array defines the array of number to store
  119148. */
  119149. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119150. /**
  119151. * Set the value of an uniform to an array of float32 (stored as matrices)
  119152. * @param uniform defines the webGL uniform location where to store the value
  119153. * @param matrices defines the array of float32 to store
  119154. */
  119155. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119156. /**
  119157. * Set the value of an uniform to a matrix (3x3)
  119158. * @param uniform defines the webGL uniform location where to store the value
  119159. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119160. */
  119161. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119162. /**
  119163. * Set the value of an uniform to a matrix (2x2)
  119164. * @param uniform defines the webGL uniform location where to store the value
  119165. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119166. */
  119167. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119168. /**
  119169. * Set the value of an uniform to a number (float)
  119170. * @param uniform defines the webGL uniform location where to store the value
  119171. * @param value defines the float number to store
  119172. */
  119173. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119174. /**
  119175. * Set the value of an uniform to a vec2
  119176. * @param uniform defines the webGL uniform location where to store the value
  119177. * @param x defines the 1st component of the value
  119178. * @param y defines the 2nd component of the value
  119179. */
  119180. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119181. /**
  119182. * Set the value of an uniform to a vec3
  119183. * @param uniform defines the webGL uniform location where to store the value
  119184. * @param x defines the 1st component of the value
  119185. * @param y defines the 2nd component of the value
  119186. * @param z defines the 3rd component of the value
  119187. */
  119188. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119189. /**
  119190. * Set the value of an uniform to a boolean
  119191. * @param uniform defines the webGL uniform location where to store the value
  119192. * @param bool defines the boolean to store
  119193. */
  119194. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119195. /**
  119196. * Set the value of an uniform to a vec4
  119197. * @param uniform defines the webGL uniform location where to store the value
  119198. * @param x defines the 1st component of the value
  119199. * @param y defines the 2nd component of the value
  119200. * @param z defines the 3rd component of the value
  119201. * @param w defines the 4th component of the value
  119202. */
  119203. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119204. /**
  119205. * Sets the current alpha mode
  119206. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119207. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119208. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119209. */
  119210. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119211. /**
  119212. * Bind webGl buffers directly to the webGL context
  119213. * @param vertexBuffers defines the vertex buffer to bind
  119214. * @param indexBuffer defines the index buffer to bind
  119215. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119216. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119217. * @param effect defines the effect associated with the vertex buffer
  119218. */
  119219. bindBuffers(vertexBuffers: {
  119220. [key: string]: VertexBuffer;
  119221. }, indexBuffer: DataBuffer, effect: Effect): void;
  119222. /**
  119223. * Force the entire cache to be cleared
  119224. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119225. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119226. */
  119227. wipeCaches(bruteForce?: boolean): void;
  119228. /**
  119229. * Send a draw order
  119230. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119231. * @param indexStart defines the starting index
  119232. * @param indexCount defines the number of index to draw
  119233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119234. */
  119235. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119236. /**
  119237. * Draw a list of indexed primitives
  119238. * @param fillMode defines the primitive to use
  119239. * @param indexStart defines the starting index
  119240. * @param indexCount defines the number of index to draw
  119241. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119242. */
  119243. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119244. /**
  119245. * Draw a list of unindexed primitives
  119246. * @param fillMode defines the primitive to use
  119247. * @param verticesStart defines the index of first vertex to draw
  119248. * @param verticesCount defines the count of vertices to draw
  119249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119250. */
  119251. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119252. /** @hidden */
  119253. _createTexture(): WebGLTexture;
  119254. /** @hidden */
  119255. _releaseTexture(texture: InternalTexture): void;
  119256. /**
  119257. * Usually called from Texture.ts.
  119258. * Passed information to create a WebGLTexture
  119259. * @param urlArg defines a value which contains one of the following:
  119260. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119261. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119262. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119263. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119264. * @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)
  119265. * @param scene needed for loading to the correct scene
  119266. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119267. * @param onLoad optional callback to be called upon successful completion
  119268. * @param onError optional callback to be called upon failure
  119269. * @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
  119270. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119271. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119272. * @param forcedExtension defines the extension to use to pick the right loader
  119273. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119274. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119275. */
  119276. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  119277. /**
  119278. * Creates a new render target texture
  119279. * @param size defines the size of the texture
  119280. * @param options defines the options used to create the texture
  119281. * @returns a new render target texture stored in an InternalTexture
  119282. */
  119283. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119284. /**
  119285. * Update the sampling mode of a given texture
  119286. * @param samplingMode defines the required sampling mode
  119287. * @param texture defines the texture to update
  119288. */
  119289. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119290. /**
  119291. * Binds the frame buffer to the specified texture.
  119292. * @param texture The texture to render to or null for the default canvas
  119293. * @param faceIndex The face of the texture to render to in case of cube texture
  119294. * @param requiredWidth The width of the target to render to
  119295. * @param requiredHeight The height of the target to render to
  119296. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119297. * @param lodLevel defines le lod level to bind to the frame buffer
  119298. */
  119299. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119300. /**
  119301. * Unbind the current render target texture from the webGL context
  119302. * @param texture defines the render target texture to unbind
  119303. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119304. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119305. */
  119306. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119307. /**
  119308. * Creates a dynamic vertex buffer
  119309. * @param vertices the data for the dynamic vertex buffer
  119310. * @returns the new WebGL dynamic buffer
  119311. */
  119312. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119313. /**
  119314. * Update the content of a dynamic texture
  119315. * @param texture defines the texture to update
  119316. * @param canvas defines the canvas containing the source
  119317. * @param invertY defines if data must be stored with Y axis inverted
  119318. * @param premulAlpha defines if alpha is stored as premultiplied
  119319. * @param format defines the format of the data
  119320. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119321. */
  119322. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119323. /**
  119324. * Gets a boolean indicating if all created effects are ready
  119325. * @returns true if all effects are ready
  119326. */
  119327. areAllEffectsReady(): boolean;
  119328. /**
  119329. * @hidden
  119330. * Get the current error code of the webGL context
  119331. * @returns the error code
  119332. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119333. */
  119334. getError(): number;
  119335. /** @hidden */
  119336. _getUnpackAlignement(): number;
  119337. /** @hidden */
  119338. _unpackFlipY(value: boolean): void;
  119339. /**
  119340. * Update a dynamic index buffer
  119341. * @param indexBuffer defines the target index buffer
  119342. * @param indices defines the data to update
  119343. * @param offset defines the offset in the target index buffer where update should start
  119344. */
  119345. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  119346. /**
  119347. * Updates a dynamic vertex buffer.
  119348. * @param vertexBuffer the vertex buffer to update
  119349. * @param vertices the data used to update the vertex buffer
  119350. * @param byteOffset the byte offset of the data (optional)
  119351. * @param byteLength the byte length of the data (optional)
  119352. */
  119353. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  119354. /** @hidden */
  119355. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  119356. /** @hidden */
  119357. _bindTexture(channel: number, texture: InternalTexture): void;
  119358. protected _deleteBuffer(buffer: WebGLBuffer): void;
  119359. /**
  119360. * 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
  119361. */
  119362. releaseEffects(): void;
  119363. displayLoadingUI(): void;
  119364. hideLoadingUI(): void;
  119365. /** @hidden */
  119366. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119367. /** @hidden */
  119368. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119369. /** @hidden */
  119370. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119371. /** @hidden */
  119372. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  119373. }
  119374. }
  119375. declare module BABYLON {
  119376. /** @hidden */
  119377. export class _OcclusionDataStorage {
  119378. /** @hidden */
  119379. occlusionInternalRetryCounter: number;
  119380. /** @hidden */
  119381. isOcclusionQueryInProgress: boolean;
  119382. /** @hidden */
  119383. isOccluded: boolean;
  119384. /** @hidden */
  119385. occlusionRetryCount: number;
  119386. /** @hidden */
  119387. occlusionType: number;
  119388. /** @hidden */
  119389. occlusionQueryAlgorithmType: number;
  119390. }
  119391. interface Engine {
  119392. /**
  119393. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  119394. * @return the new query
  119395. */
  119396. createQuery(): WebGLQuery;
  119397. /**
  119398. * Delete and release a webGL query
  119399. * @param query defines the query to delete
  119400. * @return the current engine
  119401. */
  119402. deleteQuery(query: WebGLQuery): Engine;
  119403. /**
  119404. * Check if a given query has resolved and got its value
  119405. * @param query defines the query to check
  119406. * @returns true if the query got its value
  119407. */
  119408. isQueryResultAvailable(query: WebGLQuery): boolean;
  119409. /**
  119410. * Gets the value of a given query
  119411. * @param query defines the query to check
  119412. * @returns the value of the query
  119413. */
  119414. getQueryResult(query: WebGLQuery): number;
  119415. /**
  119416. * Initiates an occlusion query
  119417. * @param algorithmType defines the algorithm to use
  119418. * @param query defines the query to use
  119419. * @returns the current engine
  119420. * @see http://doc.babylonjs.com/features/occlusionquery
  119421. */
  119422. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  119423. /**
  119424. * Ends an occlusion query
  119425. * @see http://doc.babylonjs.com/features/occlusionquery
  119426. * @param algorithmType defines the algorithm to use
  119427. * @returns the current engine
  119428. */
  119429. endOcclusionQuery(algorithmType: number): Engine;
  119430. /**
  119431. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  119432. * Please note that only one query can be issued at a time
  119433. * @returns a time token used to track the time span
  119434. */
  119435. startTimeQuery(): Nullable<_TimeToken>;
  119436. /**
  119437. * Ends a time query
  119438. * @param token defines the token used to measure the time span
  119439. * @returns the time spent (in ns)
  119440. */
  119441. endTimeQuery(token: _TimeToken): int;
  119442. /** @hidden */
  119443. _currentNonTimestampToken: Nullable<_TimeToken>;
  119444. /** @hidden */
  119445. _createTimeQuery(): WebGLQuery;
  119446. /** @hidden */
  119447. _deleteTimeQuery(query: WebGLQuery): void;
  119448. /** @hidden */
  119449. _getGlAlgorithmType(algorithmType: number): number;
  119450. /** @hidden */
  119451. _getTimeQueryResult(query: WebGLQuery): any;
  119452. /** @hidden */
  119453. _getTimeQueryAvailability(query: WebGLQuery): any;
  119454. }
  119455. interface AbstractMesh {
  119456. /**
  119457. * Backing filed
  119458. * @hidden
  119459. */
  119460. __occlusionDataStorage: _OcclusionDataStorage;
  119461. /**
  119462. * Access property
  119463. * @hidden
  119464. */
  119465. _occlusionDataStorage: _OcclusionDataStorage;
  119466. /**
  119467. * 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.
  119468. * The default value is -1 which means don't break the query and wait till the result
  119469. * @see http://doc.babylonjs.com/features/occlusionquery
  119470. */
  119471. occlusionRetryCount: number;
  119472. /**
  119473. * 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:
  119474. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  119475. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  119476. * * 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.
  119477. * @see http://doc.babylonjs.com/features/occlusionquery
  119478. */
  119479. occlusionType: number;
  119480. /**
  119481. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  119482. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  119483. * * 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.
  119484. * @see http://doc.babylonjs.com/features/occlusionquery
  119485. */
  119486. occlusionQueryAlgorithmType: number;
  119487. /**
  119488. * 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
  119489. * @see http://doc.babylonjs.com/features/occlusionquery
  119490. */
  119491. isOccluded: boolean;
  119492. /**
  119493. * Flag to check the progress status of the query
  119494. * @see http://doc.babylonjs.com/features/occlusionquery
  119495. */
  119496. isOcclusionQueryInProgress: boolean;
  119497. }
  119498. }
  119499. declare module BABYLON {
  119500. /** @hidden */
  119501. export var _forceTransformFeedbackToBundle: boolean;
  119502. interface Engine {
  119503. /**
  119504. * Creates a webGL transform feedback object
  119505. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  119506. * @returns the webGL transform feedback object
  119507. */
  119508. createTransformFeedback(): WebGLTransformFeedback;
  119509. /**
  119510. * Delete a webGL transform feedback object
  119511. * @param value defines the webGL transform feedback object to delete
  119512. */
  119513. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  119514. /**
  119515. * Bind a webGL transform feedback object to the webgl context
  119516. * @param value defines the webGL transform feedback object to bind
  119517. */
  119518. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  119519. /**
  119520. * Begins a transform feedback operation
  119521. * @param usePoints defines if points or triangles must be used
  119522. */
  119523. beginTransformFeedback(usePoints: boolean): void;
  119524. /**
  119525. * Ends a transform feedback operation
  119526. */
  119527. endTransformFeedback(): void;
  119528. /**
  119529. * Specify the varyings to use with transform feedback
  119530. * @param program defines the associated webGL program
  119531. * @param value defines the list of strings representing the varying names
  119532. */
  119533. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  119534. /**
  119535. * Bind a webGL buffer for a transform feedback operation
  119536. * @param value defines the webGL buffer to bind
  119537. */
  119538. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  119539. }
  119540. }
  119541. declare module BABYLON {
  119542. /**
  119543. * Creation options of the multi render target texture.
  119544. */
  119545. export interface IMultiRenderTargetOptions {
  119546. /**
  119547. * Define if the texture needs to create mip maps after render.
  119548. */
  119549. generateMipMaps?: boolean;
  119550. /**
  119551. * Define the types of all the draw buffers we want to create
  119552. */
  119553. types?: number[];
  119554. /**
  119555. * Define the sampling modes of all the draw buffers we want to create
  119556. */
  119557. samplingModes?: number[];
  119558. /**
  119559. * Define if a depth buffer is required
  119560. */
  119561. generateDepthBuffer?: boolean;
  119562. /**
  119563. * Define if a stencil buffer is required
  119564. */
  119565. generateStencilBuffer?: boolean;
  119566. /**
  119567. * Define if a depth texture is required instead of a depth buffer
  119568. */
  119569. generateDepthTexture?: boolean;
  119570. /**
  119571. * Define the number of desired draw buffers
  119572. */
  119573. textureCount?: number;
  119574. /**
  119575. * Define if aspect ratio should be adapted to the texture or stay the scene one
  119576. */
  119577. doNotChangeAspectRatio?: boolean;
  119578. /**
  119579. * Define the default type of the buffers we are creating
  119580. */
  119581. defaultType?: number;
  119582. }
  119583. /**
  119584. * A multi render target, like a render target provides the ability to render to a texture.
  119585. * Unlike the render target, it can render to several draw buffers in one draw.
  119586. * This is specially interesting in deferred rendering or for any effects requiring more than
  119587. * just one color from a single pass.
  119588. */
  119589. export class MultiRenderTarget extends RenderTargetTexture {
  119590. private _internalTextures;
  119591. private _textures;
  119592. private _multiRenderTargetOptions;
  119593. /**
  119594. * Get if draw buffers are currently supported by the used hardware and browser.
  119595. */
  119596. get isSupported(): boolean;
  119597. /**
  119598. * Get the list of textures generated by the multi render target.
  119599. */
  119600. get textures(): Texture[];
  119601. /**
  119602. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  119603. */
  119604. get depthTexture(): Texture;
  119605. /**
  119606. * Set the wrapping mode on U of all the textures we are rendering to.
  119607. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119608. */
  119609. set wrapU(wrap: number);
  119610. /**
  119611. * Set the wrapping mode on V of all the textures we are rendering to.
  119612. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119613. */
  119614. set wrapV(wrap: number);
  119615. /**
  119616. * Instantiate a new multi render target texture.
  119617. * A multi render target, like a render target provides the ability to render to a texture.
  119618. * Unlike the render target, it can render to several draw buffers in one draw.
  119619. * This is specially interesting in deferred rendering or for any effects requiring more than
  119620. * just one color from a single pass.
  119621. * @param name Define the name of the texture
  119622. * @param size Define the size of the buffers to render to
  119623. * @param count Define the number of target we are rendering into
  119624. * @param scene Define the scene the texture belongs to
  119625. * @param options Define the options used to create the multi render target
  119626. */
  119627. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  119628. /** @hidden */
  119629. _rebuild(): void;
  119630. private _createInternalTextures;
  119631. private _createTextures;
  119632. /**
  119633. * Define the number of samples used if MSAA is enabled.
  119634. */
  119635. get samples(): number;
  119636. set samples(value: number);
  119637. /**
  119638. * Resize all the textures in the multi render target.
  119639. * Be carrefull as it will recreate all the data in the new texture.
  119640. * @param size Define the new size
  119641. */
  119642. resize(size: any): void;
  119643. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119644. /**
  119645. * Dispose the render targets and their associated resources
  119646. */
  119647. dispose(): void;
  119648. /**
  119649. * Release all the underlying texture used as draw buffers.
  119650. */
  119651. releaseInternalTextures(): void;
  119652. }
  119653. }
  119654. declare module BABYLON {
  119655. interface ThinEngine {
  119656. /**
  119657. * Unbind a list of render target textures from the webGL context
  119658. * This is used only when drawBuffer extension or webGL2 are active
  119659. * @param textures defines the render target textures to unbind
  119660. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119661. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119662. */
  119663. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  119664. /**
  119665. * Create a multi render target texture
  119666. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  119667. * @param size defines the size of the texture
  119668. * @param options defines the creation options
  119669. * @returns the cube texture as an InternalTexture
  119670. */
  119671. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  119672. /**
  119673. * Update the sample count for a given multiple render target texture
  119674. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  119675. * @param textures defines the textures to update
  119676. * @param samples defines the sample count to set
  119677. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  119678. */
  119679. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  119680. }
  119681. }
  119682. declare module BABYLON {
  119683. /**
  119684. * Class used to define an additional view for the engine
  119685. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119686. */
  119687. export class EngineView {
  119688. /** Defines the canvas where to render the view */
  119689. target: HTMLCanvasElement;
  119690. /** Defines an optional camera used to render the view (will use active camera else) */
  119691. camera?: Camera;
  119692. }
  119693. interface Engine {
  119694. /**
  119695. * Gets or sets the HTML element to use for attaching events
  119696. */
  119697. inputElement: Nullable<HTMLElement>;
  119698. /**
  119699. * Gets the current engine view
  119700. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119701. */
  119702. activeView: Nullable<EngineView>;
  119703. /** Gets or sets the list of views */
  119704. views: EngineView[];
  119705. /**
  119706. * Register a new child canvas
  119707. * @param canvas defines the canvas to register
  119708. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  119709. * @returns the associated view
  119710. */
  119711. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  119712. /**
  119713. * Remove a registered child canvas
  119714. * @param canvas defines the canvas to remove
  119715. * @returns the current engine
  119716. */
  119717. unRegisterView(canvas: HTMLCanvasElement): Engine;
  119718. }
  119719. }
  119720. declare module BABYLON {
  119721. /**
  119722. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  119723. */
  119724. export interface CubeMapInfo {
  119725. /**
  119726. * The pixel array for the front face.
  119727. * This is stored in format, left to right, up to down format.
  119728. */
  119729. front: Nullable<ArrayBufferView>;
  119730. /**
  119731. * The pixel array for the back face.
  119732. * This is stored in format, left to right, up to down format.
  119733. */
  119734. back: Nullable<ArrayBufferView>;
  119735. /**
  119736. * The pixel array for the left face.
  119737. * This is stored in format, left to right, up to down format.
  119738. */
  119739. left: Nullable<ArrayBufferView>;
  119740. /**
  119741. * The pixel array for the right face.
  119742. * This is stored in format, left to right, up to down format.
  119743. */
  119744. right: Nullable<ArrayBufferView>;
  119745. /**
  119746. * The pixel array for the up face.
  119747. * This is stored in format, left to right, up to down format.
  119748. */
  119749. up: Nullable<ArrayBufferView>;
  119750. /**
  119751. * The pixel array for the down face.
  119752. * This is stored in format, left to right, up to down format.
  119753. */
  119754. down: Nullable<ArrayBufferView>;
  119755. /**
  119756. * The size of the cubemap stored.
  119757. *
  119758. * Each faces will be size * size pixels.
  119759. */
  119760. size: number;
  119761. /**
  119762. * The format of the texture.
  119763. *
  119764. * RGBA, RGB.
  119765. */
  119766. format: number;
  119767. /**
  119768. * The type of the texture data.
  119769. *
  119770. * UNSIGNED_INT, FLOAT.
  119771. */
  119772. type: number;
  119773. /**
  119774. * Specifies whether the texture is in gamma space.
  119775. */
  119776. gammaSpace: boolean;
  119777. }
  119778. /**
  119779. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  119780. */
  119781. export class PanoramaToCubeMapTools {
  119782. private static FACE_FRONT;
  119783. private static FACE_BACK;
  119784. private static FACE_RIGHT;
  119785. private static FACE_LEFT;
  119786. private static FACE_DOWN;
  119787. private static FACE_UP;
  119788. /**
  119789. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  119790. *
  119791. * @param float32Array The source data.
  119792. * @param inputWidth The width of the input panorama.
  119793. * @param inputHeight The height of the input panorama.
  119794. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  119795. * @return The cubemap data
  119796. */
  119797. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  119798. private static CreateCubemapTexture;
  119799. private static CalcProjectionSpherical;
  119800. }
  119801. }
  119802. declare module BABYLON {
  119803. /**
  119804. * Helper class dealing with the extraction of spherical polynomial dataArray
  119805. * from a cube map.
  119806. */
  119807. export class CubeMapToSphericalPolynomialTools {
  119808. private static FileFaces;
  119809. /**
  119810. * Converts a texture to the according Spherical Polynomial data.
  119811. * This extracts the first 3 orders only as they are the only one used in the lighting.
  119812. *
  119813. * @param texture The texture to extract the information from.
  119814. * @return The Spherical Polynomial data.
  119815. */
  119816. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  119817. /**
  119818. * Converts a cubemap to the according Spherical Polynomial data.
  119819. * This extracts the first 3 orders only as they are the only one used in the lighting.
  119820. *
  119821. * @param cubeInfo The Cube map to extract the information from.
  119822. * @return The Spherical Polynomial data.
  119823. */
  119824. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  119825. }
  119826. }
  119827. declare module BABYLON {
  119828. interface BaseTexture {
  119829. /**
  119830. * Get the polynomial representation of the texture data.
  119831. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  119832. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  119833. */
  119834. sphericalPolynomial: Nullable<SphericalPolynomial>;
  119835. }
  119836. }
  119837. declare module BABYLON {
  119838. /** @hidden */
  119839. export var rgbdEncodePixelShader: {
  119840. name: string;
  119841. shader: string;
  119842. };
  119843. }
  119844. declare module BABYLON {
  119845. /** @hidden */
  119846. export var rgbdDecodePixelShader: {
  119847. name: string;
  119848. shader: string;
  119849. };
  119850. }
  119851. declare module BABYLON {
  119852. /**
  119853. * Raw texture data and descriptor sufficient for WebGL texture upload
  119854. */
  119855. export interface EnvironmentTextureInfo {
  119856. /**
  119857. * Version of the environment map
  119858. */
  119859. version: number;
  119860. /**
  119861. * Width of image
  119862. */
  119863. width: number;
  119864. /**
  119865. * Irradiance information stored in the file.
  119866. */
  119867. irradiance: any;
  119868. /**
  119869. * Specular information stored in the file.
  119870. */
  119871. specular: any;
  119872. }
  119873. /**
  119874. * Defines One Image in the file. It requires only the position in the file
  119875. * as well as the length.
  119876. */
  119877. interface BufferImageData {
  119878. /**
  119879. * Length of the image data.
  119880. */
  119881. length: number;
  119882. /**
  119883. * Position of the data from the null terminator delimiting the end of the JSON.
  119884. */
  119885. position: number;
  119886. }
  119887. /**
  119888. * Defines the specular data enclosed in the file.
  119889. * This corresponds to the version 1 of the data.
  119890. */
  119891. export interface EnvironmentTextureSpecularInfoV1 {
  119892. /**
  119893. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  119894. */
  119895. specularDataPosition?: number;
  119896. /**
  119897. * This contains all the images data needed to reconstruct the cubemap.
  119898. */
  119899. mipmaps: Array<BufferImageData>;
  119900. /**
  119901. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  119902. */
  119903. lodGenerationScale: number;
  119904. }
  119905. /**
  119906. * Sets of helpers addressing the serialization and deserialization of environment texture
  119907. * stored in a BabylonJS env file.
  119908. * Those files are usually stored as .env files.
  119909. */
  119910. export class EnvironmentTextureTools {
  119911. /**
  119912. * Magic number identifying the env file.
  119913. */
  119914. private static _MagicBytes;
  119915. /**
  119916. * Gets the environment info from an env file.
  119917. * @param data The array buffer containing the .env bytes.
  119918. * @returns the environment file info (the json header) if successfully parsed.
  119919. */
  119920. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  119921. /**
  119922. * Creates an environment texture from a loaded cube texture.
  119923. * @param texture defines the cube texture to convert in env file
  119924. * @return a promise containing the environment data if succesfull.
  119925. */
  119926. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  119927. /**
  119928. * Creates a JSON representation of the spherical data.
  119929. * @param texture defines the texture containing the polynomials
  119930. * @return the JSON representation of the spherical info
  119931. */
  119932. private static _CreateEnvTextureIrradiance;
  119933. /**
  119934. * Creates the ArrayBufferViews used for initializing environment texture image data.
  119935. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  119936. * @param info parameters that determine what views will be created for accessing the underlying buffer
  119937. * @return the views described by info providing access to the underlying buffer
  119938. */
  119939. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  119940. /**
  119941. * Uploads the texture info contained in the env file to the GPU.
  119942. * @param texture defines the internal texture to upload to
  119943. * @param arrayBuffer defines the buffer cotaining the data to load
  119944. * @param info defines the texture info retrieved through the GetEnvInfo method
  119945. * @returns a promise
  119946. */
  119947. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  119948. private static _OnImageReadyAsync;
  119949. /**
  119950. * Uploads the levels of image data to the GPU.
  119951. * @param texture defines the internal texture to upload to
  119952. * @param imageData defines the array buffer views of image data [mipmap][face]
  119953. * @returns a promise
  119954. */
  119955. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  119956. /**
  119957. * Uploads spherical polynomials information to the texture.
  119958. * @param texture defines the texture we are trying to upload the information to
  119959. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  119960. */
  119961. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  119962. /** @hidden */
  119963. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119964. }
  119965. }
  119966. declare module BABYLON {
  119967. /**
  119968. * Contains position and normal vectors for a vertex
  119969. */
  119970. export class PositionNormalVertex {
  119971. /** the position of the vertex (defaut: 0,0,0) */
  119972. position: Vector3;
  119973. /** the normal of the vertex (defaut: 0,1,0) */
  119974. normal: Vector3;
  119975. /**
  119976. * Creates a PositionNormalVertex
  119977. * @param position the position of the vertex (defaut: 0,0,0)
  119978. * @param normal the normal of the vertex (defaut: 0,1,0)
  119979. */
  119980. constructor(
  119981. /** the position of the vertex (defaut: 0,0,0) */
  119982. position?: Vector3,
  119983. /** the normal of the vertex (defaut: 0,1,0) */
  119984. normal?: Vector3);
  119985. /**
  119986. * Clones the PositionNormalVertex
  119987. * @returns the cloned PositionNormalVertex
  119988. */
  119989. clone(): PositionNormalVertex;
  119990. }
  119991. /**
  119992. * Contains position, normal and uv vectors for a vertex
  119993. */
  119994. export class PositionNormalTextureVertex {
  119995. /** the position of the vertex (defaut: 0,0,0) */
  119996. position: Vector3;
  119997. /** the normal of the vertex (defaut: 0,1,0) */
  119998. normal: Vector3;
  119999. /** the uv of the vertex (default: 0,0) */
  120000. uv: Vector2;
  120001. /**
  120002. * Creates a PositionNormalTextureVertex
  120003. * @param position the position of the vertex (defaut: 0,0,0)
  120004. * @param normal the normal of the vertex (defaut: 0,1,0)
  120005. * @param uv the uv of the vertex (default: 0,0)
  120006. */
  120007. constructor(
  120008. /** the position of the vertex (defaut: 0,0,0) */
  120009. position?: Vector3,
  120010. /** the normal of the vertex (defaut: 0,1,0) */
  120011. normal?: Vector3,
  120012. /** the uv of the vertex (default: 0,0) */
  120013. uv?: Vector2);
  120014. /**
  120015. * Clones the PositionNormalTextureVertex
  120016. * @returns the cloned PositionNormalTextureVertex
  120017. */
  120018. clone(): PositionNormalTextureVertex;
  120019. }
  120020. }
  120021. declare module BABYLON {
  120022. /** @hidden */
  120023. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120024. private _genericAttributeLocation;
  120025. private _varyingLocationCount;
  120026. private _varyingLocationMap;
  120027. private _replacements;
  120028. private _textureCount;
  120029. private _uniforms;
  120030. lineProcessor(line: string): string;
  120031. attributeProcessor(attribute: string): string;
  120032. varyingProcessor(varying: string, isFragment: boolean): string;
  120033. uniformProcessor(uniform: string): string;
  120034. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120035. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120036. }
  120037. }
  120038. declare module BABYLON {
  120039. /**
  120040. * Container for accessors for natively-stored mesh data buffers.
  120041. */
  120042. class NativeDataBuffer extends DataBuffer {
  120043. /**
  120044. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120045. */
  120046. nativeIndexBuffer?: any;
  120047. /**
  120048. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120049. */
  120050. nativeVertexBuffer?: any;
  120051. }
  120052. /** @hidden */
  120053. class NativeTexture extends InternalTexture {
  120054. getInternalTexture(): InternalTexture;
  120055. getViewCount(): number;
  120056. }
  120057. /** @hidden */
  120058. export class NativeEngine extends Engine {
  120059. private readonly _native;
  120060. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120061. private readonly INVALID_HANDLE;
  120062. getHardwareScalingLevel(): number;
  120063. constructor();
  120064. /**
  120065. * Can be used to override the current requestAnimationFrame requester.
  120066. * @hidden
  120067. */
  120068. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120069. /**
  120070. * Override default engine behavior.
  120071. * @param color
  120072. * @param backBuffer
  120073. * @param depth
  120074. * @param stencil
  120075. */
  120076. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120077. /**
  120078. * Gets host document
  120079. * @returns the host document object
  120080. */
  120081. getHostDocument(): Nullable<Document>;
  120082. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120083. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120084. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120085. recordVertexArrayObject(vertexBuffers: {
  120086. [key: string]: VertexBuffer;
  120087. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120088. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120089. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120090. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120091. /**
  120092. * Draw a list of indexed primitives
  120093. * @param fillMode defines the primitive to use
  120094. * @param indexStart defines the starting index
  120095. * @param indexCount defines the number of index to draw
  120096. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120097. */
  120098. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120099. /**
  120100. * Draw a list of unindexed primitives
  120101. * @param fillMode defines the primitive to use
  120102. * @param verticesStart defines the index of first vertex to draw
  120103. * @param verticesCount defines the count of vertices to draw
  120104. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120105. */
  120106. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120107. createPipelineContext(): IPipelineContext;
  120108. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120109. /** @hidden */
  120110. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120111. /** @hidden */
  120112. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120113. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120114. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120115. protected _setProgram(program: WebGLProgram): void;
  120116. _releaseEffect(effect: Effect): void;
  120117. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120118. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120119. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120120. bindSamplers(effect: Effect): void;
  120121. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120122. getRenderWidth(useScreen?: boolean): number;
  120123. getRenderHeight(useScreen?: boolean): number;
  120124. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120125. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120126. /**
  120127. * Set the z offset to apply to current rendering
  120128. * @param value defines the offset to apply
  120129. */
  120130. setZOffset(value: number): void;
  120131. /**
  120132. * Gets the current value of the zOffset
  120133. * @returns the current zOffset state
  120134. */
  120135. getZOffset(): number;
  120136. /**
  120137. * Enable or disable depth buffering
  120138. * @param enable defines the state to set
  120139. */
  120140. setDepthBuffer(enable: boolean): void;
  120141. /**
  120142. * Gets a boolean indicating if depth writing is enabled
  120143. * @returns the current depth writing state
  120144. */
  120145. getDepthWrite(): boolean;
  120146. /**
  120147. * Enable or disable depth writing
  120148. * @param enable defines the state to set
  120149. */
  120150. setDepthWrite(enable: boolean): void;
  120151. /**
  120152. * Enable or disable color writing
  120153. * @param enable defines the state to set
  120154. */
  120155. setColorWrite(enable: boolean): void;
  120156. /**
  120157. * Gets a boolean indicating if color writing is enabled
  120158. * @returns the current color writing state
  120159. */
  120160. getColorWrite(): boolean;
  120161. /**
  120162. * Sets alpha constants used by some alpha blending modes
  120163. * @param r defines the red component
  120164. * @param g defines the green component
  120165. * @param b defines the blue component
  120166. * @param a defines the alpha component
  120167. */
  120168. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120169. /**
  120170. * Sets the current alpha mode
  120171. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120172. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120173. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120174. */
  120175. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120176. /**
  120177. * Gets the current alpha mode
  120178. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120179. * @returns the current alpha mode
  120180. */
  120181. getAlphaMode(): number;
  120182. setInt(uniform: WebGLUniformLocation, int: number): void;
  120183. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120184. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120185. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120186. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120187. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120188. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120189. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120190. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120191. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120192. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120193. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120194. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120195. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120196. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120197. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120198. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120199. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120200. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120201. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120202. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120203. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120204. wipeCaches(bruteForce?: boolean): void;
  120205. _createTexture(): WebGLTexture;
  120206. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120207. /**
  120208. * Usually called from BABYLON.Texture.ts.
  120209. * Passed information to create a WebGLTexture
  120210. * @param urlArg defines a value which contains one of the following:
  120211. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120212. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120213. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120214. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120215. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120216. * @param scene needed for loading to the correct scene
  120217. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120218. * @param onLoad optional callback to be called upon successful completion
  120219. * @param onError optional callback to be called upon failure
  120220. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120221. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120222. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120223. * @param forcedExtension defines the extension to use to pick the right loader
  120224. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120225. */
  120226. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  120227. /**
  120228. * Creates a cube texture
  120229. * @param rootUrl defines the url where the files to load is located
  120230. * @param scene defines the current scene
  120231. * @param files defines the list of files to load (1 per face)
  120232. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120233. * @param onLoad defines an optional callback raised when the texture is loaded
  120234. * @param onError defines an optional callback raised if there is an issue to load the texture
  120235. * @param format defines the format of the data
  120236. * @param forcedExtension defines the extension to use to pick the right loader
  120237. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120238. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120239. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120240. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120241. * @returns the cube texture as an InternalTexture
  120242. */
  120243. 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;
  120244. private _getSamplingFilter;
  120245. private static _GetNativeTextureFormat;
  120246. createRenderTargetTexture(size: number | {
  120247. width: number;
  120248. height: number;
  120249. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120250. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120251. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120252. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120253. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120254. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120255. /**
  120256. * Updates a dynamic vertex buffer.
  120257. * @param vertexBuffer the vertex buffer to update
  120258. * @param data the data used to update the vertex buffer
  120259. * @param byteOffset the byte offset of the data (optional)
  120260. * @param byteLength the byte length of the data (optional)
  120261. */
  120262. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120263. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120264. private _updateAnisotropicLevel;
  120265. private _getAddressMode;
  120266. /** @hidden */
  120267. _bindTexture(channel: number, texture: InternalTexture): void;
  120268. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120269. releaseEffects(): void;
  120270. /** @hidden */
  120271. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120272. /** @hidden */
  120273. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120274. /** @hidden */
  120275. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120276. /** @hidden */
  120277. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120278. }
  120279. }
  120280. declare module BABYLON {
  120281. /**
  120282. * Gather the list of clipboard event types as constants.
  120283. */
  120284. export class ClipboardEventTypes {
  120285. /**
  120286. * The clipboard event is fired when a copy command is active (pressed).
  120287. */
  120288. static readonly COPY: number;
  120289. /**
  120290. * The clipboard event is fired when a cut command is active (pressed).
  120291. */
  120292. static readonly CUT: number;
  120293. /**
  120294. * The clipboard event is fired when a paste command is active (pressed).
  120295. */
  120296. static readonly PASTE: number;
  120297. }
  120298. /**
  120299. * This class is used to store clipboard related info for the onClipboardObservable event.
  120300. */
  120301. export class ClipboardInfo {
  120302. /**
  120303. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120304. */
  120305. type: number;
  120306. /**
  120307. * Defines the related dom event
  120308. */
  120309. event: ClipboardEvent;
  120310. /**
  120311. *Creates an instance of ClipboardInfo.
  120312. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120313. * @param event Defines the related dom event
  120314. */
  120315. constructor(
  120316. /**
  120317. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120318. */
  120319. type: number,
  120320. /**
  120321. * Defines the related dom event
  120322. */
  120323. event: ClipboardEvent);
  120324. /**
  120325. * Get the clipboard event's type from the keycode.
  120326. * @param keyCode Defines the keyCode for the current keyboard event.
  120327. * @return {number}
  120328. */
  120329. static GetTypeFromCharacter(keyCode: number): number;
  120330. }
  120331. }
  120332. declare module BABYLON {
  120333. /**
  120334. * Google Daydream controller
  120335. */
  120336. export class DaydreamController extends WebVRController {
  120337. /**
  120338. * Base Url for the controller model.
  120339. */
  120340. static MODEL_BASE_URL: string;
  120341. /**
  120342. * File name for the controller model.
  120343. */
  120344. static MODEL_FILENAME: string;
  120345. /**
  120346. * Gamepad Id prefix used to identify Daydream Controller.
  120347. */
  120348. static readonly GAMEPAD_ID_PREFIX: string;
  120349. /**
  120350. * Creates a new DaydreamController from a gamepad
  120351. * @param vrGamepad the gamepad that the controller should be created from
  120352. */
  120353. constructor(vrGamepad: any);
  120354. /**
  120355. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120356. * @param scene scene in which to add meshes
  120357. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120358. */
  120359. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120360. /**
  120361. * Called once for each button that changed state since the last frame
  120362. * @param buttonIdx Which button index changed
  120363. * @param state New state of the button
  120364. * @param changes Which properties on the state changed since last frame
  120365. */
  120366. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120367. }
  120368. }
  120369. declare module BABYLON {
  120370. /**
  120371. * Gear VR Controller
  120372. */
  120373. export class GearVRController extends WebVRController {
  120374. /**
  120375. * Base Url for the controller model.
  120376. */
  120377. static MODEL_BASE_URL: string;
  120378. /**
  120379. * File name for the controller model.
  120380. */
  120381. static MODEL_FILENAME: string;
  120382. /**
  120383. * Gamepad Id prefix used to identify this controller.
  120384. */
  120385. static readonly GAMEPAD_ID_PREFIX: string;
  120386. private readonly _buttonIndexToObservableNameMap;
  120387. /**
  120388. * Creates a new GearVRController from a gamepad
  120389. * @param vrGamepad the gamepad that the controller should be created from
  120390. */
  120391. constructor(vrGamepad: any);
  120392. /**
  120393. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120394. * @param scene scene in which to add meshes
  120395. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120396. */
  120397. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120398. /**
  120399. * Called once for each button that changed state since the last frame
  120400. * @param buttonIdx Which button index changed
  120401. * @param state New state of the button
  120402. * @param changes Which properties on the state changed since last frame
  120403. */
  120404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120405. }
  120406. }
  120407. declare module BABYLON {
  120408. /**
  120409. * Generic Controller
  120410. */
  120411. export class GenericController extends WebVRController {
  120412. /**
  120413. * Base Url for the controller model.
  120414. */
  120415. static readonly MODEL_BASE_URL: string;
  120416. /**
  120417. * File name for the controller model.
  120418. */
  120419. static readonly MODEL_FILENAME: string;
  120420. /**
  120421. * Creates a new GenericController from a gamepad
  120422. * @param vrGamepad the gamepad that the controller should be created from
  120423. */
  120424. constructor(vrGamepad: any);
  120425. /**
  120426. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120427. * @param scene scene in which to add meshes
  120428. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120429. */
  120430. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120431. /**
  120432. * Called once for each button that changed state since the last frame
  120433. * @param buttonIdx Which button index changed
  120434. * @param state New state of the button
  120435. * @param changes Which properties on the state changed since last frame
  120436. */
  120437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120438. }
  120439. }
  120440. declare module BABYLON {
  120441. /**
  120442. * Oculus Touch Controller
  120443. */
  120444. export class OculusTouchController extends WebVRController {
  120445. /**
  120446. * Base Url for the controller model.
  120447. */
  120448. static MODEL_BASE_URL: string;
  120449. /**
  120450. * File name for the left controller model.
  120451. */
  120452. static MODEL_LEFT_FILENAME: string;
  120453. /**
  120454. * File name for the right controller model.
  120455. */
  120456. static MODEL_RIGHT_FILENAME: string;
  120457. /**
  120458. * Base Url for the Quest controller model.
  120459. */
  120460. static QUEST_MODEL_BASE_URL: string;
  120461. /**
  120462. * @hidden
  120463. * If the controllers are running on a device that needs the updated Quest controller models
  120464. */
  120465. static _IsQuest: boolean;
  120466. /**
  120467. * Fired when the secondary trigger on this controller is modified
  120468. */
  120469. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  120470. /**
  120471. * Fired when the thumb rest on this controller is modified
  120472. */
  120473. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  120474. /**
  120475. * Creates a new OculusTouchController from a gamepad
  120476. * @param vrGamepad the gamepad that the controller should be created from
  120477. */
  120478. constructor(vrGamepad: any);
  120479. /**
  120480. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120481. * @param scene scene in which to add meshes
  120482. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120483. */
  120484. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120485. /**
  120486. * Fired when the A button on this controller is modified
  120487. */
  120488. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120489. /**
  120490. * Fired when the B button on this controller is modified
  120491. */
  120492. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120493. /**
  120494. * Fired when the X button on this controller is modified
  120495. */
  120496. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120497. /**
  120498. * Fired when the Y button on this controller is modified
  120499. */
  120500. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120501. /**
  120502. * Called once for each button that changed state since the last frame
  120503. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  120504. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  120505. * 2) secondary trigger (same)
  120506. * 3) A (right) X (left), touch, pressed = value
  120507. * 4) B / Y
  120508. * 5) thumb rest
  120509. * @param buttonIdx Which button index changed
  120510. * @param state New state of the button
  120511. * @param changes Which properties on the state changed since last frame
  120512. */
  120513. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120514. }
  120515. }
  120516. declare module BABYLON {
  120517. /**
  120518. * Vive Controller
  120519. */
  120520. export class ViveController extends WebVRController {
  120521. /**
  120522. * Base Url for the controller model.
  120523. */
  120524. static MODEL_BASE_URL: string;
  120525. /**
  120526. * File name for the controller model.
  120527. */
  120528. static MODEL_FILENAME: string;
  120529. /**
  120530. * Creates a new ViveController from a gamepad
  120531. * @param vrGamepad the gamepad that the controller should be created from
  120532. */
  120533. constructor(vrGamepad: any);
  120534. /**
  120535. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120536. * @param scene scene in which to add meshes
  120537. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120538. */
  120539. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120540. /**
  120541. * Fired when the left button on this controller is modified
  120542. */
  120543. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120544. /**
  120545. * Fired when the right button on this controller is modified
  120546. */
  120547. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120548. /**
  120549. * Fired when the menu button on this controller is modified
  120550. */
  120551. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120552. /**
  120553. * Called once for each button that changed state since the last frame
  120554. * Vive mapping:
  120555. * 0: touchpad
  120556. * 1: trigger
  120557. * 2: left AND right buttons
  120558. * 3: menu button
  120559. * @param buttonIdx Which button index changed
  120560. * @param state New state of the button
  120561. * @param changes Which properties on the state changed since last frame
  120562. */
  120563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120564. }
  120565. }
  120566. declare module BABYLON {
  120567. /**
  120568. * Defines the WindowsMotionController object that the state of the windows motion controller
  120569. */
  120570. export class WindowsMotionController extends WebVRController {
  120571. /**
  120572. * The base url used to load the left and right controller models
  120573. */
  120574. static MODEL_BASE_URL: string;
  120575. /**
  120576. * The name of the left controller model file
  120577. */
  120578. static MODEL_LEFT_FILENAME: string;
  120579. /**
  120580. * The name of the right controller model file
  120581. */
  120582. static MODEL_RIGHT_FILENAME: string;
  120583. /**
  120584. * The controller name prefix for this controller type
  120585. */
  120586. static readonly GAMEPAD_ID_PREFIX: string;
  120587. /**
  120588. * The controller id pattern for this controller type
  120589. */
  120590. private static readonly GAMEPAD_ID_PATTERN;
  120591. private _loadedMeshInfo;
  120592. protected readonly _mapping: {
  120593. buttons: string[];
  120594. buttonMeshNames: {
  120595. 'trigger': string;
  120596. 'menu': string;
  120597. 'grip': string;
  120598. 'thumbstick': string;
  120599. 'trackpad': string;
  120600. };
  120601. buttonObservableNames: {
  120602. 'trigger': string;
  120603. 'menu': string;
  120604. 'grip': string;
  120605. 'thumbstick': string;
  120606. 'trackpad': string;
  120607. };
  120608. axisMeshNames: string[];
  120609. pointingPoseMeshName: string;
  120610. };
  120611. /**
  120612. * Fired when the trackpad on this controller is clicked
  120613. */
  120614. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120615. /**
  120616. * Fired when the trackpad on this controller is modified
  120617. */
  120618. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120619. /**
  120620. * The current x and y values of this controller's trackpad
  120621. */
  120622. trackpad: StickValues;
  120623. /**
  120624. * Creates a new WindowsMotionController from a gamepad
  120625. * @param vrGamepad the gamepad that the controller should be created from
  120626. */
  120627. constructor(vrGamepad: any);
  120628. /**
  120629. * Fired when the trigger on this controller is modified
  120630. */
  120631. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120632. /**
  120633. * Fired when the menu button on this controller is modified
  120634. */
  120635. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120636. /**
  120637. * Fired when the grip button on this controller is modified
  120638. */
  120639. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120640. /**
  120641. * Fired when the thumbstick button on this controller is modified
  120642. */
  120643. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120644. /**
  120645. * Fired when the touchpad button on this controller is modified
  120646. */
  120647. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120648. /**
  120649. * Fired when the touchpad values on this controller are modified
  120650. */
  120651. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  120652. protected _updateTrackpad(): void;
  120653. /**
  120654. * Called once per frame by the engine.
  120655. */
  120656. update(): void;
  120657. /**
  120658. * Called once for each button that changed state since the last frame
  120659. * @param buttonIdx Which button index changed
  120660. * @param state New state of the button
  120661. * @param changes Which properties on the state changed since last frame
  120662. */
  120663. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120664. /**
  120665. * Moves the buttons on the controller mesh based on their current state
  120666. * @param buttonName the name of the button to move
  120667. * @param buttonValue the value of the button which determines the buttons new position
  120668. */
  120669. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  120670. /**
  120671. * Moves the axis on the controller mesh based on its current state
  120672. * @param axis the index of the axis
  120673. * @param axisValue the value of the axis which determines the meshes new position
  120674. * @hidden
  120675. */
  120676. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  120677. /**
  120678. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120679. * @param scene scene in which to add meshes
  120680. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120681. */
  120682. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  120683. /**
  120684. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  120685. * can be transformed by button presses and axes values, based on this._mapping.
  120686. *
  120687. * @param scene scene in which the meshes exist
  120688. * @param meshes list of meshes that make up the controller model to process
  120689. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  120690. */
  120691. private processModel;
  120692. private createMeshInfo;
  120693. /**
  120694. * Gets the ray of the controller in the direction the controller is pointing
  120695. * @param length the length the resulting ray should be
  120696. * @returns a ray in the direction the controller is pointing
  120697. */
  120698. getForwardRay(length?: number): Ray;
  120699. /**
  120700. * Disposes of the controller
  120701. */
  120702. dispose(): void;
  120703. }
  120704. /**
  120705. * This class represents a new windows motion controller in XR.
  120706. */
  120707. export class XRWindowsMotionController extends WindowsMotionController {
  120708. /**
  120709. * Changing the original WIndowsMotionController mapping to fir the new mapping
  120710. */
  120711. protected readonly _mapping: {
  120712. buttons: string[];
  120713. buttonMeshNames: {
  120714. 'trigger': string;
  120715. 'menu': string;
  120716. 'grip': string;
  120717. 'thumbstick': string;
  120718. 'trackpad': string;
  120719. };
  120720. buttonObservableNames: {
  120721. 'trigger': string;
  120722. 'menu': string;
  120723. 'grip': string;
  120724. 'thumbstick': string;
  120725. 'trackpad': string;
  120726. };
  120727. axisMeshNames: string[];
  120728. pointingPoseMeshName: string;
  120729. };
  120730. /**
  120731. * Construct a new XR-Based windows motion controller
  120732. *
  120733. * @param gamepadInfo the gamepad object from the browser
  120734. */
  120735. constructor(gamepadInfo: any);
  120736. /**
  120737. * holds the thumbstick values (X,Y)
  120738. */
  120739. thumbstickValues: StickValues;
  120740. /**
  120741. * Fired when the thumbstick on this controller is clicked
  120742. */
  120743. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  120744. /**
  120745. * Fired when the thumbstick on this controller is modified
  120746. */
  120747. onThumbstickValuesChangedObservable: Observable<StickValues>;
  120748. /**
  120749. * Fired when the touchpad button on this controller is modified
  120750. */
  120751. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120752. /**
  120753. * Fired when the touchpad values on this controller are modified
  120754. */
  120755. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120756. /**
  120757. * Fired when the thumbstick button on this controller is modified
  120758. * here to prevent breaking changes
  120759. */
  120760. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120761. /**
  120762. * updating the thumbstick(!) and not the trackpad.
  120763. * This is named this way due to the difference between WebVR and XR and to avoid
  120764. * changing the parent class.
  120765. */
  120766. protected _updateTrackpad(): void;
  120767. /**
  120768. * Disposes the class with joy
  120769. */
  120770. dispose(): void;
  120771. }
  120772. }
  120773. declare module BABYLON {
  120774. /**
  120775. * Class containing static functions to help procedurally build meshes
  120776. */
  120777. export class PolyhedronBuilder {
  120778. /**
  120779. * Creates a polyhedron mesh
  120780. * * 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
  120781. * * The parameter `size` (positive float, default 1) sets the polygon size
  120782. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120783. * * 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`
  120784. * * 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
  120785. * * 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)`)
  120786. * * 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
  120787. * * 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
  120788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120791. * @param name defines the name of the mesh
  120792. * @param options defines the options used to create the mesh
  120793. * @param scene defines the hosting scene
  120794. * @returns the polyhedron mesh
  120795. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120796. */
  120797. static CreatePolyhedron(name: string, options: {
  120798. type?: number;
  120799. size?: number;
  120800. sizeX?: number;
  120801. sizeY?: number;
  120802. sizeZ?: number;
  120803. custom?: any;
  120804. faceUV?: Vector4[];
  120805. faceColors?: Color4[];
  120806. flat?: boolean;
  120807. updatable?: boolean;
  120808. sideOrientation?: number;
  120809. frontUVs?: Vector4;
  120810. backUVs?: Vector4;
  120811. }, scene?: Nullable<Scene>): Mesh;
  120812. }
  120813. }
  120814. declare module BABYLON {
  120815. /**
  120816. * Gizmo that enables scaling a mesh along 3 axis
  120817. */
  120818. export class ScaleGizmo extends Gizmo {
  120819. /**
  120820. * Internal gizmo used for interactions on the x axis
  120821. */
  120822. xGizmo: AxisScaleGizmo;
  120823. /**
  120824. * Internal gizmo used for interactions on the y axis
  120825. */
  120826. yGizmo: AxisScaleGizmo;
  120827. /**
  120828. * Internal gizmo used for interactions on the z axis
  120829. */
  120830. zGizmo: AxisScaleGizmo;
  120831. /**
  120832. * Internal gizmo used to scale all axis equally
  120833. */
  120834. uniformScaleGizmo: AxisScaleGizmo;
  120835. private _meshAttached;
  120836. private _updateGizmoRotationToMatchAttachedMesh;
  120837. private _snapDistance;
  120838. private _scaleRatio;
  120839. private _uniformScalingMesh;
  120840. private _octahedron;
  120841. private _sensitivity;
  120842. /** Fires an event when any of it's sub gizmos are dragged */
  120843. onDragStartObservable: Observable<unknown>;
  120844. /** Fires an event when any of it's sub gizmos are released from dragging */
  120845. onDragEndObservable: Observable<unknown>;
  120846. get attachedMesh(): Nullable<AbstractMesh>;
  120847. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120848. /**
  120849. * Creates a ScaleGizmo
  120850. * @param gizmoLayer The utility layer the gizmo will be added to
  120851. */
  120852. constructor(gizmoLayer?: UtilityLayerRenderer);
  120853. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120854. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120855. /**
  120856. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120857. */
  120858. set snapDistance(value: number);
  120859. get snapDistance(): number;
  120860. /**
  120861. * Ratio for the scale of the gizmo (Default: 1)
  120862. */
  120863. set scaleRatio(value: number);
  120864. get scaleRatio(): number;
  120865. /**
  120866. * Sensitivity factor for dragging (Default: 1)
  120867. */
  120868. set sensitivity(value: number);
  120869. get sensitivity(): number;
  120870. /**
  120871. * Disposes of the gizmo
  120872. */
  120873. dispose(): void;
  120874. }
  120875. }
  120876. declare module BABYLON {
  120877. /**
  120878. * Single axis scale gizmo
  120879. */
  120880. export class AxisScaleGizmo extends Gizmo {
  120881. /**
  120882. * Drag behavior responsible for the gizmos dragging interactions
  120883. */
  120884. dragBehavior: PointerDragBehavior;
  120885. private _pointerObserver;
  120886. /**
  120887. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120888. */
  120889. snapDistance: number;
  120890. /**
  120891. * Event that fires each time the gizmo snaps to a new location.
  120892. * * snapDistance is the the change in distance
  120893. */
  120894. onSnapObservable: Observable<{
  120895. snapDistance: number;
  120896. }>;
  120897. /**
  120898. * If the scaling operation should be done on all axis (default: false)
  120899. */
  120900. uniformScaling: boolean;
  120901. /**
  120902. * Custom sensitivity value for the drag strength
  120903. */
  120904. sensitivity: number;
  120905. private _isEnabled;
  120906. private _parent;
  120907. private _arrow;
  120908. private _coloredMaterial;
  120909. private _hoverMaterial;
  120910. /**
  120911. * Creates an AxisScaleGizmo
  120912. * @param gizmoLayer The utility layer the gizmo will be added to
  120913. * @param dragAxis The axis which the gizmo will be able to scale on
  120914. * @param color The color of the gizmo
  120915. */
  120916. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  120917. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120918. /**
  120919. * If the gizmo is enabled
  120920. */
  120921. set isEnabled(value: boolean);
  120922. get isEnabled(): boolean;
  120923. /**
  120924. * Disposes of the gizmo
  120925. */
  120926. dispose(): void;
  120927. /**
  120928. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120929. * @param mesh The mesh to replace the default mesh of the gizmo
  120930. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  120931. */
  120932. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  120933. }
  120934. }
  120935. declare module BABYLON {
  120936. /**
  120937. * Bounding box gizmo
  120938. */
  120939. export class BoundingBoxGizmo extends Gizmo {
  120940. private _lineBoundingBox;
  120941. private _rotateSpheresParent;
  120942. private _scaleBoxesParent;
  120943. private _boundingDimensions;
  120944. private _renderObserver;
  120945. private _pointerObserver;
  120946. private _scaleDragSpeed;
  120947. private _tmpQuaternion;
  120948. private _tmpVector;
  120949. private _tmpRotationMatrix;
  120950. /**
  120951. * 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)
  120952. */
  120953. ignoreChildren: boolean;
  120954. /**
  120955. * 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)
  120956. */
  120957. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  120958. /**
  120959. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  120960. */
  120961. rotationSphereSize: number;
  120962. /**
  120963. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  120964. */
  120965. scaleBoxSize: number;
  120966. /**
  120967. * 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)
  120968. */
  120969. fixedDragMeshScreenSize: boolean;
  120970. /**
  120971. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  120972. */
  120973. fixedDragMeshScreenSizeDistanceFactor: number;
  120974. /**
  120975. * Fired when a rotation sphere or scale box is dragged
  120976. */
  120977. onDragStartObservable: Observable<{}>;
  120978. /**
  120979. * Fired when a scale box is dragged
  120980. */
  120981. onScaleBoxDragObservable: Observable<{}>;
  120982. /**
  120983. * Fired when a scale box drag is ended
  120984. */
  120985. onScaleBoxDragEndObservable: Observable<{}>;
  120986. /**
  120987. * Fired when a rotation sphere is dragged
  120988. */
  120989. onRotationSphereDragObservable: Observable<{}>;
  120990. /**
  120991. * Fired when a rotation sphere drag is ended
  120992. */
  120993. onRotationSphereDragEndObservable: Observable<{}>;
  120994. /**
  120995. * 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)
  120996. */
  120997. scalePivot: Nullable<Vector3>;
  120998. /**
  120999. * Mesh used as a pivot to rotate the attached mesh
  121000. */
  121001. private _anchorMesh;
  121002. private _existingMeshScale;
  121003. private _dragMesh;
  121004. private pointerDragBehavior;
  121005. private coloredMaterial;
  121006. private hoverColoredMaterial;
  121007. /**
  121008. * Sets the color of the bounding box gizmo
  121009. * @param color the color to set
  121010. */
  121011. setColor(color: Color3): void;
  121012. /**
  121013. * Creates an BoundingBoxGizmo
  121014. * @param gizmoLayer The utility layer the gizmo will be added to
  121015. * @param color The color of the gizmo
  121016. */
  121017. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121018. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121019. private _selectNode;
  121020. /**
  121021. * Updates the bounding box information for the Gizmo
  121022. */
  121023. updateBoundingBox(): void;
  121024. private _updateRotationSpheres;
  121025. private _updateScaleBoxes;
  121026. /**
  121027. * Enables rotation on the specified axis and disables rotation on the others
  121028. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121029. */
  121030. setEnabledRotationAxis(axis: string): void;
  121031. /**
  121032. * Enables/disables scaling
  121033. * @param enable if scaling should be enabled
  121034. */
  121035. setEnabledScaling(enable: boolean): void;
  121036. private _updateDummy;
  121037. /**
  121038. * Enables a pointer drag behavior on the bounding box of the gizmo
  121039. */
  121040. enableDragBehavior(): void;
  121041. /**
  121042. * Disposes of the gizmo
  121043. */
  121044. dispose(): void;
  121045. /**
  121046. * 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)
  121047. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121048. * @returns the bounding box mesh with the passed in mesh as a child
  121049. */
  121050. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121051. /**
  121052. * CustomMeshes are not supported by this gizmo
  121053. * @param mesh The mesh to replace the default mesh of the gizmo
  121054. */
  121055. setCustomMesh(mesh: Mesh): void;
  121056. }
  121057. }
  121058. declare module BABYLON {
  121059. /**
  121060. * Single plane rotation gizmo
  121061. */
  121062. export class PlaneRotationGizmo extends Gizmo {
  121063. /**
  121064. * Drag behavior responsible for the gizmos dragging interactions
  121065. */
  121066. dragBehavior: PointerDragBehavior;
  121067. private _pointerObserver;
  121068. /**
  121069. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121070. */
  121071. snapDistance: number;
  121072. /**
  121073. * Event that fires each time the gizmo snaps to a new location.
  121074. * * snapDistance is the the change in distance
  121075. */
  121076. onSnapObservable: Observable<{
  121077. snapDistance: number;
  121078. }>;
  121079. private _isEnabled;
  121080. private _parent;
  121081. /**
  121082. * Creates a PlaneRotationGizmo
  121083. * @param gizmoLayer The utility layer the gizmo will be added to
  121084. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121085. * @param color The color of the gizmo
  121086. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121087. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121088. */
  121089. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121090. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121091. /**
  121092. * If the gizmo is enabled
  121093. */
  121094. set isEnabled(value: boolean);
  121095. get isEnabled(): boolean;
  121096. /**
  121097. * Disposes of the gizmo
  121098. */
  121099. dispose(): void;
  121100. }
  121101. }
  121102. declare module BABYLON {
  121103. /**
  121104. * Gizmo that enables rotating a mesh along 3 axis
  121105. */
  121106. export class RotationGizmo extends Gizmo {
  121107. /**
  121108. * Internal gizmo used for interactions on the x axis
  121109. */
  121110. xGizmo: PlaneRotationGizmo;
  121111. /**
  121112. * Internal gizmo used for interactions on the y axis
  121113. */
  121114. yGizmo: PlaneRotationGizmo;
  121115. /**
  121116. * Internal gizmo used for interactions on the z axis
  121117. */
  121118. zGizmo: PlaneRotationGizmo;
  121119. /** Fires an event when any of it's sub gizmos are dragged */
  121120. onDragStartObservable: Observable<unknown>;
  121121. /** Fires an event when any of it's sub gizmos are released from dragging */
  121122. onDragEndObservable: Observable<unknown>;
  121123. private _meshAttached;
  121124. get attachedMesh(): Nullable<AbstractMesh>;
  121125. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121126. /**
  121127. * Creates a RotationGizmo
  121128. * @param gizmoLayer The utility layer the gizmo will be added to
  121129. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121130. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121131. */
  121132. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121133. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121134. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121135. /**
  121136. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121137. */
  121138. set snapDistance(value: number);
  121139. get snapDistance(): number;
  121140. /**
  121141. * Ratio for the scale of the gizmo (Default: 1)
  121142. */
  121143. set scaleRatio(value: number);
  121144. get scaleRatio(): number;
  121145. /**
  121146. * Disposes of the gizmo
  121147. */
  121148. dispose(): void;
  121149. /**
  121150. * CustomMeshes are not supported by this gizmo
  121151. * @param mesh The mesh to replace the default mesh of the gizmo
  121152. */
  121153. setCustomMesh(mesh: Mesh): void;
  121154. }
  121155. }
  121156. declare module BABYLON {
  121157. /**
  121158. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121159. */
  121160. export class GizmoManager implements IDisposable {
  121161. private scene;
  121162. /**
  121163. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121164. */
  121165. gizmos: {
  121166. positionGizmo: Nullable<PositionGizmo>;
  121167. rotationGizmo: Nullable<RotationGizmo>;
  121168. scaleGizmo: Nullable<ScaleGizmo>;
  121169. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121170. };
  121171. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121172. clearGizmoOnEmptyPointerEvent: boolean;
  121173. /** Fires an event when the manager is attached to a mesh */
  121174. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121175. private _gizmosEnabled;
  121176. private _pointerObserver;
  121177. private _attachedMesh;
  121178. private _boundingBoxColor;
  121179. private _defaultUtilityLayer;
  121180. private _defaultKeepDepthUtilityLayer;
  121181. /**
  121182. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121183. */
  121184. boundingBoxDragBehavior: SixDofDragBehavior;
  121185. /**
  121186. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121187. */
  121188. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121189. /**
  121190. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121191. */
  121192. usePointerToAttachGizmos: boolean;
  121193. /**
  121194. * Utility layer that the bounding box gizmo belongs to
  121195. */
  121196. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121197. /**
  121198. * Utility layer that all gizmos besides bounding box belong to
  121199. */
  121200. get utilityLayer(): UtilityLayerRenderer;
  121201. /**
  121202. * Instatiates a gizmo manager
  121203. * @param scene the scene to overlay the gizmos on top of
  121204. */
  121205. constructor(scene: Scene);
  121206. /**
  121207. * Attaches a set of gizmos to the specified mesh
  121208. * @param mesh The mesh the gizmo's should be attached to
  121209. */
  121210. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121211. /**
  121212. * If the position gizmo is enabled
  121213. */
  121214. set positionGizmoEnabled(value: boolean);
  121215. get positionGizmoEnabled(): boolean;
  121216. /**
  121217. * If the rotation gizmo is enabled
  121218. */
  121219. set rotationGizmoEnabled(value: boolean);
  121220. get rotationGizmoEnabled(): boolean;
  121221. /**
  121222. * If the scale gizmo is enabled
  121223. */
  121224. set scaleGizmoEnabled(value: boolean);
  121225. get scaleGizmoEnabled(): boolean;
  121226. /**
  121227. * If the boundingBox gizmo is enabled
  121228. */
  121229. set boundingBoxGizmoEnabled(value: boolean);
  121230. get boundingBoxGizmoEnabled(): boolean;
  121231. /**
  121232. * Disposes of the gizmo manager
  121233. */
  121234. dispose(): void;
  121235. }
  121236. }
  121237. declare module BABYLON {
  121238. /**
  121239. * A directional light is defined by a direction (what a surprise!).
  121240. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121241. * 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.
  121242. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121243. */
  121244. export class DirectionalLight extends ShadowLight {
  121245. private _shadowFrustumSize;
  121246. /**
  121247. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121248. */
  121249. get shadowFrustumSize(): number;
  121250. /**
  121251. * Specifies a fix frustum size for the shadow generation.
  121252. */
  121253. set shadowFrustumSize(value: number);
  121254. private _shadowOrthoScale;
  121255. /**
  121256. * Gets the shadow projection scale against the optimal computed one.
  121257. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121258. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121259. */
  121260. get shadowOrthoScale(): number;
  121261. /**
  121262. * Sets the shadow projection scale against the optimal computed one.
  121263. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121264. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121265. */
  121266. set shadowOrthoScale(value: number);
  121267. /**
  121268. * Automatically compute the projection matrix to best fit (including all the casters)
  121269. * on each frame.
  121270. */
  121271. autoUpdateExtends: boolean;
  121272. /**
  121273. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121274. * on each frame. autoUpdateExtends must be set to true for this to work
  121275. */
  121276. autoCalcShadowZBounds: boolean;
  121277. private _orthoLeft;
  121278. private _orthoRight;
  121279. private _orthoTop;
  121280. private _orthoBottom;
  121281. /**
  121282. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121283. * The directional light is emitted from everywhere in the given direction.
  121284. * It can cast shadows.
  121285. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121286. * @param name The friendly name of the light
  121287. * @param direction The direction of the light
  121288. * @param scene The scene the light belongs to
  121289. */
  121290. constructor(name: string, direction: Vector3, scene: Scene);
  121291. /**
  121292. * Returns the string "DirectionalLight".
  121293. * @return The class name
  121294. */
  121295. getClassName(): string;
  121296. /**
  121297. * Returns the integer 1.
  121298. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121299. */
  121300. getTypeID(): number;
  121301. /**
  121302. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121303. * Returns the DirectionalLight Shadow projection matrix.
  121304. */
  121305. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121306. /**
  121307. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121308. * Returns the DirectionalLight Shadow projection matrix.
  121309. */
  121310. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121311. /**
  121312. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121313. * Returns the DirectionalLight Shadow projection matrix.
  121314. */
  121315. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121316. protected _buildUniformLayout(): void;
  121317. /**
  121318. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121319. * @param effect The effect to update
  121320. * @param lightIndex The index of the light in the effect to update
  121321. * @returns The directional light
  121322. */
  121323. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  121324. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  121325. /**
  121326. * Gets the minZ used for shadow according to both the scene and the light.
  121327. *
  121328. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121329. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121330. * @param activeCamera The camera we are returning the min for
  121331. * @returns the depth min z
  121332. */
  121333. getDepthMinZ(activeCamera: Camera): number;
  121334. /**
  121335. * Gets the maxZ used for shadow according to both the scene and the light.
  121336. *
  121337. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121338. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121339. * @param activeCamera The camera we are returning the max for
  121340. * @returns the depth max z
  121341. */
  121342. getDepthMaxZ(activeCamera: Camera): number;
  121343. /**
  121344. * Prepares the list of defines specific to the light type.
  121345. * @param defines the list of defines
  121346. * @param lightIndex defines the index of the light for the effect
  121347. */
  121348. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121349. }
  121350. }
  121351. declare module BABYLON {
  121352. /**
  121353. * Class containing static functions to help procedurally build meshes
  121354. */
  121355. export class HemisphereBuilder {
  121356. /**
  121357. * Creates a hemisphere mesh
  121358. * @param name defines the name of the mesh
  121359. * @param options defines the options used to create the mesh
  121360. * @param scene defines the hosting scene
  121361. * @returns the hemisphere mesh
  121362. */
  121363. static CreateHemisphere(name: string, options: {
  121364. segments?: number;
  121365. diameter?: number;
  121366. sideOrientation?: number;
  121367. }, scene: any): Mesh;
  121368. }
  121369. }
  121370. declare module BABYLON {
  121371. /**
  121372. * A spot light is defined by a position, a direction, an angle, and an exponent.
  121373. * These values define a cone of light starting from the position, emitting toward the direction.
  121374. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  121375. * and the exponent defines the speed of the decay of the light with distance (reach).
  121376. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121377. */
  121378. export class SpotLight extends ShadowLight {
  121379. private _angle;
  121380. private _innerAngle;
  121381. private _cosHalfAngle;
  121382. private _lightAngleScale;
  121383. private _lightAngleOffset;
  121384. /**
  121385. * Gets the cone angle of the spot light in Radians.
  121386. */
  121387. get angle(): number;
  121388. /**
  121389. * Sets the cone angle of the spot light in Radians.
  121390. */
  121391. set angle(value: number);
  121392. /**
  121393. * Only used in gltf falloff mode, this defines the angle where
  121394. * the directional falloff will start before cutting at angle which could be seen
  121395. * as outer angle.
  121396. */
  121397. get innerAngle(): number;
  121398. /**
  121399. * Only used in gltf falloff mode, this defines the angle where
  121400. * the directional falloff will start before cutting at angle which could be seen
  121401. * as outer angle.
  121402. */
  121403. set innerAngle(value: number);
  121404. private _shadowAngleScale;
  121405. /**
  121406. * Allows scaling the angle of the light for shadow generation only.
  121407. */
  121408. get shadowAngleScale(): number;
  121409. /**
  121410. * Allows scaling the angle of the light for shadow generation only.
  121411. */
  121412. set shadowAngleScale(value: number);
  121413. /**
  121414. * The light decay speed with the distance from the emission spot.
  121415. */
  121416. exponent: number;
  121417. private _projectionTextureMatrix;
  121418. /**
  121419. * Allows reading the projecton texture
  121420. */
  121421. get projectionTextureMatrix(): Matrix;
  121422. protected _projectionTextureLightNear: number;
  121423. /**
  121424. * Gets the near clip of the Spotlight for texture projection.
  121425. */
  121426. get projectionTextureLightNear(): number;
  121427. /**
  121428. * Sets the near clip of the Spotlight for texture projection.
  121429. */
  121430. set projectionTextureLightNear(value: number);
  121431. protected _projectionTextureLightFar: number;
  121432. /**
  121433. * Gets the far clip of the Spotlight for texture projection.
  121434. */
  121435. get projectionTextureLightFar(): number;
  121436. /**
  121437. * Sets the far clip of the Spotlight for texture projection.
  121438. */
  121439. set projectionTextureLightFar(value: number);
  121440. protected _projectionTextureUpDirection: Vector3;
  121441. /**
  121442. * Gets the Up vector of the Spotlight for texture projection.
  121443. */
  121444. get projectionTextureUpDirection(): Vector3;
  121445. /**
  121446. * Sets the Up vector of the Spotlight for texture projection.
  121447. */
  121448. set projectionTextureUpDirection(value: Vector3);
  121449. private _projectionTexture;
  121450. /**
  121451. * Gets the projection texture of the light.
  121452. */
  121453. get projectionTexture(): Nullable<BaseTexture>;
  121454. /**
  121455. * Sets the projection texture of the light.
  121456. */
  121457. set projectionTexture(value: Nullable<BaseTexture>);
  121458. private _projectionTextureViewLightDirty;
  121459. private _projectionTextureProjectionLightDirty;
  121460. private _projectionTextureDirty;
  121461. private _projectionTextureViewTargetVector;
  121462. private _projectionTextureViewLightMatrix;
  121463. private _projectionTextureProjectionLightMatrix;
  121464. private _projectionTextureScalingMatrix;
  121465. /**
  121466. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  121467. * It can cast shadows.
  121468. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121469. * @param name The light friendly name
  121470. * @param position The position of the spot light in the scene
  121471. * @param direction The direction of the light in the scene
  121472. * @param angle The cone angle of the light in Radians
  121473. * @param exponent The light decay speed with the distance from the emission spot
  121474. * @param scene The scene the lights belongs to
  121475. */
  121476. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  121477. /**
  121478. * Returns the string "SpotLight".
  121479. * @returns the class name
  121480. */
  121481. getClassName(): string;
  121482. /**
  121483. * Returns the integer 2.
  121484. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121485. */
  121486. getTypeID(): number;
  121487. /**
  121488. * Overrides the direction setter to recompute the projection texture view light Matrix.
  121489. */
  121490. protected _setDirection(value: Vector3): void;
  121491. /**
  121492. * Overrides the position setter to recompute the projection texture view light Matrix.
  121493. */
  121494. protected _setPosition(value: Vector3): void;
  121495. /**
  121496. * 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.
  121497. * Returns the SpotLight.
  121498. */
  121499. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121500. protected _computeProjectionTextureViewLightMatrix(): void;
  121501. protected _computeProjectionTextureProjectionLightMatrix(): void;
  121502. /**
  121503. * Main function for light texture projection matrix computing.
  121504. */
  121505. protected _computeProjectionTextureMatrix(): void;
  121506. protected _buildUniformLayout(): void;
  121507. private _computeAngleValues;
  121508. /**
  121509. * Sets the passed Effect "effect" with the Light textures.
  121510. * @param effect The effect to update
  121511. * @param lightIndex The index of the light in the effect to update
  121512. * @returns The light
  121513. */
  121514. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  121515. /**
  121516. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  121517. * @param effect The effect to update
  121518. * @param lightIndex The index of the light in the effect to update
  121519. * @returns The spot light
  121520. */
  121521. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  121522. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121523. /**
  121524. * Disposes the light and the associated resources.
  121525. */
  121526. dispose(): void;
  121527. /**
  121528. * Prepares the list of defines specific to the light type.
  121529. * @param defines the list of defines
  121530. * @param lightIndex defines the index of the light for the effect
  121531. */
  121532. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121533. }
  121534. }
  121535. declare module BABYLON {
  121536. /**
  121537. * Gizmo that enables viewing a light
  121538. */
  121539. export class LightGizmo extends Gizmo {
  121540. private _lightMesh;
  121541. private _material;
  121542. private _cachedPosition;
  121543. private _cachedForward;
  121544. private _attachedMeshParent;
  121545. /**
  121546. * Creates a LightGizmo
  121547. * @param gizmoLayer The utility layer the gizmo will be added to
  121548. */
  121549. constructor(gizmoLayer?: UtilityLayerRenderer);
  121550. private _light;
  121551. /**
  121552. * The light that the gizmo is attached to
  121553. */
  121554. set light(light: Nullable<Light>);
  121555. get light(): Nullable<Light>;
  121556. /**
  121557. * Gets the material used to render the light gizmo
  121558. */
  121559. get material(): StandardMaterial;
  121560. /**
  121561. * @hidden
  121562. * Updates the gizmo to match the attached mesh's position/rotation
  121563. */
  121564. protected _update(): void;
  121565. private static _Scale;
  121566. /**
  121567. * Creates the lines for a light mesh
  121568. */
  121569. private static _CreateLightLines;
  121570. /**
  121571. * Disposes of the light gizmo
  121572. */
  121573. dispose(): void;
  121574. private static _CreateHemisphericLightMesh;
  121575. private static _CreatePointLightMesh;
  121576. private static _CreateSpotLightMesh;
  121577. private static _CreateDirectionalLightMesh;
  121578. }
  121579. }
  121580. declare module BABYLON {
  121581. /** @hidden */
  121582. export var backgroundFragmentDeclaration: {
  121583. name: string;
  121584. shader: string;
  121585. };
  121586. }
  121587. declare module BABYLON {
  121588. /** @hidden */
  121589. export var backgroundUboDeclaration: {
  121590. name: string;
  121591. shader: string;
  121592. };
  121593. }
  121594. declare module BABYLON {
  121595. /** @hidden */
  121596. export var backgroundPixelShader: {
  121597. name: string;
  121598. shader: string;
  121599. };
  121600. }
  121601. declare module BABYLON {
  121602. /** @hidden */
  121603. export var backgroundVertexDeclaration: {
  121604. name: string;
  121605. shader: string;
  121606. };
  121607. }
  121608. declare module BABYLON {
  121609. /** @hidden */
  121610. export var backgroundVertexShader: {
  121611. name: string;
  121612. shader: string;
  121613. };
  121614. }
  121615. declare module BABYLON {
  121616. /**
  121617. * Background material used to create an efficient environement around your scene.
  121618. */
  121619. export class BackgroundMaterial extends PushMaterial {
  121620. /**
  121621. * Standard reflectance value at parallel view angle.
  121622. */
  121623. static StandardReflectance0: number;
  121624. /**
  121625. * Standard reflectance value at grazing angle.
  121626. */
  121627. static StandardReflectance90: number;
  121628. protected _primaryColor: Color3;
  121629. /**
  121630. * Key light Color (multiply against the environement texture)
  121631. */
  121632. primaryColor: Color3;
  121633. protected __perceptualColor: Nullable<Color3>;
  121634. /**
  121635. * Experimental Internal Use Only.
  121636. *
  121637. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  121638. * This acts as a helper to set the primary color to a more "human friendly" value.
  121639. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  121640. * output color as close as possible from the chosen value.
  121641. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  121642. * part of lighting setup.)
  121643. */
  121644. get _perceptualColor(): Nullable<Color3>;
  121645. set _perceptualColor(value: Nullable<Color3>);
  121646. protected _primaryColorShadowLevel: float;
  121647. /**
  121648. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  121649. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  121650. */
  121651. get primaryColorShadowLevel(): float;
  121652. set primaryColorShadowLevel(value: float);
  121653. protected _primaryColorHighlightLevel: float;
  121654. /**
  121655. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  121656. * The primary color is used at the level chosen to define what the white area would look.
  121657. */
  121658. get primaryColorHighlightLevel(): float;
  121659. set primaryColorHighlightLevel(value: float);
  121660. protected _reflectionTexture: Nullable<BaseTexture>;
  121661. /**
  121662. * Reflection Texture used in the material.
  121663. * Should be author in a specific way for the best result (refer to the documentation).
  121664. */
  121665. reflectionTexture: Nullable<BaseTexture>;
  121666. protected _reflectionBlur: float;
  121667. /**
  121668. * Reflection Texture level of blur.
  121669. *
  121670. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  121671. * texture twice.
  121672. */
  121673. reflectionBlur: float;
  121674. protected _diffuseTexture: Nullable<BaseTexture>;
  121675. /**
  121676. * Diffuse Texture used in the material.
  121677. * Should be author in a specific way for the best result (refer to the documentation).
  121678. */
  121679. diffuseTexture: Nullable<BaseTexture>;
  121680. protected _shadowLights: Nullable<IShadowLight[]>;
  121681. /**
  121682. * Specify the list of lights casting shadow on the material.
  121683. * All scene shadow lights will be included if null.
  121684. */
  121685. shadowLights: Nullable<IShadowLight[]>;
  121686. protected _shadowLevel: float;
  121687. /**
  121688. * Helps adjusting the shadow to a softer level if required.
  121689. * 0 means black shadows and 1 means no shadows.
  121690. */
  121691. shadowLevel: float;
  121692. protected _sceneCenter: Vector3;
  121693. /**
  121694. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  121695. * It is usually zero but might be interesting to modify according to your setup.
  121696. */
  121697. sceneCenter: Vector3;
  121698. protected _opacityFresnel: boolean;
  121699. /**
  121700. * This helps specifying that the material is falling off to the sky box at grazing angle.
  121701. * This helps ensuring a nice transition when the camera goes under the ground.
  121702. */
  121703. opacityFresnel: boolean;
  121704. protected _reflectionFresnel: boolean;
  121705. /**
  121706. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  121707. * This helps adding a mirror texture on the ground.
  121708. */
  121709. reflectionFresnel: boolean;
  121710. protected _reflectionFalloffDistance: number;
  121711. /**
  121712. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  121713. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  121714. */
  121715. reflectionFalloffDistance: number;
  121716. protected _reflectionAmount: number;
  121717. /**
  121718. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  121719. */
  121720. reflectionAmount: number;
  121721. protected _reflectionReflectance0: number;
  121722. /**
  121723. * This specifies the weight of the reflection at grazing angle.
  121724. */
  121725. reflectionReflectance0: number;
  121726. protected _reflectionReflectance90: number;
  121727. /**
  121728. * This specifies the weight of the reflection at a perpendicular point of view.
  121729. */
  121730. reflectionReflectance90: number;
  121731. /**
  121732. * Sets the reflection reflectance fresnel values according to the default standard
  121733. * empirically know to work well :-)
  121734. */
  121735. set reflectionStandardFresnelWeight(value: number);
  121736. protected _useRGBColor: boolean;
  121737. /**
  121738. * Helps to directly use the maps channels instead of their level.
  121739. */
  121740. useRGBColor: boolean;
  121741. protected _enableNoise: boolean;
  121742. /**
  121743. * This helps reducing the banding effect that could occur on the background.
  121744. */
  121745. enableNoise: boolean;
  121746. /**
  121747. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121748. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  121749. * Recommended to be keep at 1.0 except for special cases.
  121750. */
  121751. get fovMultiplier(): number;
  121752. set fovMultiplier(value: number);
  121753. private _fovMultiplier;
  121754. /**
  121755. * Enable the FOV adjustment feature controlled by fovMultiplier.
  121756. */
  121757. useEquirectangularFOV: boolean;
  121758. private _maxSimultaneousLights;
  121759. /**
  121760. * Number of Simultaneous lights allowed on the material.
  121761. */
  121762. maxSimultaneousLights: int;
  121763. /**
  121764. * Default configuration related to image processing available in the Background Material.
  121765. */
  121766. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121767. /**
  121768. * Keep track of the image processing observer to allow dispose and replace.
  121769. */
  121770. private _imageProcessingObserver;
  121771. /**
  121772. * Attaches a new image processing configuration to the PBR Material.
  121773. * @param configuration (if null the scene configuration will be use)
  121774. */
  121775. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121776. /**
  121777. * Gets the image processing configuration used either in this material.
  121778. */
  121779. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  121780. /**
  121781. * Sets the Default image processing configuration used either in the this material.
  121782. *
  121783. * If sets to null, the scene one is in use.
  121784. */
  121785. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  121786. /**
  121787. * Gets wether the color curves effect is enabled.
  121788. */
  121789. get cameraColorCurvesEnabled(): boolean;
  121790. /**
  121791. * Sets wether the color curves effect is enabled.
  121792. */
  121793. set cameraColorCurvesEnabled(value: boolean);
  121794. /**
  121795. * Gets wether the color grading effect is enabled.
  121796. */
  121797. get cameraColorGradingEnabled(): boolean;
  121798. /**
  121799. * Gets wether the color grading effect is enabled.
  121800. */
  121801. set cameraColorGradingEnabled(value: boolean);
  121802. /**
  121803. * Gets wether tonemapping is enabled or not.
  121804. */
  121805. get cameraToneMappingEnabled(): boolean;
  121806. /**
  121807. * Sets wether tonemapping is enabled or not
  121808. */
  121809. set cameraToneMappingEnabled(value: boolean);
  121810. /**
  121811. * The camera exposure used on this material.
  121812. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121813. * This corresponds to a photographic exposure.
  121814. */
  121815. get cameraExposure(): float;
  121816. /**
  121817. * The camera exposure used on this material.
  121818. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121819. * This corresponds to a photographic exposure.
  121820. */
  121821. set cameraExposure(value: float);
  121822. /**
  121823. * Gets The camera contrast used on this material.
  121824. */
  121825. get cameraContrast(): float;
  121826. /**
  121827. * Sets The camera contrast used on this material.
  121828. */
  121829. set cameraContrast(value: float);
  121830. /**
  121831. * Gets the Color Grading 2D Lookup Texture.
  121832. */
  121833. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121834. /**
  121835. * Sets the Color Grading 2D Lookup Texture.
  121836. */
  121837. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121838. /**
  121839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121841. * 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;
  121842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121843. */
  121844. get cameraColorCurves(): Nullable<ColorCurves>;
  121845. /**
  121846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121848. * 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;
  121849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121850. */
  121851. set cameraColorCurves(value: Nullable<ColorCurves>);
  121852. /**
  121853. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  121854. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  121855. */
  121856. switchToBGR: boolean;
  121857. private _renderTargets;
  121858. private _reflectionControls;
  121859. private _white;
  121860. private _primaryShadowColor;
  121861. private _primaryHighlightColor;
  121862. /**
  121863. * Instantiates a Background Material in the given scene
  121864. * @param name The friendly name of the material
  121865. * @param scene The scene to add the material to
  121866. */
  121867. constructor(name: string, scene: Scene);
  121868. /**
  121869. * Gets a boolean indicating that current material needs to register RTT
  121870. */
  121871. get hasRenderTargetTextures(): boolean;
  121872. /**
  121873. * The entire material has been created in order to prevent overdraw.
  121874. * @returns false
  121875. */
  121876. needAlphaTesting(): boolean;
  121877. /**
  121878. * The entire material has been created in order to prevent overdraw.
  121879. * @returns true if blending is enable
  121880. */
  121881. needAlphaBlending(): boolean;
  121882. /**
  121883. * Checks wether the material is ready to be rendered for a given mesh.
  121884. * @param mesh The mesh to render
  121885. * @param subMesh The submesh to check against
  121886. * @param useInstances Specify wether or not the material is used with instances
  121887. * @returns true if all the dependencies are ready (Textures, Effects...)
  121888. */
  121889. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121890. /**
  121891. * Compute the primary color according to the chosen perceptual color.
  121892. */
  121893. private _computePrimaryColorFromPerceptualColor;
  121894. /**
  121895. * Compute the highlights and shadow colors according to their chosen levels.
  121896. */
  121897. private _computePrimaryColors;
  121898. /**
  121899. * Build the uniform buffer used in the material.
  121900. */
  121901. buildUniformLayout(): void;
  121902. /**
  121903. * Unbind the material.
  121904. */
  121905. unbind(): void;
  121906. /**
  121907. * Bind only the world matrix to the material.
  121908. * @param world The world matrix to bind.
  121909. */
  121910. bindOnlyWorldMatrix(world: Matrix): void;
  121911. /**
  121912. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  121913. * @param world The world matrix to bind.
  121914. * @param subMesh The submesh to bind for.
  121915. */
  121916. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121917. /**
  121918. * Checks to see if a texture is used in the material.
  121919. * @param texture - Base texture to use.
  121920. * @returns - Boolean specifying if a texture is used in the material.
  121921. */
  121922. hasTexture(texture: BaseTexture): boolean;
  121923. /**
  121924. * Dispose the material.
  121925. * @param forceDisposeEffect Force disposal of the associated effect.
  121926. * @param forceDisposeTextures Force disposal of the associated textures.
  121927. */
  121928. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  121929. /**
  121930. * Clones the material.
  121931. * @param name The cloned name.
  121932. * @returns The cloned material.
  121933. */
  121934. clone(name: string): BackgroundMaterial;
  121935. /**
  121936. * Serializes the current material to its JSON representation.
  121937. * @returns The JSON representation.
  121938. */
  121939. serialize(): any;
  121940. /**
  121941. * Gets the class name of the material
  121942. * @returns "BackgroundMaterial"
  121943. */
  121944. getClassName(): string;
  121945. /**
  121946. * Parse a JSON input to create back a background material.
  121947. * @param source The JSON data to parse
  121948. * @param scene The scene to create the parsed material in
  121949. * @param rootUrl The root url of the assets the material depends upon
  121950. * @returns the instantiated BackgroundMaterial.
  121951. */
  121952. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  121953. }
  121954. }
  121955. declare module BABYLON {
  121956. /**
  121957. * Represents the different options available during the creation of
  121958. * a Environment helper.
  121959. *
  121960. * This can control the default ground, skybox and image processing setup of your scene.
  121961. */
  121962. export interface IEnvironmentHelperOptions {
  121963. /**
  121964. * Specifies wether or not to create a ground.
  121965. * True by default.
  121966. */
  121967. createGround: boolean;
  121968. /**
  121969. * Specifies the ground size.
  121970. * 15 by default.
  121971. */
  121972. groundSize: number;
  121973. /**
  121974. * The texture used on the ground for the main color.
  121975. * Comes from the BabylonJS CDN by default.
  121976. *
  121977. * Remarks: Can be either a texture or a url.
  121978. */
  121979. groundTexture: string | BaseTexture;
  121980. /**
  121981. * The color mixed in the ground texture by default.
  121982. * BabylonJS clearColor by default.
  121983. */
  121984. groundColor: Color3;
  121985. /**
  121986. * Specifies the ground opacity.
  121987. * 1 by default.
  121988. */
  121989. groundOpacity: number;
  121990. /**
  121991. * Enables the ground to receive shadows.
  121992. * True by default.
  121993. */
  121994. enableGroundShadow: boolean;
  121995. /**
  121996. * Helps preventing the shadow to be fully black on the ground.
  121997. * 0.5 by default.
  121998. */
  121999. groundShadowLevel: number;
  122000. /**
  122001. * Creates a mirror texture attach to the ground.
  122002. * false by default.
  122003. */
  122004. enableGroundMirror: boolean;
  122005. /**
  122006. * Specifies the ground mirror size ratio.
  122007. * 0.3 by default as the default kernel is 64.
  122008. */
  122009. groundMirrorSizeRatio: number;
  122010. /**
  122011. * Specifies the ground mirror blur kernel size.
  122012. * 64 by default.
  122013. */
  122014. groundMirrorBlurKernel: number;
  122015. /**
  122016. * Specifies the ground mirror visibility amount.
  122017. * 1 by default
  122018. */
  122019. groundMirrorAmount: number;
  122020. /**
  122021. * Specifies the ground mirror reflectance weight.
  122022. * This uses the standard weight of the background material to setup the fresnel effect
  122023. * of the mirror.
  122024. * 1 by default.
  122025. */
  122026. groundMirrorFresnelWeight: number;
  122027. /**
  122028. * Specifies the ground mirror Falloff distance.
  122029. * This can helps reducing the size of the reflection.
  122030. * 0 by Default.
  122031. */
  122032. groundMirrorFallOffDistance: number;
  122033. /**
  122034. * Specifies the ground mirror texture type.
  122035. * Unsigned Int by Default.
  122036. */
  122037. groundMirrorTextureType: number;
  122038. /**
  122039. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122040. * the shown objects.
  122041. */
  122042. groundYBias: number;
  122043. /**
  122044. * Specifies wether or not to create a skybox.
  122045. * True by default.
  122046. */
  122047. createSkybox: boolean;
  122048. /**
  122049. * Specifies the skybox size.
  122050. * 20 by default.
  122051. */
  122052. skyboxSize: number;
  122053. /**
  122054. * The texture used on the skybox for the main color.
  122055. * Comes from the BabylonJS CDN by default.
  122056. *
  122057. * Remarks: Can be either a texture or a url.
  122058. */
  122059. skyboxTexture: string | BaseTexture;
  122060. /**
  122061. * The color mixed in the skybox texture by default.
  122062. * BabylonJS clearColor by default.
  122063. */
  122064. skyboxColor: Color3;
  122065. /**
  122066. * The background rotation around the Y axis of the scene.
  122067. * This helps aligning the key lights of your scene with the background.
  122068. * 0 by default.
  122069. */
  122070. backgroundYRotation: number;
  122071. /**
  122072. * Compute automatically the size of the elements to best fit with the scene.
  122073. */
  122074. sizeAuto: boolean;
  122075. /**
  122076. * Default position of the rootMesh if autoSize is not true.
  122077. */
  122078. rootPosition: Vector3;
  122079. /**
  122080. * Sets up the image processing in the scene.
  122081. * true by default.
  122082. */
  122083. setupImageProcessing: boolean;
  122084. /**
  122085. * The texture used as your environment texture in the scene.
  122086. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122087. *
  122088. * Remarks: Can be either a texture or a url.
  122089. */
  122090. environmentTexture: string | BaseTexture;
  122091. /**
  122092. * The value of the exposure to apply to the scene.
  122093. * 0.6 by default if setupImageProcessing is true.
  122094. */
  122095. cameraExposure: number;
  122096. /**
  122097. * The value of the contrast to apply to the scene.
  122098. * 1.6 by default if setupImageProcessing is true.
  122099. */
  122100. cameraContrast: number;
  122101. /**
  122102. * Specifies wether or not tonemapping should be enabled in the scene.
  122103. * true by default if setupImageProcessing is true.
  122104. */
  122105. toneMappingEnabled: boolean;
  122106. }
  122107. /**
  122108. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122109. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122110. * It also helps with the default setup of your imageProcessing configuration.
  122111. */
  122112. export class EnvironmentHelper {
  122113. /**
  122114. * Default ground texture URL.
  122115. */
  122116. private static _groundTextureCDNUrl;
  122117. /**
  122118. * Default skybox texture URL.
  122119. */
  122120. private static _skyboxTextureCDNUrl;
  122121. /**
  122122. * Default environment texture URL.
  122123. */
  122124. private static _environmentTextureCDNUrl;
  122125. /**
  122126. * Creates the default options for the helper.
  122127. */
  122128. private static _getDefaultOptions;
  122129. private _rootMesh;
  122130. /**
  122131. * Gets the root mesh created by the helper.
  122132. */
  122133. get rootMesh(): Mesh;
  122134. private _skybox;
  122135. /**
  122136. * Gets the skybox created by the helper.
  122137. */
  122138. get skybox(): Nullable<Mesh>;
  122139. private _skyboxTexture;
  122140. /**
  122141. * Gets the skybox texture created by the helper.
  122142. */
  122143. get skyboxTexture(): Nullable<BaseTexture>;
  122144. private _skyboxMaterial;
  122145. /**
  122146. * Gets the skybox material created by the helper.
  122147. */
  122148. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122149. private _ground;
  122150. /**
  122151. * Gets the ground mesh created by the helper.
  122152. */
  122153. get ground(): Nullable<Mesh>;
  122154. private _groundTexture;
  122155. /**
  122156. * Gets the ground texture created by the helper.
  122157. */
  122158. get groundTexture(): Nullable<BaseTexture>;
  122159. private _groundMirror;
  122160. /**
  122161. * Gets the ground mirror created by the helper.
  122162. */
  122163. get groundMirror(): Nullable<MirrorTexture>;
  122164. /**
  122165. * Gets the ground mirror render list to helps pushing the meshes
  122166. * you wish in the ground reflection.
  122167. */
  122168. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122169. private _groundMaterial;
  122170. /**
  122171. * Gets the ground material created by the helper.
  122172. */
  122173. get groundMaterial(): Nullable<BackgroundMaterial>;
  122174. /**
  122175. * Stores the creation options.
  122176. */
  122177. private readonly _scene;
  122178. private _options;
  122179. /**
  122180. * This observable will be notified with any error during the creation of the environment,
  122181. * mainly texture creation errors.
  122182. */
  122183. onErrorObservable: Observable<{
  122184. message?: string;
  122185. exception?: any;
  122186. }>;
  122187. /**
  122188. * constructor
  122189. * @param options Defines the options we want to customize the helper
  122190. * @param scene The scene to add the material to
  122191. */
  122192. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122193. /**
  122194. * Updates the background according to the new options
  122195. * @param options
  122196. */
  122197. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122198. /**
  122199. * Sets the primary color of all the available elements.
  122200. * @param color the main color to affect to the ground and the background
  122201. */
  122202. setMainColor(color: Color3): void;
  122203. /**
  122204. * Setup the image processing according to the specified options.
  122205. */
  122206. private _setupImageProcessing;
  122207. /**
  122208. * Setup the environment texture according to the specified options.
  122209. */
  122210. private _setupEnvironmentTexture;
  122211. /**
  122212. * Setup the background according to the specified options.
  122213. */
  122214. private _setupBackground;
  122215. /**
  122216. * Get the scene sizes according to the setup.
  122217. */
  122218. private _getSceneSize;
  122219. /**
  122220. * Setup the ground according to the specified options.
  122221. */
  122222. private _setupGround;
  122223. /**
  122224. * Setup the ground material according to the specified options.
  122225. */
  122226. private _setupGroundMaterial;
  122227. /**
  122228. * Setup the ground diffuse texture according to the specified options.
  122229. */
  122230. private _setupGroundDiffuseTexture;
  122231. /**
  122232. * Setup the ground mirror texture according to the specified options.
  122233. */
  122234. private _setupGroundMirrorTexture;
  122235. /**
  122236. * Setup the ground to receive the mirror texture.
  122237. */
  122238. private _setupMirrorInGroundMaterial;
  122239. /**
  122240. * Setup the skybox according to the specified options.
  122241. */
  122242. private _setupSkybox;
  122243. /**
  122244. * Setup the skybox material according to the specified options.
  122245. */
  122246. private _setupSkyboxMaterial;
  122247. /**
  122248. * Setup the skybox reflection texture according to the specified options.
  122249. */
  122250. private _setupSkyboxReflectionTexture;
  122251. private _errorHandler;
  122252. /**
  122253. * Dispose all the elements created by the Helper.
  122254. */
  122255. dispose(): void;
  122256. }
  122257. }
  122258. declare module BABYLON {
  122259. /**
  122260. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122261. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122262. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122263. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122264. */
  122265. export class PhotoDome extends TransformNode {
  122266. /**
  122267. * Define the image as a Monoscopic panoramic 360 image.
  122268. */
  122269. static readonly MODE_MONOSCOPIC: number;
  122270. /**
  122271. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122272. */
  122273. static readonly MODE_TOPBOTTOM: number;
  122274. /**
  122275. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122276. */
  122277. static readonly MODE_SIDEBYSIDE: number;
  122278. private _useDirectMapping;
  122279. /**
  122280. * The texture being displayed on the sphere
  122281. */
  122282. protected _photoTexture: Texture;
  122283. /**
  122284. * Gets or sets the texture being displayed on the sphere
  122285. */
  122286. get photoTexture(): Texture;
  122287. set photoTexture(value: Texture);
  122288. /**
  122289. * Observable raised when an error occured while loading the 360 image
  122290. */
  122291. onLoadErrorObservable: Observable<string>;
  122292. /**
  122293. * The skybox material
  122294. */
  122295. protected _material: BackgroundMaterial;
  122296. /**
  122297. * The surface used for the skybox
  122298. */
  122299. protected _mesh: Mesh;
  122300. /**
  122301. * Gets the mesh used for the skybox.
  122302. */
  122303. get mesh(): Mesh;
  122304. /**
  122305. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122306. * Also see the options.resolution property.
  122307. */
  122308. get fovMultiplier(): number;
  122309. set fovMultiplier(value: number);
  122310. private _imageMode;
  122311. /**
  122312. * Gets or set the current video mode for the video. It can be:
  122313. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122314. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122315. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122316. */
  122317. get imageMode(): number;
  122318. set imageMode(value: number);
  122319. /**
  122320. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  122321. * @param name Element's name, child elements will append suffixes for their own names.
  122322. * @param urlsOfPhoto defines the url of the photo to display
  122323. * @param options defines an object containing optional or exposed sub element properties
  122324. * @param onError defines a callback called when an error occured while loading the texture
  122325. */
  122326. constructor(name: string, urlOfPhoto: string, options: {
  122327. resolution?: number;
  122328. size?: number;
  122329. useDirectMapping?: boolean;
  122330. faceForward?: boolean;
  122331. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  122332. private _onBeforeCameraRenderObserver;
  122333. private _changeImageMode;
  122334. /**
  122335. * Releases resources associated with this node.
  122336. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122337. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122338. */
  122339. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122340. }
  122341. }
  122342. declare module BABYLON {
  122343. /**
  122344. * Class used to host RGBD texture specific utilities
  122345. */
  122346. export class RGBDTextureTools {
  122347. /**
  122348. * Expand the RGBD Texture from RGBD to Half Float if possible.
  122349. * @param texture the texture to expand.
  122350. */
  122351. static ExpandRGBDTexture(texture: Texture): void;
  122352. }
  122353. }
  122354. declare module BABYLON {
  122355. /**
  122356. * Class used to host texture specific utilities
  122357. */
  122358. export class BRDFTextureTools {
  122359. /**
  122360. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  122361. * @param scene defines the hosting scene
  122362. * @returns the environment BRDF texture
  122363. */
  122364. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  122365. private static _environmentBRDFBase64Texture;
  122366. }
  122367. }
  122368. declare module BABYLON {
  122369. /**
  122370. * @hidden
  122371. */
  122372. export interface IMaterialClearCoatDefines {
  122373. CLEARCOAT: boolean;
  122374. CLEARCOAT_DEFAULTIOR: boolean;
  122375. CLEARCOAT_TEXTURE: boolean;
  122376. CLEARCOAT_TEXTUREDIRECTUV: number;
  122377. CLEARCOAT_BUMP: boolean;
  122378. CLEARCOAT_BUMPDIRECTUV: number;
  122379. CLEARCOAT_TINT: boolean;
  122380. CLEARCOAT_TINT_TEXTURE: boolean;
  122381. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  122382. /** @hidden */
  122383. _areTexturesDirty: boolean;
  122384. }
  122385. /**
  122386. * Define the code related to the clear coat parameters of the pbr material.
  122387. */
  122388. export class PBRClearCoatConfiguration {
  122389. /**
  122390. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122391. * The default fits with a polyurethane material.
  122392. */
  122393. private static readonly _DefaultIndexOfRefraction;
  122394. private _isEnabled;
  122395. /**
  122396. * Defines if the clear coat is enabled in the material.
  122397. */
  122398. isEnabled: boolean;
  122399. /**
  122400. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  122401. */
  122402. intensity: number;
  122403. /**
  122404. * Defines the clear coat layer roughness.
  122405. */
  122406. roughness: number;
  122407. private _indexOfRefraction;
  122408. /**
  122409. * Defines the index of refraction of the clear coat.
  122410. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122411. * The default fits with a polyurethane material.
  122412. * Changing the default value is more performance intensive.
  122413. */
  122414. indexOfRefraction: number;
  122415. private _texture;
  122416. /**
  122417. * Stores the clear coat values in a texture.
  122418. */
  122419. texture: Nullable<BaseTexture>;
  122420. private _bumpTexture;
  122421. /**
  122422. * Define the clear coat specific bump texture.
  122423. */
  122424. bumpTexture: Nullable<BaseTexture>;
  122425. private _isTintEnabled;
  122426. /**
  122427. * Defines if the clear coat tint is enabled in the material.
  122428. */
  122429. isTintEnabled: boolean;
  122430. /**
  122431. * Defines the clear coat tint of the material.
  122432. * This is only use if tint is enabled
  122433. */
  122434. tintColor: Color3;
  122435. /**
  122436. * Defines the distance at which the tint color should be found in the
  122437. * clear coat media.
  122438. * This is only use if tint is enabled
  122439. */
  122440. tintColorAtDistance: number;
  122441. /**
  122442. * Defines the clear coat layer thickness.
  122443. * This is only use if tint is enabled
  122444. */
  122445. tintThickness: number;
  122446. private _tintTexture;
  122447. /**
  122448. * Stores the clear tint values in a texture.
  122449. * rgb is tint
  122450. * a is a thickness factor
  122451. */
  122452. tintTexture: Nullable<BaseTexture>;
  122453. /** @hidden */
  122454. private _internalMarkAllSubMeshesAsTexturesDirty;
  122455. /** @hidden */
  122456. _markAllSubMeshesAsTexturesDirty(): void;
  122457. /**
  122458. * Instantiate a new istance of clear coat configuration.
  122459. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122460. */
  122461. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122462. /**
  122463. * Gets wehter the submesh is ready to be used or not.
  122464. * @param defines the list of "defines" to update.
  122465. * @param scene defines the scene the material belongs to.
  122466. * @param engine defines the engine the material belongs to.
  122467. * @param disableBumpMap defines wether the material disables bump or not.
  122468. * @returns - boolean indicating that the submesh is ready or not.
  122469. */
  122470. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  122471. /**
  122472. * Checks to see if a texture is used in the material.
  122473. * @param defines the list of "defines" to update.
  122474. * @param scene defines the scene to the material belongs to.
  122475. */
  122476. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  122477. /**
  122478. * Binds the material data.
  122479. * @param uniformBuffer defines the Uniform buffer to fill in.
  122480. * @param scene defines the scene the material belongs to.
  122481. * @param engine defines the engine the material belongs to.
  122482. * @param disableBumpMap defines wether the material disables bump or not.
  122483. * @param isFrozen defines wether the material is frozen or not.
  122484. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122485. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122486. */
  122487. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  122488. /**
  122489. * Checks to see if a texture is used in the material.
  122490. * @param texture - Base texture to use.
  122491. * @returns - Boolean specifying if a texture is used in the material.
  122492. */
  122493. hasTexture(texture: BaseTexture): boolean;
  122494. /**
  122495. * Returns an array of the actively used textures.
  122496. * @param activeTextures Array of BaseTextures
  122497. */
  122498. getActiveTextures(activeTextures: BaseTexture[]): void;
  122499. /**
  122500. * Returns the animatable textures.
  122501. * @param animatables Array of animatable textures.
  122502. */
  122503. getAnimatables(animatables: IAnimatable[]): void;
  122504. /**
  122505. * Disposes the resources of the material.
  122506. * @param forceDisposeTextures - Forces the disposal of all textures.
  122507. */
  122508. dispose(forceDisposeTextures?: boolean): void;
  122509. /**
  122510. * Get the current class name of the texture useful for serialization or dynamic coding.
  122511. * @returns "PBRClearCoatConfiguration"
  122512. */
  122513. getClassName(): string;
  122514. /**
  122515. * Add fallbacks to the effect fallbacks list.
  122516. * @param defines defines the Base texture to use.
  122517. * @param fallbacks defines the current fallback list.
  122518. * @param currentRank defines the current fallback rank.
  122519. * @returns the new fallback rank.
  122520. */
  122521. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122522. /**
  122523. * Add the required uniforms to the current list.
  122524. * @param uniforms defines the current uniform list.
  122525. */
  122526. static AddUniforms(uniforms: string[]): void;
  122527. /**
  122528. * Add the required samplers to the current list.
  122529. * @param samplers defines the current sampler list.
  122530. */
  122531. static AddSamplers(samplers: string[]): void;
  122532. /**
  122533. * Add the required uniforms to the current buffer.
  122534. * @param uniformBuffer defines the current uniform buffer.
  122535. */
  122536. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122537. /**
  122538. * Makes a duplicate of the current configuration into another one.
  122539. * @param clearCoatConfiguration define the config where to copy the info
  122540. */
  122541. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  122542. /**
  122543. * Serializes this clear coat configuration.
  122544. * @returns - An object with the serialized config.
  122545. */
  122546. serialize(): any;
  122547. /**
  122548. * Parses a anisotropy Configuration from a serialized object.
  122549. * @param source - Serialized object.
  122550. * @param scene Defines the scene we are parsing for
  122551. * @param rootUrl Defines the rootUrl to load from
  122552. */
  122553. parse(source: any, scene: Scene, rootUrl: string): void;
  122554. }
  122555. }
  122556. declare module BABYLON {
  122557. /**
  122558. * @hidden
  122559. */
  122560. export interface IMaterialAnisotropicDefines {
  122561. ANISOTROPIC: boolean;
  122562. ANISOTROPIC_TEXTURE: boolean;
  122563. ANISOTROPIC_TEXTUREDIRECTUV: number;
  122564. MAINUV1: boolean;
  122565. _areTexturesDirty: boolean;
  122566. _needUVs: boolean;
  122567. }
  122568. /**
  122569. * Define the code related to the anisotropic parameters of the pbr material.
  122570. */
  122571. export class PBRAnisotropicConfiguration {
  122572. private _isEnabled;
  122573. /**
  122574. * Defines if the anisotropy is enabled in the material.
  122575. */
  122576. isEnabled: boolean;
  122577. /**
  122578. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  122579. */
  122580. intensity: number;
  122581. /**
  122582. * Defines if the effect is along the tangents, bitangents or in between.
  122583. * By default, the effect is "strectching" the highlights along the tangents.
  122584. */
  122585. direction: Vector2;
  122586. private _texture;
  122587. /**
  122588. * Stores the anisotropy values in a texture.
  122589. * rg is direction (like normal from -1 to 1)
  122590. * b is a intensity
  122591. */
  122592. texture: Nullable<BaseTexture>;
  122593. /** @hidden */
  122594. private _internalMarkAllSubMeshesAsTexturesDirty;
  122595. /** @hidden */
  122596. _markAllSubMeshesAsTexturesDirty(): void;
  122597. /**
  122598. * Instantiate a new istance of anisotropy configuration.
  122599. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122600. */
  122601. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122602. /**
  122603. * Specifies that the submesh is ready to be used.
  122604. * @param defines the list of "defines" to update.
  122605. * @param scene defines the scene the material belongs to.
  122606. * @returns - boolean indicating that the submesh is ready or not.
  122607. */
  122608. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  122609. /**
  122610. * Checks to see if a texture is used in the material.
  122611. * @param defines the list of "defines" to update.
  122612. * @param mesh the mesh we are preparing the defines for.
  122613. * @param scene defines the scene the material belongs to.
  122614. */
  122615. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  122616. /**
  122617. * Binds the material data.
  122618. * @param uniformBuffer defines the Uniform buffer to fill in.
  122619. * @param scene defines the scene the material belongs to.
  122620. * @param isFrozen defines wether the material is frozen or not.
  122621. */
  122622. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  122623. /**
  122624. * Checks to see if a texture is used in the material.
  122625. * @param texture - Base texture to use.
  122626. * @returns - Boolean specifying if a texture is used in the material.
  122627. */
  122628. hasTexture(texture: BaseTexture): boolean;
  122629. /**
  122630. * Returns an array of the actively used textures.
  122631. * @param activeTextures Array of BaseTextures
  122632. */
  122633. getActiveTextures(activeTextures: BaseTexture[]): void;
  122634. /**
  122635. * Returns the animatable textures.
  122636. * @param animatables Array of animatable textures.
  122637. */
  122638. getAnimatables(animatables: IAnimatable[]): void;
  122639. /**
  122640. * Disposes the resources of the material.
  122641. * @param forceDisposeTextures - Forces the disposal of all textures.
  122642. */
  122643. dispose(forceDisposeTextures?: boolean): void;
  122644. /**
  122645. * Get the current class name of the texture useful for serialization or dynamic coding.
  122646. * @returns "PBRAnisotropicConfiguration"
  122647. */
  122648. getClassName(): string;
  122649. /**
  122650. * Add fallbacks to the effect fallbacks list.
  122651. * @param defines defines the Base texture to use.
  122652. * @param fallbacks defines the current fallback list.
  122653. * @param currentRank defines the current fallback rank.
  122654. * @returns the new fallback rank.
  122655. */
  122656. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122657. /**
  122658. * Add the required uniforms to the current list.
  122659. * @param uniforms defines the current uniform list.
  122660. */
  122661. static AddUniforms(uniforms: string[]): void;
  122662. /**
  122663. * Add the required uniforms to the current buffer.
  122664. * @param uniformBuffer defines the current uniform buffer.
  122665. */
  122666. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122667. /**
  122668. * Add the required samplers to the current list.
  122669. * @param samplers defines the current sampler list.
  122670. */
  122671. static AddSamplers(samplers: string[]): void;
  122672. /**
  122673. * Makes a duplicate of the current configuration into another one.
  122674. * @param anisotropicConfiguration define the config where to copy the info
  122675. */
  122676. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  122677. /**
  122678. * Serializes this anisotropy configuration.
  122679. * @returns - An object with the serialized config.
  122680. */
  122681. serialize(): any;
  122682. /**
  122683. * Parses a anisotropy Configuration from a serialized object.
  122684. * @param source - Serialized object.
  122685. * @param scene Defines the scene we are parsing for
  122686. * @param rootUrl Defines the rootUrl to load from
  122687. */
  122688. parse(source: any, scene: Scene, rootUrl: string): void;
  122689. }
  122690. }
  122691. declare module BABYLON {
  122692. /**
  122693. * @hidden
  122694. */
  122695. export interface IMaterialBRDFDefines {
  122696. BRDF_V_HEIGHT_CORRELATED: boolean;
  122697. MS_BRDF_ENERGY_CONSERVATION: boolean;
  122698. SPHERICAL_HARMONICS: boolean;
  122699. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  122700. /** @hidden */
  122701. _areMiscDirty: boolean;
  122702. }
  122703. /**
  122704. * Define the code related to the BRDF parameters of the pbr material.
  122705. */
  122706. export class PBRBRDFConfiguration {
  122707. /**
  122708. * Default value used for the energy conservation.
  122709. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122710. */
  122711. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  122712. /**
  122713. * Default value used for the Smith Visibility Height Correlated mode.
  122714. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122715. */
  122716. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  122717. /**
  122718. * Default value used for the IBL diffuse part.
  122719. * This can help switching back to the polynomials mode globally which is a tiny bit
  122720. * less GPU intensive at the drawback of a lower quality.
  122721. */
  122722. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  122723. /**
  122724. * Default value used for activating energy conservation for the specular workflow.
  122725. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122726. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122727. */
  122728. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  122729. private _useEnergyConservation;
  122730. /**
  122731. * Defines if the material uses energy conservation.
  122732. */
  122733. useEnergyConservation: boolean;
  122734. private _useSmithVisibilityHeightCorrelated;
  122735. /**
  122736. * LEGACY Mode set to false
  122737. * Defines if the material uses height smith correlated visibility term.
  122738. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  122739. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  122740. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  122741. * Not relying on height correlated will also disable energy conservation.
  122742. */
  122743. useSmithVisibilityHeightCorrelated: boolean;
  122744. private _useSphericalHarmonics;
  122745. /**
  122746. * LEGACY Mode set to false
  122747. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  122748. * diffuse part of the IBL.
  122749. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  122750. * to the ground truth.
  122751. */
  122752. useSphericalHarmonics: boolean;
  122753. private _useSpecularGlossinessInputEnergyConservation;
  122754. /**
  122755. * Defines if the material uses energy conservation, when the specular workflow is active.
  122756. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122757. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122758. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  122759. */
  122760. useSpecularGlossinessInputEnergyConservation: boolean;
  122761. /** @hidden */
  122762. private _internalMarkAllSubMeshesAsMiscDirty;
  122763. /** @hidden */
  122764. _markAllSubMeshesAsMiscDirty(): void;
  122765. /**
  122766. * Instantiate a new istance of clear coat configuration.
  122767. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  122768. */
  122769. constructor(markAllSubMeshesAsMiscDirty: () => void);
  122770. /**
  122771. * Checks to see if a texture is used in the material.
  122772. * @param defines the list of "defines" to update.
  122773. */
  122774. prepareDefines(defines: IMaterialBRDFDefines): void;
  122775. /**
  122776. * Get the current class name of the texture useful for serialization or dynamic coding.
  122777. * @returns "PBRClearCoatConfiguration"
  122778. */
  122779. getClassName(): string;
  122780. /**
  122781. * Makes a duplicate of the current configuration into another one.
  122782. * @param brdfConfiguration define the config where to copy the info
  122783. */
  122784. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  122785. /**
  122786. * Serializes this BRDF configuration.
  122787. * @returns - An object with the serialized config.
  122788. */
  122789. serialize(): any;
  122790. /**
  122791. * Parses a anisotropy Configuration from a serialized object.
  122792. * @param source - Serialized object.
  122793. * @param scene Defines the scene we are parsing for
  122794. * @param rootUrl Defines the rootUrl to load from
  122795. */
  122796. parse(source: any, scene: Scene, rootUrl: string): void;
  122797. }
  122798. }
  122799. declare module BABYLON {
  122800. /**
  122801. * @hidden
  122802. */
  122803. export interface IMaterialSheenDefines {
  122804. SHEEN: boolean;
  122805. SHEEN_TEXTURE: boolean;
  122806. SHEEN_TEXTUREDIRECTUV: number;
  122807. SHEEN_LINKWITHALBEDO: boolean;
  122808. /** @hidden */
  122809. _areTexturesDirty: boolean;
  122810. }
  122811. /**
  122812. * Define the code related to the Sheen parameters of the pbr material.
  122813. */
  122814. export class PBRSheenConfiguration {
  122815. private _isEnabled;
  122816. /**
  122817. * Defines if the material uses sheen.
  122818. */
  122819. isEnabled: boolean;
  122820. private _linkSheenWithAlbedo;
  122821. /**
  122822. * Defines if the sheen is linked to the sheen color.
  122823. */
  122824. linkSheenWithAlbedo: boolean;
  122825. /**
  122826. * Defines the sheen intensity.
  122827. */
  122828. intensity: number;
  122829. /**
  122830. * Defines the sheen color.
  122831. */
  122832. color: Color3;
  122833. private _texture;
  122834. /**
  122835. * Stores the sheen tint values in a texture.
  122836. * rgb is tint
  122837. * a is a intensity
  122838. */
  122839. texture: Nullable<BaseTexture>;
  122840. /** @hidden */
  122841. private _internalMarkAllSubMeshesAsTexturesDirty;
  122842. /** @hidden */
  122843. _markAllSubMeshesAsTexturesDirty(): void;
  122844. /**
  122845. * Instantiate a new istance of clear coat configuration.
  122846. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122847. */
  122848. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122849. /**
  122850. * Specifies that the submesh is ready to be used.
  122851. * @param defines the list of "defines" to update.
  122852. * @param scene defines the scene the material belongs to.
  122853. * @returns - boolean indicating that the submesh is ready or not.
  122854. */
  122855. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  122856. /**
  122857. * Checks to see if a texture is used in the material.
  122858. * @param defines the list of "defines" to update.
  122859. * @param scene defines the scene the material belongs to.
  122860. */
  122861. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  122862. /**
  122863. * Binds the material data.
  122864. * @param uniformBuffer defines the Uniform buffer to fill in.
  122865. * @param scene defines the scene the material belongs to.
  122866. * @param isFrozen defines wether the material is frozen or not.
  122867. */
  122868. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  122869. /**
  122870. * Checks to see if a texture is used in the material.
  122871. * @param texture - Base texture to use.
  122872. * @returns - Boolean specifying if a texture is used in the material.
  122873. */
  122874. hasTexture(texture: BaseTexture): boolean;
  122875. /**
  122876. * Returns an array of the actively used textures.
  122877. * @param activeTextures Array of BaseTextures
  122878. */
  122879. getActiveTextures(activeTextures: BaseTexture[]): void;
  122880. /**
  122881. * Returns the animatable textures.
  122882. * @param animatables Array of animatable textures.
  122883. */
  122884. getAnimatables(animatables: IAnimatable[]): void;
  122885. /**
  122886. * Disposes the resources of the material.
  122887. * @param forceDisposeTextures - Forces the disposal of all textures.
  122888. */
  122889. dispose(forceDisposeTextures?: boolean): void;
  122890. /**
  122891. * Get the current class name of the texture useful for serialization or dynamic coding.
  122892. * @returns "PBRSheenConfiguration"
  122893. */
  122894. getClassName(): string;
  122895. /**
  122896. * Add fallbacks to the effect fallbacks list.
  122897. * @param defines defines the Base texture to use.
  122898. * @param fallbacks defines the current fallback list.
  122899. * @param currentRank defines the current fallback rank.
  122900. * @returns the new fallback rank.
  122901. */
  122902. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122903. /**
  122904. * Add the required uniforms to the current list.
  122905. * @param uniforms defines the current uniform list.
  122906. */
  122907. static AddUniforms(uniforms: string[]): void;
  122908. /**
  122909. * Add the required uniforms to the current buffer.
  122910. * @param uniformBuffer defines the current uniform buffer.
  122911. */
  122912. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122913. /**
  122914. * Add the required samplers to the current list.
  122915. * @param samplers defines the current sampler list.
  122916. */
  122917. static AddSamplers(samplers: string[]): void;
  122918. /**
  122919. * Makes a duplicate of the current configuration into another one.
  122920. * @param sheenConfiguration define the config where to copy the info
  122921. */
  122922. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  122923. /**
  122924. * Serializes this BRDF configuration.
  122925. * @returns - An object with the serialized config.
  122926. */
  122927. serialize(): any;
  122928. /**
  122929. * Parses a anisotropy Configuration from a serialized object.
  122930. * @param source - Serialized object.
  122931. * @param scene Defines the scene we are parsing for
  122932. * @param rootUrl Defines the rootUrl to load from
  122933. */
  122934. parse(source: any, scene: Scene, rootUrl: string): void;
  122935. }
  122936. }
  122937. declare module BABYLON {
  122938. /**
  122939. * @hidden
  122940. */
  122941. export interface IMaterialSubSurfaceDefines {
  122942. SUBSURFACE: boolean;
  122943. SS_REFRACTION: boolean;
  122944. SS_TRANSLUCENCY: boolean;
  122945. SS_SCATERRING: boolean;
  122946. SS_THICKNESSANDMASK_TEXTURE: boolean;
  122947. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  122948. SS_REFRACTIONMAP_3D: boolean;
  122949. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  122950. SS_LODINREFRACTIONALPHA: boolean;
  122951. SS_GAMMAREFRACTION: boolean;
  122952. SS_RGBDREFRACTION: boolean;
  122953. SS_LINEARSPECULARREFRACTION: boolean;
  122954. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  122955. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  122956. /** @hidden */
  122957. _areTexturesDirty: boolean;
  122958. }
  122959. /**
  122960. * Define the code related to the sub surface parameters of the pbr material.
  122961. */
  122962. export class PBRSubSurfaceConfiguration {
  122963. private _isRefractionEnabled;
  122964. /**
  122965. * Defines if the refraction is enabled in the material.
  122966. */
  122967. isRefractionEnabled: boolean;
  122968. private _isTranslucencyEnabled;
  122969. /**
  122970. * Defines if the translucency is enabled in the material.
  122971. */
  122972. isTranslucencyEnabled: boolean;
  122973. private _isScatteringEnabled;
  122974. /**
  122975. * Defines the refraction intensity of the material.
  122976. * The refraction when enabled replaces the Diffuse part of the material.
  122977. * The intensity helps transitionning between diffuse and refraction.
  122978. */
  122979. refractionIntensity: number;
  122980. /**
  122981. * Defines the translucency intensity of the material.
  122982. * When translucency has been enabled, this defines how much of the "translucency"
  122983. * is addded to the diffuse part of the material.
  122984. */
  122985. translucencyIntensity: number;
  122986. /**
  122987. * Defines the scattering intensity of the material.
  122988. * When scattering has been enabled, this defines how much of the "scattered light"
  122989. * is addded to the diffuse part of the material.
  122990. */
  122991. scatteringIntensity: number;
  122992. private _thicknessTexture;
  122993. /**
  122994. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  122995. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  122996. * 0 would mean minimumThickness
  122997. * 1 would mean maximumThickness
  122998. * The other channels might be use as a mask to vary the different effects intensity.
  122999. */
  123000. thicknessTexture: Nullable<BaseTexture>;
  123001. private _refractionTexture;
  123002. /**
  123003. * Defines the texture to use for refraction.
  123004. */
  123005. refractionTexture: Nullable<BaseTexture>;
  123006. private _indexOfRefraction;
  123007. /**
  123008. * Defines the index of refraction used in the material.
  123009. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123010. */
  123011. indexOfRefraction: number;
  123012. private _invertRefractionY;
  123013. /**
  123014. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123015. */
  123016. invertRefractionY: boolean;
  123017. private _linkRefractionWithTransparency;
  123018. /**
  123019. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123020. * Materials half opaque for instance using refraction could benefit from this control.
  123021. */
  123022. linkRefractionWithTransparency: boolean;
  123023. /**
  123024. * Defines the minimum thickness stored in the thickness map.
  123025. * If no thickness map is defined, this value will be used to simulate thickness.
  123026. */
  123027. minimumThickness: number;
  123028. /**
  123029. * Defines the maximum thickness stored in the thickness map.
  123030. */
  123031. maximumThickness: number;
  123032. /**
  123033. * Defines the volume tint of the material.
  123034. * This is used for both translucency and scattering.
  123035. */
  123036. tintColor: Color3;
  123037. /**
  123038. * Defines the distance at which the tint color should be found in the media.
  123039. * This is used for refraction only.
  123040. */
  123041. tintColorAtDistance: number;
  123042. /**
  123043. * Defines how far each channel transmit through the media.
  123044. * It is defined as a color to simplify it selection.
  123045. */
  123046. diffusionDistance: Color3;
  123047. private _useMaskFromThicknessTexture;
  123048. /**
  123049. * Stores the intensity of the different subsurface effects in the thickness texture.
  123050. * * the green channel is the translucency intensity.
  123051. * * the blue channel is the scattering intensity.
  123052. * * the alpha channel is the refraction intensity.
  123053. */
  123054. useMaskFromThicknessTexture: boolean;
  123055. /** @hidden */
  123056. private _internalMarkAllSubMeshesAsTexturesDirty;
  123057. /** @hidden */
  123058. _markAllSubMeshesAsTexturesDirty(): void;
  123059. /**
  123060. * Instantiate a new istance of sub surface configuration.
  123061. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123062. */
  123063. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123064. /**
  123065. * Gets wehter the submesh is ready to be used or not.
  123066. * @param defines the list of "defines" to update.
  123067. * @param scene defines the scene the material belongs to.
  123068. * @returns - boolean indicating that the submesh is ready or not.
  123069. */
  123070. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123071. /**
  123072. * Checks to see if a texture is used in the material.
  123073. * @param defines the list of "defines" to update.
  123074. * @param scene defines the scene to the material belongs to.
  123075. */
  123076. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123077. /**
  123078. * Binds the material data.
  123079. * @param uniformBuffer defines the Uniform buffer to fill in.
  123080. * @param scene defines the scene the material belongs to.
  123081. * @param engine defines the engine the material belongs to.
  123082. * @param isFrozen defines wether the material is frozen or not.
  123083. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123084. */
  123085. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123086. /**
  123087. * Unbinds the material from the mesh.
  123088. * @param activeEffect defines the effect that should be unbound from.
  123089. * @returns true if unbound, otherwise false
  123090. */
  123091. unbind(activeEffect: Effect): boolean;
  123092. /**
  123093. * Returns the texture used for refraction or null if none is used.
  123094. * @param scene defines the scene the material belongs to.
  123095. * @returns - Refraction texture if present. If no refraction texture and refraction
  123096. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123097. */
  123098. private _getRefractionTexture;
  123099. /**
  123100. * Returns true if alpha blending should be disabled.
  123101. */
  123102. get disableAlphaBlending(): boolean;
  123103. /**
  123104. * Fills the list of render target textures.
  123105. * @param renderTargets the list of render targets to update
  123106. */
  123107. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123108. /**
  123109. * Checks to see if a texture is used in the material.
  123110. * @param texture - Base texture to use.
  123111. * @returns - Boolean specifying if a texture is used in the material.
  123112. */
  123113. hasTexture(texture: BaseTexture): boolean;
  123114. /**
  123115. * Gets a boolean indicating that current material needs to register RTT
  123116. * @returns true if this uses a render target otherwise false.
  123117. */
  123118. hasRenderTargetTextures(): boolean;
  123119. /**
  123120. * Returns an array of the actively used textures.
  123121. * @param activeTextures Array of BaseTextures
  123122. */
  123123. getActiveTextures(activeTextures: BaseTexture[]): void;
  123124. /**
  123125. * Returns the animatable textures.
  123126. * @param animatables Array of animatable textures.
  123127. */
  123128. getAnimatables(animatables: IAnimatable[]): void;
  123129. /**
  123130. * Disposes the resources of the material.
  123131. * @param forceDisposeTextures - Forces the disposal of all textures.
  123132. */
  123133. dispose(forceDisposeTextures?: boolean): void;
  123134. /**
  123135. * Get the current class name of the texture useful for serialization or dynamic coding.
  123136. * @returns "PBRSubSurfaceConfiguration"
  123137. */
  123138. getClassName(): string;
  123139. /**
  123140. * Add fallbacks to the effect fallbacks list.
  123141. * @param defines defines the Base texture to use.
  123142. * @param fallbacks defines the current fallback list.
  123143. * @param currentRank defines the current fallback rank.
  123144. * @returns the new fallback rank.
  123145. */
  123146. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123147. /**
  123148. * Add the required uniforms to the current list.
  123149. * @param uniforms defines the current uniform list.
  123150. */
  123151. static AddUniforms(uniforms: string[]): void;
  123152. /**
  123153. * Add the required samplers to the current list.
  123154. * @param samplers defines the current sampler list.
  123155. */
  123156. static AddSamplers(samplers: string[]): void;
  123157. /**
  123158. * Add the required uniforms to the current buffer.
  123159. * @param uniformBuffer defines the current uniform buffer.
  123160. */
  123161. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123162. /**
  123163. * Makes a duplicate of the current configuration into another one.
  123164. * @param configuration define the config where to copy the info
  123165. */
  123166. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123167. /**
  123168. * Serializes this Sub Surface configuration.
  123169. * @returns - An object with the serialized config.
  123170. */
  123171. serialize(): any;
  123172. /**
  123173. * Parses a anisotropy Configuration from a serialized object.
  123174. * @param source - Serialized object.
  123175. * @param scene Defines the scene we are parsing for
  123176. * @param rootUrl Defines the rootUrl to load from
  123177. */
  123178. parse(source: any, scene: Scene, rootUrl: string): void;
  123179. }
  123180. }
  123181. declare module BABYLON {
  123182. /** @hidden */
  123183. export var pbrFragmentDeclaration: {
  123184. name: string;
  123185. shader: string;
  123186. };
  123187. }
  123188. declare module BABYLON {
  123189. /** @hidden */
  123190. export var pbrUboDeclaration: {
  123191. name: string;
  123192. shader: string;
  123193. };
  123194. }
  123195. declare module BABYLON {
  123196. /** @hidden */
  123197. export var pbrFragmentExtraDeclaration: {
  123198. name: string;
  123199. shader: string;
  123200. };
  123201. }
  123202. declare module BABYLON {
  123203. /** @hidden */
  123204. export var pbrFragmentSamplersDeclaration: {
  123205. name: string;
  123206. shader: string;
  123207. };
  123208. }
  123209. declare module BABYLON {
  123210. /** @hidden */
  123211. export var pbrHelperFunctions: {
  123212. name: string;
  123213. shader: string;
  123214. };
  123215. }
  123216. declare module BABYLON {
  123217. /** @hidden */
  123218. export var harmonicsFunctions: {
  123219. name: string;
  123220. shader: string;
  123221. };
  123222. }
  123223. declare module BABYLON {
  123224. /** @hidden */
  123225. export var pbrDirectLightingSetupFunctions: {
  123226. name: string;
  123227. shader: string;
  123228. };
  123229. }
  123230. declare module BABYLON {
  123231. /** @hidden */
  123232. export var pbrDirectLightingFalloffFunctions: {
  123233. name: string;
  123234. shader: string;
  123235. };
  123236. }
  123237. declare module BABYLON {
  123238. /** @hidden */
  123239. export var pbrBRDFFunctions: {
  123240. name: string;
  123241. shader: string;
  123242. };
  123243. }
  123244. declare module BABYLON {
  123245. /** @hidden */
  123246. export var pbrDirectLightingFunctions: {
  123247. name: string;
  123248. shader: string;
  123249. };
  123250. }
  123251. declare module BABYLON {
  123252. /** @hidden */
  123253. export var pbrIBLFunctions: {
  123254. name: string;
  123255. shader: string;
  123256. };
  123257. }
  123258. declare module BABYLON {
  123259. /** @hidden */
  123260. export var pbrDebug: {
  123261. name: string;
  123262. shader: string;
  123263. };
  123264. }
  123265. declare module BABYLON {
  123266. /** @hidden */
  123267. export var pbrPixelShader: {
  123268. name: string;
  123269. shader: string;
  123270. };
  123271. }
  123272. declare module BABYLON {
  123273. /** @hidden */
  123274. export var pbrVertexDeclaration: {
  123275. name: string;
  123276. shader: string;
  123277. };
  123278. }
  123279. declare module BABYLON {
  123280. /** @hidden */
  123281. export var pbrVertexShader: {
  123282. name: string;
  123283. shader: string;
  123284. };
  123285. }
  123286. declare module BABYLON {
  123287. /**
  123288. * Manages the defines for the PBR Material.
  123289. * @hidden
  123290. */
  123291. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123292. PBR: boolean;
  123293. MAINUV1: boolean;
  123294. MAINUV2: boolean;
  123295. UV1: boolean;
  123296. UV2: boolean;
  123297. ALBEDO: boolean;
  123298. ALBEDODIRECTUV: number;
  123299. VERTEXCOLOR: boolean;
  123300. AMBIENT: boolean;
  123301. AMBIENTDIRECTUV: number;
  123302. AMBIENTINGRAYSCALE: boolean;
  123303. OPACITY: boolean;
  123304. VERTEXALPHA: boolean;
  123305. OPACITYDIRECTUV: number;
  123306. OPACITYRGB: boolean;
  123307. ALPHATEST: boolean;
  123308. DEPTHPREPASS: boolean;
  123309. ALPHABLEND: boolean;
  123310. ALPHAFROMALBEDO: boolean;
  123311. ALPHATESTVALUE: string;
  123312. SPECULAROVERALPHA: boolean;
  123313. RADIANCEOVERALPHA: boolean;
  123314. ALPHAFRESNEL: boolean;
  123315. LINEARALPHAFRESNEL: boolean;
  123316. PREMULTIPLYALPHA: boolean;
  123317. EMISSIVE: boolean;
  123318. EMISSIVEDIRECTUV: number;
  123319. REFLECTIVITY: boolean;
  123320. REFLECTIVITYDIRECTUV: number;
  123321. SPECULARTERM: boolean;
  123322. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  123323. MICROSURFACEAUTOMATIC: boolean;
  123324. LODBASEDMICROSFURACE: boolean;
  123325. MICROSURFACEMAP: boolean;
  123326. MICROSURFACEMAPDIRECTUV: number;
  123327. METALLICWORKFLOW: boolean;
  123328. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  123329. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  123330. METALLNESSSTOREINMETALMAPBLUE: boolean;
  123331. AOSTOREINMETALMAPRED: boolean;
  123332. METALLICF0FACTORFROMMETALLICMAP: boolean;
  123333. ENVIRONMENTBRDF: boolean;
  123334. ENVIRONMENTBRDF_RGBD: boolean;
  123335. NORMAL: boolean;
  123336. TANGENT: boolean;
  123337. BUMP: boolean;
  123338. BUMPDIRECTUV: number;
  123339. OBJECTSPACE_NORMALMAP: boolean;
  123340. PARALLAX: boolean;
  123341. PARALLAXOCCLUSION: boolean;
  123342. NORMALXYSCALE: boolean;
  123343. LIGHTMAP: boolean;
  123344. LIGHTMAPDIRECTUV: number;
  123345. USELIGHTMAPASSHADOWMAP: boolean;
  123346. GAMMALIGHTMAP: boolean;
  123347. RGBDLIGHTMAP: boolean;
  123348. REFLECTION: boolean;
  123349. REFLECTIONMAP_3D: boolean;
  123350. REFLECTIONMAP_SPHERICAL: boolean;
  123351. REFLECTIONMAP_PLANAR: boolean;
  123352. REFLECTIONMAP_CUBIC: boolean;
  123353. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  123354. REFLECTIONMAP_PROJECTION: boolean;
  123355. REFLECTIONMAP_SKYBOX: boolean;
  123356. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  123357. REFLECTIONMAP_EXPLICIT: boolean;
  123358. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  123359. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  123360. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  123361. INVERTCUBICMAP: boolean;
  123362. USESPHERICALFROMREFLECTIONMAP: boolean;
  123363. USEIRRADIANCEMAP: boolean;
  123364. SPHERICAL_HARMONICS: boolean;
  123365. USESPHERICALINVERTEX: boolean;
  123366. REFLECTIONMAP_OPPOSITEZ: boolean;
  123367. LODINREFLECTIONALPHA: boolean;
  123368. GAMMAREFLECTION: boolean;
  123369. RGBDREFLECTION: boolean;
  123370. LINEARSPECULARREFLECTION: boolean;
  123371. RADIANCEOCCLUSION: boolean;
  123372. HORIZONOCCLUSION: boolean;
  123373. INSTANCES: boolean;
  123374. NUM_BONE_INFLUENCERS: number;
  123375. BonesPerMesh: number;
  123376. BONETEXTURE: boolean;
  123377. NONUNIFORMSCALING: boolean;
  123378. MORPHTARGETS: boolean;
  123379. MORPHTARGETS_NORMAL: boolean;
  123380. MORPHTARGETS_TANGENT: boolean;
  123381. MORPHTARGETS_UV: boolean;
  123382. NUM_MORPH_INFLUENCERS: number;
  123383. IMAGEPROCESSING: boolean;
  123384. VIGNETTE: boolean;
  123385. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123386. VIGNETTEBLENDMODEOPAQUE: boolean;
  123387. TONEMAPPING: boolean;
  123388. TONEMAPPING_ACES: boolean;
  123389. CONTRAST: boolean;
  123390. COLORCURVES: boolean;
  123391. COLORGRADING: boolean;
  123392. COLORGRADING3D: boolean;
  123393. SAMPLER3DGREENDEPTH: boolean;
  123394. SAMPLER3DBGRMAP: boolean;
  123395. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123396. EXPOSURE: boolean;
  123397. MULTIVIEW: boolean;
  123398. USEPHYSICALLIGHTFALLOFF: boolean;
  123399. USEGLTFLIGHTFALLOFF: boolean;
  123400. TWOSIDEDLIGHTING: boolean;
  123401. SHADOWFLOAT: boolean;
  123402. CLIPPLANE: boolean;
  123403. CLIPPLANE2: boolean;
  123404. CLIPPLANE3: boolean;
  123405. CLIPPLANE4: boolean;
  123406. CLIPPLANE5: boolean;
  123407. CLIPPLANE6: boolean;
  123408. POINTSIZE: boolean;
  123409. FOG: boolean;
  123410. LOGARITHMICDEPTH: boolean;
  123411. FORCENORMALFORWARD: boolean;
  123412. SPECULARAA: boolean;
  123413. CLEARCOAT: boolean;
  123414. CLEARCOAT_DEFAULTIOR: boolean;
  123415. CLEARCOAT_TEXTURE: boolean;
  123416. CLEARCOAT_TEXTUREDIRECTUV: number;
  123417. CLEARCOAT_BUMP: boolean;
  123418. CLEARCOAT_BUMPDIRECTUV: number;
  123419. CLEARCOAT_TINT: boolean;
  123420. CLEARCOAT_TINT_TEXTURE: boolean;
  123421. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123422. ANISOTROPIC: boolean;
  123423. ANISOTROPIC_TEXTURE: boolean;
  123424. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123425. BRDF_V_HEIGHT_CORRELATED: boolean;
  123426. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123427. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123428. SHEEN: boolean;
  123429. SHEEN_TEXTURE: boolean;
  123430. SHEEN_TEXTUREDIRECTUV: number;
  123431. SHEEN_LINKWITHALBEDO: boolean;
  123432. SUBSURFACE: boolean;
  123433. SS_REFRACTION: boolean;
  123434. SS_TRANSLUCENCY: boolean;
  123435. SS_SCATERRING: boolean;
  123436. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123437. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123438. SS_REFRACTIONMAP_3D: boolean;
  123439. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123440. SS_LODINREFRACTIONALPHA: boolean;
  123441. SS_GAMMAREFRACTION: boolean;
  123442. SS_RGBDREFRACTION: boolean;
  123443. SS_LINEARSPECULARREFRACTION: boolean;
  123444. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123445. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123446. UNLIT: boolean;
  123447. DEBUGMODE: number;
  123448. /**
  123449. * Initializes the PBR Material defines.
  123450. */
  123451. constructor();
  123452. /**
  123453. * Resets the PBR Material defines.
  123454. */
  123455. reset(): void;
  123456. }
  123457. /**
  123458. * The Physically based material base class of BJS.
  123459. *
  123460. * This offers the main features of a standard PBR material.
  123461. * For more information, please refer to the documentation :
  123462. * https://doc.babylonjs.com/how_to/physically_based_rendering
  123463. */
  123464. export abstract class PBRBaseMaterial extends PushMaterial {
  123465. /**
  123466. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  123467. */
  123468. static readonly PBRMATERIAL_OPAQUE: number;
  123469. /**
  123470. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  123471. */
  123472. static readonly PBRMATERIAL_ALPHATEST: number;
  123473. /**
  123474. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123475. */
  123476. static readonly PBRMATERIAL_ALPHABLEND: number;
  123477. /**
  123478. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123479. * They are also discarded below the alpha cutoff threshold to improve performances.
  123480. */
  123481. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  123482. /**
  123483. * Defines the default value of how much AO map is occluding the analytical lights
  123484. * (point spot...).
  123485. */
  123486. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  123487. /**
  123488. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  123489. */
  123490. static readonly LIGHTFALLOFF_PHYSICAL: number;
  123491. /**
  123492. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  123493. * to enhance interoperability with other engines.
  123494. */
  123495. static readonly LIGHTFALLOFF_GLTF: number;
  123496. /**
  123497. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  123498. * to enhance interoperability with other materials.
  123499. */
  123500. static readonly LIGHTFALLOFF_STANDARD: number;
  123501. /**
  123502. * Intensity of the direct lights e.g. the four lights available in your scene.
  123503. * This impacts both the direct diffuse and specular highlights.
  123504. */
  123505. protected _directIntensity: number;
  123506. /**
  123507. * Intensity of the emissive part of the material.
  123508. * This helps controlling the emissive effect without modifying the emissive color.
  123509. */
  123510. protected _emissiveIntensity: number;
  123511. /**
  123512. * Intensity of the environment e.g. how much the environment will light the object
  123513. * either through harmonics for rough material or through the refelction for shiny ones.
  123514. */
  123515. protected _environmentIntensity: number;
  123516. /**
  123517. * This is a special control allowing the reduction of the specular highlights coming from the
  123518. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  123519. */
  123520. protected _specularIntensity: number;
  123521. /**
  123522. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  123523. */
  123524. private _lightingInfos;
  123525. /**
  123526. * Debug Control allowing disabling the bump map on this material.
  123527. */
  123528. protected _disableBumpMap: boolean;
  123529. /**
  123530. * AKA Diffuse Texture in standard nomenclature.
  123531. */
  123532. protected _albedoTexture: Nullable<BaseTexture>;
  123533. /**
  123534. * AKA Occlusion Texture in other nomenclature.
  123535. */
  123536. protected _ambientTexture: Nullable<BaseTexture>;
  123537. /**
  123538. * AKA Occlusion Texture Intensity in other nomenclature.
  123539. */
  123540. protected _ambientTextureStrength: number;
  123541. /**
  123542. * Defines how much the AO map is occluding the analytical lights (point spot...).
  123543. * 1 means it completely occludes it
  123544. * 0 mean it has no impact
  123545. */
  123546. protected _ambientTextureImpactOnAnalyticalLights: number;
  123547. /**
  123548. * Stores the alpha values in a texture.
  123549. */
  123550. protected _opacityTexture: Nullable<BaseTexture>;
  123551. /**
  123552. * Stores the reflection values in a texture.
  123553. */
  123554. protected _reflectionTexture: Nullable<BaseTexture>;
  123555. /**
  123556. * Stores the emissive values in a texture.
  123557. */
  123558. protected _emissiveTexture: Nullable<BaseTexture>;
  123559. /**
  123560. * AKA Specular texture in other nomenclature.
  123561. */
  123562. protected _reflectivityTexture: Nullable<BaseTexture>;
  123563. /**
  123564. * Used to switch from specular/glossiness to metallic/roughness workflow.
  123565. */
  123566. protected _metallicTexture: Nullable<BaseTexture>;
  123567. /**
  123568. * Specifies the metallic scalar of the metallic/roughness workflow.
  123569. * Can also be used to scale the metalness values of the metallic texture.
  123570. */
  123571. protected _metallic: Nullable<number>;
  123572. /**
  123573. * Specifies the roughness scalar of the metallic/roughness workflow.
  123574. * Can also be used to scale the roughness values of the metallic texture.
  123575. */
  123576. protected _roughness: Nullable<number>;
  123577. /**
  123578. * Specifies the an F0 factor to help configuring the material F0.
  123579. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  123580. * to 0.5 the previously hard coded value stays the same.
  123581. * Can also be used to scale the F0 values of the metallic texture.
  123582. */
  123583. protected _metallicF0Factor: number;
  123584. /**
  123585. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  123586. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  123587. * your expectation as it multiplies with the texture data.
  123588. */
  123589. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  123590. /**
  123591. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  123592. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  123593. */
  123594. protected _microSurfaceTexture: Nullable<BaseTexture>;
  123595. /**
  123596. * Stores surface normal data used to displace a mesh in a texture.
  123597. */
  123598. protected _bumpTexture: Nullable<BaseTexture>;
  123599. /**
  123600. * Stores the pre-calculated light information of a mesh in a texture.
  123601. */
  123602. protected _lightmapTexture: Nullable<BaseTexture>;
  123603. /**
  123604. * The color of a material in ambient lighting.
  123605. */
  123606. protected _ambientColor: Color3;
  123607. /**
  123608. * AKA Diffuse Color in other nomenclature.
  123609. */
  123610. protected _albedoColor: Color3;
  123611. /**
  123612. * AKA Specular Color in other nomenclature.
  123613. */
  123614. protected _reflectivityColor: Color3;
  123615. /**
  123616. * The color applied when light is reflected from a material.
  123617. */
  123618. protected _reflectionColor: Color3;
  123619. /**
  123620. * The color applied when light is emitted from a material.
  123621. */
  123622. protected _emissiveColor: Color3;
  123623. /**
  123624. * AKA Glossiness in other nomenclature.
  123625. */
  123626. protected _microSurface: number;
  123627. /**
  123628. * Specifies that the material will use the light map as a show map.
  123629. */
  123630. protected _useLightmapAsShadowmap: boolean;
  123631. /**
  123632. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  123633. * makes the reflect vector face the model (under horizon).
  123634. */
  123635. protected _useHorizonOcclusion: boolean;
  123636. /**
  123637. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  123638. * too much the area relying on ambient texture to define their ambient occlusion.
  123639. */
  123640. protected _useRadianceOcclusion: boolean;
  123641. /**
  123642. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  123643. */
  123644. protected _useAlphaFromAlbedoTexture: boolean;
  123645. /**
  123646. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  123647. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  123648. */
  123649. protected _useSpecularOverAlpha: boolean;
  123650. /**
  123651. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  123652. */
  123653. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  123654. /**
  123655. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  123656. */
  123657. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  123658. /**
  123659. * Specifies if the metallic texture contains the roughness information in its green channel.
  123660. */
  123661. protected _useRoughnessFromMetallicTextureGreen: boolean;
  123662. /**
  123663. * Specifies if the metallic texture contains the metallness information in its blue channel.
  123664. */
  123665. protected _useMetallnessFromMetallicTextureBlue: boolean;
  123666. /**
  123667. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  123668. */
  123669. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  123670. /**
  123671. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  123672. */
  123673. protected _useAmbientInGrayScale: boolean;
  123674. /**
  123675. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  123676. * The material will try to infer what glossiness each pixel should be.
  123677. */
  123678. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  123679. /**
  123680. * Defines the falloff type used in this material.
  123681. * It by default is Physical.
  123682. */
  123683. protected _lightFalloff: number;
  123684. /**
  123685. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  123686. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  123687. */
  123688. protected _useRadianceOverAlpha: boolean;
  123689. /**
  123690. * Allows using an object space normal map (instead of tangent space).
  123691. */
  123692. protected _useObjectSpaceNormalMap: boolean;
  123693. /**
  123694. * Allows using the bump map in parallax mode.
  123695. */
  123696. protected _useParallax: boolean;
  123697. /**
  123698. * Allows using the bump map in parallax occlusion mode.
  123699. */
  123700. protected _useParallaxOcclusion: boolean;
  123701. /**
  123702. * Controls the scale bias of the parallax mode.
  123703. */
  123704. protected _parallaxScaleBias: number;
  123705. /**
  123706. * If sets to true, disables all the lights affecting the material.
  123707. */
  123708. protected _disableLighting: boolean;
  123709. /**
  123710. * Number of Simultaneous lights allowed on the material.
  123711. */
  123712. protected _maxSimultaneousLights: number;
  123713. /**
  123714. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123715. */
  123716. protected _invertNormalMapX: boolean;
  123717. /**
  123718. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123719. */
  123720. protected _invertNormalMapY: boolean;
  123721. /**
  123722. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  123723. */
  123724. protected _twoSidedLighting: boolean;
  123725. /**
  123726. * Defines the alpha limits in alpha test mode.
  123727. */
  123728. protected _alphaCutOff: number;
  123729. /**
  123730. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  123731. */
  123732. protected _forceAlphaTest: boolean;
  123733. /**
  123734. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123735. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  123736. */
  123737. protected _useAlphaFresnel: boolean;
  123738. /**
  123739. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123740. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  123741. */
  123742. protected _useLinearAlphaFresnel: boolean;
  123743. /**
  123744. * The transparency mode of the material.
  123745. */
  123746. protected _transparencyMode: Nullable<number>;
  123747. /**
  123748. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  123749. * from cos thetav and roughness:
  123750. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  123751. */
  123752. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  123753. /**
  123754. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  123755. */
  123756. protected _forceIrradianceInFragment: boolean;
  123757. /**
  123758. * Force normal to face away from face.
  123759. */
  123760. protected _forceNormalForward: boolean;
  123761. /**
  123762. * Enables specular anti aliasing in the PBR shader.
  123763. * It will both interacts on the Geometry for analytical and IBL lighting.
  123764. * It also prefilter the roughness map based on the bump values.
  123765. */
  123766. protected _enableSpecularAntiAliasing: boolean;
  123767. /**
  123768. * Default configuration related to image processing available in the PBR Material.
  123769. */
  123770. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123771. /**
  123772. * Keep track of the image processing observer to allow dispose and replace.
  123773. */
  123774. private _imageProcessingObserver;
  123775. /**
  123776. * Attaches a new image processing configuration to the PBR Material.
  123777. * @param configuration
  123778. */
  123779. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123780. /**
  123781. * Stores the available render targets.
  123782. */
  123783. private _renderTargets;
  123784. /**
  123785. * Sets the global ambient color for the material used in lighting calculations.
  123786. */
  123787. private _globalAmbientColor;
  123788. /**
  123789. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  123790. */
  123791. private _useLogarithmicDepth;
  123792. /**
  123793. * If set to true, no lighting calculations will be applied.
  123794. */
  123795. private _unlit;
  123796. private _debugMode;
  123797. /**
  123798. * @hidden
  123799. * This is reserved for the inspector.
  123800. * Defines the material debug mode.
  123801. * It helps seeing only some components of the material while troubleshooting.
  123802. */
  123803. debugMode: number;
  123804. /**
  123805. * @hidden
  123806. * This is reserved for the inspector.
  123807. * Specify from where on screen the debug mode should start.
  123808. * The value goes from -1 (full screen) to 1 (not visible)
  123809. * It helps with side by side comparison against the final render
  123810. * This defaults to -1
  123811. */
  123812. private debugLimit;
  123813. /**
  123814. * @hidden
  123815. * This is reserved for the inspector.
  123816. * As the default viewing range might not be enough (if the ambient is really small for instance)
  123817. * You can use the factor to better multiply the final value.
  123818. */
  123819. private debugFactor;
  123820. /**
  123821. * Defines the clear coat layer parameters for the material.
  123822. */
  123823. readonly clearCoat: PBRClearCoatConfiguration;
  123824. /**
  123825. * Defines the anisotropic parameters for the material.
  123826. */
  123827. readonly anisotropy: PBRAnisotropicConfiguration;
  123828. /**
  123829. * Defines the BRDF parameters for the material.
  123830. */
  123831. readonly brdf: PBRBRDFConfiguration;
  123832. /**
  123833. * Defines the Sheen parameters for the material.
  123834. */
  123835. readonly sheen: PBRSheenConfiguration;
  123836. /**
  123837. * Defines the SubSurface parameters for the material.
  123838. */
  123839. readonly subSurface: PBRSubSurfaceConfiguration;
  123840. /**
  123841. * Custom callback helping to override the default shader used in the material.
  123842. */
  123843. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  123844. protected _rebuildInParallel: boolean;
  123845. /**
  123846. * Instantiates a new PBRMaterial instance.
  123847. *
  123848. * @param name The material name
  123849. * @param scene The scene the material will be use in.
  123850. */
  123851. constructor(name: string, scene: Scene);
  123852. /**
  123853. * Gets a boolean indicating that current material needs to register RTT
  123854. */
  123855. get hasRenderTargetTextures(): boolean;
  123856. /**
  123857. * Gets the name of the material class.
  123858. */
  123859. getClassName(): string;
  123860. /**
  123861. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  123862. */
  123863. get useLogarithmicDepth(): boolean;
  123864. /**
  123865. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  123866. */
  123867. set useLogarithmicDepth(value: boolean);
  123868. /**
  123869. * Gets the current transparency mode.
  123870. */
  123871. get transparencyMode(): Nullable<number>;
  123872. /**
  123873. * Sets the transparency mode of the material.
  123874. *
  123875. * | Value | Type | Description |
  123876. * | ----- | ----------------------------------- | ----------- |
  123877. * | 0 | OPAQUE | |
  123878. * | 1 | ALPHATEST | |
  123879. * | 2 | ALPHABLEND | |
  123880. * | 3 | ALPHATESTANDBLEND | |
  123881. *
  123882. */
  123883. set transparencyMode(value: Nullable<number>);
  123884. /**
  123885. * Returns true if alpha blending should be disabled.
  123886. */
  123887. private get _disableAlphaBlending();
  123888. /**
  123889. * Specifies whether or not this material should be rendered in alpha blend mode.
  123890. */
  123891. needAlphaBlending(): boolean;
  123892. /**
  123893. * Specifies if the mesh will require alpha blending.
  123894. * @param mesh - BJS mesh.
  123895. */
  123896. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  123897. /**
  123898. * Specifies whether or not this material should be rendered in alpha test mode.
  123899. */
  123900. needAlphaTesting(): boolean;
  123901. /**
  123902. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  123903. */
  123904. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  123905. /**
  123906. * Gets the texture used for the alpha test.
  123907. */
  123908. getAlphaTestTexture(): Nullable<BaseTexture>;
  123909. /**
  123910. * Specifies that the submesh is ready to be used.
  123911. * @param mesh - BJS mesh.
  123912. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  123913. * @param useInstances - Specifies that instances should be used.
  123914. * @returns - boolean indicating that the submesh is ready or not.
  123915. */
  123916. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123917. /**
  123918. * Specifies if the material uses metallic roughness workflow.
  123919. * @returns boolean specifiying if the material uses metallic roughness workflow.
  123920. */
  123921. isMetallicWorkflow(): boolean;
  123922. private _prepareEffect;
  123923. private _prepareDefines;
  123924. /**
  123925. * Force shader compilation
  123926. */
  123927. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  123928. /**
  123929. * Initializes the uniform buffer layout for the shader.
  123930. */
  123931. buildUniformLayout(): void;
  123932. /**
  123933. * Unbinds the material from the mesh
  123934. */
  123935. unbind(): void;
  123936. /**
  123937. * Binds the submesh data.
  123938. * @param world - The world matrix.
  123939. * @param mesh - The BJS mesh.
  123940. * @param subMesh - A submesh of the BJS mesh.
  123941. */
  123942. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123943. /**
  123944. * Returns the animatable textures.
  123945. * @returns - Array of animatable textures.
  123946. */
  123947. getAnimatables(): IAnimatable[];
  123948. /**
  123949. * Returns the texture used for reflections.
  123950. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  123951. */
  123952. private _getReflectionTexture;
  123953. /**
  123954. * Returns an array of the actively used textures.
  123955. * @returns - Array of BaseTextures
  123956. */
  123957. getActiveTextures(): BaseTexture[];
  123958. /**
  123959. * Checks to see if a texture is used in the material.
  123960. * @param texture - Base texture to use.
  123961. * @returns - Boolean specifying if a texture is used in the material.
  123962. */
  123963. hasTexture(texture: BaseTexture): boolean;
  123964. /**
  123965. * Disposes the resources of the material.
  123966. * @param forceDisposeEffect - Forces the disposal of effects.
  123967. * @param forceDisposeTextures - Forces the disposal of all textures.
  123968. */
  123969. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  123970. }
  123971. }
  123972. declare module BABYLON {
  123973. /**
  123974. * The Physically based material of BJS.
  123975. *
  123976. * This offers the main features of a standard PBR material.
  123977. * For more information, please refer to the documentation :
  123978. * https://doc.babylonjs.com/how_to/physically_based_rendering
  123979. */
  123980. export class PBRMaterial extends PBRBaseMaterial {
  123981. /**
  123982. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  123983. */
  123984. static readonly PBRMATERIAL_OPAQUE: number;
  123985. /**
  123986. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  123987. */
  123988. static readonly PBRMATERIAL_ALPHATEST: number;
  123989. /**
  123990. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123991. */
  123992. static readonly PBRMATERIAL_ALPHABLEND: number;
  123993. /**
  123994. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123995. * They are also discarded below the alpha cutoff threshold to improve performances.
  123996. */
  123997. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  123998. /**
  123999. * Defines the default value of how much AO map is occluding the analytical lights
  124000. * (point spot...).
  124001. */
  124002. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124003. /**
  124004. * Intensity of the direct lights e.g. the four lights available in your scene.
  124005. * This impacts both the direct diffuse and specular highlights.
  124006. */
  124007. directIntensity: number;
  124008. /**
  124009. * Intensity of the emissive part of the material.
  124010. * This helps controlling the emissive effect without modifying the emissive color.
  124011. */
  124012. emissiveIntensity: number;
  124013. /**
  124014. * Intensity of the environment e.g. how much the environment will light the object
  124015. * either through harmonics for rough material or through the refelction for shiny ones.
  124016. */
  124017. environmentIntensity: number;
  124018. /**
  124019. * This is a special control allowing the reduction of the specular highlights coming from the
  124020. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124021. */
  124022. specularIntensity: number;
  124023. /**
  124024. * Debug Control allowing disabling the bump map on this material.
  124025. */
  124026. disableBumpMap: boolean;
  124027. /**
  124028. * AKA Diffuse Texture in standard nomenclature.
  124029. */
  124030. albedoTexture: BaseTexture;
  124031. /**
  124032. * AKA Occlusion Texture in other nomenclature.
  124033. */
  124034. ambientTexture: BaseTexture;
  124035. /**
  124036. * AKA Occlusion Texture Intensity in other nomenclature.
  124037. */
  124038. ambientTextureStrength: number;
  124039. /**
  124040. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124041. * 1 means it completely occludes it
  124042. * 0 mean it has no impact
  124043. */
  124044. ambientTextureImpactOnAnalyticalLights: number;
  124045. /**
  124046. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124047. */
  124048. opacityTexture: BaseTexture;
  124049. /**
  124050. * Stores the reflection values in a texture.
  124051. */
  124052. reflectionTexture: Nullable<BaseTexture>;
  124053. /**
  124054. * Stores the emissive values in a texture.
  124055. */
  124056. emissiveTexture: BaseTexture;
  124057. /**
  124058. * AKA Specular texture in other nomenclature.
  124059. */
  124060. reflectivityTexture: BaseTexture;
  124061. /**
  124062. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124063. */
  124064. metallicTexture: BaseTexture;
  124065. /**
  124066. * Specifies the metallic scalar of the metallic/roughness workflow.
  124067. * Can also be used to scale the metalness values of the metallic texture.
  124068. */
  124069. metallic: Nullable<number>;
  124070. /**
  124071. * Specifies the roughness scalar of the metallic/roughness workflow.
  124072. * Can also be used to scale the roughness values of the metallic texture.
  124073. */
  124074. roughness: Nullable<number>;
  124075. /**
  124076. * Specifies the an F0 factor to help configuring the material F0.
  124077. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124078. * to 0.5 the previously hard coded value stays the same.
  124079. * Can also be used to scale the F0 values of the metallic texture.
  124080. */
  124081. metallicF0Factor: number;
  124082. /**
  124083. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124084. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124085. * your expectation as it multiplies with the texture data.
  124086. */
  124087. useMetallicF0FactorFromMetallicTexture: boolean;
  124088. /**
  124089. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124090. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124091. */
  124092. microSurfaceTexture: BaseTexture;
  124093. /**
  124094. * Stores surface normal data used to displace a mesh in a texture.
  124095. */
  124096. bumpTexture: BaseTexture;
  124097. /**
  124098. * Stores the pre-calculated light information of a mesh in a texture.
  124099. */
  124100. lightmapTexture: BaseTexture;
  124101. /**
  124102. * Stores the refracted light information in a texture.
  124103. */
  124104. get refractionTexture(): Nullable<BaseTexture>;
  124105. set refractionTexture(value: Nullable<BaseTexture>);
  124106. /**
  124107. * The color of a material in ambient lighting.
  124108. */
  124109. ambientColor: Color3;
  124110. /**
  124111. * AKA Diffuse Color in other nomenclature.
  124112. */
  124113. albedoColor: Color3;
  124114. /**
  124115. * AKA Specular Color in other nomenclature.
  124116. */
  124117. reflectivityColor: Color3;
  124118. /**
  124119. * The color reflected from the material.
  124120. */
  124121. reflectionColor: Color3;
  124122. /**
  124123. * The color emitted from the material.
  124124. */
  124125. emissiveColor: Color3;
  124126. /**
  124127. * AKA Glossiness in other nomenclature.
  124128. */
  124129. microSurface: number;
  124130. /**
  124131. * source material index of refraction (IOR)' / 'destination material IOR.
  124132. */
  124133. get indexOfRefraction(): number;
  124134. set indexOfRefraction(value: number);
  124135. /**
  124136. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124137. */
  124138. get invertRefractionY(): boolean;
  124139. set invertRefractionY(value: boolean);
  124140. /**
  124141. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124142. * Materials half opaque for instance using refraction could benefit from this control.
  124143. */
  124144. get linkRefractionWithTransparency(): boolean;
  124145. set linkRefractionWithTransparency(value: boolean);
  124146. /**
  124147. * If true, the light map contains occlusion information instead of lighting info.
  124148. */
  124149. useLightmapAsShadowmap: boolean;
  124150. /**
  124151. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124152. */
  124153. useAlphaFromAlbedoTexture: boolean;
  124154. /**
  124155. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124156. */
  124157. forceAlphaTest: boolean;
  124158. /**
  124159. * Defines the alpha limits in alpha test mode.
  124160. */
  124161. alphaCutOff: number;
  124162. /**
  124163. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124164. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124165. */
  124166. useSpecularOverAlpha: boolean;
  124167. /**
  124168. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124169. */
  124170. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124171. /**
  124172. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124173. */
  124174. useRoughnessFromMetallicTextureAlpha: boolean;
  124175. /**
  124176. * Specifies if the metallic texture contains the roughness information in its green channel.
  124177. */
  124178. useRoughnessFromMetallicTextureGreen: boolean;
  124179. /**
  124180. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124181. */
  124182. useMetallnessFromMetallicTextureBlue: boolean;
  124183. /**
  124184. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124185. */
  124186. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124187. /**
  124188. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124189. */
  124190. useAmbientInGrayScale: boolean;
  124191. /**
  124192. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124193. * The material will try to infer what glossiness each pixel should be.
  124194. */
  124195. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124196. /**
  124197. * BJS is using an harcoded light falloff based on a manually sets up range.
  124198. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124199. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124200. */
  124201. get usePhysicalLightFalloff(): boolean;
  124202. /**
  124203. * BJS is using an harcoded light falloff based on a manually sets up range.
  124204. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124205. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124206. */
  124207. set usePhysicalLightFalloff(value: boolean);
  124208. /**
  124209. * In order to support the falloff compatibility with gltf, a special mode has been added
  124210. * to reproduce the gltf light falloff.
  124211. */
  124212. get useGLTFLightFalloff(): boolean;
  124213. /**
  124214. * In order to support the falloff compatibility with gltf, a special mode has been added
  124215. * to reproduce the gltf light falloff.
  124216. */
  124217. set useGLTFLightFalloff(value: boolean);
  124218. /**
  124219. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124220. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124221. */
  124222. useRadianceOverAlpha: boolean;
  124223. /**
  124224. * Allows using an object space normal map (instead of tangent space).
  124225. */
  124226. useObjectSpaceNormalMap: boolean;
  124227. /**
  124228. * Allows using the bump map in parallax mode.
  124229. */
  124230. useParallax: boolean;
  124231. /**
  124232. * Allows using the bump map in parallax occlusion mode.
  124233. */
  124234. useParallaxOcclusion: boolean;
  124235. /**
  124236. * Controls the scale bias of the parallax mode.
  124237. */
  124238. parallaxScaleBias: number;
  124239. /**
  124240. * If sets to true, disables all the lights affecting the material.
  124241. */
  124242. disableLighting: boolean;
  124243. /**
  124244. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124245. */
  124246. forceIrradianceInFragment: boolean;
  124247. /**
  124248. * Number of Simultaneous lights allowed on the material.
  124249. */
  124250. maxSimultaneousLights: number;
  124251. /**
  124252. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124253. */
  124254. invertNormalMapX: boolean;
  124255. /**
  124256. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124257. */
  124258. invertNormalMapY: boolean;
  124259. /**
  124260. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124261. */
  124262. twoSidedLighting: boolean;
  124263. /**
  124264. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124265. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124266. */
  124267. useAlphaFresnel: boolean;
  124268. /**
  124269. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124270. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124271. */
  124272. useLinearAlphaFresnel: boolean;
  124273. /**
  124274. * Let user defines the brdf lookup texture used for IBL.
  124275. * A default 8bit version is embedded but you could point at :
  124276. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124277. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124278. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124279. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124280. */
  124281. environmentBRDFTexture: Nullable<BaseTexture>;
  124282. /**
  124283. * Force normal to face away from face.
  124284. */
  124285. forceNormalForward: boolean;
  124286. /**
  124287. * Enables specular anti aliasing in the PBR shader.
  124288. * It will both interacts on the Geometry for analytical and IBL lighting.
  124289. * It also prefilter the roughness map based on the bump values.
  124290. */
  124291. enableSpecularAntiAliasing: boolean;
  124292. /**
  124293. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124294. * makes the reflect vector face the model (under horizon).
  124295. */
  124296. useHorizonOcclusion: boolean;
  124297. /**
  124298. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124299. * too much the area relying on ambient texture to define their ambient occlusion.
  124300. */
  124301. useRadianceOcclusion: boolean;
  124302. /**
  124303. * If set to true, no lighting calculations will be applied.
  124304. */
  124305. unlit: boolean;
  124306. /**
  124307. * Gets the image processing configuration used either in this material.
  124308. */
  124309. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124310. /**
  124311. * Sets the Default image processing configuration used either in the this material.
  124312. *
  124313. * If sets to null, the scene one is in use.
  124314. */
  124315. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124316. /**
  124317. * Gets wether the color curves effect is enabled.
  124318. */
  124319. get cameraColorCurvesEnabled(): boolean;
  124320. /**
  124321. * Sets wether the color curves effect is enabled.
  124322. */
  124323. set cameraColorCurvesEnabled(value: boolean);
  124324. /**
  124325. * Gets wether the color grading effect is enabled.
  124326. */
  124327. get cameraColorGradingEnabled(): boolean;
  124328. /**
  124329. * Gets wether the color grading effect is enabled.
  124330. */
  124331. set cameraColorGradingEnabled(value: boolean);
  124332. /**
  124333. * Gets wether tonemapping is enabled or not.
  124334. */
  124335. get cameraToneMappingEnabled(): boolean;
  124336. /**
  124337. * Sets wether tonemapping is enabled or not
  124338. */
  124339. set cameraToneMappingEnabled(value: boolean);
  124340. /**
  124341. * The camera exposure used on this material.
  124342. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124343. * This corresponds to a photographic exposure.
  124344. */
  124345. get cameraExposure(): number;
  124346. /**
  124347. * The camera exposure used on this material.
  124348. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124349. * This corresponds to a photographic exposure.
  124350. */
  124351. set cameraExposure(value: number);
  124352. /**
  124353. * Gets The camera contrast used on this material.
  124354. */
  124355. get cameraContrast(): number;
  124356. /**
  124357. * Sets The camera contrast used on this material.
  124358. */
  124359. set cameraContrast(value: number);
  124360. /**
  124361. * Gets the Color Grading 2D Lookup Texture.
  124362. */
  124363. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124364. /**
  124365. * Sets the Color Grading 2D Lookup Texture.
  124366. */
  124367. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124368. /**
  124369. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124370. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124371. * 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;
  124372. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124373. */
  124374. get cameraColorCurves(): Nullable<ColorCurves>;
  124375. /**
  124376. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124377. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124378. * 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;
  124379. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124380. */
  124381. set cameraColorCurves(value: Nullable<ColorCurves>);
  124382. /**
  124383. * Instantiates a new PBRMaterial instance.
  124384. *
  124385. * @param name The material name
  124386. * @param scene The scene the material will be use in.
  124387. */
  124388. constructor(name: string, scene: Scene);
  124389. /**
  124390. * Returns the name of this material class.
  124391. */
  124392. getClassName(): string;
  124393. /**
  124394. * Makes a duplicate of the current material.
  124395. * @param name - name to use for the new material.
  124396. */
  124397. clone(name: string): PBRMaterial;
  124398. /**
  124399. * Serializes this PBR Material.
  124400. * @returns - An object with the serialized material.
  124401. */
  124402. serialize(): any;
  124403. /**
  124404. * Parses a PBR Material from a serialized object.
  124405. * @param source - Serialized object.
  124406. * @param scene - BJS scene instance.
  124407. * @param rootUrl - url for the scene object
  124408. * @returns - PBRMaterial
  124409. */
  124410. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  124411. }
  124412. }
  124413. declare module BABYLON {
  124414. /**
  124415. * Direct draw surface info
  124416. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  124417. */
  124418. export interface DDSInfo {
  124419. /**
  124420. * Width of the texture
  124421. */
  124422. width: number;
  124423. /**
  124424. * Width of the texture
  124425. */
  124426. height: number;
  124427. /**
  124428. * Number of Mipmaps for the texture
  124429. * @see https://en.wikipedia.org/wiki/Mipmap
  124430. */
  124431. mipmapCount: number;
  124432. /**
  124433. * If the textures format is a known fourCC format
  124434. * @see https://www.fourcc.org/
  124435. */
  124436. isFourCC: boolean;
  124437. /**
  124438. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  124439. */
  124440. isRGB: boolean;
  124441. /**
  124442. * If the texture is a lumincance format
  124443. */
  124444. isLuminance: boolean;
  124445. /**
  124446. * If this is a cube texture
  124447. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  124448. */
  124449. isCube: boolean;
  124450. /**
  124451. * If the texture is a compressed format eg. FOURCC_DXT1
  124452. */
  124453. isCompressed: boolean;
  124454. /**
  124455. * The dxgiFormat of the texture
  124456. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  124457. */
  124458. dxgiFormat: number;
  124459. /**
  124460. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  124461. */
  124462. textureType: number;
  124463. /**
  124464. * Sphericle polynomial created for the dds texture
  124465. */
  124466. sphericalPolynomial?: SphericalPolynomial;
  124467. }
  124468. /**
  124469. * Class used to provide DDS decompression tools
  124470. */
  124471. export class DDSTools {
  124472. /**
  124473. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  124474. */
  124475. static StoreLODInAlphaChannel: boolean;
  124476. /**
  124477. * Gets DDS information from an array buffer
  124478. * @param arrayBuffer defines the array buffer to read data from
  124479. * @returns the DDS information
  124480. */
  124481. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  124482. private static _FloatView;
  124483. private static _Int32View;
  124484. private static _ToHalfFloat;
  124485. private static _FromHalfFloat;
  124486. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  124487. private static _GetHalfFloatRGBAArrayBuffer;
  124488. private static _GetFloatRGBAArrayBuffer;
  124489. private static _GetFloatAsUIntRGBAArrayBuffer;
  124490. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  124491. private static _GetRGBAArrayBuffer;
  124492. private static _ExtractLongWordOrder;
  124493. private static _GetRGBArrayBuffer;
  124494. private static _GetLuminanceArrayBuffer;
  124495. /**
  124496. * Uploads DDS Levels to a Babylon Texture
  124497. * @hidden
  124498. */
  124499. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  124500. }
  124501. interface ThinEngine {
  124502. /**
  124503. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  124504. * @param rootUrl defines the url where the file to load is located
  124505. * @param scene defines the current scene
  124506. * @param lodScale defines scale to apply to the mip map selection
  124507. * @param lodOffset defines offset to apply to the mip map selection
  124508. * @param onLoad defines an optional callback raised when the texture is loaded
  124509. * @param onError defines an optional callback raised if there is an issue to load the texture
  124510. * @param format defines the format of the data
  124511. * @param forcedExtension defines the extension to use to pick the right loader
  124512. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  124513. * @returns the cube texture as an InternalTexture
  124514. */
  124515. 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;
  124516. }
  124517. }
  124518. declare module BABYLON {
  124519. /**
  124520. * Implementation of the DDS Texture Loader.
  124521. * @hidden
  124522. */
  124523. export class _DDSTextureLoader implements IInternalTextureLoader {
  124524. /**
  124525. * Defines wether the loader supports cascade loading the different faces.
  124526. */
  124527. readonly supportCascades: boolean;
  124528. /**
  124529. * This returns if the loader support the current file information.
  124530. * @param extension defines the file extension of the file being loaded
  124531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124532. * @param fallback defines the fallback internal texture if any
  124533. * @param isBase64 defines whether the texture is encoded as a base64
  124534. * @param isBuffer defines whether the texture data are stored as a buffer
  124535. * @returns true if the loader can load the specified file
  124536. */
  124537. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124538. /**
  124539. * Transform the url before loading if required.
  124540. * @param rootUrl the url of the texture
  124541. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124542. * @returns the transformed texture
  124543. */
  124544. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124545. /**
  124546. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124547. * @param rootUrl the url of the texture
  124548. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124549. * @returns the fallback texture
  124550. */
  124551. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124552. /**
  124553. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124554. * @param data contains the texture data
  124555. * @param texture defines the BabylonJS internal texture
  124556. * @param createPolynomials will be true if polynomials have been requested
  124557. * @param onLoad defines the callback to trigger once the texture is ready
  124558. * @param onError defines the callback to trigger in case of error
  124559. */
  124560. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124561. /**
  124562. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124563. * @param data contains the texture data
  124564. * @param texture defines the BabylonJS internal texture
  124565. * @param callback defines the method to call once ready to upload
  124566. */
  124567. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124568. }
  124569. }
  124570. declare module BABYLON {
  124571. /**
  124572. * Implementation of the ENV Texture Loader.
  124573. * @hidden
  124574. */
  124575. export class _ENVTextureLoader implements IInternalTextureLoader {
  124576. /**
  124577. * Defines wether the loader supports cascade loading the different faces.
  124578. */
  124579. readonly supportCascades: boolean;
  124580. /**
  124581. * This returns if the loader support the current file information.
  124582. * @param extension defines the file extension of the file being loaded
  124583. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124584. * @param fallback defines the fallback internal texture if any
  124585. * @param isBase64 defines whether the texture is encoded as a base64
  124586. * @param isBuffer defines whether the texture data are stored as a buffer
  124587. * @returns true if the loader can load the specified file
  124588. */
  124589. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124590. /**
  124591. * Transform the url before loading if required.
  124592. * @param rootUrl the url of the texture
  124593. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124594. * @returns the transformed texture
  124595. */
  124596. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124597. /**
  124598. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124599. * @param rootUrl the url of the texture
  124600. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124601. * @returns the fallback texture
  124602. */
  124603. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124604. /**
  124605. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124606. * @param data contains the texture data
  124607. * @param texture defines the BabylonJS internal texture
  124608. * @param createPolynomials will be true if polynomials have been requested
  124609. * @param onLoad defines the callback to trigger once the texture is ready
  124610. * @param onError defines the callback to trigger in case of error
  124611. */
  124612. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124613. /**
  124614. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124615. * @param data contains the texture data
  124616. * @param texture defines the BabylonJS internal texture
  124617. * @param callback defines the method to call once ready to upload
  124618. */
  124619. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124620. }
  124621. }
  124622. declare module BABYLON {
  124623. /**
  124624. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  124625. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  124626. */
  124627. export class KhronosTextureContainer {
  124628. /** contents of the KTX container file */
  124629. arrayBuffer: any;
  124630. private static HEADER_LEN;
  124631. private static COMPRESSED_2D;
  124632. private static COMPRESSED_3D;
  124633. private static TEX_2D;
  124634. private static TEX_3D;
  124635. /**
  124636. * Gets the openGL type
  124637. */
  124638. glType: number;
  124639. /**
  124640. * Gets the openGL type size
  124641. */
  124642. glTypeSize: number;
  124643. /**
  124644. * Gets the openGL format
  124645. */
  124646. glFormat: number;
  124647. /**
  124648. * Gets the openGL internal format
  124649. */
  124650. glInternalFormat: number;
  124651. /**
  124652. * Gets the base internal format
  124653. */
  124654. glBaseInternalFormat: number;
  124655. /**
  124656. * Gets image width in pixel
  124657. */
  124658. pixelWidth: number;
  124659. /**
  124660. * Gets image height in pixel
  124661. */
  124662. pixelHeight: number;
  124663. /**
  124664. * Gets image depth in pixels
  124665. */
  124666. pixelDepth: number;
  124667. /**
  124668. * Gets the number of array elements
  124669. */
  124670. numberOfArrayElements: number;
  124671. /**
  124672. * Gets the number of faces
  124673. */
  124674. numberOfFaces: number;
  124675. /**
  124676. * Gets the number of mipmap levels
  124677. */
  124678. numberOfMipmapLevels: number;
  124679. /**
  124680. * Gets the bytes of key value data
  124681. */
  124682. bytesOfKeyValueData: number;
  124683. /**
  124684. * Gets the load type
  124685. */
  124686. loadType: number;
  124687. /**
  124688. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  124689. */
  124690. isInvalid: boolean;
  124691. /**
  124692. * Creates a new KhronosTextureContainer
  124693. * @param arrayBuffer contents of the KTX container file
  124694. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  124695. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  124696. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  124697. */
  124698. constructor(
  124699. /** contents of the KTX container file */
  124700. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  124701. /**
  124702. * Uploads KTX content to a Babylon Texture.
  124703. * It is assumed that the texture has already been created & is currently bound
  124704. * @hidden
  124705. */
  124706. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  124707. private _upload2DCompressedLevels;
  124708. }
  124709. }
  124710. declare module BABYLON {
  124711. /**
  124712. * Implementation of the KTX Texture Loader.
  124713. * @hidden
  124714. */
  124715. export class _KTXTextureLoader implements IInternalTextureLoader {
  124716. /**
  124717. * Defines wether the loader supports cascade loading the different faces.
  124718. */
  124719. readonly supportCascades: boolean;
  124720. /**
  124721. * This returns if the loader support the current file information.
  124722. * @param extension defines the file extension of the file being loaded
  124723. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124724. * @param fallback defines the fallback internal texture if any
  124725. * @param isBase64 defines whether the texture is encoded as a base64
  124726. * @param isBuffer defines whether the texture data are stored as a buffer
  124727. * @returns true if the loader can load the specified file
  124728. */
  124729. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124730. /**
  124731. * Transform the url before loading if required.
  124732. * @param rootUrl the url of the texture
  124733. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124734. * @returns the transformed texture
  124735. */
  124736. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124737. /**
  124738. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124739. * @param rootUrl the url of the texture
  124740. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124741. * @returns the fallback texture
  124742. */
  124743. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124744. /**
  124745. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124746. * @param data contains the texture data
  124747. * @param texture defines the BabylonJS internal texture
  124748. * @param createPolynomials will be true if polynomials have been requested
  124749. * @param onLoad defines the callback to trigger once the texture is ready
  124750. * @param onError defines the callback to trigger in case of error
  124751. */
  124752. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124753. /**
  124754. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124755. * @param data contains the texture data
  124756. * @param texture defines the BabylonJS internal texture
  124757. * @param callback defines the method to call once ready to upload
  124758. */
  124759. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  124760. }
  124761. }
  124762. declare module BABYLON {
  124763. /** @hidden */
  124764. export var _forceSceneHelpersToBundle: boolean;
  124765. interface Scene {
  124766. /**
  124767. * Creates a default light for the scene.
  124768. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  124769. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  124770. */
  124771. createDefaultLight(replace?: boolean): void;
  124772. /**
  124773. * Creates a default camera for the scene.
  124774. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  124775. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124776. * @param replace has default false, when true replaces the active camera in the scene
  124777. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  124778. */
  124779. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124780. /**
  124781. * Creates a default camera and a default light.
  124782. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  124783. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124784. * @param replace has the default false, when true replaces the active camera/light in the scene
  124785. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  124786. */
  124787. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124788. /**
  124789. * Creates a new sky box
  124790. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  124791. * @param environmentTexture defines the texture to use as environment texture
  124792. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  124793. * @param scale defines the overall scale of the skybox
  124794. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  124795. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  124796. * @returns a new mesh holding the sky box
  124797. */
  124798. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  124799. /**
  124800. * Creates a new environment
  124801. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  124802. * @param options defines the options you can use to configure the environment
  124803. * @returns the new EnvironmentHelper
  124804. */
  124805. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  124806. /**
  124807. * Creates a new VREXperienceHelper
  124808. * @see http://doc.babylonjs.com/how_to/webvr_helper
  124809. * @param webVROptions defines the options used to create the new VREXperienceHelper
  124810. * @returns a new VREXperienceHelper
  124811. */
  124812. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  124813. /**
  124814. * Creates a new WebXRDefaultExperience
  124815. * @see http://doc.babylonjs.com/how_to/webxr
  124816. * @param options experience options
  124817. * @returns a promise for a new WebXRDefaultExperience
  124818. */
  124819. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  124820. }
  124821. }
  124822. declare module BABYLON {
  124823. /**
  124824. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  124825. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  124826. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  124827. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124828. */
  124829. export class VideoDome extends TransformNode {
  124830. /**
  124831. * Define the video source as a Monoscopic panoramic 360 video.
  124832. */
  124833. static readonly MODE_MONOSCOPIC: number;
  124834. /**
  124835. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  124836. */
  124837. static readonly MODE_TOPBOTTOM: number;
  124838. /**
  124839. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  124840. */
  124841. static readonly MODE_SIDEBYSIDE: number;
  124842. private _halfDome;
  124843. private _useDirectMapping;
  124844. /**
  124845. * The video texture being displayed on the sphere
  124846. */
  124847. protected _videoTexture: VideoTexture;
  124848. /**
  124849. * Gets the video texture being displayed on the sphere
  124850. */
  124851. get videoTexture(): VideoTexture;
  124852. /**
  124853. * The skybox material
  124854. */
  124855. protected _material: BackgroundMaterial;
  124856. /**
  124857. * The surface used for the skybox
  124858. */
  124859. protected _mesh: Mesh;
  124860. /**
  124861. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  124862. */
  124863. private _halfDomeMask;
  124864. /**
  124865. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124866. * Also see the options.resolution property.
  124867. */
  124868. get fovMultiplier(): number;
  124869. set fovMultiplier(value: number);
  124870. private _videoMode;
  124871. /**
  124872. * Gets or set the current video mode for the video. It can be:
  124873. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  124874. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  124875. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  124876. */
  124877. get videoMode(): number;
  124878. set videoMode(value: number);
  124879. /**
  124880. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  124881. *
  124882. */
  124883. get halfDome(): boolean;
  124884. /**
  124885. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  124886. */
  124887. set halfDome(enabled: boolean);
  124888. /**
  124889. * Oberserver used in Stereoscopic VR Mode.
  124890. */
  124891. private _onBeforeCameraRenderObserver;
  124892. /**
  124893. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  124894. * @param name Element's name, child elements will append suffixes for their own names.
  124895. * @param urlsOrVideo defines the url(s) or the video element to use
  124896. * @param options An object containing optional or exposed sub element properties
  124897. */
  124898. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  124899. resolution?: number;
  124900. clickToPlay?: boolean;
  124901. autoPlay?: boolean;
  124902. loop?: boolean;
  124903. size?: number;
  124904. poster?: string;
  124905. faceForward?: boolean;
  124906. useDirectMapping?: boolean;
  124907. halfDomeMode?: boolean;
  124908. }, scene: Scene);
  124909. private _changeVideoMode;
  124910. /**
  124911. * Releases resources associated with this node.
  124912. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124913. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124914. */
  124915. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124916. }
  124917. }
  124918. declare module BABYLON {
  124919. /**
  124920. * This class can be used to get instrumentation data from a Babylon engine
  124921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  124922. */
  124923. export class EngineInstrumentation implements IDisposable {
  124924. /**
  124925. * Define the instrumented engine.
  124926. */
  124927. engine: Engine;
  124928. private _captureGPUFrameTime;
  124929. private _gpuFrameTimeToken;
  124930. private _gpuFrameTime;
  124931. private _captureShaderCompilationTime;
  124932. private _shaderCompilationTime;
  124933. private _onBeginFrameObserver;
  124934. private _onEndFrameObserver;
  124935. private _onBeforeShaderCompilationObserver;
  124936. private _onAfterShaderCompilationObserver;
  124937. /**
  124938. * Gets the perf counter used for GPU frame time
  124939. */
  124940. get gpuFrameTimeCounter(): PerfCounter;
  124941. /**
  124942. * Gets the GPU frame time capture status
  124943. */
  124944. get captureGPUFrameTime(): boolean;
  124945. /**
  124946. * Enable or disable the GPU frame time capture
  124947. */
  124948. set captureGPUFrameTime(value: boolean);
  124949. /**
  124950. * Gets the perf counter used for shader compilation time
  124951. */
  124952. get shaderCompilationTimeCounter(): PerfCounter;
  124953. /**
  124954. * Gets the shader compilation time capture status
  124955. */
  124956. get captureShaderCompilationTime(): boolean;
  124957. /**
  124958. * Enable or disable the shader compilation time capture
  124959. */
  124960. set captureShaderCompilationTime(value: boolean);
  124961. /**
  124962. * Instantiates a new engine instrumentation.
  124963. * This class can be used to get instrumentation data from a Babylon engine
  124964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  124965. * @param engine Defines the engine to instrument
  124966. */
  124967. constructor(
  124968. /**
  124969. * Define the instrumented engine.
  124970. */
  124971. engine: Engine);
  124972. /**
  124973. * Dispose and release associated resources.
  124974. */
  124975. dispose(): void;
  124976. }
  124977. }
  124978. declare module BABYLON {
  124979. /**
  124980. * This class can be used to get instrumentation data from a Babylon engine
  124981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  124982. */
  124983. export class SceneInstrumentation implements IDisposable {
  124984. /**
  124985. * Defines the scene to instrument
  124986. */
  124987. scene: Scene;
  124988. private _captureActiveMeshesEvaluationTime;
  124989. private _activeMeshesEvaluationTime;
  124990. private _captureRenderTargetsRenderTime;
  124991. private _renderTargetsRenderTime;
  124992. private _captureFrameTime;
  124993. private _frameTime;
  124994. private _captureRenderTime;
  124995. private _renderTime;
  124996. private _captureInterFrameTime;
  124997. private _interFrameTime;
  124998. private _captureParticlesRenderTime;
  124999. private _particlesRenderTime;
  125000. private _captureSpritesRenderTime;
  125001. private _spritesRenderTime;
  125002. private _capturePhysicsTime;
  125003. private _physicsTime;
  125004. private _captureAnimationsTime;
  125005. private _animationsTime;
  125006. private _captureCameraRenderTime;
  125007. private _cameraRenderTime;
  125008. private _onBeforeActiveMeshesEvaluationObserver;
  125009. private _onAfterActiveMeshesEvaluationObserver;
  125010. private _onBeforeRenderTargetsRenderObserver;
  125011. private _onAfterRenderTargetsRenderObserver;
  125012. private _onAfterRenderObserver;
  125013. private _onBeforeDrawPhaseObserver;
  125014. private _onAfterDrawPhaseObserver;
  125015. private _onBeforeAnimationsObserver;
  125016. private _onBeforeParticlesRenderingObserver;
  125017. private _onAfterParticlesRenderingObserver;
  125018. private _onBeforeSpritesRenderingObserver;
  125019. private _onAfterSpritesRenderingObserver;
  125020. private _onBeforePhysicsObserver;
  125021. private _onAfterPhysicsObserver;
  125022. private _onAfterAnimationsObserver;
  125023. private _onBeforeCameraRenderObserver;
  125024. private _onAfterCameraRenderObserver;
  125025. /**
  125026. * Gets the perf counter used for active meshes evaluation time
  125027. */
  125028. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125029. /**
  125030. * Gets the active meshes evaluation time capture status
  125031. */
  125032. get captureActiveMeshesEvaluationTime(): boolean;
  125033. /**
  125034. * Enable or disable the active meshes evaluation time capture
  125035. */
  125036. set captureActiveMeshesEvaluationTime(value: boolean);
  125037. /**
  125038. * Gets the perf counter used for render targets render time
  125039. */
  125040. get renderTargetsRenderTimeCounter(): PerfCounter;
  125041. /**
  125042. * Gets the render targets render time capture status
  125043. */
  125044. get captureRenderTargetsRenderTime(): boolean;
  125045. /**
  125046. * Enable or disable the render targets render time capture
  125047. */
  125048. set captureRenderTargetsRenderTime(value: boolean);
  125049. /**
  125050. * Gets the perf counter used for particles render time
  125051. */
  125052. get particlesRenderTimeCounter(): PerfCounter;
  125053. /**
  125054. * Gets the particles render time capture status
  125055. */
  125056. get captureParticlesRenderTime(): boolean;
  125057. /**
  125058. * Enable or disable the particles render time capture
  125059. */
  125060. set captureParticlesRenderTime(value: boolean);
  125061. /**
  125062. * Gets the perf counter used for sprites render time
  125063. */
  125064. get spritesRenderTimeCounter(): PerfCounter;
  125065. /**
  125066. * Gets the sprites render time capture status
  125067. */
  125068. get captureSpritesRenderTime(): boolean;
  125069. /**
  125070. * Enable or disable the sprites render time capture
  125071. */
  125072. set captureSpritesRenderTime(value: boolean);
  125073. /**
  125074. * Gets the perf counter used for physics time
  125075. */
  125076. get physicsTimeCounter(): PerfCounter;
  125077. /**
  125078. * Gets the physics time capture status
  125079. */
  125080. get capturePhysicsTime(): boolean;
  125081. /**
  125082. * Enable or disable the physics time capture
  125083. */
  125084. set capturePhysicsTime(value: boolean);
  125085. /**
  125086. * Gets the perf counter used for animations time
  125087. */
  125088. get animationsTimeCounter(): PerfCounter;
  125089. /**
  125090. * Gets the animations time capture status
  125091. */
  125092. get captureAnimationsTime(): boolean;
  125093. /**
  125094. * Enable or disable the animations time capture
  125095. */
  125096. set captureAnimationsTime(value: boolean);
  125097. /**
  125098. * Gets the perf counter used for frame time capture
  125099. */
  125100. get frameTimeCounter(): PerfCounter;
  125101. /**
  125102. * Gets the frame time capture status
  125103. */
  125104. get captureFrameTime(): boolean;
  125105. /**
  125106. * Enable or disable the frame time capture
  125107. */
  125108. set captureFrameTime(value: boolean);
  125109. /**
  125110. * Gets the perf counter used for inter-frames time capture
  125111. */
  125112. get interFrameTimeCounter(): PerfCounter;
  125113. /**
  125114. * Gets the inter-frames time capture status
  125115. */
  125116. get captureInterFrameTime(): boolean;
  125117. /**
  125118. * Enable or disable the inter-frames time capture
  125119. */
  125120. set captureInterFrameTime(value: boolean);
  125121. /**
  125122. * Gets the perf counter used for render time capture
  125123. */
  125124. get renderTimeCounter(): PerfCounter;
  125125. /**
  125126. * Gets the render time capture status
  125127. */
  125128. get captureRenderTime(): boolean;
  125129. /**
  125130. * Enable or disable the render time capture
  125131. */
  125132. set captureRenderTime(value: boolean);
  125133. /**
  125134. * Gets the perf counter used for camera render time capture
  125135. */
  125136. get cameraRenderTimeCounter(): PerfCounter;
  125137. /**
  125138. * Gets the camera render time capture status
  125139. */
  125140. get captureCameraRenderTime(): boolean;
  125141. /**
  125142. * Enable or disable the camera render time capture
  125143. */
  125144. set captureCameraRenderTime(value: boolean);
  125145. /**
  125146. * Gets the perf counter used for draw calls
  125147. */
  125148. get drawCallsCounter(): PerfCounter;
  125149. /**
  125150. * Instantiates a new scene instrumentation.
  125151. * This class can be used to get instrumentation data from a Babylon engine
  125152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125153. * @param scene Defines the scene to instrument
  125154. */
  125155. constructor(
  125156. /**
  125157. * Defines the scene to instrument
  125158. */
  125159. scene: Scene);
  125160. /**
  125161. * Dispose and release associated resources.
  125162. */
  125163. dispose(): void;
  125164. }
  125165. }
  125166. declare module BABYLON {
  125167. /** @hidden */
  125168. export var glowMapGenerationPixelShader: {
  125169. name: string;
  125170. shader: string;
  125171. };
  125172. }
  125173. declare module BABYLON {
  125174. /** @hidden */
  125175. export var glowMapGenerationVertexShader: {
  125176. name: string;
  125177. shader: string;
  125178. };
  125179. }
  125180. declare module BABYLON {
  125181. /**
  125182. * Effect layer options. This helps customizing the behaviour
  125183. * of the effect layer.
  125184. */
  125185. export interface IEffectLayerOptions {
  125186. /**
  125187. * Multiplication factor apply to the canvas size to compute the render target size
  125188. * used to generated the objects (the smaller the faster).
  125189. */
  125190. mainTextureRatio: number;
  125191. /**
  125192. * Enforces a fixed size texture to ensure effect stability across devices.
  125193. */
  125194. mainTextureFixedSize?: number;
  125195. /**
  125196. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125197. */
  125198. alphaBlendingMode: number;
  125199. /**
  125200. * The camera attached to the layer.
  125201. */
  125202. camera: Nullable<Camera>;
  125203. /**
  125204. * The rendering group to draw the layer in.
  125205. */
  125206. renderingGroupId: number;
  125207. }
  125208. /**
  125209. * The effect layer Helps adding post process effect blended with the main pass.
  125210. *
  125211. * This can be for instance use to generate glow or higlight effects on the scene.
  125212. *
  125213. * The effect layer class can not be used directly and is intented to inherited from to be
  125214. * customized per effects.
  125215. */
  125216. export abstract class EffectLayer {
  125217. private _vertexBuffers;
  125218. private _indexBuffer;
  125219. private _cachedDefines;
  125220. private _effectLayerMapGenerationEffect;
  125221. private _effectLayerOptions;
  125222. private _mergeEffect;
  125223. protected _scene: Scene;
  125224. protected _engine: Engine;
  125225. protected _maxSize: number;
  125226. protected _mainTextureDesiredSize: ISize;
  125227. protected _mainTexture: RenderTargetTexture;
  125228. protected _shouldRender: boolean;
  125229. protected _postProcesses: PostProcess[];
  125230. protected _textures: BaseTexture[];
  125231. protected _emissiveTextureAndColor: {
  125232. texture: Nullable<BaseTexture>;
  125233. color: Color4;
  125234. };
  125235. /**
  125236. * The name of the layer
  125237. */
  125238. name: string;
  125239. /**
  125240. * The clear color of the texture used to generate the glow map.
  125241. */
  125242. neutralColor: Color4;
  125243. /**
  125244. * Specifies wether the highlight layer is enabled or not.
  125245. */
  125246. isEnabled: boolean;
  125247. /**
  125248. * Gets the camera attached to the layer.
  125249. */
  125250. get camera(): Nullable<Camera>;
  125251. /**
  125252. * Gets the rendering group id the layer should render in.
  125253. */
  125254. get renderingGroupId(): number;
  125255. set renderingGroupId(renderingGroupId: number);
  125256. /**
  125257. * An event triggered when the effect layer has been disposed.
  125258. */
  125259. onDisposeObservable: Observable<EffectLayer>;
  125260. /**
  125261. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125262. */
  125263. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125264. /**
  125265. * An event triggered when the generated texture is being merged in the scene.
  125266. */
  125267. onBeforeComposeObservable: Observable<EffectLayer>;
  125268. /**
  125269. * An event triggered when the mesh is rendered into the effect render target.
  125270. */
  125271. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125272. /**
  125273. * An event triggered after the mesh has been rendered into the effect render target.
  125274. */
  125275. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125276. /**
  125277. * An event triggered when the generated texture has been merged in the scene.
  125278. */
  125279. onAfterComposeObservable: Observable<EffectLayer>;
  125280. /**
  125281. * An event triggered when the efffect layer changes its size.
  125282. */
  125283. onSizeChangedObservable: Observable<EffectLayer>;
  125284. /** @hidden */
  125285. static _SceneComponentInitialization: (scene: Scene) => void;
  125286. /**
  125287. * Instantiates a new effect Layer and references it in the scene.
  125288. * @param name The name of the layer
  125289. * @param scene The scene to use the layer in
  125290. */
  125291. constructor(
  125292. /** The Friendly of the effect in the scene */
  125293. name: string, scene: Scene);
  125294. /**
  125295. * Get the effect name of the layer.
  125296. * @return The effect name
  125297. */
  125298. abstract getEffectName(): string;
  125299. /**
  125300. * Checks for the readiness of the element composing the layer.
  125301. * @param subMesh the mesh to check for
  125302. * @param useInstances specify wether or not to use instances to render the mesh
  125303. * @return true if ready otherwise, false
  125304. */
  125305. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125306. /**
  125307. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125308. * @returns true if the effect requires stencil during the main canvas render pass.
  125309. */
  125310. abstract needStencil(): boolean;
  125311. /**
  125312. * Create the merge effect. This is the shader use to blit the information back
  125313. * to the main canvas at the end of the scene rendering.
  125314. * @returns The effect containing the shader used to merge the effect on the main canvas
  125315. */
  125316. protected abstract _createMergeEffect(): Effect;
  125317. /**
  125318. * Creates the render target textures and post processes used in the effect layer.
  125319. */
  125320. protected abstract _createTextureAndPostProcesses(): void;
  125321. /**
  125322. * Implementation specific of rendering the generating effect on the main canvas.
  125323. * @param effect The effect used to render through
  125324. */
  125325. protected abstract _internalRender(effect: Effect): void;
  125326. /**
  125327. * Sets the required values for both the emissive texture and and the main color.
  125328. */
  125329. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125330. /**
  125331. * Free any resources and references associated to a mesh.
  125332. * Internal use
  125333. * @param mesh The mesh to free.
  125334. */
  125335. abstract _disposeMesh(mesh: Mesh): void;
  125336. /**
  125337. * Serializes this layer (Glow or Highlight for example)
  125338. * @returns a serialized layer object
  125339. */
  125340. abstract serialize?(): any;
  125341. /**
  125342. * Initializes the effect layer with the required options.
  125343. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  125344. */
  125345. protected _init(options: Partial<IEffectLayerOptions>): void;
  125346. /**
  125347. * Generates the index buffer of the full screen quad blending to the main canvas.
  125348. */
  125349. private _generateIndexBuffer;
  125350. /**
  125351. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  125352. */
  125353. private _generateVertexBuffer;
  125354. /**
  125355. * Sets the main texture desired size which is the closest power of two
  125356. * of the engine canvas size.
  125357. */
  125358. private _setMainTextureSize;
  125359. /**
  125360. * Creates the main texture for the effect layer.
  125361. */
  125362. protected _createMainTexture(): void;
  125363. /**
  125364. * Adds specific effects defines.
  125365. * @param defines The defines to add specifics to.
  125366. */
  125367. protected _addCustomEffectDefines(defines: string[]): void;
  125368. /**
  125369. * Checks for the readiness of the element composing the layer.
  125370. * @param subMesh the mesh to check for
  125371. * @param useInstances specify wether or not to use instances to render the mesh
  125372. * @param emissiveTexture the associated emissive texture used to generate the glow
  125373. * @return true if ready otherwise, false
  125374. */
  125375. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  125376. /**
  125377. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  125378. */
  125379. render(): void;
  125380. /**
  125381. * Determine if a given mesh will be used in the current effect.
  125382. * @param mesh mesh to test
  125383. * @returns true if the mesh will be used
  125384. */
  125385. hasMesh(mesh: AbstractMesh): boolean;
  125386. /**
  125387. * Returns true if the layer contains information to display, otherwise false.
  125388. * @returns true if the glow layer should be rendered
  125389. */
  125390. shouldRender(): boolean;
  125391. /**
  125392. * Returns true if the mesh should render, otherwise false.
  125393. * @param mesh The mesh to render
  125394. * @returns true if it should render otherwise false
  125395. */
  125396. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  125397. /**
  125398. * Returns true if the mesh can be rendered, otherwise false.
  125399. * @param mesh The mesh to render
  125400. * @param material The material used on the mesh
  125401. * @returns true if it can be rendered otherwise false
  125402. */
  125403. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125404. /**
  125405. * Returns true if the mesh should render, otherwise false.
  125406. * @param mesh The mesh to render
  125407. * @returns true if it should render otherwise false
  125408. */
  125409. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  125410. /**
  125411. * Renders the submesh passed in parameter to the generation map.
  125412. */
  125413. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  125414. /**
  125415. * Defines wether the current material of the mesh should be use to render the effect.
  125416. * @param mesh defines the current mesh to render
  125417. */
  125418. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125419. /**
  125420. * Rebuild the required buffers.
  125421. * @hidden Internal use only.
  125422. */
  125423. _rebuild(): void;
  125424. /**
  125425. * Dispose only the render target textures and post process.
  125426. */
  125427. private _disposeTextureAndPostProcesses;
  125428. /**
  125429. * Dispose the highlight layer and free resources.
  125430. */
  125431. dispose(): void;
  125432. /**
  125433. * Gets the class name of the effect layer
  125434. * @returns the string with the class name of the effect layer
  125435. */
  125436. getClassName(): string;
  125437. /**
  125438. * Creates an effect layer from parsed effect layer data
  125439. * @param parsedEffectLayer defines effect layer data
  125440. * @param scene defines the current scene
  125441. * @param rootUrl defines the root URL containing the effect layer information
  125442. * @returns a parsed effect Layer
  125443. */
  125444. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  125445. }
  125446. }
  125447. declare module BABYLON {
  125448. interface AbstractScene {
  125449. /**
  125450. * The list of effect layers (highlights/glow) added to the scene
  125451. * @see http://doc.babylonjs.com/how_to/highlight_layer
  125452. * @see http://doc.babylonjs.com/how_to/glow_layer
  125453. */
  125454. effectLayers: Array<EffectLayer>;
  125455. /**
  125456. * Removes the given effect layer from this scene.
  125457. * @param toRemove defines the effect layer to remove
  125458. * @returns the index of the removed effect layer
  125459. */
  125460. removeEffectLayer(toRemove: EffectLayer): number;
  125461. /**
  125462. * Adds the given effect layer to this scene
  125463. * @param newEffectLayer defines the effect layer to add
  125464. */
  125465. addEffectLayer(newEffectLayer: EffectLayer): void;
  125466. }
  125467. /**
  125468. * Defines the layer scene component responsible to manage any effect layers
  125469. * in a given scene.
  125470. */
  125471. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  125472. /**
  125473. * The component name helpfull to identify the component in the list of scene components.
  125474. */
  125475. readonly name: string;
  125476. /**
  125477. * The scene the component belongs to.
  125478. */
  125479. scene: Scene;
  125480. private _engine;
  125481. private _renderEffects;
  125482. private _needStencil;
  125483. private _previousStencilState;
  125484. /**
  125485. * Creates a new instance of the component for the given scene
  125486. * @param scene Defines the scene to register the component in
  125487. */
  125488. constructor(scene: Scene);
  125489. /**
  125490. * Registers the component in a given scene
  125491. */
  125492. register(): void;
  125493. /**
  125494. * Rebuilds the elements related to this component in case of
  125495. * context lost for instance.
  125496. */
  125497. rebuild(): void;
  125498. /**
  125499. * Serializes the component data to the specified json object
  125500. * @param serializationObject The object to serialize to
  125501. */
  125502. serialize(serializationObject: any): void;
  125503. /**
  125504. * Adds all the elements from the container to the scene
  125505. * @param container the container holding the elements
  125506. */
  125507. addFromContainer(container: AbstractScene): void;
  125508. /**
  125509. * Removes all the elements in the container from the scene
  125510. * @param container contains the elements to remove
  125511. * @param dispose if the removed element should be disposed (default: false)
  125512. */
  125513. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125514. /**
  125515. * Disposes the component and the associated ressources.
  125516. */
  125517. dispose(): void;
  125518. private _isReadyForMesh;
  125519. private _renderMainTexture;
  125520. private _setStencil;
  125521. private _setStencilBack;
  125522. private _draw;
  125523. private _drawCamera;
  125524. private _drawRenderingGroup;
  125525. }
  125526. }
  125527. declare module BABYLON {
  125528. /** @hidden */
  125529. export var glowMapMergePixelShader: {
  125530. name: string;
  125531. shader: string;
  125532. };
  125533. }
  125534. declare module BABYLON {
  125535. /** @hidden */
  125536. export var glowMapMergeVertexShader: {
  125537. name: string;
  125538. shader: string;
  125539. };
  125540. }
  125541. declare module BABYLON {
  125542. interface AbstractScene {
  125543. /**
  125544. * Return a the first highlight layer of the scene with a given name.
  125545. * @param name The name of the highlight layer to look for.
  125546. * @return The highlight layer if found otherwise null.
  125547. */
  125548. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  125549. }
  125550. /**
  125551. * Glow layer options. This helps customizing the behaviour
  125552. * of the glow layer.
  125553. */
  125554. export interface IGlowLayerOptions {
  125555. /**
  125556. * Multiplication factor apply to the canvas size to compute the render target size
  125557. * used to generated the glowing objects (the smaller the faster).
  125558. */
  125559. mainTextureRatio: number;
  125560. /**
  125561. * Enforces a fixed size texture to ensure resize independant blur.
  125562. */
  125563. mainTextureFixedSize?: number;
  125564. /**
  125565. * How big is the kernel of the blur texture.
  125566. */
  125567. blurKernelSize: number;
  125568. /**
  125569. * The camera attached to the layer.
  125570. */
  125571. camera: Nullable<Camera>;
  125572. /**
  125573. * Enable MSAA by chosing the number of samples.
  125574. */
  125575. mainTextureSamples?: number;
  125576. /**
  125577. * The rendering group to draw the layer in.
  125578. */
  125579. renderingGroupId: number;
  125580. }
  125581. /**
  125582. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  125583. *
  125584. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  125585. *
  125586. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  125587. */
  125588. export class GlowLayer extends EffectLayer {
  125589. /**
  125590. * Effect Name of the layer.
  125591. */
  125592. static readonly EffectName: string;
  125593. /**
  125594. * The default blur kernel size used for the glow.
  125595. */
  125596. static DefaultBlurKernelSize: number;
  125597. /**
  125598. * The default texture size ratio used for the glow.
  125599. */
  125600. static DefaultTextureRatio: number;
  125601. /**
  125602. * Sets the kernel size of the blur.
  125603. */
  125604. set blurKernelSize(value: number);
  125605. /**
  125606. * Gets the kernel size of the blur.
  125607. */
  125608. get blurKernelSize(): number;
  125609. /**
  125610. * Sets the glow intensity.
  125611. */
  125612. set intensity(value: number);
  125613. /**
  125614. * Gets the glow intensity.
  125615. */
  125616. get intensity(): number;
  125617. private _options;
  125618. private _intensity;
  125619. private _horizontalBlurPostprocess1;
  125620. private _verticalBlurPostprocess1;
  125621. private _horizontalBlurPostprocess2;
  125622. private _verticalBlurPostprocess2;
  125623. private _blurTexture1;
  125624. private _blurTexture2;
  125625. private _postProcesses1;
  125626. private _postProcesses2;
  125627. private _includedOnlyMeshes;
  125628. private _excludedMeshes;
  125629. private _meshesUsingTheirOwnMaterials;
  125630. /**
  125631. * Callback used to let the user override the color selection on a per mesh basis
  125632. */
  125633. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  125634. /**
  125635. * Callback used to let the user override the texture selection on a per mesh basis
  125636. */
  125637. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  125638. /**
  125639. * Instantiates a new glow Layer and references it to the scene.
  125640. * @param name The name of the layer
  125641. * @param scene The scene to use the layer in
  125642. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  125643. */
  125644. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  125645. /**
  125646. * Get the effect name of the layer.
  125647. * @return The effect name
  125648. */
  125649. getEffectName(): string;
  125650. /**
  125651. * Create the merge effect. This is the shader use to blit the information back
  125652. * to the main canvas at the end of the scene rendering.
  125653. */
  125654. protected _createMergeEffect(): Effect;
  125655. /**
  125656. * Creates the render target textures and post processes used in the glow layer.
  125657. */
  125658. protected _createTextureAndPostProcesses(): void;
  125659. /**
  125660. * Checks for the readiness of the element composing the layer.
  125661. * @param subMesh the mesh to check for
  125662. * @param useInstances specify wether or not to use instances to render the mesh
  125663. * @param emissiveTexture the associated emissive texture used to generate the glow
  125664. * @return true if ready otherwise, false
  125665. */
  125666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125667. /**
  125668. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125669. */
  125670. needStencil(): boolean;
  125671. /**
  125672. * Returns true if the mesh can be rendered, otherwise false.
  125673. * @param mesh The mesh to render
  125674. * @param material The material used on the mesh
  125675. * @returns true if it can be rendered otherwise false
  125676. */
  125677. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125678. /**
  125679. * Implementation specific of rendering the generating effect on the main canvas.
  125680. * @param effect The effect used to render through
  125681. */
  125682. protected _internalRender(effect: Effect): void;
  125683. /**
  125684. * Sets the required values for both the emissive texture and and the main color.
  125685. */
  125686. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125687. /**
  125688. * Returns true if the mesh should render, otherwise false.
  125689. * @param mesh The mesh to render
  125690. * @returns true if it should render otherwise false
  125691. */
  125692. protected _shouldRenderMesh(mesh: Mesh): boolean;
  125693. /**
  125694. * Adds specific effects defines.
  125695. * @param defines The defines to add specifics to.
  125696. */
  125697. protected _addCustomEffectDefines(defines: string[]): void;
  125698. /**
  125699. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  125700. * @param mesh The mesh to exclude from the glow layer
  125701. */
  125702. addExcludedMesh(mesh: Mesh): void;
  125703. /**
  125704. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  125705. * @param mesh The mesh to remove
  125706. */
  125707. removeExcludedMesh(mesh: Mesh): void;
  125708. /**
  125709. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  125710. * @param mesh The mesh to include in the glow layer
  125711. */
  125712. addIncludedOnlyMesh(mesh: Mesh): void;
  125713. /**
  125714. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  125715. * @param mesh The mesh to remove
  125716. */
  125717. removeIncludedOnlyMesh(mesh: Mesh): void;
  125718. /**
  125719. * Determine if a given mesh will be used in the glow layer
  125720. * @param mesh The mesh to test
  125721. * @returns true if the mesh will be highlighted by the current glow layer
  125722. */
  125723. hasMesh(mesh: AbstractMesh): boolean;
  125724. /**
  125725. * Defines wether the current material of the mesh should be use to render the effect.
  125726. * @param mesh defines the current mesh to render
  125727. */
  125728. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125729. /**
  125730. * Add a mesh to be rendered through its own material and not with emissive only.
  125731. * @param mesh The mesh for which we need to use its material
  125732. */
  125733. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  125734. /**
  125735. * Remove a mesh from being rendered through its own material and not with emissive only.
  125736. * @param mesh The mesh for which we need to not use its material
  125737. */
  125738. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  125739. /**
  125740. * Free any resources and references associated to a mesh.
  125741. * Internal use
  125742. * @param mesh The mesh to free.
  125743. * @hidden
  125744. */
  125745. _disposeMesh(mesh: Mesh): void;
  125746. /**
  125747. * Gets the class name of the effect layer
  125748. * @returns the string with the class name of the effect layer
  125749. */
  125750. getClassName(): string;
  125751. /**
  125752. * Serializes this glow layer
  125753. * @returns a serialized glow layer object
  125754. */
  125755. serialize(): any;
  125756. /**
  125757. * Creates a Glow Layer from parsed glow layer data
  125758. * @param parsedGlowLayer defines glow layer data
  125759. * @param scene defines the current scene
  125760. * @param rootUrl defines the root URL containing the glow layer information
  125761. * @returns a parsed Glow Layer
  125762. */
  125763. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  125764. }
  125765. }
  125766. declare module BABYLON {
  125767. /** @hidden */
  125768. export var glowBlurPostProcessPixelShader: {
  125769. name: string;
  125770. shader: string;
  125771. };
  125772. }
  125773. declare module BABYLON {
  125774. interface AbstractScene {
  125775. /**
  125776. * Return a the first highlight layer of the scene with a given name.
  125777. * @param name The name of the highlight layer to look for.
  125778. * @return The highlight layer if found otherwise null.
  125779. */
  125780. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  125781. }
  125782. /**
  125783. * Highlight layer options. This helps customizing the behaviour
  125784. * of the highlight layer.
  125785. */
  125786. export interface IHighlightLayerOptions {
  125787. /**
  125788. * Multiplication factor apply to the canvas size to compute the render target size
  125789. * used to generated the glowing objects (the smaller the faster).
  125790. */
  125791. mainTextureRatio: number;
  125792. /**
  125793. * Enforces a fixed size texture to ensure resize independant blur.
  125794. */
  125795. mainTextureFixedSize?: number;
  125796. /**
  125797. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  125798. * of the picture to blur (the smaller the faster).
  125799. */
  125800. blurTextureSizeRatio: number;
  125801. /**
  125802. * How big in texel of the blur texture is the vertical blur.
  125803. */
  125804. blurVerticalSize: number;
  125805. /**
  125806. * How big in texel of the blur texture is the horizontal blur.
  125807. */
  125808. blurHorizontalSize: number;
  125809. /**
  125810. * Alpha blending mode used to apply the blur. Default is combine.
  125811. */
  125812. alphaBlendingMode: number;
  125813. /**
  125814. * The camera attached to the layer.
  125815. */
  125816. camera: Nullable<Camera>;
  125817. /**
  125818. * Should we display highlight as a solid stroke?
  125819. */
  125820. isStroke?: boolean;
  125821. /**
  125822. * The rendering group to draw the layer in.
  125823. */
  125824. renderingGroupId: number;
  125825. }
  125826. /**
  125827. * The highlight layer Helps adding a glow effect around a mesh.
  125828. *
  125829. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  125830. * glowy meshes to your scene.
  125831. *
  125832. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  125833. */
  125834. export class HighlightLayer extends EffectLayer {
  125835. name: string;
  125836. /**
  125837. * Effect Name of the highlight layer.
  125838. */
  125839. static readonly EffectName: string;
  125840. /**
  125841. * The neutral color used during the preparation of the glow effect.
  125842. * This is black by default as the blend operation is a blend operation.
  125843. */
  125844. static NeutralColor: Color4;
  125845. /**
  125846. * Stencil value used for glowing meshes.
  125847. */
  125848. static GlowingMeshStencilReference: number;
  125849. /**
  125850. * Stencil value used for the other meshes in the scene.
  125851. */
  125852. static NormalMeshStencilReference: number;
  125853. /**
  125854. * Specifies whether or not the inner glow is ACTIVE in the layer.
  125855. */
  125856. innerGlow: boolean;
  125857. /**
  125858. * Specifies whether or not the outer glow is ACTIVE in the layer.
  125859. */
  125860. outerGlow: boolean;
  125861. /**
  125862. * Specifies the horizontal size of the blur.
  125863. */
  125864. set blurHorizontalSize(value: number);
  125865. /**
  125866. * Specifies the vertical size of the blur.
  125867. */
  125868. set blurVerticalSize(value: number);
  125869. /**
  125870. * Gets the horizontal size of the blur.
  125871. */
  125872. get blurHorizontalSize(): number;
  125873. /**
  125874. * Gets the vertical size of the blur.
  125875. */
  125876. get blurVerticalSize(): number;
  125877. /**
  125878. * An event triggered when the highlight layer is being blurred.
  125879. */
  125880. onBeforeBlurObservable: Observable<HighlightLayer>;
  125881. /**
  125882. * An event triggered when the highlight layer has been blurred.
  125883. */
  125884. onAfterBlurObservable: Observable<HighlightLayer>;
  125885. private _instanceGlowingMeshStencilReference;
  125886. private _options;
  125887. private _downSamplePostprocess;
  125888. private _horizontalBlurPostprocess;
  125889. private _verticalBlurPostprocess;
  125890. private _blurTexture;
  125891. private _meshes;
  125892. private _excludedMeshes;
  125893. /**
  125894. * Instantiates a new highlight Layer and references it to the scene..
  125895. * @param name The name of the layer
  125896. * @param scene The scene to use the layer in
  125897. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  125898. */
  125899. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  125900. /**
  125901. * Get the effect name of the layer.
  125902. * @return The effect name
  125903. */
  125904. getEffectName(): string;
  125905. /**
  125906. * Create the merge effect. This is the shader use to blit the information back
  125907. * to the main canvas at the end of the scene rendering.
  125908. */
  125909. protected _createMergeEffect(): Effect;
  125910. /**
  125911. * Creates the render target textures and post processes used in the highlight layer.
  125912. */
  125913. protected _createTextureAndPostProcesses(): void;
  125914. /**
  125915. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125916. */
  125917. needStencil(): boolean;
  125918. /**
  125919. * Checks for the readiness of the element composing the layer.
  125920. * @param subMesh the mesh to check for
  125921. * @param useInstances specify wether or not to use instances to render the mesh
  125922. * @param emissiveTexture the associated emissive texture used to generate the glow
  125923. * @return true if ready otherwise, false
  125924. */
  125925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125926. /**
  125927. * Implementation specific of rendering the generating effect on the main canvas.
  125928. * @param effect The effect used to render through
  125929. */
  125930. protected _internalRender(effect: Effect): void;
  125931. /**
  125932. * Returns true if the layer contains information to display, otherwise false.
  125933. */
  125934. shouldRender(): boolean;
  125935. /**
  125936. * Returns true if the mesh should render, otherwise false.
  125937. * @param mesh The mesh to render
  125938. * @returns true if it should render otherwise false
  125939. */
  125940. protected _shouldRenderMesh(mesh: Mesh): boolean;
  125941. /**
  125942. * Sets the required values for both the emissive texture and and the main color.
  125943. */
  125944. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125945. /**
  125946. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  125947. * @param mesh The mesh to exclude from the highlight layer
  125948. */
  125949. addExcludedMesh(mesh: Mesh): void;
  125950. /**
  125951. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  125952. * @param mesh The mesh to highlight
  125953. */
  125954. removeExcludedMesh(mesh: Mesh): void;
  125955. /**
  125956. * Determine if a given mesh will be highlighted by the current HighlightLayer
  125957. * @param mesh mesh to test
  125958. * @returns true if the mesh will be highlighted by the current HighlightLayer
  125959. */
  125960. hasMesh(mesh: AbstractMesh): boolean;
  125961. /**
  125962. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  125963. * @param mesh The mesh to highlight
  125964. * @param color The color of the highlight
  125965. * @param glowEmissiveOnly Extract the glow from the emissive texture
  125966. */
  125967. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  125968. /**
  125969. * Remove a mesh from the highlight layer in order to make it stop glowing.
  125970. * @param mesh The mesh to highlight
  125971. */
  125972. removeMesh(mesh: Mesh): void;
  125973. /**
  125974. * Force the stencil to the normal expected value for none glowing parts
  125975. */
  125976. private _defaultStencilReference;
  125977. /**
  125978. * Free any resources and references associated to a mesh.
  125979. * Internal use
  125980. * @param mesh The mesh to free.
  125981. * @hidden
  125982. */
  125983. _disposeMesh(mesh: Mesh): void;
  125984. /**
  125985. * Dispose the highlight layer and free resources.
  125986. */
  125987. dispose(): void;
  125988. /**
  125989. * Gets the class name of the effect layer
  125990. * @returns the string with the class name of the effect layer
  125991. */
  125992. getClassName(): string;
  125993. /**
  125994. * Serializes this Highlight layer
  125995. * @returns a serialized Highlight layer object
  125996. */
  125997. serialize(): any;
  125998. /**
  125999. * Creates a Highlight layer from parsed Highlight layer data
  126000. * @param parsedHightlightLayer defines the Highlight layer data
  126001. * @param scene defines the current scene
  126002. * @param rootUrl defines the root URL containing the Highlight layer information
  126003. * @returns a parsed Highlight layer
  126004. */
  126005. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126006. }
  126007. }
  126008. declare module BABYLON {
  126009. interface AbstractScene {
  126010. /**
  126011. * The list of layers (background and foreground) of the scene
  126012. */
  126013. layers: Array<Layer>;
  126014. }
  126015. /**
  126016. * Defines the layer scene component responsible to manage any layers
  126017. * in a given scene.
  126018. */
  126019. export class LayerSceneComponent implements ISceneComponent {
  126020. /**
  126021. * The component name helpfull to identify the component in the list of scene components.
  126022. */
  126023. readonly name: string;
  126024. /**
  126025. * The scene the component belongs to.
  126026. */
  126027. scene: Scene;
  126028. private _engine;
  126029. /**
  126030. * Creates a new instance of the component for the given scene
  126031. * @param scene Defines the scene to register the component in
  126032. */
  126033. constructor(scene: Scene);
  126034. /**
  126035. * Registers the component in a given scene
  126036. */
  126037. register(): void;
  126038. /**
  126039. * Rebuilds the elements related to this component in case of
  126040. * context lost for instance.
  126041. */
  126042. rebuild(): void;
  126043. /**
  126044. * Disposes the component and the associated ressources.
  126045. */
  126046. dispose(): void;
  126047. private _draw;
  126048. private _drawCameraPredicate;
  126049. private _drawCameraBackground;
  126050. private _drawCameraForeground;
  126051. private _drawRenderTargetPredicate;
  126052. private _drawRenderTargetBackground;
  126053. private _drawRenderTargetForeground;
  126054. /**
  126055. * Adds all the elements from the container to the scene
  126056. * @param container the container holding the elements
  126057. */
  126058. addFromContainer(container: AbstractScene): void;
  126059. /**
  126060. * Removes all the elements in the container from the scene
  126061. * @param container contains the elements to remove
  126062. * @param dispose if the removed element should be disposed (default: false)
  126063. */
  126064. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126065. }
  126066. }
  126067. declare module BABYLON {
  126068. /** @hidden */
  126069. export var layerPixelShader: {
  126070. name: string;
  126071. shader: string;
  126072. };
  126073. }
  126074. declare module BABYLON {
  126075. /** @hidden */
  126076. export var layerVertexShader: {
  126077. name: string;
  126078. shader: string;
  126079. };
  126080. }
  126081. declare module BABYLON {
  126082. /**
  126083. * This represents a full screen 2d layer.
  126084. * This can be useful to display a picture in the background of your scene for instance.
  126085. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126086. */
  126087. export class Layer {
  126088. /**
  126089. * Define the name of the layer.
  126090. */
  126091. name: string;
  126092. /**
  126093. * Define the texture the layer should display.
  126094. */
  126095. texture: Nullable<Texture>;
  126096. /**
  126097. * Is the layer in background or foreground.
  126098. */
  126099. isBackground: boolean;
  126100. /**
  126101. * Define the color of the layer (instead of texture).
  126102. */
  126103. color: Color4;
  126104. /**
  126105. * Define the scale of the layer in order to zoom in out of the texture.
  126106. */
  126107. scale: Vector2;
  126108. /**
  126109. * Define an offset for the layer in order to shift the texture.
  126110. */
  126111. offset: Vector2;
  126112. /**
  126113. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126114. */
  126115. alphaBlendingMode: number;
  126116. /**
  126117. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126118. * Alpha test will not mix with the background color in case of transparency.
  126119. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126120. */
  126121. alphaTest: boolean;
  126122. /**
  126123. * Define a mask to restrict the layer to only some of the scene cameras.
  126124. */
  126125. layerMask: number;
  126126. /**
  126127. * Define the list of render target the layer is visible into.
  126128. */
  126129. renderTargetTextures: RenderTargetTexture[];
  126130. /**
  126131. * Define if the layer is only used in renderTarget or if it also
  126132. * renders in the main frame buffer of the canvas.
  126133. */
  126134. renderOnlyInRenderTargetTextures: boolean;
  126135. private _scene;
  126136. private _vertexBuffers;
  126137. private _indexBuffer;
  126138. private _effect;
  126139. private _previousDefines;
  126140. /**
  126141. * An event triggered when the layer is disposed.
  126142. */
  126143. onDisposeObservable: Observable<Layer>;
  126144. private _onDisposeObserver;
  126145. /**
  126146. * Back compatibility with callback before the onDisposeObservable existed.
  126147. * The set callback will be triggered when the layer has been disposed.
  126148. */
  126149. set onDispose(callback: () => void);
  126150. /**
  126151. * An event triggered before rendering the scene
  126152. */
  126153. onBeforeRenderObservable: Observable<Layer>;
  126154. private _onBeforeRenderObserver;
  126155. /**
  126156. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126157. * The set callback will be triggered just before rendering the layer.
  126158. */
  126159. set onBeforeRender(callback: () => void);
  126160. /**
  126161. * An event triggered after rendering the scene
  126162. */
  126163. onAfterRenderObservable: Observable<Layer>;
  126164. private _onAfterRenderObserver;
  126165. /**
  126166. * Back compatibility with callback before the onAfterRenderObservable existed.
  126167. * The set callback will be triggered just after rendering the layer.
  126168. */
  126169. set onAfterRender(callback: () => void);
  126170. /**
  126171. * Instantiates a new layer.
  126172. * This represents a full screen 2d layer.
  126173. * This can be useful to display a picture in the background of your scene for instance.
  126174. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126175. * @param name Define the name of the layer in the scene
  126176. * @param imgUrl Define the url of the texture to display in the layer
  126177. * @param scene Define the scene the layer belongs to
  126178. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126179. * @param color Defines a color for the layer
  126180. */
  126181. constructor(
  126182. /**
  126183. * Define the name of the layer.
  126184. */
  126185. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126186. private _createIndexBuffer;
  126187. /** @hidden */
  126188. _rebuild(): void;
  126189. /**
  126190. * Renders the layer in the scene.
  126191. */
  126192. render(): void;
  126193. /**
  126194. * Disposes and releases the associated ressources.
  126195. */
  126196. dispose(): void;
  126197. }
  126198. }
  126199. declare module BABYLON {
  126200. /** @hidden */
  126201. export var lensFlarePixelShader: {
  126202. name: string;
  126203. shader: string;
  126204. };
  126205. }
  126206. declare module BABYLON {
  126207. /** @hidden */
  126208. export var lensFlareVertexShader: {
  126209. name: string;
  126210. shader: string;
  126211. };
  126212. }
  126213. declare module BABYLON {
  126214. /**
  126215. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126216. * It is usually composed of several `lensFlare`.
  126217. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126218. */
  126219. export class LensFlareSystem {
  126220. /**
  126221. * Define the name of the lens flare system
  126222. */
  126223. name: string;
  126224. /**
  126225. * List of lens flares used in this system.
  126226. */
  126227. lensFlares: LensFlare[];
  126228. /**
  126229. * Define a limit from the border the lens flare can be visible.
  126230. */
  126231. borderLimit: number;
  126232. /**
  126233. * Define a viewport border we do not want to see the lens flare in.
  126234. */
  126235. viewportBorder: number;
  126236. /**
  126237. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126238. */
  126239. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126240. /**
  126241. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126242. */
  126243. layerMask: number;
  126244. /**
  126245. * Define the id of the lens flare system in the scene.
  126246. * (equal to name by default)
  126247. */
  126248. id: string;
  126249. private _scene;
  126250. private _emitter;
  126251. private _vertexBuffers;
  126252. private _indexBuffer;
  126253. private _effect;
  126254. private _positionX;
  126255. private _positionY;
  126256. private _isEnabled;
  126257. /** @hidden */
  126258. static _SceneComponentInitialization: (scene: Scene) => void;
  126259. /**
  126260. * Instantiates a lens flare system.
  126261. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126262. * It is usually composed of several `lensFlare`.
  126263. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126264. * @param name Define the name of the lens flare system in the scene
  126265. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126266. * @param scene Define the scene the lens flare system belongs to
  126267. */
  126268. constructor(
  126269. /**
  126270. * Define the name of the lens flare system
  126271. */
  126272. name: string, emitter: any, scene: Scene);
  126273. /**
  126274. * Define if the lens flare system is enabled.
  126275. */
  126276. get isEnabled(): boolean;
  126277. set isEnabled(value: boolean);
  126278. /**
  126279. * Get the scene the effects belongs to.
  126280. * @returns the scene holding the lens flare system
  126281. */
  126282. getScene(): Scene;
  126283. /**
  126284. * Get the emitter of the lens flare system.
  126285. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126286. * @returns the emitter of the lens flare system
  126287. */
  126288. getEmitter(): any;
  126289. /**
  126290. * Set the emitter of the lens flare system.
  126291. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126292. * @param newEmitter Define the new emitter of the system
  126293. */
  126294. setEmitter(newEmitter: any): void;
  126295. /**
  126296. * Get the lens flare system emitter position.
  126297. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126298. * @returns the position
  126299. */
  126300. getEmitterPosition(): Vector3;
  126301. /**
  126302. * @hidden
  126303. */
  126304. computeEffectivePosition(globalViewport: Viewport): boolean;
  126305. /** @hidden */
  126306. _isVisible(): boolean;
  126307. /**
  126308. * @hidden
  126309. */
  126310. render(): boolean;
  126311. /**
  126312. * Dispose and release the lens flare with its associated resources.
  126313. */
  126314. dispose(): void;
  126315. /**
  126316. * Parse a lens flare system from a JSON repressentation
  126317. * @param parsedLensFlareSystem Define the JSON to parse
  126318. * @param scene Define the scene the parsed system should be instantiated in
  126319. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126320. * @returns the parsed system
  126321. */
  126322. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126323. /**
  126324. * Serialize the current Lens Flare System into a JSON representation.
  126325. * @returns the serialized JSON
  126326. */
  126327. serialize(): any;
  126328. }
  126329. }
  126330. declare module BABYLON {
  126331. /**
  126332. * This represents one of the lens effect in a `lensFlareSystem`.
  126333. * It controls one of the indiviual texture used in the effect.
  126334. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126335. */
  126336. export class LensFlare {
  126337. /**
  126338. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126339. */
  126340. size: number;
  126341. /**
  126342. * 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.
  126343. */
  126344. position: number;
  126345. /**
  126346. * Define the lens color.
  126347. */
  126348. color: Color3;
  126349. /**
  126350. * Define the lens texture.
  126351. */
  126352. texture: Nullable<Texture>;
  126353. /**
  126354. * Define the alpha mode to render this particular lens.
  126355. */
  126356. alphaMode: number;
  126357. private _system;
  126358. /**
  126359. * Creates a new Lens Flare.
  126360. * This represents one of the lens effect in a `lensFlareSystem`.
  126361. * It controls one of the indiviual texture used in the effect.
  126362. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126363. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  126364. * @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.
  126365. * @param color Define the lens color
  126366. * @param imgUrl Define the lens texture url
  126367. * @param system Define the `lensFlareSystem` this flare is part of
  126368. * @returns The newly created Lens Flare
  126369. */
  126370. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  126371. /**
  126372. * Instantiates a new Lens Flare.
  126373. * This represents one of the lens effect in a `lensFlareSystem`.
  126374. * It controls one of the indiviual texture used in the effect.
  126375. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126376. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  126377. * @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.
  126378. * @param color Define the lens color
  126379. * @param imgUrl Define the lens texture url
  126380. * @param system Define the `lensFlareSystem` this flare is part of
  126381. */
  126382. constructor(
  126383. /**
  126384. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126385. */
  126386. size: number,
  126387. /**
  126388. * 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.
  126389. */
  126390. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  126391. /**
  126392. * Dispose and release the lens flare with its associated resources.
  126393. */
  126394. dispose(): void;
  126395. }
  126396. }
  126397. declare module BABYLON {
  126398. interface AbstractScene {
  126399. /**
  126400. * The list of lens flare system added to the scene
  126401. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126402. */
  126403. lensFlareSystems: Array<LensFlareSystem>;
  126404. /**
  126405. * Removes the given lens flare system from this scene.
  126406. * @param toRemove The lens flare system to remove
  126407. * @returns The index of the removed lens flare system
  126408. */
  126409. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  126410. /**
  126411. * Adds the given lens flare system to this scene
  126412. * @param newLensFlareSystem The lens flare system to add
  126413. */
  126414. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  126415. /**
  126416. * Gets a lens flare system using its name
  126417. * @param name defines the name to look for
  126418. * @returns the lens flare system or null if not found
  126419. */
  126420. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  126421. /**
  126422. * Gets a lens flare system using its id
  126423. * @param id defines the id to look for
  126424. * @returns the lens flare system or null if not found
  126425. */
  126426. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  126427. }
  126428. /**
  126429. * Defines the lens flare scene component responsible to manage any lens flares
  126430. * in a given scene.
  126431. */
  126432. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  126433. /**
  126434. * The component name helpfull to identify the component in the list of scene components.
  126435. */
  126436. readonly name: string;
  126437. /**
  126438. * The scene the component belongs to.
  126439. */
  126440. scene: Scene;
  126441. /**
  126442. * Creates a new instance of the component for the given scene
  126443. * @param scene Defines the scene to register the component in
  126444. */
  126445. constructor(scene: Scene);
  126446. /**
  126447. * Registers the component in a given scene
  126448. */
  126449. register(): void;
  126450. /**
  126451. * Rebuilds the elements related to this component in case of
  126452. * context lost for instance.
  126453. */
  126454. rebuild(): void;
  126455. /**
  126456. * Adds all the elements from the container to the scene
  126457. * @param container the container holding the elements
  126458. */
  126459. addFromContainer(container: AbstractScene): void;
  126460. /**
  126461. * Removes all the elements in the container from the scene
  126462. * @param container contains the elements to remove
  126463. * @param dispose if the removed element should be disposed (default: false)
  126464. */
  126465. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126466. /**
  126467. * Serializes the component data to the specified json object
  126468. * @param serializationObject The object to serialize to
  126469. */
  126470. serialize(serializationObject: any): void;
  126471. /**
  126472. * Disposes the component and the associated ressources.
  126473. */
  126474. dispose(): void;
  126475. private _draw;
  126476. }
  126477. }
  126478. declare module BABYLON {
  126479. /** @hidden */
  126480. export var depthPixelShader: {
  126481. name: string;
  126482. shader: string;
  126483. };
  126484. }
  126485. declare module BABYLON {
  126486. /** @hidden */
  126487. export var depthVertexShader: {
  126488. name: string;
  126489. shader: string;
  126490. };
  126491. }
  126492. declare module BABYLON {
  126493. /**
  126494. * This represents a depth renderer in Babylon.
  126495. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126496. */
  126497. export class DepthRenderer {
  126498. private _scene;
  126499. private _depthMap;
  126500. private _effect;
  126501. private readonly _storeNonLinearDepth;
  126502. private readonly _clearColor;
  126503. /** Get if the depth renderer is using packed depth or not */
  126504. readonly isPacked: boolean;
  126505. private _cachedDefines;
  126506. private _camera;
  126507. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  126508. enabled: boolean;
  126509. /**
  126510. * Specifiess that the depth renderer will only be used within
  126511. * the camera it is created for.
  126512. * This can help forcing its rendering during the camera processing.
  126513. */
  126514. useOnlyInActiveCamera: boolean;
  126515. /** @hidden */
  126516. static _SceneComponentInitialization: (scene: Scene) => void;
  126517. /**
  126518. * Instantiates a depth renderer
  126519. * @param scene The scene the renderer belongs to
  126520. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126521. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126522. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126523. */
  126524. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126525. /**
  126526. * Creates the depth rendering effect and checks if the effect is ready.
  126527. * @param subMesh The submesh to be used to render the depth map of
  126528. * @param useInstances If multiple world instances should be used
  126529. * @returns if the depth renderer is ready to render the depth map
  126530. */
  126531. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126532. /**
  126533. * Gets the texture which the depth map will be written to.
  126534. * @returns The depth map texture
  126535. */
  126536. getDepthMap(): RenderTargetTexture;
  126537. /**
  126538. * Disposes of the depth renderer.
  126539. */
  126540. dispose(): void;
  126541. }
  126542. }
  126543. declare module BABYLON {
  126544. /** @hidden */
  126545. export var minmaxReduxPixelShader: {
  126546. name: string;
  126547. shader: string;
  126548. };
  126549. }
  126550. declare module BABYLON {
  126551. /**
  126552. * This class computes a min/max reduction from a texture: it means it computes the minimum
  126553. * and maximum values from all values of the texture.
  126554. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  126555. * The source values are read from the red channel of the texture.
  126556. */
  126557. export class MinMaxReducer {
  126558. /**
  126559. * Observable triggered when the computation has been performed
  126560. */
  126561. onAfterReductionPerformed: Observable<{
  126562. min: number;
  126563. max: number;
  126564. }>;
  126565. protected _camera: Camera;
  126566. protected _sourceTexture: Nullable<RenderTargetTexture>;
  126567. protected _reductionSteps: Nullable<Array<PostProcess>>;
  126568. protected _postProcessManager: PostProcessManager;
  126569. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  126570. protected _forceFullscreenViewport: boolean;
  126571. /**
  126572. * Creates a min/max reducer
  126573. * @param camera The camera to use for the post processes
  126574. */
  126575. constructor(camera: Camera);
  126576. /**
  126577. * Gets the texture used to read the values from.
  126578. */
  126579. get sourceTexture(): Nullable<RenderTargetTexture>;
  126580. /**
  126581. * Sets the source texture to read the values from.
  126582. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  126583. * because in such textures '1' value must not be taken into account to compute the maximum
  126584. * as this value is used to clear the texture.
  126585. * Note that the computation is not activated by calling this function, you must call activate() for that!
  126586. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  126587. * @param depthRedux Indicates if the texture is a depth texture or not
  126588. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  126589. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126590. */
  126591. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126592. /**
  126593. * Defines the refresh rate of the computation.
  126594. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  126595. */
  126596. get refreshRate(): number;
  126597. set refreshRate(value: number);
  126598. protected _activated: boolean;
  126599. /**
  126600. * Gets the activation status of the reducer
  126601. */
  126602. get activated(): boolean;
  126603. /**
  126604. * Activates the reduction computation.
  126605. * When activated, the observers registered in onAfterReductionPerformed are
  126606. * called after the compuation is performed
  126607. */
  126608. activate(): void;
  126609. /**
  126610. * Deactivates the reduction computation.
  126611. */
  126612. deactivate(): void;
  126613. /**
  126614. * Disposes the min/max reducer
  126615. * @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.
  126616. */
  126617. dispose(disposeAll?: boolean): void;
  126618. }
  126619. }
  126620. declare module BABYLON {
  126621. /**
  126622. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  126623. */
  126624. export class DepthReducer extends MinMaxReducer {
  126625. private _depthRenderer;
  126626. private _depthRendererId;
  126627. /**
  126628. * Gets the depth renderer used for the computation.
  126629. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  126630. */
  126631. get depthRenderer(): Nullable<DepthRenderer>;
  126632. /**
  126633. * Creates a depth reducer
  126634. * @param camera The camera used to render the depth texture
  126635. */
  126636. constructor(camera: Camera);
  126637. /**
  126638. * Sets the depth renderer to use to generate the depth map
  126639. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  126640. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  126641. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126642. */
  126643. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  126644. /** @hidden */
  126645. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126646. /**
  126647. * Activates the reduction computation.
  126648. * When activated, the observers registered in onAfterReductionPerformed are
  126649. * called after the compuation is performed
  126650. */
  126651. activate(): void;
  126652. /**
  126653. * Deactivates the reduction computation.
  126654. */
  126655. deactivate(): void;
  126656. /**
  126657. * Disposes the depth reducer
  126658. * @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.
  126659. */
  126660. dispose(disposeAll?: boolean): void;
  126661. }
  126662. }
  126663. declare module BABYLON {
  126664. /**
  126665. * A CSM implementation allowing casting shadows on large scenes.
  126666. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  126667. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  126668. */
  126669. export class CascadedShadowGenerator implements IShadowGenerator {
  126670. private static readonly frustumCornersNDCSpace;
  126671. /**
  126672. * Defines the default number of cascades used by the CSM.
  126673. */
  126674. static readonly DEFAULT_CASCADES_COUNT: number;
  126675. /**
  126676. * Defines the minimum number of cascades used by the CSM.
  126677. */
  126678. static readonly MIN_CASCADES_COUNT: number;
  126679. /**
  126680. * Defines the maximum number of cascades used by the CSM.
  126681. */
  126682. static readonly MAX_CASCADES_COUNT: number;
  126683. /**
  126684. * Shadow generator mode None: no filtering applied.
  126685. */
  126686. static readonly FILTER_NONE: number;
  126687. /**
  126688. * Shadow generator mode PCF: Percentage Closer Filtering
  126689. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  126690. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  126691. */
  126692. static readonly FILTER_PCF: number;
  126693. /**
  126694. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  126695. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  126696. * Contact Hardening
  126697. */
  126698. static readonly FILTER_PCSS: number;
  126699. /**
  126700. * Reserved for PCF and PCSS
  126701. * Highest Quality.
  126702. *
  126703. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  126704. *
  126705. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  126706. */
  126707. static readonly QUALITY_HIGH: number;
  126708. /**
  126709. * Reserved for PCF and PCSS
  126710. * Good tradeoff for quality/perf cross devices
  126711. *
  126712. * Execute PCF on a 3*3 kernel.
  126713. *
  126714. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  126715. */
  126716. static readonly QUALITY_MEDIUM: number;
  126717. /**
  126718. * Reserved for PCF and PCSS
  126719. * The lowest quality but the fastest.
  126720. *
  126721. * Execute PCF on a 1*1 kernel.
  126722. *
  126723. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  126724. */
  126725. static readonly QUALITY_LOW: number;
  126726. private static readonly _CLEARONE;
  126727. /**
  126728. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  126729. */
  126730. onBeforeShadowMapRenderObservable: Observable<Effect>;
  126731. /**
  126732. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  126733. */
  126734. onAfterShadowMapRenderObservable: Observable<Effect>;
  126735. /**
  126736. * Observable triggered before a mesh is rendered in the shadow map.
  126737. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  126738. */
  126739. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  126740. /**
  126741. * Observable triggered after a mesh is rendered in the shadow map.
  126742. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  126743. */
  126744. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  126745. private _bias;
  126746. /**
  126747. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  126748. */
  126749. get bias(): number;
  126750. /**
  126751. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  126752. */
  126753. set bias(bias: number);
  126754. private _normalBias;
  126755. /**
  126756. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  126757. */
  126758. get normalBias(): number;
  126759. /**
  126760. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  126761. */
  126762. set normalBias(normalBias: number);
  126763. private _filter;
  126764. /**
  126765. * Gets the current mode of the shadow generator (normal, PCF, PCSS...).
  126766. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  126767. */
  126768. get filter(): number;
  126769. /**
  126770. * Sets the current mode of the shadow generator (normal, PCF, PCSS...).
  126771. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  126772. */
  126773. set filter(value: number);
  126774. /**
  126775. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  126776. */
  126777. get usePercentageCloserFiltering(): boolean;
  126778. /**
  126779. * Sets the current filter to "PCF" (percentage closer filtering).
  126780. */
  126781. set usePercentageCloserFiltering(value: boolean);
  126782. private _filteringQuality;
  126783. /**
  126784. * Gets the PCF or PCSS Quality.
  126785. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  126786. */
  126787. get filteringQuality(): number;
  126788. /**
  126789. * Sets the PCF or PCSS Quality.
  126790. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  126791. */
  126792. set filteringQuality(filteringQuality: number);
  126793. /**
  126794. * Gets if the current filter is set to "PCSS" (contact hardening).
  126795. */
  126796. get useContactHardeningShadow(): boolean;
  126797. /**
  126798. * Sets the current filter to "PCSS" (contact hardening).
  126799. */
  126800. set useContactHardeningShadow(value: boolean);
  126801. private _contactHardeningLightSizeUVRatio;
  126802. /**
  126803. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  126804. * Using a ratio helps keeping shape stability independently of the map size.
  126805. *
  126806. * It does not account for the light projection as it was having too much
  126807. * instability during the light setup or during light position changes.
  126808. *
  126809. * Only valid if useContactHardeningShadow is true.
  126810. */
  126811. get contactHardeningLightSizeUVRatio(): number;
  126812. /**
  126813. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  126814. * Using a ratio helps keeping shape stability independently of the map size.
  126815. *
  126816. * It does not account for the light projection as it was having too much
  126817. * instability during the light setup or during light position changes.
  126818. *
  126819. * Only valid if useContactHardeningShadow is true.
  126820. */
  126821. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  126822. private _darkness;
  126823. /** Gets or sets the actual darkness of a shadow */
  126824. get darkness(): number;
  126825. set darkness(value: number);
  126826. /**
  126827. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  126828. * 0 means strongest and 1 would means no shadow.
  126829. * @returns the darkness.
  126830. */
  126831. getDarkness(): number;
  126832. /**
  126833. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  126834. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  126835. * @returns the shadow generator allowing fluent coding.
  126836. */
  126837. setDarkness(darkness: number): CascadedShadowGenerator;
  126838. /**
  126839. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  126840. */
  126841. penumbraDarkness: number;
  126842. private _transparencyShadow;
  126843. /** Gets or sets the ability to have transparent shadow */
  126844. get transparencyShadow(): boolean;
  126845. set transparencyShadow(value: boolean);
  126846. /**
  126847. * Sets the ability to have transparent shadow (boolean).
  126848. * @param transparent True if transparent else False
  126849. * @returns the shadow generator allowing fluent coding
  126850. */
  126851. setTransparencyShadow(transparent: boolean): CascadedShadowGenerator;
  126852. private _numCascades;
  126853. /**
  126854. * Gets or set the number of cascades used by the CSM.
  126855. */
  126856. get numCascades(): number;
  126857. set numCascades(value: number);
  126858. /**
  126859. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  126860. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  126861. */
  126862. stabilizeCascades: boolean;
  126863. private _shadowMap;
  126864. /**
  126865. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  126866. * @returns The render target texture if present otherwise, null
  126867. */
  126868. getShadowMap(): Nullable<RenderTargetTexture>;
  126869. protected _freezeShadowCastersBoundingInfo: boolean;
  126870. private _freezeShadowCastersBoundingInfoObservable;
  126871. /**
  126872. * Enables or disables the shadow casters bounding info computation.
  126873. * If your shadow casters don't move, you can disable this feature.
  126874. * If it is enabled, the bounding box computation is done every frame.
  126875. */
  126876. get freezeShadowCastersBoundingInfo(): boolean;
  126877. set freezeShadowCastersBoundingInfo(freeze: boolean);
  126878. private _scbiMin;
  126879. private _scbiMax;
  126880. protected _computeShadowCastersBoundingInfo(): void;
  126881. protected _shadowCastersBoundingInfo: BoundingInfo;
  126882. /**
  126883. * Gets or sets the shadow casters bounding info.
  126884. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  126885. * so that the system won't overwrite the bounds you provide
  126886. */
  126887. get shadowCastersBoundingInfo(): BoundingInfo;
  126888. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  126889. protected _breaksAreDirty: boolean;
  126890. protected _minDistance: number;
  126891. protected _maxDistance: number;
  126892. /**
  126893. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  126894. *
  126895. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  126896. * If you don't know these values, simply leave them to their defaults and don't call this function.
  126897. * @param min minimal distance for the breaks (default to 0.)
  126898. * @param max maximal distance for the breaks (default to 1.)
  126899. */
  126900. setMinMaxDistance(min: number, max: number): void;
  126901. /**
  126902. * Gets the class name of that object
  126903. * @returns "ShadowGenerator"
  126904. */
  126905. getClassName(): string;
  126906. /**
  126907. * Helper function to add a mesh and its descendants to the list of shadow casters.
  126908. * @param mesh Mesh to add
  126909. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  126910. * @returns the Shadow Generator itself
  126911. */
  126912. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  126913. /**
  126914. * Helper function to remove a mesh and its descendants from the list of shadow casters
  126915. * @param mesh Mesh to remove
  126916. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  126917. * @returns the Shadow Generator itself
  126918. */
  126919. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  126920. /**
  126921. * Controls the extent to which the shadows fade out at the edge of the frustum
  126922. */
  126923. frustumEdgeFalloff: number;
  126924. private _light;
  126925. /**
  126926. * Returns the associated light object.
  126927. * @returns the light generating the shadow
  126928. */
  126929. getLight(): DirectionalLight;
  126930. /**
  126931. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  126932. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  126933. * It might on the other hand introduce peter panning.
  126934. */
  126935. forceBackFacesOnly: boolean;
  126936. private _cascadeMinExtents;
  126937. private _cascadeMaxExtents;
  126938. /**
  126939. * Gets a cascade minimum extents
  126940. * @param cascadeIndex index of the cascade
  126941. * @returns the minimum cascade extents
  126942. */
  126943. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  126944. /**
  126945. * Gets a cascade maximum extents
  126946. * @param cascadeIndex index of the cascade
  126947. * @returns the maximum cascade extents
  126948. */
  126949. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  126950. private _scene;
  126951. private _lightDirection;
  126952. private _effect;
  126953. private _cascades;
  126954. private _cachedPosition;
  126955. private _cachedDirection;
  126956. private _cachedDefines;
  126957. private _currentRenderID;
  126958. private _mapSize;
  126959. private _currentLayer;
  126960. private _textureType;
  126961. private _defaultTextureMatrix;
  126962. private _storedUniqueId;
  126963. private _viewSpaceFrustumsZ;
  126964. private _viewMatrices;
  126965. private _projectionMatrices;
  126966. private _transformMatrices;
  126967. private _transformMatricesAsArray;
  126968. private _frustumLengths;
  126969. private _lightSizeUVCorrection;
  126970. private _depthCorrection;
  126971. private _frustumCornersWorldSpace;
  126972. private _frustumCenter;
  126973. private _shadowCameraPos;
  126974. private _shadowMaxZ;
  126975. /**
  126976. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  126977. * It defaults to camera.maxZ
  126978. */
  126979. get shadowMaxZ(): number;
  126980. /**
  126981. * Sets the shadow max z distance.
  126982. */
  126983. set shadowMaxZ(value: number);
  126984. protected _debug: boolean;
  126985. /**
  126986. * Gets or sets the debug flag.
  126987. * When enabled, the cascades are materialized by different colors on the screen.
  126988. */
  126989. get debug(): boolean;
  126990. set debug(dbg: boolean);
  126991. private _depthClamp;
  126992. /**
  126993. * Gets or sets the depth clamping value.
  126994. *
  126995. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  126996. * to account for the shadow casters far away.
  126997. *
  126998. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  126999. */
  127000. get depthClamp(): boolean;
  127001. set depthClamp(value: boolean);
  127002. /**
  127003. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127004. * It defaults to 0.1 (10% blending).
  127005. */
  127006. cascadeBlendPercentage: number;
  127007. private _lambda;
  127008. /**
  127009. * Gets or set the lambda parameter.
  127010. * This parameter is used to split the camera frustum and create the cascades.
  127011. * 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.
  127012. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127013. */
  127014. get lambda(): number;
  127015. set lambda(value: number);
  127016. /**
  127017. * Gets the view matrix corresponding to a given cascade
  127018. * @param cascadeNum cascade to retrieve the view matrix from
  127019. * @returns the cascade view matrix
  127020. */
  127021. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127022. private _depthRenderer;
  127023. /**
  127024. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127025. *
  127026. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127027. *
  127028. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127029. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127030. * @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
  127031. */
  127032. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127033. private _depthReducer;
  127034. private _autoCalcDepthBounds;
  127035. /**
  127036. * Gets or sets the autoCalcDepthBounds property.
  127037. *
  127038. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127039. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127040. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127041. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127042. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127043. */
  127044. get autoCalcDepthBounds(): boolean;
  127045. set autoCalcDepthBounds(value: boolean);
  127046. /**
  127047. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127048. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127049. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127050. * for setting the refresh rate on the renderer yourself!
  127051. */
  127052. get autoCalcDepthBoundsRefreshRate(): number;
  127053. set autoCalcDepthBoundsRefreshRate(value: number);
  127054. /**
  127055. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127056. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127057. * you change the camera near/far planes!
  127058. */
  127059. splitFrustum(): void;
  127060. private _splitFrustum;
  127061. /**
  127062. * Gets the CSM transformation matrix used to project the meshes into the map from the light point of view.
  127063. * (eq to view projection * shadow projection matrices)
  127064. * @param cascadeIndex index number of the cascaded shadow map
  127065. * @returns The transform matrix used to create the CSM shadow map
  127066. */
  127067. getCSMTransformMatrix(cascadeIndex: number): Matrix;
  127068. private _computeFrustumInWorldSpace;
  127069. private _computeCascadeFrustum;
  127070. /** @hidden */
  127071. static _SceneComponentInitialization: (scene: Scene) => void;
  127072. /**
  127073. * Creates a Cascaded Shadow Generator object.
  127074. * A ShadowGenerator is the required tool to use the shadows.
  127075. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127076. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127077. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127078. * @param light The directional light object generating the shadows.
  127079. * @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.
  127080. */
  127081. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127082. private _initializeGenerator;
  127083. private _initializeShadowMap;
  127084. private _renderForShadowMap;
  127085. private _renderSubMeshForShadowMap;
  127086. private _applyFilterValues;
  127087. /**
  127088. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  127089. * @param onCompiled Callback triggered at the and of the effects compilation
  127090. * @param options Sets of optional options forcing the compilation with different modes
  127091. */
  127092. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  127093. useInstances: boolean;
  127094. }>): void;
  127095. /**
  127096. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  127097. * @param options Sets of optional options forcing the compilation with different modes
  127098. * @returns A promise that resolves when the compilation completes
  127099. */
  127100. forceCompilationAsync(options?: Partial<{
  127101. useInstances: boolean;
  127102. }>): Promise<void>;
  127103. /**
  127104. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  127105. * @param subMesh The submesh we want to render in the shadow map
  127106. * @param useInstances Defines wether will draw in the map using instances
  127107. * @returns true if ready otherwise, false
  127108. */
  127109. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127110. /**
  127111. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127112. * @param defines Defines of the material we want to update
  127113. * @param lightIndex Index of the light in the enabled light list of the material
  127114. */
  127115. prepareDefines(defines: any, lightIndex: number): void;
  127116. /**
  127117. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127118. * defined in the generator but impacting the effect).
  127119. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127120. * @param effect The effect we are binfing the information for
  127121. */
  127122. bindShadowLight(lightIndex: string, effect: Effect): void;
  127123. /**
  127124. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127125. * (eq to view projection * shadow projection matrices)
  127126. * @returns The transform matrix used to create the shadow map
  127127. */
  127128. getTransformMatrix(): Matrix;
  127129. /**
  127130. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  127131. * Cube and 2D textures for instance.
  127132. */
  127133. recreateShadowMap(): void;
  127134. private _disposeRTT;
  127135. /**
  127136. * Disposes the ShadowGenerator.
  127137. * Returns nothing.
  127138. */
  127139. dispose(): void;
  127140. /**
  127141. * Serializes the shadow generator setup to a json object.
  127142. * @returns The serialized JSON object
  127143. */
  127144. serialize(): any;
  127145. /**
  127146. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127147. * @param parsedShadowGenerator The JSON object to parse
  127148. * @param scene The scene to create the shadow map for
  127149. * @returns The parsed shadow generator
  127150. */
  127151. static Parse(parsedShadowGenerator: any, scene: Scene): CascadedShadowGenerator;
  127152. }
  127153. }
  127154. declare module BABYLON {
  127155. /**
  127156. * Defines the shadow generator component responsible to manage any shadow generators
  127157. * in a given scene.
  127158. */
  127159. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127160. /**
  127161. * The component name helpfull to identify the component in the list of scene components.
  127162. */
  127163. readonly name: string;
  127164. /**
  127165. * The scene the component belongs to.
  127166. */
  127167. scene: Scene;
  127168. /**
  127169. * Creates a new instance of the component for the given scene
  127170. * @param scene Defines the scene to register the component in
  127171. */
  127172. constructor(scene: Scene);
  127173. /**
  127174. * Registers the component in a given scene
  127175. */
  127176. register(): void;
  127177. /**
  127178. * Rebuilds the elements related to this component in case of
  127179. * context lost for instance.
  127180. */
  127181. rebuild(): void;
  127182. /**
  127183. * Serializes the component data to the specified json object
  127184. * @param serializationObject The object to serialize to
  127185. */
  127186. serialize(serializationObject: any): void;
  127187. /**
  127188. * Adds all the elements from the container to the scene
  127189. * @param container the container holding the elements
  127190. */
  127191. addFromContainer(container: AbstractScene): void;
  127192. /**
  127193. * Removes all the elements in the container from the scene
  127194. * @param container contains the elements to remove
  127195. * @param dispose if the removed element should be disposed (default: false)
  127196. */
  127197. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127198. /**
  127199. * Rebuilds the elements related to this component in case of
  127200. * context lost for instance.
  127201. */
  127202. dispose(): void;
  127203. private _gatherRenderTargets;
  127204. }
  127205. }
  127206. declare module BABYLON {
  127207. /**
  127208. * A point light is a light defined by an unique point in world space.
  127209. * The light is emitted in every direction from this point.
  127210. * A good example of a point light is a standard light bulb.
  127211. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127212. */
  127213. export class PointLight extends ShadowLight {
  127214. private _shadowAngle;
  127215. /**
  127216. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127217. * This specifies what angle the shadow will use to be created.
  127218. *
  127219. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127220. */
  127221. get shadowAngle(): number;
  127222. /**
  127223. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127224. * This specifies what angle the shadow will use to be created.
  127225. *
  127226. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127227. */
  127228. set shadowAngle(value: number);
  127229. /**
  127230. * Gets the direction if it has been set.
  127231. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127232. */
  127233. get direction(): Vector3;
  127234. /**
  127235. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127236. */
  127237. set direction(value: Vector3);
  127238. /**
  127239. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127240. * A PointLight emits the light in every direction.
  127241. * It can cast shadows.
  127242. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127243. * ```javascript
  127244. * var pointLight = new PointLight("pl", camera.position, scene);
  127245. * ```
  127246. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127247. * @param name The light friendly name
  127248. * @param position The position of the point light in the scene
  127249. * @param scene The scene the lights belongs to
  127250. */
  127251. constructor(name: string, position: Vector3, scene: Scene);
  127252. /**
  127253. * Returns the string "PointLight"
  127254. * @returns the class name
  127255. */
  127256. getClassName(): string;
  127257. /**
  127258. * Returns the integer 0.
  127259. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127260. */
  127261. getTypeID(): number;
  127262. /**
  127263. * Specifies wether or not the shadowmap should be a cube texture.
  127264. * @returns true if the shadowmap needs to be a cube texture.
  127265. */
  127266. needCube(): boolean;
  127267. /**
  127268. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127269. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127270. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127271. */
  127272. getShadowDirection(faceIndex?: number): Vector3;
  127273. /**
  127274. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127275. * - fov = PI / 2
  127276. * - aspect ratio : 1.0
  127277. * - z-near and far equal to the active camera minZ and maxZ.
  127278. * Returns the PointLight.
  127279. */
  127280. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127281. protected _buildUniformLayout(): void;
  127282. /**
  127283. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127284. * @param effect The effect to update
  127285. * @param lightIndex The index of the light in the effect to update
  127286. * @returns The point light
  127287. */
  127288. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127289. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127290. /**
  127291. * Prepares the list of defines specific to the light type.
  127292. * @param defines the list of defines
  127293. * @param lightIndex defines the index of the light for the effect
  127294. */
  127295. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127296. }
  127297. }
  127298. declare module BABYLON {
  127299. /**
  127300. * Header information of HDR texture files.
  127301. */
  127302. export interface HDRInfo {
  127303. /**
  127304. * The height of the texture in pixels.
  127305. */
  127306. height: number;
  127307. /**
  127308. * The width of the texture in pixels.
  127309. */
  127310. width: number;
  127311. /**
  127312. * The index of the beginning of the data in the binary file.
  127313. */
  127314. dataPosition: number;
  127315. }
  127316. /**
  127317. * This groups tools to convert HDR texture to native colors array.
  127318. */
  127319. export class HDRTools {
  127320. private static Ldexp;
  127321. private static Rgbe2float;
  127322. private static readStringLine;
  127323. /**
  127324. * Reads header information from an RGBE texture stored in a native array.
  127325. * More information on this format are available here:
  127326. * https://en.wikipedia.org/wiki/RGBE_image_format
  127327. *
  127328. * @param uint8array The binary file stored in native array.
  127329. * @return The header information.
  127330. */
  127331. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127332. /**
  127333. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127334. * This RGBE texture needs to store the information as a panorama.
  127335. *
  127336. * More information on this format are available here:
  127337. * https://en.wikipedia.org/wiki/RGBE_image_format
  127338. *
  127339. * @param buffer The binary file stored in an array buffer.
  127340. * @param size The expected size of the extracted cubemap.
  127341. * @return The Cube Map information.
  127342. */
  127343. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127344. /**
  127345. * Returns the pixels data extracted from an RGBE texture.
  127346. * This pixels will be stored left to right up to down in the R G B order in one array.
  127347. *
  127348. * More information on this format are available here:
  127349. * https://en.wikipedia.org/wiki/RGBE_image_format
  127350. *
  127351. * @param uint8array The binary file stored in an array buffer.
  127352. * @param hdrInfo The header information of the file.
  127353. * @return The pixels data in RGB right to left up to down order.
  127354. */
  127355. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127356. private static RGBE_ReadPixels_RLE;
  127357. }
  127358. }
  127359. declare module BABYLON {
  127360. /**
  127361. * This represents a texture coming from an HDR input.
  127362. *
  127363. * The only supported format is currently panorama picture stored in RGBE format.
  127364. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127365. */
  127366. export class HDRCubeTexture extends BaseTexture {
  127367. private static _facesMapping;
  127368. private _generateHarmonics;
  127369. private _noMipmap;
  127370. private _textureMatrix;
  127371. private _size;
  127372. private _onLoad;
  127373. private _onError;
  127374. /**
  127375. * The texture URL.
  127376. */
  127377. url: string;
  127378. /**
  127379. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127380. */
  127381. coordinatesMode: number;
  127382. protected _isBlocking: boolean;
  127383. /**
  127384. * Sets wether or not the texture is blocking during loading.
  127385. */
  127386. set isBlocking(value: boolean);
  127387. /**
  127388. * Gets wether or not the texture is blocking during loading.
  127389. */
  127390. get isBlocking(): boolean;
  127391. protected _rotationY: number;
  127392. /**
  127393. * Sets texture matrix rotation angle around Y axis in radians.
  127394. */
  127395. set rotationY(value: number);
  127396. /**
  127397. * Gets texture matrix rotation angle around Y axis radians.
  127398. */
  127399. get rotationY(): number;
  127400. /**
  127401. * Gets or sets the center of the bounding box associated with the cube texture
  127402. * It must define where the camera used to render the texture was set
  127403. */
  127404. boundingBoxPosition: Vector3;
  127405. private _boundingBoxSize;
  127406. /**
  127407. * Gets or sets the size of the bounding box associated with the cube texture
  127408. * When defined, the cubemap will switch to local mode
  127409. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127410. * @example https://www.babylonjs-playground.com/#RNASML
  127411. */
  127412. set boundingBoxSize(value: Vector3);
  127413. get boundingBoxSize(): Vector3;
  127414. /**
  127415. * Instantiates an HDRTexture from the following parameters.
  127416. *
  127417. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127418. * @param scene The scene the texture will be used in
  127419. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127420. * @param noMipmap Forces to not generate the mipmap if true
  127421. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127422. * @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)
  127423. * @param reserved Reserved flag for internal use.
  127424. */
  127425. 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>);
  127426. /**
  127427. * Get the current class name of the texture useful for serialization or dynamic coding.
  127428. * @returns "HDRCubeTexture"
  127429. */
  127430. getClassName(): string;
  127431. /**
  127432. * Occurs when the file is raw .hdr file.
  127433. */
  127434. private loadTexture;
  127435. clone(): HDRCubeTexture;
  127436. delayLoad(): void;
  127437. /**
  127438. * Get the texture reflection matrix used to rotate/transform the reflection.
  127439. * @returns the reflection matrix
  127440. */
  127441. getReflectionTextureMatrix(): Matrix;
  127442. /**
  127443. * Set the texture reflection matrix used to rotate/transform the reflection.
  127444. * @param value Define the reflection matrix to set
  127445. */
  127446. setReflectionTextureMatrix(value: Matrix): void;
  127447. /**
  127448. * Parses a JSON representation of an HDR Texture in order to create the texture
  127449. * @param parsedTexture Define the JSON representation
  127450. * @param scene Define the scene the texture should be created in
  127451. * @param rootUrl Define the root url in case we need to load relative dependencies
  127452. * @returns the newly created texture after parsing
  127453. */
  127454. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127455. serialize(): any;
  127456. }
  127457. }
  127458. declare module BABYLON {
  127459. /**
  127460. * Class used to control physics engine
  127461. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127462. */
  127463. export class PhysicsEngine implements IPhysicsEngine {
  127464. private _physicsPlugin;
  127465. /**
  127466. * Global value used to control the smallest number supported by the simulation
  127467. */
  127468. static Epsilon: number;
  127469. private _impostors;
  127470. private _joints;
  127471. private _subTimeStep;
  127472. /**
  127473. * Gets the gravity vector used by the simulation
  127474. */
  127475. gravity: Vector3;
  127476. /**
  127477. * Factory used to create the default physics plugin.
  127478. * @returns The default physics plugin
  127479. */
  127480. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127481. /**
  127482. * Creates a new Physics Engine
  127483. * @param gravity defines the gravity vector used by the simulation
  127484. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127485. */
  127486. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127487. /**
  127488. * Sets the gravity vector used by the simulation
  127489. * @param gravity defines the gravity vector to use
  127490. */
  127491. setGravity(gravity: Vector3): void;
  127492. /**
  127493. * Set the time step of the physics engine.
  127494. * Default is 1/60.
  127495. * To slow it down, enter 1/600 for example.
  127496. * To speed it up, 1/30
  127497. * @param newTimeStep defines the new timestep to apply to this world.
  127498. */
  127499. setTimeStep(newTimeStep?: number): void;
  127500. /**
  127501. * Get the time step of the physics engine.
  127502. * @returns the current time step
  127503. */
  127504. getTimeStep(): number;
  127505. /**
  127506. * Set the sub time step of the physics engine.
  127507. * Default is 0 meaning there is no sub steps
  127508. * To increase physics resolution precision, set a small value (like 1 ms)
  127509. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127510. */
  127511. setSubTimeStep(subTimeStep?: number): void;
  127512. /**
  127513. * Get the sub time step of the physics engine.
  127514. * @returns the current sub time step
  127515. */
  127516. getSubTimeStep(): number;
  127517. /**
  127518. * Release all resources
  127519. */
  127520. dispose(): void;
  127521. /**
  127522. * Gets the name of the current physics plugin
  127523. * @returns the name of the plugin
  127524. */
  127525. getPhysicsPluginName(): string;
  127526. /**
  127527. * Adding a new impostor for the impostor tracking.
  127528. * This will be done by the impostor itself.
  127529. * @param impostor the impostor to add
  127530. */
  127531. addImpostor(impostor: PhysicsImpostor): void;
  127532. /**
  127533. * Remove an impostor from the engine.
  127534. * This impostor and its mesh will not longer be updated by the physics engine.
  127535. * @param impostor the impostor to remove
  127536. */
  127537. removeImpostor(impostor: PhysicsImpostor): void;
  127538. /**
  127539. * Add a joint to the physics engine
  127540. * @param mainImpostor defines the main impostor to which the joint is added.
  127541. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127542. * @param joint defines the joint that will connect both impostors.
  127543. */
  127544. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127545. /**
  127546. * Removes a joint from the simulation
  127547. * @param mainImpostor defines the impostor used with the joint
  127548. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127549. * @param joint defines the joint to remove
  127550. */
  127551. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127552. /**
  127553. * Called by the scene. No need to call it.
  127554. * @param delta defines the timespam between frames
  127555. */
  127556. _step(delta: number): void;
  127557. /**
  127558. * Gets the current plugin used to run the simulation
  127559. * @returns current plugin
  127560. */
  127561. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127562. /**
  127563. * Gets the list of physic impostors
  127564. * @returns an array of PhysicsImpostor
  127565. */
  127566. getImpostors(): Array<PhysicsImpostor>;
  127567. /**
  127568. * Gets the impostor for a physics enabled object
  127569. * @param object defines the object impersonated by the impostor
  127570. * @returns the PhysicsImpostor or null if not found
  127571. */
  127572. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  127573. /**
  127574. * Gets the impostor for a physics body object
  127575. * @param body defines physics body used by the impostor
  127576. * @returns the PhysicsImpostor or null if not found
  127577. */
  127578. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  127579. /**
  127580. * Does a raycast in the physics world
  127581. * @param from when should the ray start?
  127582. * @param to when should the ray end?
  127583. * @returns PhysicsRaycastResult
  127584. */
  127585. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127586. }
  127587. }
  127588. declare module BABYLON {
  127589. /** @hidden */
  127590. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  127591. private _useDeltaForWorldStep;
  127592. world: any;
  127593. name: string;
  127594. private _physicsMaterials;
  127595. private _fixedTimeStep;
  127596. private _cannonRaycastResult;
  127597. private _raycastResult;
  127598. private _physicsBodysToRemoveAfterStep;
  127599. BJSCANNON: any;
  127600. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  127601. setGravity(gravity: Vector3): void;
  127602. setTimeStep(timeStep: number): void;
  127603. getTimeStep(): number;
  127604. executeStep(delta: number): void;
  127605. private _removeMarkedPhysicsBodiesFromWorld;
  127606. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127607. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127608. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127609. private _processChildMeshes;
  127610. removePhysicsBody(impostor: PhysicsImpostor): void;
  127611. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127612. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127613. private _addMaterial;
  127614. private _checkWithEpsilon;
  127615. private _createShape;
  127616. private _createHeightmap;
  127617. private _minus90X;
  127618. private _plus90X;
  127619. private _tmpPosition;
  127620. private _tmpDeltaPosition;
  127621. private _tmpUnityRotation;
  127622. private _updatePhysicsBodyTransformation;
  127623. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127624. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127625. isSupported(): boolean;
  127626. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127627. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127628. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127629. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127630. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127631. getBodyMass(impostor: PhysicsImpostor): number;
  127632. getBodyFriction(impostor: PhysicsImpostor): number;
  127633. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127634. getBodyRestitution(impostor: PhysicsImpostor): number;
  127635. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127636. sleepBody(impostor: PhysicsImpostor): void;
  127637. wakeUpBody(impostor: PhysicsImpostor): void;
  127638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  127639. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  127640. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  127641. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127642. getRadius(impostor: PhysicsImpostor): number;
  127643. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127644. dispose(): void;
  127645. private _extendNamespace;
  127646. /**
  127647. * Does a raycast in the physics world
  127648. * @param from when should the ray start?
  127649. * @param to when should the ray end?
  127650. * @returns PhysicsRaycastResult
  127651. */
  127652. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127653. }
  127654. }
  127655. declare module BABYLON {
  127656. /** @hidden */
  127657. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  127658. world: any;
  127659. name: string;
  127660. BJSOIMO: any;
  127661. private _raycastResult;
  127662. constructor(iterations?: number, oimoInjection?: any);
  127663. setGravity(gravity: Vector3): void;
  127664. setTimeStep(timeStep: number): void;
  127665. getTimeStep(): number;
  127666. private _tmpImpostorsArray;
  127667. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127668. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127669. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127670. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127671. private _tmpPositionVector;
  127672. removePhysicsBody(impostor: PhysicsImpostor): void;
  127673. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127674. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127675. isSupported(): boolean;
  127676. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127677. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127678. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127679. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127680. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127681. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127682. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127683. getBodyMass(impostor: PhysicsImpostor): number;
  127684. getBodyFriction(impostor: PhysicsImpostor): number;
  127685. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127686. getBodyRestitution(impostor: PhysicsImpostor): number;
  127687. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127688. sleepBody(impostor: PhysicsImpostor): void;
  127689. wakeUpBody(impostor: PhysicsImpostor): void;
  127690. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  127691. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  127692. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  127693. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127694. getRadius(impostor: PhysicsImpostor): number;
  127695. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127696. dispose(): void;
  127697. /**
  127698. * Does a raycast in the physics world
  127699. * @param from when should the ray start?
  127700. * @param to when should the ray end?
  127701. * @returns PhysicsRaycastResult
  127702. */
  127703. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127704. }
  127705. }
  127706. declare module BABYLON {
  127707. /**
  127708. * Class containing static functions to help procedurally build meshes
  127709. */
  127710. export class RibbonBuilder {
  127711. /**
  127712. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127713. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127714. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127715. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127716. * * 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
  127717. * * 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
  127718. * * 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
  127719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127721. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127722. * * 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
  127723. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127724. * * 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
  127725. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127727. * @param name defines the name of the mesh
  127728. * @param options defines the options used to create the mesh
  127729. * @param scene defines the hosting scene
  127730. * @returns the ribbon mesh
  127731. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127733. */
  127734. static CreateRibbon(name: string, options: {
  127735. pathArray: Vector3[][];
  127736. closeArray?: boolean;
  127737. closePath?: boolean;
  127738. offset?: number;
  127739. updatable?: boolean;
  127740. sideOrientation?: number;
  127741. frontUVs?: Vector4;
  127742. backUVs?: Vector4;
  127743. instance?: Mesh;
  127744. invertUV?: boolean;
  127745. uvs?: Vector2[];
  127746. colors?: Color4[];
  127747. }, scene?: Nullable<Scene>): Mesh;
  127748. }
  127749. }
  127750. declare module BABYLON {
  127751. /**
  127752. * Class containing static functions to help procedurally build meshes
  127753. */
  127754. export class ShapeBuilder {
  127755. /**
  127756. * 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.
  127757. * * 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.
  127758. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127759. * * 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.
  127760. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127761. * * 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
  127762. * * 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
  127763. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127768. * @param name defines the name of the mesh
  127769. * @param options defines the options used to create the mesh
  127770. * @param scene defines the hosting scene
  127771. * @returns the extruded shape mesh
  127772. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127774. */
  127775. static ExtrudeShape(name: string, options: {
  127776. shape: Vector3[];
  127777. path: Vector3[];
  127778. scale?: number;
  127779. rotation?: number;
  127780. cap?: number;
  127781. updatable?: boolean;
  127782. sideOrientation?: number;
  127783. frontUVs?: Vector4;
  127784. backUVs?: Vector4;
  127785. instance?: Mesh;
  127786. invertUV?: boolean;
  127787. }, scene?: Nullable<Scene>): Mesh;
  127788. /**
  127789. * Creates an custom extruded shape mesh.
  127790. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127791. * * 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.
  127792. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127793. * * 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
  127794. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127795. * * 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
  127796. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127797. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127798. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127799. * * 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
  127800. * * 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
  127801. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127804. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127806. * @param name defines the name of the mesh
  127807. * @param options defines the options used to create the mesh
  127808. * @param scene defines the hosting scene
  127809. * @returns the custom extruded shape mesh
  127810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127811. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127813. */
  127814. static ExtrudeShapeCustom(name: string, options: {
  127815. shape: Vector3[];
  127816. path: Vector3[];
  127817. scaleFunction?: any;
  127818. rotationFunction?: any;
  127819. ribbonCloseArray?: boolean;
  127820. ribbonClosePath?: boolean;
  127821. cap?: number;
  127822. updatable?: boolean;
  127823. sideOrientation?: number;
  127824. frontUVs?: Vector4;
  127825. backUVs?: Vector4;
  127826. instance?: Mesh;
  127827. invertUV?: boolean;
  127828. }, scene?: Nullable<Scene>): Mesh;
  127829. private static _ExtrudeShapeGeneric;
  127830. }
  127831. }
  127832. declare module BABYLON {
  127833. /**
  127834. * AmmoJS Physics plugin
  127835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  127836. * @see https://github.com/kripken/ammo.js/
  127837. */
  127838. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  127839. private _useDeltaForWorldStep;
  127840. /**
  127841. * Reference to the Ammo library
  127842. */
  127843. bjsAMMO: any;
  127844. /**
  127845. * Created ammoJS world which physics bodies are added to
  127846. */
  127847. world: any;
  127848. /**
  127849. * Name of the plugin
  127850. */
  127851. name: string;
  127852. private _timeStep;
  127853. private _fixedTimeStep;
  127854. private _maxSteps;
  127855. private _tmpQuaternion;
  127856. private _tmpAmmoTransform;
  127857. private _tmpAmmoQuaternion;
  127858. private _tmpAmmoConcreteContactResultCallback;
  127859. private _collisionConfiguration;
  127860. private _dispatcher;
  127861. private _overlappingPairCache;
  127862. private _solver;
  127863. private _softBodySolver;
  127864. private _tmpAmmoVectorA;
  127865. private _tmpAmmoVectorB;
  127866. private _tmpAmmoVectorC;
  127867. private _tmpAmmoVectorD;
  127868. private _tmpContactCallbackResult;
  127869. private _tmpAmmoVectorRCA;
  127870. private _tmpAmmoVectorRCB;
  127871. private _raycastResult;
  127872. private static readonly DISABLE_COLLISION_FLAG;
  127873. private static readonly KINEMATIC_FLAG;
  127874. private static readonly DISABLE_DEACTIVATION_FLAG;
  127875. /**
  127876. * Initializes the ammoJS plugin
  127877. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  127878. * @param ammoInjection can be used to inject your own ammo reference
  127879. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  127880. */
  127881. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  127882. /**
  127883. * Sets the gravity of the physics world (m/(s^2))
  127884. * @param gravity Gravity to set
  127885. */
  127886. setGravity(gravity: Vector3): void;
  127887. /**
  127888. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  127889. * @param timeStep timestep to use in seconds
  127890. */
  127891. setTimeStep(timeStep: number): void;
  127892. /**
  127893. * 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)
  127894. * @param fixedTimeStep fixedTimeStep to use in seconds
  127895. */
  127896. setFixedTimeStep(fixedTimeStep: number): void;
  127897. /**
  127898. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  127899. * @param maxSteps the maximum number of steps by the physics engine per frame
  127900. */
  127901. setMaxSteps(maxSteps: number): void;
  127902. /**
  127903. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  127904. * @returns the current timestep in seconds
  127905. */
  127906. getTimeStep(): number;
  127907. /**
  127908. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  127909. */
  127910. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  127911. private _isImpostorInContact;
  127912. private _isImpostorPairInContact;
  127913. private _stepSimulation;
  127914. /**
  127915. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  127916. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  127917. * After the step the babylon meshes are set to the position of the physics imposters
  127918. * @param delta amount of time to step forward
  127919. * @param impostors array of imposters to update before/after the step
  127920. */
  127921. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127922. /**
  127923. * Update babylon mesh to match physics world object
  127924. * @param impostor imposter to match
  127925. */
  127926. private _afterSoftStep;
  127927. /**
  127928. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127929. * @param impostor imposter to match
  127930. */
  127931. private _ropeStep;
  127932. /**
  127933. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127934. * @param impostor imposter to match
  127935. */
  127936. private _softbodyOrClothStep;
  127937. private _tmpVector;
  127938. private _tmpMatrix;
  127939. /**
  127940. * Applies an impulse on the imposter
  127941. * @param impostor imposter to apply impulse to
  127942. * @param force amount of force to be applied to the imposter
  127943. * @param contactPoint the location to apply the impulse on the imposter
  127944. */
  127945. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127946. /**
  127947. * Applies a force on the imposter
  127948. * @param impostor imposter to apply force
  127949. * @param force amount of force to be applied to the imposter
  127950. * @param contactPoint the location to apply the force on the imposter
  127951. */
  127952. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127953. /**
  127954. * Creates a physics body using the plugin
  127955. * @param impostor the imposter to create the physics body on
  127956. */
  127957. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127958. /**
  127959. * Removes the physics body from the imposter and disposes of the body's memory
  127960. * @param impostor imposter to remove the physics body from
  127961. */
  127962. removePhysicsBody(impostor: PhysicsImpostor): void;
  127963. /**
  127964. * Generates a joint
  127965. * @param impostorJoint the imposter joint to create the joint with
  127966. */
  127967. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127968. /**
  127969. * Removes a joint
  127970. * @param impostorJoint the imposter joint to remove the joint from
  127971. */
  127972. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127973. private _addMeshVerts;
  127974. /**
  127975. * Initialise the soft body vertices to match its object's (mesh) vertices
  127976. * Softbody vertices (nodes) are in world space and to match this
  127977. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  127978. * @param impostor to create the softbody for
  127979. */
  127980. private _softVertexData;
  127981. /**
  127982. * Create an impostor's soft body
  127983. * @param impostor to create the softbody for
  127984. */
  127985. private _createSoftbody;
  127986. /**
  127987. * Create cloth for an impostor
  127988. * @param impostor to create the softbody for
  127989. */
  127990. private _createCloth;
  127991. /**
  127992. * Create rope for an impostor
  127993. * @param impostor to create the softbody for
  127994. */
  127995. private _createRope;
  127996. /**
  127997. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  127998. * @param impostor to create the custom physics shape for
  127999. */
  128000. private _createCustom;
  128001. private _addHullVerts;
  128002. private _createShape;
  128003. /**
  128004. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128005. * @param impostor imposter containing the physics body and babylon object
  128006. */
  128007. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128008. /**
  128009. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128010. * @param impostor imposter containing the physics body and babylon object
  128011. * @param newPosition new position
  128012. * @param newRotation new rotation
  128013. */
  128014. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128015. /**
  128016. * If this plugin is supported
  128017. * @returns true if its supported
  128018. */
  128019. isSupported(): boolean;
  128020. /**
  128021. * Sets the linear velocity of the physics body
  128022. * @param impostor imposter to set the velocity on
  128023. * @param velocity velocity to set
  128024. */
  128025. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128026. /**
  128027. * Sets the angular velocity of the physics body
  128028. * @param impostor imposter to set the velocity on
  128029. * @param velocity velocity to set
  128030. */
  128031. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128032. /**
  128033. * gets the linear velocity
  128034. * @param impostor imposter to get linear velocity from
  128035. * @returns linear velocity
  128036. */
  128037. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128038. /**
  128039. * gets the angular velocity
  128040. * @param impostor imposter to get angular velocity from
  128041. * @returns angular velocity
  128042. */
  128043. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128044. /**
  128045. * Sets the mass of physics body
  128046. * @param impostor imposter to set the mass on
  128047. * @param mass mass to set
  128048. */
  128049. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128050. /**
  128051. * Gets the mass of the physics body
  128052. * @param impostor imposter to get the mass from
  128053. * @returns mass
  128054. */
  128055. getBodyMass(impostor: PhysicsImpostor): number;
  128056. /**
  128057. * Gets friction of the impostor
  128058. * @param impostor impostor to get friction from
  128059. * @returns friction value
  128060. */
  128061. getBodyFriction(impostor: PhysicsImpostor): number;
  128062. /**
  128063. * Sets friction of the impostor
  128064. * @param impostor impostor to set friction on
  128065. * @param friction friction value
  128066. */
  128067. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128068. /**
  128069. * Gets restitution of the impostor
  128070. * @param impostor impostor to get restitution from
  128071. * @returns restitution value
  128072. */
  128073. getBodyRestitution(impostor: PhysicsImpostor): number;
  128074. /**
  128075. * Sets resitution of the impostor
  128076. * @param impostor impostor to set resitution on
  128077. * @param restitution resitution value
  128078. */
  128079. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128080. /**
  128081. * Gets pressure inside the impostor
  128082. * @param impostor impostor to get pressure from
  128083. * @returns pressure value
  128084. */
  128085. getBodyPressure(impostor: PhysicsImpostor): number;
  128086. /**
  128087. * Sets pressure inside a soft body impostor
  128088. * Cloth and rope must remain 0 pressure
  128089. * @param impostor impostor to set pressure on
  128090. * @param pressure pressure value
  128091. */
  128092. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128093. /**
  128094. * Gets stiffness of the impostor
  128095. * @param impostor impostor to get stiffness from
  128096. * @returns pressure value
  128097. */
  128098. getBodyStiffness(impostor: PhysicsImpostor): number;
  128099. /**
  128100. * Sets stiffness of the impostor
  128101. * @param impostor impostor to set stiffness on
  128102. * @param stiffness stiffness value from 0 to 1
  128103. */
  128104. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128105. /**
  128106. * Gets velocityIterations of the impostor
  128107. * @param impostor impostor to get velocity iterations from
  128108. * @returns velocityIterations value
  128109. */
  128110. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128111. /**
  128112. * Sets velocityIterations of the impostor
  128113. * @param impostor impostor to set velocity iterations on
  128114. * @param velocityIterations velocityIterations value
  128115. */
  128116. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128117. /**
  128118. * Gets positionIterations of the impostor
  128119. * @param impostor impostor to get position iterations from
  128120. * @returns positionIterations value
  128121. */
  128122. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128123. /**
  128124. * Sets positionIterations of the impostor
  128125. * @param impostor impostor to set position on
  128126. * @param positionIterations positionIterations value
  128127. */
  128128. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128129. /**
  128130. * Append an anchor to a cloth object
  128131. * @param impostor is the cloth impostor to add anchor to
  128132. * @param otherImpostor is the rigid impostor to anchor to
  128133. * @param width ratio across width from 0 to 1
  128134. * @param height ratio up height from 0 to 1
  128135. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128136. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128137. */
  128138. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128139. /**
  128140. * Append an hook to a rope object
  128141. * @param impostor is the rope impostor to add hook to
  128142. * @param otherImpostor is the rigid impostor to hook to
  128143. * @param length ratio along the rope from 0 to 1
  128144. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128145. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128146. */
  128147. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128148. /**
  128149. * Sleeps the physics body and stops it from being active
  128150. * @param impostor impostor to sleep
  128151. */
  128152. sleepBody(impostor: PhysicsImpostor): void;
  128153. /**
  128154. * Activates the physics body
  128155. * @param impostor impostor to activate
  128156. */
  128157. wakeUpBody(impostor: PhysicsImpostor): void;
  128158. /**
  128159. * Updates the distance parameters of the joint
  128160. * @param joint joint to update
  128161. * @param maxDistance maximum distance of the joint
  128162. * @param minDistance minimum distance of the joint
  128163. */
  128164. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128165. /**
  128166. * Sets a motor on the joint
  128167. * @param joint joint to set motor on
  128168. * @param speed speed of the motor
  128169. * @param maxForce maximum force of the motor
  128170. * @param motorIndex index of the motor
  128171. */
  128172. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128173. /**
  128174. * Sets the motors limit
  128175. * @param joint joint to set limit on
  128176. * @param upperLimit upper limit
  128177. * @param lowerLimit lower limit
  128178. */
  128179. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128180. /**
  128181. * Syncs the position and rotation of a mesh with the impostor
  128182. * @param mesh mesh to sync
  128183. * @param impostor impostor to update the mesh with
  128184. */
  128185. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128186. /**
  128187. * Gets the radius of the impostor
  128188. * @param impostor impostor to get radius from
  128189. * @returns the radius
  128190. */
  128191. getRadius(impostor: PhysicsImpostor): number;
  128192. /**
  128193. * Gets the box size of the impostor
  128194. * @param impostor impostor to get box size from
  128195. * @param result the resulting box size
  128196. */
  128197. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128198. /**
  128199. * Disposes of the impostor
  128200. */
  128201. dispose(): void;
  128202. /**
  128203. * Does a raycast in the physics world
  128204. * @param from when should the ray start?
  128205. * @param to when should the ray end?
  128206. * @returns PhysicsRaycastResult
  128207. */
  128208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128209. }
  128210. }
  128211. declare module BABYLON {
  128212. interface AbstractScene {
  128213. /**
  128214. * The list of reflection probes added to the scene
  128215. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128216. */
  128217. reflectionProbes: Array<ReflectionProbe>;
  128218. /**
  128219. * Removes the given reflection probe from this scene.
  128220. * @param toRemove The reflection probe to remove
  128221. * @returns The index of the removed reflection probe
  128222. */
  128223. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128224. /**
  128225. * Adds the given reflection probe to this scene.
  128226. * @param newReflectionProbe The reflection probe to add
  128227. */
  128228. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128229. }
  128230. /**
  128231. * Class used to generate realtime reflection / refraction cube textures
  128232. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128233. */
  128234. export class ReflectionProbe {
  128235. /** defines the name of the probe */
  128236. name: string;
  128237. private _scene;
  128238. private _renderTargetTexture;
  128239. private _projectionMatrix;
  128240. private _viewMatrix;
  128241. private _target;
  128242. private _add;
  128243. private _attachedMesh;
  128244. private _invertYAxis;
  128245. /** Gets or sets probe position (center of the cube map) */
  128246. position: Vector3;
  128247. /**
  128248. * Creates a new reflection probe
  128249. * @param name defines the name of the probe
  128250. * @param size defines the texture resolution (for each face)
  128251. * @param scene defines the hosting scene
  128252. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128253. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128254. */
  128255. constructor(
  128256. /** defines the name of the probe */
  128257. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128258. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128259. get samples(): number;
  128260. set samples(value: number);
  128261. /** Gets or sets the refresh rate to use (on every frame by default) */
  128262. get refreshRate(): number;
  128263. set refreshRate(value: number);
  128264. /**
  128265. * Gets the hosting scene
  128266. * @returns a Scene
  128267. */
  128268. getScene(): Scene;
  128269. /** Gets the internal CubeTexture used to render to */
  128270. get cubeTexture(): RenderTargetTexture;
  128271. /** Gets the list of meshes to render */
  128272. get renderList(): Nullable<AbstractMesh[]>;
  128273. /**
  128274. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128275. * @param mesh defines the mesh to attach to
  128276. */
  128277. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128278. /**
  128279. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128280. * @param renderingGroupId The rendering group id corresponding to its index
  128281. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128282. */
  128283. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128284. /**
  128285. * Clean all associated resources
  128286. */
  128287. dispose(): void;
  128288. /**
  128289. * Converts the reflection probe information to a readable string for debug purpose.
  128290. * @param fullDetails Supports for multiple levels of logging within scene loading
  128291. * @returns the human readable reflection probe info
  128292. */
  128293. toString(fullDetails?: boolean): string;
  128294. /**
  128295. * Get the class name of the relfection probe.
  128296. * @returns "ReflectionProbe"
  128297. */
  128298. getClassName(): string;
  128299. /**
  128300. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128301. * @returns The JSON representation of the texture
  128302. */
  128303. serialize(): any;
  128304. /**
  128305. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128306. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128307. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128308. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128309. * @returns The parsed reflection probe if successful
  128310. */
  128311. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128312. }
  128313. }
  128314. declare module BABYLON {
  128315. /** @hidden */
  128316. export var _BabylonLoaderRegistered: boolean;
  128317. /**
  128318. * Helps setting up some configuration for the babylon file loader.
  128319. */
  128320. export class BabylonFileLoaderConfiguration {
  128321. /**
  128322. * The loader does not allow injecting custom physix engine into the plugins.
  128323. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128324. * So you could set this variable to your engine import to make it work.
  128325. */
  128326. static LoaderInjectedPhysicsEngine: any;
  128327. }
  128328. }
  128329. declare module BABYLON {
  128330. /**
  128331. * The Physically based simple base material of BJS.
  128332. *
  128333. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128334. * It is used as the base class for both the specGloss and metalRough conventions.
  128335. */
  128336. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128337. /**
  128338. * Number of Simultaneous lights allowed on the material.
  128339. */
  128340. maxSimultaneousLights: number;
  128341. /**
  128342. * If sets to true, disables all the lights affecting the material.
  128343. */
  128344. disableLighting: boolean;
  128345. /**
  128346. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128347. */
  128348. environmentTexture: BaseTexture;
  128349. /**
  128350. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128351. */
  128352. invertNormalMapX: boolean;
  128353. /**
  128354. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128355. */
  128356. invertNormalMapY: boolean;
  128357. /**
  128358. * Normal map used in the model.
  128359. */
  128360. normalTexture: BaseTexture;
  128361. /**
  128362. * Emissivie color used to self-illuminate the model.
  128363. */
  128364. emissiveColor: Color3;
  128365. /**
  128366. * Emissivie texture used to self-illuminate the model.
  128367. */
  128368. emissiveTexture: BaseTexture;
  128369. /**
  128370. * Occlusion Channel Strenght.
  128371. */
  128372. occlusionStrength: number;
  128373. /**
  128374. * Occlusion Texture of the material (adding extra occlusion effects).
  128375. */
  128376. occlusionTexture: BaseTexture;
  128377. /**
  128378. * Defines the alpha limits in alpha test mode.
  128379. */
  128380. alphaCutOff: number;
  128381. /**
  128382. * Gets the current double sided mode.
  128383. */
  128384. get doubleSided(): boolean;
  128385. /**
  128386. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128387. */
  128388. set doubleSided(value: boolean);
  128389. /**
  128390. * Stores the pre-calculated light information of a mesh in a texture.
  128391. */
  128392. lightmapTexture: BaseTexture;
  128393. /**
  128394. * If true, the light map contains occlusion information instead of lighting info.
  128395. */
  128396. useLightmapAsShadowmap: boolean;
  128397. /**
  128398. * Instantiates a new PBRMaterial instance.
  128399. *
  128400. * @param name The material name
  128401. * @param scene The scene the material will be use in.
  128402. */
  128403. constructor(name: string, scene: Scene);
  128404. getClassName(): string;
  128405. }
  128406. }
  128407. declare module BABYLON {
  128408. /**
  128409. * The PBR material of BJS following the metal roughness convention.
  128410. *
  128411. * This fits to the PBR convention in the GLTF definition:
  128412. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128413. */
  128414. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128415. /**
  128416. * The base color has two different interpretations depending on the value of metalness.
  128417. * When the material is a metal, the base color is the specific measured reflectance value
  128418. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128419. * of the material.
  128420. */
  128421. baseColor: Color3;
  128422. /**
  128423. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128424. * well as opacity information in the alpha channel.
  128425. */
  128426. baseTexture: BaseTexture;
  128427. /**
  128428. * Specifies the metallic scalar value of the material.
  128429. * Can also be used to scale the metalness values of the metallic texture.
  128430. */
  128431. metallic: number;
  128432. /**
  128433. * Specifies the roughness scalar value of the material.
  128434. * Can also be used to scale the roughness values of the metallic texture.
  128435. */
  128436. roughness: number;
  128437. /**
  128438. * Texture containing both the metallic value in the B channel and the
  128439. * roughness value in the G channel to keep better precision.
  128440. */
  128441. metallicRoughnessTexture: BaseTexture;
  128442. /**
  128443. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128444. *
  128445. * @param name The material name
  128446. * @param scene The scene the material will be use in.
  128447. */
  128448. constructor(name: string, scene: Scene);
  128449. /**
  128450. * Return the currrent class name of the material.
  128451. */
  128452. getClassName(): string;
  128453. /**
  128454. * Makes a duplicate of the current material.
  128455. * @param name - name to use for the new material.
  128456. */
  128457. clone(name: string): PBRMetallicRoughnessMaterial;
  128458. /**
  128459. * Serialize the material to a parsable JSON object.
  128460. */
  128461. serialize(): any;
  128462. /**
  128463. * Parses a JSON object correponding to the serialize function.
  128464. */
  128465. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128466. }
  128467. }
  128468. declare module BABYLON {
  128469. /**
  128470. * The PBR material of BJS following the specular glossiness convention.
  128471. *
  128472. * This fits to the PBR convention in the GLTF definition:
  128473. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128474. */
  128475. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128476. /**
  128477. * Specifies the diffuse color of the material.
  128478. */
  128479. diffuseColor: Color3;
  128480. /**
  128481. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128482. * channel.
  128483. */
  128484. diffuseTexture: BaseTexture;
  128485. /**
  128486. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128487. */
  128488. specularColor: Color3;
  128489. /**
  128490. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128491. */
  128492. glossiness: number;
  128493. /**
  128494. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128495. */
  128496. specularGlossinessTexture: BaseTexture;
  128497. /**
  128498. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128499. *
  128500. * @param name The material name
  128501. * @param scene The scene the material will be use in.
  128502. */
  128503. constructor(name: string, scene: Scene);
  128504. /**
  128505. * Return the currrent class name of the material.
  128506. */
  128507. getClassName(): string;
  128508. /**
  128509. * Makes a duplicate of the current material.
  128510. * @param name - name to use for the new material.
  128511. */
  128512. clone(name: string): PBRSpecularGlossinessMaterial;
  128513. /**
  128514. * Serialize the material to a parsable JSON object.
  128515. */
  128516. serialize(): any;
  128517. /**
  128518. * Parses a JSON object correponding to the serialize function.
  128519. */
  128520. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128521. }
  128522. }
  128523. declare module BABYLON {
  128524. /**
  128525. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128526. * It can help converting any input color in a desired output one. This can then be used to create effects
  128527. * from sepia, black and white to sixties or futuristic rendering...
  128528. *
  128529. * The only supported format is currently 3dl.
  128530. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128531. */
  128532. export class ColorGradingTexture extends BaseTexture {
  128533. /**
  128534. * The current texture matrix. (will always be identity in color grading texture)
  128535. */
  128536. private _textureMatrix;
  128537. /**
  128538. * The texture URL.
  128539. */
  128540. url: string;
  128541. /**
  128542. * Empty line regex stored for GC.
  128543. */
  128544. private static _noneEmptyLineRegex;
  128545. private _engine;
  128546. /**
  128547. * Instantiates a ColorGradingTexture from the following parameters.
  128548. *
  128549. * @param url The location of the color gradind data (currently only supporting 3dl)
  128550. * @param scene The scene the texture will be used in
  128551. */
  128552. constructor(url: string, scene: Scene);
  128553. /**
  128554. * Returns the texture matrix used in most of the material.
  128555. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128556. */
  128557. getTextureMatrix(): Matrix;
  128558. /**
  128559. * Occurs when the file being loaded is a .3dl LUT file.
  128560. */
  128561. private load3dlTexture;
  128562. /**
  128563. * Starts the loading process of the texture.
  128564. */
  128565. private loadTexture;
  128566. /**
  128567. * Clones the color gradind texture.
  128568. */
  128569. clone(): ColorGradingTexture;
  128570. /**
  128571. * Called during delayed load for textures.
  128572. */
  128573. delayLoad(): void;
  128574. /**
  128575. * Parses a color grading texture serialized by Babylon.
  128576. * @param parsedTexture The texture information being parsedTexture
  128577. * @param scene The scene to load the texture in
  128578. * @param rootUrl The root url of the data assets to load
  128579. * @return A color gradind texture
  128580. */
  128581. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  128582. /**
  128583. * Serializes the LUT texture to json format.
  128584. */
  128585. serialize(): any;
  128586. }
  128587. }
  128588. declare module BABYLON {
  128589. /**
  128590. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  128591. */
  128592. export class EquiRectangularCubeTexture extends BaseTexture {
  128593. /** The six faces of the cube. */
  128594. private static _FacesMapping;
  128595. private _noMipmap;
  128596. private _onLoad;
  128597. private _onError;
  128598. /** The size of the cubemap. */
  128599. private _size;
  128600. /** The buffer of the image. */
  128601. private _buffer;
  128602. /** The width of the input image. */
  128603. private _width;
  128604. /** The height of the input image. */
  128605. private _height;
  128606. /** The URL to the image. */
  128607. url: string;
  128608. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  128609. coordinatesMode: number;
  128610. /**
  128611. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  128612. * @param url The location of the image
  128613. * @param scene The scene the texture will be used in
  128614. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128615. * @param noMipmap Forces to not generate the mipmap if true
  128616. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128617. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128618. * @param onLoad — defines a callback called when texture is loaded
  128619. * @param onError — defines a callback called if there is an error
  128620. */
  128621. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  128622. /**
  128623. * Load the image data, by putting the image on a canvas and extracting its buffer.
  128624. */
  128625. private loadImage;
  128626. /**
  128627. * Convert the image buffer into a cubemap and create a CubeTexture.
  128628. */
  128629. private loadTexture;
  128630. /**
  128631. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  128632. * @param buffer The ArrayBuffer that should be converted.
  128633. * @returns The buffer as Float32Array.
  128634. */
  128635. private getFloat32ArrayFromArrayBuffer;
  128636. /**
  128637. * Get the current class name of the texture useful for serialization or dynamic coding.
  128638. * @returns "EquiRectangularCubeTexture"
  128639. */
  128640. getClassName(): string;
  128641. /**
  128642. * Create a clone of the current EquiRectangularCubeTexture and return it.
  128643. * @returns A clone of the current EquiRectangularCubeTexture.
  128644. */
  128645. clone(): EquiRectangularCubeTexture;
  128646. }
  128647. }
  128648. declare module BABYLON {
  128649. /**
  128650. * Based on jsTGALoader - Javascript loader for TGA file
  128651. * By Vincent Thibault
  128652. * @see http://blog.robrowser.com/javascript-tga-loader.html
  128653. */
  128654. export class TGATools {
  128655. private static _TYPE_INDEXED;
  128656. private static _TYPE_RGB;
  128657. private static _TYPE_GREY;
  128658. private static _TYPE_RLE_INDEXED;
  128659. private static _TYPE_RLE_RGB;
  128660. private static _TYPE_RLE_GREY;
  128661. private static _ORIGIN_MASK;
  128662. private static _ORIGIN_SHIFT;
  128663. private static _ORIGIN_BL;
  128664. private static _ORIGIN_BR;
  128665. private static _ORIGIN_UL;
  128666. private static _ORIGIN_UR;
  128667. /**
  128668. * Gets the header of a TGA file
  128669. * @param data defines the TGA data
  128670. * @returns the header
  128671. */
  128672. static GetTGAHeader(data: Uint8Array): any;
  128673. /**
  128674. * Uploads TGA content to a Babylon Texture
  128675. * @hidden
  128676. */
  128677. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  128678. /** @hidden */
  128679. 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;
  128680. /** @hidden */
  128681. 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;
  128682. /** @hidden */
  128683. 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;
  128684. /** @hidden */
  128685. 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;
  128686. /** @hidden */
  128687. 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;
  128688. /** @hidden */
  128689. 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;
  128690. }
  128691. }
  128692. declare module BABYLON {
  128693. /**
  128694. * Implementation of the TGA Texture Loader.
  128695. * @hidden
  128696. */
  128697. export class _TGATextureLoader implements IInternalTextureLoader {
  128698. /**
  128699. * Defines wether the loader supports cascade loading the different faces.
  128700. */
  128701. readonly supportCascades: boolean;
  128702. /**
  128703. * This returns if the loader support the current file information.
  128704. * @param extension defines the file extension of the file being loaded
  128705. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128706. * @param fallback defines the fallback internal texture if any
  128707. * @param isBase64 defines whether the texture is encoded as a base64
  128708. * @param isBuffer defines whether the texture data are stored as a buffer
  128709. * @returns true if the loader can load the specified file
  128710. */
  128711. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128712. /**
  128713. * Transform the url before loading if required.
  128714. * @param rootUrl the url of the texture
  128715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128716. * @returns the transformed texture
  128717. */
  128718. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128719. /**
  128720. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128721. * @param rootUrl the url of the texture
  128722. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128723. * @returns the fallback texture
  128724. */
  128725. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128726. /**
  128727. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  128728. * @param data contains the texture data
  128729. * @param texture defines the BabylonJS internal texture
  128730. * @param createPolynomials will be true if polynomials have been requested
  128731. * @param onLoad defines the callback to trigger once the texture is ready
  128732. * @param onError defines the callback to trigger in case of error
  128733. */
  128734. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128735. /**
  128736. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128737. * @param data contains the texture data
  128738. * @param texture defines the BabylonJS internal texture
  128739. * @param callback defines the method to call once ready to upload
  128740. */
  128741. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128742. }
  128743. }
  128744. declare module BABYLON {
  128745. /**
  128746. * Info about the .basis files
  128747. */
  128748. class BasisFileInfo {
  128749. /**
  128750. * If the file has alpha
  128751. */
  128752. hasAlpha: boolean;
  128753. /**
  128754. * Info about each image of the basis file
  128755. */
  128756. images: Array<{
  128757. levels: Array<{
  128758. width: number;
  128759. height: number;
  128760. transcodedPixels: ArrayBufferView;
  128761. }>;
  128762. }>;
  128763. }
  128764. /**
  128765. * Result of transcoding a basis file
  128766. */
  128767. class TranscodeResult {
  128768. /**
  128769. * Info about the .basis file
  128770. */
  128771. fileInfo: BasisFileInfo;
  128772. /**
  128773. * Format to use when loading the file
  128774. */
  128775. format: number;
  128776. }
  128777. /**
  128778. * Configuration options for the Basis transcoder
  128779. */
  128780. export class BasisTranscodeConfiguration {
  128781. /**
  128782. * Supported compression formats used to determine the supported output format of the transcoder
  128783. */
  128784. supportedCompressionFormats?: {
  128785. /**
  128786. * etc1 compression format
  128787. */
  128788. etc1?: boolean;
  128789. /**
  128790. * s3tc compression format
  128791. */
  128792. s3tc?: boolean;
  128793. /**
  128794. * pvrtc compression format
  128795. */
  128796. pvrtc?: boolean;
  128797. /**
  128798. * etc2 compression format
  128799. */
  128800. etc2?: boolean;
  128801. };
  128802. /**
  128803. * If mipmap levels should be loaded for transcoded images (Default: true)
  128804. */
  128805. loadMipmapLevels?: boolean;
  128806. /**
  128807. * Index of a single image to load (Default: all images)
  128808. */
  128809. loadSingleImage?: number;
  128810. }
  128811. /**
  128812. * Used to load .Basis files
  128813. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  128814. */
  128815. export class BasisTools {
  128816. private static _IgnoreSupportedFormats;
  128817. /**
  128818. * URL to use when loading the basis transcoder
  128819. */
  128820. static JSModuleURL: string;
  128821. /**
  128822. * URL to use when loading the wasm module for the transcoder
  128823. */
  128824. static WasmModuleURL: string;
  128825. /**
  128826. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  128827. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  128828. * @returns internal format corresponding to the Basis format
  128829. */
  128830. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  128831. private static _WorkerPromise;
  128832. private static _Worker;
  128833. private static _actionId;
  128834. private static _CreateWorkerAsync;
  128835. /**
  128836. * Transcodes a loaded image file to compressed pixel data
  128837. * @param imageData image data to transcode
  128838. * @param config configuration options for the transcoding
  128839. * @returns a promise resulting in the transcoded image
  128840. */
  128841. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  128842. /**
  128843. * Loads a texture from the transcode result
  128844. * @param texture texture load to
  128845. * @param transcodeResult the result of transcoding the basis file to load from
  128846. */
  128847. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  128848. }
  128849. }
  128850. declare module BABYLON {
  128851. /**
  128852. * Loader for .basis file format
  128853. */
  128854. export class _BasisTextureLoader implements IInternalTextureLoader {
  128855. /**
  128856. * Defines whether the loader supports cascade loading the different faces.
  128857. */
  128858. readonly supportCascades: boolean;
  128859. /**
  128860. * This returns if the loader support the current file information.
  128861. * @param extension defines the file extension of the file being loaded
  128862. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128863. * @param fallback defines the fallback internal texture if any
  128864. * @param isBase64 defines whether the texture is encoded as a base64
  128865. * @param isBuffer defines whether the texture data are stored as a buffer
  128866. * @returns true if the loader can load the specified file
  128867. */
  128868. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128869. /**
  128870. * Transform the url before loading if required.
  128871. * @param rootUrl the url of the texture
  128872. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128873. * @returns the transformed texture
  128874. */
  128875. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128876. /**
  128877. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128878. * @param rootUrl the url of the texture
  128879. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128880. * @returns the fallback texture
  128881. */
  128882. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128883. /**
  128884. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  128885. * @param data contains the texture data
  128886. * @param texture defines the BabylonJS internal texture
  128887. * @param createPolynomials will be true if polynomials have been requested
  128888. * @param onLoad defines the callback to trigger once the texture is ready
  128889. * @param onError defines the callback to trigger in case of error
  128890. */
  128891. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128892. /**
  128893. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128894. * @param data contains the texture data
  128895. * @param texture defines the BabylonJS internal texture
  128896. * @param callback defines the method to call once ready to upload
  128897. */
  128898. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128899. }
  128900. }
  128901. declare module BABYLON {
  128902. /**
  128903. * 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.
  128904. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128905. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128906. */
  128907. export class CustomProceduralTexture extends ProceduralTexture {
  128908. private _animate;
  128909. private _time;
  128910. private _config;
  128911. private _texturePath;
  128912. /**
  128913. * Instantiates a new Custom Procedural Texture.
  128914. * 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.
  128915. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128916. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128917. * @param name Define the name of the texture
  128918. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  128919. * @param size Define the size of the texture to create
  128920. * @param scene Define the scene the texture belongs to
  128921. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  128922. * @param generateMipMaps Define if the texture should creates mip maps or not
  128923. */
  128924. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128925. private _loadJson;
  128926. /**
  128927. * Is the texture ready to be used ? (rendered at least once)
  128928. * @returns true if ready, otherwise, false.
  128929. */
  128930. isReady(): boolean;
  128931. /**
  128932. * Render the texture to its associated render target.
  128933. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  128934. */
  128935. render(useCameraPostProcess?: boolean): void;
  128936. /**
  128937. * Update the list of dependant textures samplers in the shader.
  128938. */
  128939. updateTextures(): void;
  128940. /**
  128941. * Update the uniform values of the procedural texture in the shader.
  128942. */
  128943. updateShaderUniforms(): void;
  128944. /**
  128945. * Define if the texture animates or not.
  128946. */
  128947. get animate(): boolean;
  128948. set animate(value: boolean);
  128949. }
  128950. }
  128951. declare module BABYLON {
  128952. /** @hidden */
  128953. export var noisePixelShader: {
  128954. name: string;
  128955. shader: string;
  128956. };
  128957. }
  128958. declare module BABYLON {
  128959. /**
  128960. * Class used to generate noise procedural textures
  128961. */
  128962. export class NoiseProceduralTexture extends ProceduralTexture {
  128963. private _time;
  128964. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  128965. brightness: number;
  128966. /** Defines the number of octaves to process */
  128967. octaves: number;
  128968. /** Defines the level of persistence (0.8 by default) */
  128969. persistence: number;
  128970. /** Gets or sets animation speed factor (default is 1) */
  128971. animationSpeedFactor: number;
  128972. /**
  128973. * Creates a new NoiseProceduralTexture
  128974. * @param name defines the name fo the texture
  128975. * @param size defines the size of the texture (default is 256)
  128976. * @param scene defines the hosting scene
  128977. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  128978. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  128979. */
  128980. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128981. private _updateShaderUniforms;
  128982. protected _getDefines(): string;
  128983. /** Generate the current state of the procedural texture */
  128984. render(useCameraPostProcess?: boolean): void;
  128985. /**
  128986. * Serializes this noise procedural texture
  128987. * @returns a serialized noise procedural texture object
  128988. */
  128989. serialize(): any;
  128990. /**
  128991. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  128992. * @param parsedTexture defines parsed texture data
  128993. * @param scene defines the current scene
  128994. * @param rootUrl defines the root URL containing noise procedural texture information
  128995. * @returns a parsed NoiseProceduralTexture
  128996. */
  128997. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  128998. }
  128999. }
  129000. declare module BABYLON {
  129001. /**
  129002. * Raw cube texture where the raw buffers are passed in
  129003. */
  129004. export class RawCubeTexture extends CubeTexture {
  129005. /**
  129006. * Creates a cube texture where the raw buffers are passed in.
  129007. * @param scene defines the scene the texture is attached to
  129008. * @param data defines the array of data to use to create each face
  129009. * @param size defines the size of the textures
  129010. * @param format defines the format of the data
  129011. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129012. * @param generateMipMaps defines if the engine should generate the mip levels
  129013. * @param invertY defines if data must be stored with Y axis inverted
  129014. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129015. * @param compression defines the compression used (null by default)
  129016. */
  129017. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129018. /**
  129019. * Updates the raw cube texture.
  129020. * @param data defines the data to store
  129021. * @param format defines the data format
  129022. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129023. * @param invertY defines if data must be stored with Y axis inverted
  129024. * @param compression defines the compression used (null by default)
  129025. * @param level defines which level of the texture to update
  129026. */
  129027. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129028. /**
  129029. * Updates a raw cube texture with RGBD encoded data.
  129030. * @param data defines the array of data [mipmap][face] to use to create each face
  129031. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129032. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129033. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129034. * @returns a promsie that resolves when the operation is complete
  129035. */
  129036. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129037. /**
  129038. * Clones the raw cube texture.
  129039. * @return a new cube texture
  129040. */
  129041. clone(): CubeTexture;
  129042. /** @hidden */
  129043. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129044. }
  129045. }
  129046. declare module BABYLON {
  129047. /**
  129048. * Class used to store 3D textures containing user data
  129049. */
  129050. export class RawTexture3D extends Texture {
  129051. /** Gets or sets the texture format to use */
  129052. format: number;
  129053. private _engine;
  129054. /**
  129055. * Create a new RawTexture3D
  129056. * @param data defines the data of the texture
  129057. * @param width defines the width of the texture
  129058. * @param height defines the height of the texture
  129059. * @param depth defines the depth of the texture
  129060. * @param format defines the texture format to use
  129061. * @param scene defines the hosting scene
  129062. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129063. * @param invertY defines if texture must be stored with Y axis inverted
  129064. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129065. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129066. */
  129067. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129068. /** Gets or sets the texture format to use */
  129069. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129070. /**
  129071. * Update the texture with new data
  129072. * @param data defines the data to store in the texture
  129073. */
  129074. update(data: ArrayBufferView): void;
  129075. }
  129076. }
  129077. declare module BABYLON {
  129078. /**
  129079. * Class used to store 2D array textures containing user data
  129080. */
  129081. export class RawTexture2DArray extends Texture {
  129082. /** Gets or sets the texture format to use */
  129083. format: number;
  129084. private _engine;
  129085. /**
  129086. * Create a new RawTexture2DArray
  129087. * @param data defines the data of the texture
  129088. * @param width defines the width of the texture
  129089. * @param height defines the height of the texture
  129090. * @param depth defines the number of layers of the texture
  129091. * @param format defines the texture format to use
  129092. * @param scene defines the hosting scene
  129093. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129094. * @param invertY defines if texture must be stored with Y axis inverted
  129095. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129096. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129097. */
  129098. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129099. /** Gets or sets the texture format to use */
  129100. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129101. /**
  129102. * Update the texture with new data
  129103. * @param data defines the data to store in the texture
  129104. */
  129105. update(data: ArrayBufferView): void;
  129106. }
  129107. }
  129108. declare module BABYLON {
  129109. /**
  129110. * Creates a refraction texture used by refraction channel of the standard material.
  129111. * It is like a mirror but to see through a material.
  129112. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129113. */
  129114. export class RefractionTexture extends RenderTargetTexture {
  129115. /**
  129116. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129117. * 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.
  129118. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129119. */
  129120. refractionPlane: Plane;
  129121. /**
  129122. * Define how deep under the surface we should see.
  129123. */
  129124. depth: number;
  129125. /**
  129126. * Creates a refraction texture used by refraction channel of the standard material.
  129127. * It is like a mirror but to see through a material.
  129128. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129129. * @param name Define the texture name
  129130. * @param size Define the size of the underlying texture
  129131. * @param scene Define the scene the refraction belongs to
  129132. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129133. */
  129134. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129135. /**
  129136. * Clone the refraction texture.
  129137. * @returns the cloned texture
  129138. */
  129139. clone(): RefractionTexture;
  129140. /**
  129141. * Serialize the texture to a JSON representation you could use in Parse later on
  129142. * @returns the serialized JSON representation
  129143. */
  129144. serialize(): any;
  129145. }
  129146. }
  129147. declare module BABYLON {
  129148. /**
  129149. * Defines the options related to the creation of an HtmlElementTexture
  129150. */
  129151. export interface IHtmlElementTextureOptions {
  129152. /**
  129153. * Defines wether mip maps should be created or not.
  129154. */
  129155. generateMipMaps?: boolean;
  129156. /**
  129157. * Defines the sampling mode of the texture.
  129158. */
  129159. samplingMode?: number;
  129160. /**
  129161. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129162. */
  129163. engine: Nullable<ThinEngine>;
  129164. /**
  129165. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129166. */
  129167. scene: Nullable<Scene>;
  129168. }
  129169. /**
  129170. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129171. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129172. * is automatically managed.
  129173. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129174. * in your application.
  129175. *
  129176. * As the update is not automatic, you need to call them manually.
  129177. */
  129178. export class HtmlElementTexture extends BaseTexture {
  129179. /**
  129180. * The texture URL.
  129181. */
  129182. element: HTMLVideoElement | HTMLCanvasElement;
  129183. private static readonly DefaultOptions;
  129184. private _textureMatrix;
  129185. private _engine;
  129186. private _isVideo;
  129187. private _generateMipMaps;
  129188. private _samplingMode;
  129189. /**
  129190. * Instantiates a HtmlElementTexture from the following parameters.
  129191. *
  129192. * @param name Defines the name of the texture
  129193. * @param element Defines the video or canvas the texture is filled with
  129194. * @param options Defines the other none mandatory texture creation options
  129195. */
  129196. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129197. private _createInternalTexture;
  129198. /**
  129199. * Returns the texture matrix used in most of the material.
  129200. */
  129201. getTextureMatrix(): Matrix;
  129202. /**
  129203. * Updates the content of the texture.
  129204. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129205. */
  129206. update(invertY?: Nullable<boolean>): void;
  129207. }
  129208. }
  129209. declare module BABYLON {
  129210. /**
  129211. * Enum used to define the target of a block
  129212. */
  129213. export enum NodeMaterialBlockTargets {
  129214. /** Vertex shader */
  129215. Vertex = 1,
  129216. /** Fragment shader */
  129217. Fragment = 2,
  129218. /** Neutral */
  129219. Neutral = 4,
  129220. /** Vertex and Fragment */
  129221. VertexAndFragment = 3
  129222. }
  129223. }
  129224. declare module BABYLON {
  129225. /**
  129226. * Defines the kind of connection point for node based material
  129227. */
  129228. export enum NodeMaterialBlockConnectionPointTypes {
  129229. /** Float */
  129230. Float = 1,
  129231. /** Int */
  129232. Int = 2,
  129233. /** Vector2 */
  129234. Vector2 = 4,
  129235. /** Vector3 */
  129236. Vector3 = 8,
  129237. /** Vector4 */
  129238. Vector4 = 16,
  129239. /** Color3 */
  129240. Color3 = 32,
  129241. /** Color4 */
  129242. Color4 = 64,
  129243. /** Matrix */
  129244. Matrix = 128,
  129245. /** Detect type based on connection */
  129246. AutoDetect = 1024,
  129247. /** Output type that will be defined by input type */
  129248. BasedOnInput = 2048
  129249. }
  129250. }
  129251. declare module BABYLON {
  129252. /**
  129253. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129254. */
  129255. export enum NodeMaterialBlockConnectionPointMode {
  129256. /** Value is an uniform */
  129257. Uniform = 0,
  129258. /** Value is a mesh attribute */
  129259. Attribute = 1,
  129260. /** Value is a varying between vertex and fragment shaders */
  129261. Varying = 2,
  129262. /** Mode is undefined */
  129263. Undefined = 3
  129264. }
  129265. }
  129266. declare module BABYLON {
  129267. /**
  129268. * Enum used to define system values e.g. values automatically provided by the system
  129269. */
  129270. export enum NodeMaterialSystemValues {
  129271. /** World */
  129272. World = 1,
  129273. /** View */
  129274. View = 2,
  129275. /** Projection */
  129276. Projection = 3,
  129277. /** ViewProjection */
  129278. ViewProjection = 4,
  129279. /** WorldView */
  129280. WorldView = 5,
  129281. /** WorldViewProjection */
  129282. WorldViewProjection = 6,
  129283. /** CameraPosition */
  129284. CameraPosition = 7,
  129285. /** Fog Color */
  129286. FogColor = 8,
  129287. /** Delta time */
  129288. DeltaTime = 9
  129289. }
  129290. }
  129291. declare module BABYLON {
  129292. /**
  129293. * Root class for all node material optimizers
  129294. */
  129295. export class NodeMaterialOptimizer {
  129296. /**
  129297. * Function used to optimize a NodeMaterial graph
  129298. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129299. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129300. */
  129301. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129302. }
  129303. }
  129304. declare module BABYLON {
  129305. /**
  129306. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129307. */
  129308. export class TransformBlock extends NodeMaterialBlock {
  129309. /**
  129310. * Defines the value to use to complement W value to transform it to a Vector4
  129311. */
  129312. complementW: number;
  129313. /**
  129314. * Defines the value to use to complement z value to transform it to a Vector4
  129315. */
  129316. complementZ: number;
  129317. /**
  129318. * Creates a new TransformBlock
  129319. * @param name defines the block name
  129320. */
  129321. constructor(name: string);
  129322. /**
  129323. * Gets the current class name
  129324. * @returns the class name
  129325. */
  129326. getClassName(): string;
  129327. /**
  129328. * Gets the vector input
  129329. */
  129330. get vector(): NodeMaterialConnectionPoint;
  129331. /**
  129332. * Gets the output component
  129333. */
  129334. get output(): NodeMaterialConnectionPoint;
  129335. /**
  129336. * Gets the matrix transform input
  129337. */
  129338. get transform(): NodeMaterialConnectionPoint;
  129339. protected _buildBlock(state: NodeMaterialBuildState): this;
  129340. serialize(): any;
  129341. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129342. protected _dumpPropertiesCode(): string;
  129343. }
  129344. }
  129345. declare module BABYLON {
  129346. /**
  129347. * Block used to output the vertex position
  129348. */
  129349. export class VertexOutputBlock extends NodeMaterialBlock {
  129350. /**
  129351. * Creates a new VertexOutputBlock
  129352. * @param name defines the block name
  129353. */
  129354. constructor(name: string);
  129355. /**
  129356. * Gets the current class name
  129357. * @returns the class name
  129358. */
  129359. getClassName(): string;
  129360. /**
  129361. * Gets the vector input component
  129362. */
  129363. get vector(): NodeMaterialConnectionPoint;
  129364. protected _buildBlock(state: NodeMaterialBuildState): this;
  129365. }
  129366. }
  129367. declare module BABYLON {
  129368. /**
  129369. * Block used to output the final color
  129370. */
  129371. export class FragmentOutputBlock extends NodeMaterialBlock {
  129372. /**
  129373. * Create a new FragmentOutputBlock
  129374. * @param name defines the block name
  129375. */
  129376. constructor(name: string);
  129377. /**
  129378. * Gets the current class name
  129379. * @returns the class name
  129380. */
  129381. getClassName(): string;
  129382. /**
  129383. * Gets the rgba input component
  129384. */
  129385. get rgba(): NodeMaterialConnectionPoint;
  129386. /**
  129387. * Gets the rgb input component
  129388. */
  129389. get rgb(): NodeMaterialConnectionPoint;
  129390. /**
  129391. * Gets the a input component
  129392. */
  129393. get a(): NodeMaterialConnectionPoint;
  129394. protected _buildBlock(state: NodeMaterialBuildState): this;
  129395. }
  129396. }
  129397. declare module BABYLON {
  129398. /**
  129399. * Block used to read a reflection texture from a sampler
  129400. */
  129401. export class ReflectionTextureBlock extends NodeMaterialBlock {
  129402. private _define3DName;
  129403. private _defineCubicName;
  129404. private _defineExplicitName;
  129405. private _defineProjectionName;
  129406. private _defineLocalCubicName;
  129407. private _defineSphericalName;
  129408. private _definePlanarName;
  129409. private _defineEquirectangularName;
  129410. private _defineMirroredEquirectangularFixedName;
  129411. private _defineEquirectangularFixedName;
  129412. private _defineSkyboxName;
  129413. private _cubeSamplerName;
  129414. private _2DSamplerName;
  129415. private _positionUVWName;
  129416. private _directionWName;
  129417. private _reflectionCoordsName;
  129418. private _reflection2DCoordsName;
  129419. private _reflectionColorName;
  129420. private _reflectionMatrixName;
  129421. /**
  129422. * Gets or sets the texture associated with the node
  129423. */
  129424. texture: Nullable<BaseTexture>;
  129425. /**
  129426. * Create a new TextureBlock
  129427. * @param name defines the block name
  129428. */
  129429. constructor(name: string);
  129430. /**
  129431. * Gets the current class name
  129432. * @returns the class name
  129433. */
  129434. getClassName(): string;
  129435. /**
  129436. * Gets the world position input component
  129437. */
  129438. get position(): NodeMaterialConnectionPoint;
  129439. /**
  129440. * Gets the world position input component
  129441. */
  129442. get worldPosition(): NodeMaterialConnectionPoint;
  129443. /**
  129444. * Gets the world normal input component
  129445. */
  129446. get worldNormal(): NodeMaterialConnectionPoint;
  129447. /**
  129448. * Gets the world input component
  129449. */
  129450. get world(): NodeMaterialConnectionPoint;
  129451. /**
  129452. * Gets the camera (or eye) position component
  129453. */
  129454. get cameraPosition(): NodeMaterialConnectionPoint;
  129455. /**
  129456. * Gets the view input component
  129457. */
  129458. get view(): NodeMaterialConnectionPoint;
  129459. /**
  129460. * Gets the rgb output component
  129461. */
  129462. get rgb(): NodeMaterialConnectionPoint;
  129463. /**
  129464. * Gets the r output component
  129465. */
  129466. get r(): NodeMaterialConnectionPoint;
  129467. /**
  129468. * Gets the g output component
  129469. */
  129470. get g(): NodeMaterialConnectionPoint;
  129471. /**
  129472. * Gets the b output component
  129473. */
  129474. get b(): NodeMaterialConnectionPoint;
  129475. autoConfigure(material: NodeMaterial): void;
  129476. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129477. isReady(): boolean;
  129478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129479. private _injectVertexCode;
  129480. private _writeOutput;
  129481. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129482. protected _dumpPropertiesCode(): string;
  129483. serialize(): any;
  129484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129485. }
  129486. }
  129487. declare module BABYLON {
  129488. /**
  129489. * Interface used to configure the node material editor
  129490. */
  129491. export interface INodeMaterialEditorOptions {
  129492. /** Define the URl to load node editor script */
  129493. editorURL?: string;
  129494. }
  129495. /** @hidden */
  129496. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  129497. /** BONES */
  129498. NUM_BONE_INFLUENCERS: number;
  129499. BonesPerMesh: number;
  129500. BONETEXTURE: boolean;
  129501. /** MORPH TARGETS */
  129502. MORPHTARGETS: boolean;
  129503. MORPHTARGETS_NORMAL: boolean;
  129504. MORPHTARGETS_TANGENT: boolean;
  129505. MORPHTARGETS_UV: boolean;
  129506. NUM_MORPH_INFLUENCERS: number;
  129507. /** IMAGE PROCESSING */
  129508. IMAGEPROCESSING: boolean;
  129509. VIGNETTE: boolean;
  129510. VIGNETTEBLENDMODEMULTIPLY: boolean;
  129511. VIGNETTEBLENDMODEOPAQUE: boolean;
  129512. TONEMAPPING: boolean;
  129513. TONEMAPPING_ACES: boolean;
  129514. CONTRAST: boolean;
  129515. EXPOSURE: boolean;
  129516. COLORCURVES: boolean;
  129517. COLORGRADING: boolean;
  129518. COLORGRADING3D: boolean;
  129519. SAMPLER3DGREENDEPTH: boolean;
  129520. SAMPLER3DBGRMAP: boolean;
  129521. IMAGEPROCESSINGPOSTPROCESS: boolean;
  129522. /** MISC. */
  129523. BUMPDIRECTUV: number;
  129524. constructor();
  129525. setValue(name: string, value: boolean): void;
  129526. }
  129527. /**
  129528. * Class used to configure NodeMaterial
  129529. */
  129530. export interface INodeMaterialOptions {
  129531. /**
  129532. * Defines if blocks should emit comments
  129533. */
  129534. emitComments: boolean;
  129535. }
  129536. /**
  129537. * Class used to create a node based material built by assembling shader blocks
  129538. */
  129539. export class NodeMaterial extends PushMaterial {
  129540. private static _BuildIdGenerator;
  129541. private _options;
  129542. private _vertexCompilationState;
  129543. private _fragmentCompilationState;
  129544. private _sharedData;
  129545. private _buildId;
  129546. private _buildWasSuccessful;
  129547. private _cachedWorldViewMatrix;
  129548. private _cachedWorldViewProjectionMatrix;
  129549. private _optimizers;
  129550. private _animationFrame;
  129551. /** Define the URl to load node editor script */
  129552. static EditorURL: string;
  129553. private BJSNODEMATERIALEDITOR;
  129554. /** Get the inspector from bundle or global */
  129555. private _getGlobalNodeMaterialEditor;
  129556. /**
  129557. * Gets or sets data used by visual editor
  129558. * @see https://nme.babylonjs.com
  129559. */
  129560. editorData: any;
  129561. /**
  129562. * 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)
  129563. */
  129564. ignoreAlpha: boolean;
  129565. /**
  129566. * Defines the maximum number of lights that can be used in the material
  129567. */
  129568. maxSimultaneousLights: number;
  129569. /**
  129570. * Observable raised when the material is built
  129571. */
  129572. onBuildObservable: Observable<NodeMaterial>;
  129573. /**
  129574. * Gets or sets the root nodes of the material vertex shader
  129575. */
  129576. _vertexOutputNodes: NodeMaterialBlock[];
  129577. /**
  129578. * Gets or sets the root nodes of the material fragment (pixel) shader
  129579. */
  129580. _fragmentOutputNodes: NodeMaterialBlock[];
  129581. /** Gets or sets options to control the node material overall behavior */
  129582. get options(): INodeMaterialOptions;
  129583. set options(options: INodeMaterialOptions);
  129584. /**
  129585. * Default configuration related to image processing available in the standard Material.
  129586. */
  129587. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129588. /**
  129589. * Gets the image processing configuration used either in this material.
  129590. */
  129591. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  129592. /**
  129593. * Sets the Default image processing configuration used either in the this material.
  129594. *
  129595. * If sets to null, the scene one is in use.
  129596. */
  129597. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  129598. /**
  129599. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  129600. */
  129601. attachedBlocks: NodeMaterialBlock[];
  129602. /**
  129603. * Create a new node based material
  129604. * @param name defines the material name
  129605. * @param scene defines the hosting scene
  129606. * @param options defines creation option
  129607. */
  129608. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  129609. /**
  129610. * Gets the current class name of the material e.g. "NodeMaterial"
  129611. * @returns the class name
  129612. */
  129613. getClassName(): string;
  129614. /**
  129615. * Keep track of the image processing observer to allow dispose and replace.
  129616. */
  129617. private _imageProcessingObserver;
  129618. /**
  129619. * Attaches a new image processing configuration to the Standard Material.
  129620. * @param configuration
  129621. */
  129622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129623. /**
  129624. * Get a block by its name
  129625. * @param name defines the name of the block to retrieve
  129626. * @returns the required block or null if not found
  129627. */
  129628. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  129629. /**
  129630. * Get a block by its name
  129631. * @param predicate defines the predicate used to find the good candidate
  129632. * @returns the required block or null if not found
  129633. */
  129634. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  129635. /**
  129636. * Get an input block by its name
  129637. * @param predicate defines the predicate used to find the good candidate
  129638. * @returns the required input block or null if not found
  129639. */
  129640. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  129641. /**
  129642. * Gets the list of input blocks attached to this material
  129643. * @returns an array of InputBlocks
  129644. */
  129645. getInputBlocks(): InputBlock[];
  129646. /**
  129647. * Adds a new optimizer to the list of optimizers
  129648. * @param optimizer defines the optimizers to add
  129649. * @returns the current material
  129650. */
  129651. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129652. /**
  129653. * Remove an optimizer from the list of optimizers
  129654. * @param optimizer defines the optimizers to remove
  129655. * @returns the current material
  129656. */
  129657. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129658. /**
  129659. * Add a new block to the list of output nodes
  129660. * @param node defines the node to add
  129661. * @returns the current material
  129662. */
  129663. addOutputNode(node: NodeMaterialBlock): this;
  129664. /**
  129665. * Remove a block from the list of root nodes
  129666. * @param node defines the node to remove
  129667. * @returns the current material
  129668. */
  129669. removeOutputNode(node: NodeMaterialBlock): this;
  129670. private _addVertexOutputNode;
  129671. private _removeVertexOutputNode;
  129672. private _addFragmentOutputNode;
  129673. private _removeFragmentOutputNode;
  129674. /**
  129675. * Specifies if the material will require alpha blending
  129676. * @returns a boolean specifying if alpha blending is needed
  129677. */
  129678. needAlphaBlending(): boolean;
  129679. /**
  129680. * Specifies if this material should be rendered in alpha test mode
  129681. * @returns a boolean specifying if an alpha test is needed.
  129682. */
  129683. needAlphaTesting(): boolean;
  129684. private _initializeBlock;
  129685. private _resetDualBlocks;
  129686. /**
  129687. * Remove a block from the current node material
  129688. * @param block defines the block to remove
  129689. */
  129690. removeBlock(block: NodeMaterialBlock): void;
  129691. /**
  129692. * Build the material and generates the inner effect
  129693. * @param verbose defines if the build should log activity
  129694. */
  129695. build(verbose?: boolean): void;
  129696. /**
  129697. * Runs an otpimization phase to try to improve the shader code
  129698. */
  129699. optimize(): void;
  129700. private _prepareDefinesForAttributes;
  129701. /**
  129702. * Get if the submesh is ready to be used and all its information available.
  129703. * Child classes can use it to update shaders
  129704. * @param mesh defines the mesh to check
  129705. * @param subMesh defines which submesh to check
  129706. * @param useInstances specifies that instances should be used
  129707. * @returns a boolean indicating that the submesh is ready or not
  129708. */
  129709. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  129710. /**
  129711. * Get a string representing the shaders built by the current node graph
  129712. */
  129713. get compiledShaders(): string;
  129714. /**
  129715. * Binds the world matrix to the material
  129716. * @param world defines the world transformation matrix
  129717. */
  129718. bindOnlyWorldMatrix(world: Matrix): void;
  129719. /**
  129720. * Binds the submesh to this material by preparing the effect and shader to draw
  129721. * @param world defines the world transformation matrix
  129722. * @param mesh defines the mesh containing the submesh
  129723. * @param subMesh defines the submesh to bind the material to
  129724. */
  129725. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  129726. /**
  129727. * Gets the active textures from the material
  129728. * @returns an array of textures
  129729. */
  129730. getActiveTextures(): BaseTexture[];
  129731. /**
  129732. * Gets the list of texture blocks
  129733. * @returns an array of texture blocks
  129734. */
  129735. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  129736. /**
  129737. * Specifies if the material uses a texture
  129738. * @param texture defines the texture to check against the material
  129739. * @returns a boolean specifying if the material uses the texture
  129740. */
  129741. hasTexture(texture: BaseTexture): boolean;
  129742. /**
  129743. * Disposes the material
  129744. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  129745. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  129746. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  129747. */
  129748. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  129749. /** Creates the node editor window. */
  129750. private _createNodeEditor;
  129751. /**
  129752. * Launch the node material editor
  129753. * @param config Define the configuration of the editor
  129754. * @return a promise fulfilled when the node editor is visible
  129755. */
  129756. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  129757. /**
  129758. * Clear the current material
  129759. */
  129760. clear(): void;
  129761. /**
  129762. * Clear the current material and set it to a default state
  129763. */
  129764. setToDefault(): void;
  129765. /**
  129766. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  129767. * @param url defines the url to load from
  129768. * @returns a promise that will fullfil when the material is fully loaded
  129769. */
  129770. loadAsync(url: string): Promise<void>;
  129771. private _gatherBlocks;
  129772. /**
  129773. * Generate a string containing the code declaration required to create an equivalent of this material
  129774. * @returns a string
  129775. */
  129776. generateCode(): string;
  129777. /**
  129778. * Serializes this material in a JSON representation
  129779. * @returns the serialized material object
  129780. */
  129781. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  129782. private _restoreConnections;
  129783. /**
  129784. * Clear the current graph and load a new one from a serialization object
  129785. * @param source defines the JSON representation of the material
  129786. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129787. */
  129788. loadFromSerialization(source: any, rootUrl?: string): void;
  129789. /**
  129790. * Creates a node material from parsed material data
  129791. * @param source defines the JSON representation of the material
  129792. * @param scene defines the hosting scene
  129793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129794. * @returns a new node material
  129795. */
  129796. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  129797. /**
  129798. * Creates a new node material set to default basic configuration
  129799. * @param name defines the name of the material
  129800. * @param scene defines the hosting scene
  129801. * @returns a new NodeMaterial
  129802. */
  129803. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  129804. }
  129805. }
  129806. declare module BABYLON {
  129807. /**
  129808. * Block used to read a texture from a sampler
  129809. */
  129810. export class TextureBlock extends NodeMaterialBlock {
  129811. private _defineName;
  129812. private _linearDefineName;
  129813. private _tempTextureRead;
  129814. private _samplerName;
  129815. private _transformedUVName;
  129816. private _textureTransformName;
  129817. private _textureInfoName;
  129818. private _mainUVName;
  129819. private _mainUVDefineName;
  129820. /**
  129821. * Gets or sets the texture associated with the node
  129822. */
  129823. texture: Nullable<Texture>;
  129824. /**
  129825. * Create a new TextureBlock
  129826. * @param name defines the block name
  129827. */
  129828. constructor(name: string);
  129829. /**
  129830. * Gets the current class name
  129831. * @returns the class name
  129832. */
  129833. getClassName(): string;
  129834. /**
  129835. * Gets the uv input component
  129836. */
  129837. get uv(): NodeMaterialConnectionPoint;
  129838. /**
  129839. * Gets the rgba output component
  129840. */
  129841. get rgba(): NodeMaterialConnectionPoint;
  129842. /**
  129843. * Gets the rgb output component
  129844. */
  129845. get rgb(): NodeMaterialConnectionPoint;
  129846. /**
  129847. * Gets the r output component
  129848. */
  129849. get r(): NodeMaterialConnectionPoint;
  129850. /**
  129851. * Gets the g output component
  129852. */
  129853. get g(): NodeMaterialConnectionPoint;
  129854. /**
  129855. * Gets the b output component
  129856. */
  129857. get b(): NodeMaterialConnectionPoint;
  129858. /**
  129859. * Gets the a output component
  129860. */
  129861. get a(): NodeMaterialConnectionPoint;
  129862. get target(): NodeMaterialBlockTargets;
  129863. autoConfigure(material: NodeMaterial): void;
  129864. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  129865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129866. private _getTextureBase;
  129867. isReady(): boolean;
  129868. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129869. private get _isMixed();
  129870. private _injectVertexCode;
  129871. private _writeTextureRead;
  129872. private _writeOutput;
  129873. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129874. protected _dumpPropertiesCode(): string;
  129875. serialize(): any;
  129876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129877. }
  129878. }
  129879. declare module BABYLON {
  129880. /**
  129881. * Class used to store shared data between 2 NodeMaterialBuildState
  129882. */
  129883. export class NodeMaterialBuildStateSharedData {
  129884. /**
  129885. * Gets the list of emitted varyings
  129886. */
  129887. temps: string[];
  129888. /**
  129889. * Gets the list of emitted varyings
  129890. */
  129891. varyings: string[];
  129892. /**
  129893. * Gets the varying declaration string
  129894. */
  129895. varyingDeclaration: string;
  129896. /**
  129897. * Input blocks
  129898. */
  129899. inputBlocks: InputBlock[];
  129900. /**
  129901. * Input blocks
  129902. */
  129903. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  129904. /**
  129905. * Bindable blocks (Blocks that need to set data to the effect)
  129906. */
  129907. bindableBlocks: NodeMaterialBlock[];
  129908. /**
  129909. * List of blocks that can provide a compilation fallback
  129910. */
  129911. blocksWithFallbacks: NodeMaterialBlock[];
  129912. /**
  129913. * List of blocks that can provide a define update
  129914. */
  129915. blocksWithDefines: NodeMaterialBlock[];
  129916. /**
  129917. * List of blocks that can provide a repeatable content
  129918. */
  129919. repeatableContentBlocks: NodeMaterialBlock[];
  129920. /**
  129921. * List of blocks that can provide a dynamic list of uniforms
  129922. */
  129923. dynamicUniformBlocks: NodeMaterialBlock[];
  129924. /**
  129925. * List of blocks that can block the isReady function for the material
  129926. */
  129927. blockingBlocks: NodeMaterialBlock[];
  129928. /**
  129929. * Gets the list of animated inputs
  129930. */
  129931. animatedInputs: InputBlock[];
  129932. /**
  129933. * Build Id used to avoid multiple recompilations
  129934. */
  129935. buildId: number;
  129936. /** List of emitted variables */
  129937. variableNames: {
  129938. [key: string]: number;
  129939. };
  129940. /** List of emitted defines */
  129941. defineNames: {
  129942. [key: string]: number;
  129943. };
  129944. /** Should emit comments? */
  129945. emitComments: boolean;
  129946. /** Emit build activity */
  129947. verbose: boolean;
  129948. /** Gets or sets the hosting scene */
  129949. scene: Scene;
  129950. /**
  129951. * Gets the compilation hints emitted at compilation time
  129952. */
  129953. hints: {
  129954. needWorldViewMatrix: boolean;
  129955. needWorldViewProjectionMatrix: boolean;
  129956. needAlphaBlending: boolean;
  129957. needAlphaTesting: boolean;
  129958. };
  129959. /**
  129960. * List of compilation checks
  129961. */
  129962. checks: {
  129963. emitVertex: boolean;
  129964. emitFragment: boolean;
  129965. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  129966. };
  129967. /** Creates a new shared data */
  129968. constructor();
  129969. /**
  129970. * Emits console errors and exceptions if there is a failing check
  129971. */
  129972. emitErrors(): void;
  129973. }
  129974. }
  129975. declare module BABYLON {
  129976. /**
  129977. * Class used to store node based material build state
  129978. */
  129979. export class NodeMaterialBuildState {
  129980. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  129981. supportUniformBuffers: boolean;
  129982. /**
  129983. * Gets the list of emitted attributes
  129984. */
  129985. attributes: string[];
  129986. /**
  129987. * Gets the list of emitted uniforms
  129988. */
  129989. uniforms: string[];
  129990. /**
  129991. * Gets the list of emitted constants
  129992. */
  129993. constants: string[];
  129994. /**
  129995. * Gets the list of emitted samplers
  129996. */
  129997. samplers: string[];
  129998. /**
  129999. * Gets the list of emitted functions
  130000. */
  130001. functions: {
  130002. [key: string]: string;
  130003. };
  130004. /**
  130005. * Gets the list of emitted extensions
  130006. */
  130007. extensions: {
  130008. [key: string]: string;
  130009. };
  130010. /**
  130011. * Gets the target of the compilation state
  130012. */
  130013. target: NodeMaterialBlockTargets;
  130014. /**
  130015. * Gets the list of emitted counters
  130016. */
  130017. counters: {
  130018. [key: string]: number;
  130019. };
  130020. /**
  130021. * Shared data between multiple NodeMaterialBuildState instances
  130022. */
  130023. sharedData: NodeMaterialBuildStateSharedData;
  130024. /** @hidden */
  130025. _vertexState: NodeMaterialBuildState;
  130026. /** @hidden */
  130027. _attributeDeclaration: string;
  130028. /** @hidden */
  130029. _uniformDeclaration: string;
  130030. /** @hidden */
  130031. _constantDeclaration: string;
  130032. /** @hidden */
  130033. _samplerDeclaration: string;
  130034. /** @hidden */
  130035. _varyingTransfer: string;
  130036. private _repeatableContentAnchorIndex;
  130037. /** @hidden */
  130038. _builtCompilationString: string;
  130039. /**
  130040. * Gets the emitted compilation strings
  130041. */
  130042. compilationString: string;
  130043. /**
  130044. * Finalize the compilation strings
  130045. * @param state defines the current compilation state
  130046. */
  130047. finalize(state: NodeMaterialBuildState): void;
  130048. /** @hidden */
  130049. get _repeatableContentAnchor(): string;
  130050. /** @hidden */
  130051. _getFreeVariableName(prefix: string): string;
  130052. /** @hidden */
  130053. _getFreeDefineName(prefix: string): string;
  130054. /** @hidden */
  130055. _excludeVariableName(name: string): void;
  130056. /** @hidden */
  130057. _emit2DSampler(name: string): void;
  130058. /** @hidden */
  130059. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130060. /** @hidden */
  130061. _emitExtension(name: string, extension: string): void;
  130062. /** @hidden */
  130063. _emitFunction(name: string, code: string, comments: string): void;
  130064. /** @hidden */
  130065. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130066. replaceStrings?: {
  130067. search: RegExp;
  130068. replace: string;
  130069. }[];
  130070. repeatKey?: string;
  130071. }): string;
  130072. /** @hidden */
  130073. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130074. repeatKey?: string;
  130075. removeAttributes?: boolean;
  130076. removeUniforms?: boolean;
  130077. removeVaryings?: boolean;
  130078. removeIfDef?: boolean;
  130079. replaceStrings?: {
  130080. search: RegExp;
  130081. replace: string;
  130082. }[];
  130083. }, storeKey?: string): void;
  130084. /** @hidden */
  130085. _registerTempVariable(name: string): boolean;
  130086. /** @hidden */
  130087. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130088. /** @hidden */
  130089. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130090. /** @hidden */
  130091. _emitFloat(value: number): string;
  130092. }
  130093. }
  130094. declare module BABYLON {
  130095. /**
  130096. * Defines a block that can be used inside a node based material
  130097. */
  130098. export class NodeMaterialBlock {
  130099. private _buildId;
  130100. private _buildTarget;
  130101. private _target;
  130102. private _isFinalMerger;
  130103. private _isInput;
  130104. protected _isUnique: boolean;
  130105. /** @hidden */
  130106. _codeVariableName: string;
  130107. /** @hidden */
  130108. _inputs: NodeMaterialConnectionPoint[];
  130109. /** @hidden */
  130110. _outputs: NodeMaterialConnectionPoint[];
  130111. /** @hidden */
  130112. _preparationId: number;
  130113. /**
  130114. * Gets or sets the name of the block
  130115. */
  130116. name: string;
  130117. /**
  130118. * Gets or sets the unique id of the node
  130119. */
  130120. uniqueId: number;
  130121. /**
  130122. * Gets or sets the comments associated with this block
  130123. */
  130124. comments: string;
  130125. /**
  130126. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130127. */
  130128. get isUnique(): boolean;
  130129. /**
  130130. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130131. */
  130132. get isFinalMerger(): boolean;
  130133. /**
  130134. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130135. */
  130136. get isInput(): boolean;
  130137. /**
  130138. * Gets or sets the build Id
  130139. */
  130140. get buildId(): number;
  130141. set buildId(value: number);
  130142. /**
  130143. * Gets or sets the target of the block
  130144. */
  130145. get target(): NodeMaterialBlockTargets;
  130146. set target(value: NodeMaterialBlockTargets);
  130147. /**
  130148. * Gets the list of input points
  130149. */
  130150. get inputs(): NodeMaterialConnectionPoint[];
  130151. /** Gets the list of output points */
  130152. get outputs(): NodeMaterialConnectionPoint[];
  130153. /**
  130154. * Find an input by its name
  130155. * @param name defines the name of the input to look for
  130156. * @returns the input or null if not found
  130157. */
  130158. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130159. /**
  130160. * Find an output by its name
  130161. * @param name defines the name of the outputto look for
  130162. * @returns the output or null if not found
  130163. */
  130164. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130165. /**
  130166. * Creates a new NodeMaterialBlock
  130167. * @param name defines the block name
  130168. * @param target defines the target of that block (Vertex by default)
  130169. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130170. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130171. */
  130172. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130173. /**
  130174. * Initialize the block and prepare the context for build
  130175. * @param state defines the state that will be used for the build
  130176. */
  130177. initialize(state: NodeMaterialBuildState): void;
  130178. /**
  130179. * Bind data to effect. Will only be called for blocks with isBindable === true
  130180. * @param effect defines the effect to bind data to
  130181. * @param nodeMaterial defines the hosting NodeMaterial
  130182. * @param mesh defines the mesh that will be rendered
  130183. */
  130184. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130185. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130186. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130187. protected _writeFloat(value: number): string;
  130188. /**
  130189. * Gets the current class name e.g. "NodeMaterialBlock"
  130190. * @returns the class name
  130191. */
  130192. getClassName(): string;
  130193. /**
  130194. * Register a new input. Must be called inside a block constructor
  130195. * @param name defines the connection point name
  130196. * @param type defines the connection point type
  130197. * @param isOptional defines a boolean indicating that this input can be omitted
  130198. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130199. * @returns the current block
  130200. */
  130201. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130202. /**
  130203. * Register a new output. Must be called inside a block constructor
  130204. * @param name defines the connection point name
  130205. * @param type defines the connection point type
  130206. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130207. * @returns the current block
  130208. */
  130209. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130210. /**
  130211. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130212. * @param forOutput defines an optional connection point to check compatibility with
  130213. * @returns the first available input or null
  130214. */
  130215. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130216. /**
  130217. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130218. * @param forBlock defines an optional block to check compatibility with
  130219. * @returns the first available input or null
  130220. */
  130221. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130222. /**
  130223. * Gets the sibling of the given output
  130224. * @param current defines the current output
  130225. * @returns the next output in the list or null
  130226. */
  130227. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130228. /**
  130229. * Connect current block with another block
  130230. * @param other defines the block to connect with
  130231. * @param options define the various options to help pick the right connections
  130232. * @returns the current block
  130233. */
  130234. connectTo(other: NodeMaterialBlock, options?: {
  130235. input?: string;
  130236. output?: string;
  130237. outputSwizzle?: string;
  130238. }): this | undefined;
  130239. protected _buildBlock(state: NodeMaterialBuildState): void;
  130240. /**
  130241. * Add uniforms, samplers and uniform buffers at compilation time
  130242. * @param state defines the state to update
  130243. * @param nodeMaterial defines the node material requesting the update
  130244. * @param defines defines the material defines to update
  130245. * @param uniformBuffers defines the list of uniform buffer names
  130246. */
  130247. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130248. /**
  130249. * Add potential fallbacks if shader compilation fails
  130250. * @param mesh defines the mesh to be rendered
  130251. * @param fallbacks defines the current prioritized list of fallbacks
  130252. */
  130253. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130254. /**
  130255. * Initialize defines for shader compilation
  130256. * @param mesh defines the mesh to be rendered
  130257. * @param nodeMaterial defines the node material requesting the update
  130258. * @param defines defines the material defines to update
  130259. * @param useInstances specifies that instances should be used
  130260. */
  130261. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130262. /**
  130263. * Update defines for shader compilation
  130264. * @param mesh defines the mesh to be rendered
  130265. * @param nodeMaterial defines the node material requesting the update
  130266. * @param defines defines the material defines to update
  130267. * @param useInstances specifies that instances should be used
  130268. */
  130269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130270. /**
  130271. * Lets the block try to connect some inputs automatically
  130272. * @param material defines the hosting NodeMaterial
  130273. */
  130274. autoConfigure(material: NodeMaterial): void;
  130275. /**
  130276. * Function called when a block is declared as repeatable content generator
  130277. * @param vertexShaderState defines the current compilation state for the vertex shader
  130278. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130279. * @param mesh defines the mesh to be rendered
  130280. * @param defines defines the material defines to update
  130281. */
  130282. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130283. /**
  130284. * Checks if the block is ready
  130285. * @param mesh defines the mesh to be rendered
  130286. * @param nodeMaterial defines the node material requesting the update
  130287. * @param defines defines the material defines to update
  130288. * @param useInstances specifies that instances should be used
  130289. * @returns true if the block is ready
  130290. */
  130291. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130292. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130293. private _processBuild;
  130294. /**
  130295. * Compile the current node and generate the shader code
  130296. * @param state defines the current compilation state (uniforms, samplers, current string)
  130297. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130298. * @returns true if already built
  130299. */
  130300. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130301. protected _inputRename(name: string): string;
  130302. protected _outputRename(name: string): string;
  130303. protected _dumpPropertiesCode(): string;
  130304. /** @hidden */
  130305. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130306. /** @hidden */
  130307. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130308. /**
  130309. * Clone the current block to a new identical block
  130310. * @param scene defines the hosting scene
  130311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130312. * @returns a copy of the current block
  130313. */
  130314. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130315. /**
  130316. * Serializes this block in a JSON representation
  130317. * @returns the serialized block object
  130318. */
  130319. serialize(): any;
  130320. /** @hidden */
  130321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130322. /**
  130323. * Release resources
  130324. */
  130325. dispose(): void;
  130326. }
  130327. }
  130328. declare module BABYLON {
  130329. /**
  130330. * Enum defining the type of animations supported by InputBlock
  130331. */
  130332. export enum AnimatedInputBlockTypes {
  130333. /** No animation */
  130334. None = 0,
  130335. /** Time based animation. Will only work for floats */
  130336. Time = 1
  130337. }
  130338. }
  130339. declare module BABYLON {
  130340. /**
  130341. * Block used to expose an input value
  130342. */
  130343. export class InputBlock extends NodeMaterialBlock {
  130344. private _mode;
  130345. private _associatedVariableName;
  130346. private _storedValue;
  130347. private _valueCallback;
  130348. private _type;
  130349. private _animationType;
  130350. /** Gets or set a value used to limit the range of float values */
  130351. min: number;
  130352. /** Gets or set a value used to limit the range of float values */
  130353. max: number;
  130354. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  130355. matrixMode: number;
  130356. /** @hidden */
  130357. _systemValue: Nullable<NodeMaterialSystemValues>;
  130358. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  130359. visibleInInspector: boolean;
  130360. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  130361. isConstant: boolean;
  130362. /** Gets or sets the group to use to display this block in the Inspector */
  130363. groupInInspector: string;
  130364. /**
  130365. * Gets or sets the connection point type (default is float)
  130366. */
  130367. get type(): NodeMaterialBlockConnectionPointTypes;
  130368. /**
  130369. * Creates a new InputBlock
  130370. * @param name defines the block name
  130371. * @param target defines the target of that block (Vertex by default)
  130372. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  130373. */
  130374. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  130375. /**
  130376. * Gets the output component
  130377. */
  130378. get output(): NodeMaterialConnectionPoint;
  130379. /**
  130380. * Set the source of this connection point to a vertex attribute
  130381. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  130382. * @returns the current connection point
  130383. */
  130384. setAsAttribute(attributeName?: string): InputBlock;
  130385. /**
  130386. * Set the source of this connection point to a system value
  130387. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  130388. * @returns the current connection point
  130389. */
  130390. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  130391. /**
  130392. * Gets or sets the value of that point.
  130393. * Please note that this value will be ignored if valueCallback is defined
  130394. */
  130395. get value(): any;
  130396. set value(value: any);
  130397. /**
  130398. * Gets or sets a callback used to get the value of that point.
  130399. * Please note that setting this value will force the connection point to ignore the value property
  130400. */
  130401. get valueCallback(): () => any;
  130402. set valueCallback(value: () => any);
  130403. /**
  130404. * Gets or sets the associated variable name in the shader
  130405. */
  130406. get associatedVariableName(): string;
  130407. set associatedVariableName(value: string);
  130408. /** Gets or sets the type of animation applied to the input */
  130409. get animationType(): AnimatedInputBlockTypes;
  130410. set animationType(value: AnimatedInputBlockTypes);
  130411. /**
  130412. * Gets a boolean indicating that this connection point not defined yet
  130413. */
  130414. get isUndefined(): boolean;
  130415. /**
  130416. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  130417. * In this case the connection point name must be the name of the uniform to use.
  130418. * Can only be set on inputs
  130419. */
  130420. get isUniform(): boolean;
  130421. set isUniform(value: boolean);
  130422. /**
  130423. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  130424. * In this case the connection point name must be the name of the attribute to use
  130425. * Can only be set on inputs
  130426. */
  130427. get isAttribute(): boolean;
  130428. set isAttribute(value: boolean);
  130429. /**
  130430. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  130431. * Can only be set on exit points
  130432. */
  130433. get isVarying(): boolean;
  130434. set isVarying(value: boolean);
  130435. /**
  130436. * Gets a boolean indicating that the current connection point is a system value
  130437. */
  130438. get isSystemValue(): boolean;
  130439. /**
  130440. * Gets or sets the current well known value or null if not defined as a system value
  130441. */
  130442. get systemValue(): Nullable<NodeMaterialSystemValues>;
  130443. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  130444. /**
  130445. * Gets the current class name
  130446. * @returns the class name
  130447. */
  130448. getClassName(): string;
  130449. /**
  130450. * Animate the input if animationType !== None
  130451. * @param scene defines the rendering scene
  130452. */
  130453. animate(scene: Scene): void;
  130454. private _emitDefine;
  130455. initialize(state: NodeMaterialBuildState): void;
  130456. /**
  130457. * Set the input block to its default value (based on its type)
  130458. */
  130459. setDefaultValue(): void;
  130460. private _emitConstant;
  130461. private _emit;
  130462. /** @hidden */
  130463. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  130464. /** @hidden */
  130465. _transmit(effect: Effect, scene: Scene): void;
  130466. protected _buildBlock(state: NodeMaterialBuildState): void;
  130467. protected _dumpPropertiesCode(): string;
  130468. serialize(): any;
  130469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130470. }
  130471. }
  130472. declare module BABYLON {
  130473. /**
  130474. * Enum used to define the compatibility state between two connection points
  130475. */
  130476. export enum NodeMaterialConnectionPointCompatibilityStates {
  130477. /** Points are compatibles */
  130478. Compatible = 0,
  130479. /** Points are incompatible because of their types */
  130480. TypeIncompatible = 1,
  130481. /** Points are incompatible because of their targets (vertex vs fragment) */
  130482. TargetIncompatible = 2
  130483. }
  130484. /**
  130485. * Defines the direction of a connection point
  130486. */
  130487. export enum NodeMaterialConnectionPointDirection {
  130488. /** Input */
  130489. Input = 0,
  130490. /** Output */
  130491. Output = 1
  130492. }
  130493. /**
  130494. * Defines a connection point for a block
  130495. */
  130496. export class NodeMaterialConnectionPoint {
  130497. /** @hidden */
  130498. _ownerBlock: NodeMaterialBlock;
  130499. /** @hidden */
  130500. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  130501. private _endpoints;
  130502. private _associatedVariableName;
  130503. private _direction;
  130504. /** @hidden */
  130505. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130506. /** @hidden */
  130507. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130508. private _type;
  130509. /** @hidden */
  130510. _enforceAssociatedVariableName: boolean;
  130511. /** Gets the direction of the point */
  130512. get direction(): NodeMaterialConnectionPointDirection;
  130513. /**
  130514. * Gets or sets the additional types supported by this connection point
  130515. */
  130516. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130517. /**
  130518. * Gets or sets the additional types excluded by this connection point
  130519. */
  130520. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130521. /**
  130522. * Observable triggered when this point is connected
  130523. */
  130524. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  130525. /**
  130526. * Gets or sets the associated variable name in the shader
  130527. */
  130528. get associatedVariableName(): string;
  130529. set associatedVariableName(value: string);
  130530. /**
  130531. * Gets or sets the connection point type (default is float)
  130532. */
  130533. get type(): NodeMaterialBlockConnectionPointTypes;
  130534. set type(value: NodeMaterialBlockConnectionPointTypes);
  130535. /**
  130536. * Gets or sets the connection point name
  130537. */
  130538. name: string;
  130539. /**
  130540. * Gets or sets a boolean indicating that this connection point can be omitted
  130541. */
  130542. isOptional: boolean;
  130543. /**
  130544. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  130545. */
  130546. define: string;
  130547. /** @hidden */
  130548. _prioritizeVertex: boolean;
  130549. private _target;
  130550. /** Gets or sets the target of that connection point */
  130551. get target(): NodeMaterialBlockTargets;
  130552. set target(value: NodeMaterialBlockTargets);
  130553. /**
  130554. * Gets a boolean indicating that the current point is connected
  130555. */
  130556. get isConnected(): boolean;
  130557. /**
  130558. * Gets a boolean indicating that the current point is connected to an input block
  130559. */
  130560. get isConnectedToInputBlock(): boolean;
  130561. /**
  130562. * Gets a the connected input block (if any)
  130563. */
  130564. get connectInputBlock(): Nullable<InputBlock>;
  130565. /** Get the other side of the connection (if any) */
  130566. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  130567. /** Get the block that owns this connection point */
  130568. get ownerBlock(): NodeMaterialBlock;
  130569. /** Get the block connected on the other side of this connection (if any) */
  130570. get sourceBlock(): Nullable<NodeMaterialBlock>;
  130571. /** Get the block connected on the endpoints of this connection (if any) */
  130572. get connectedBlocks(): Array<NodeMaterialBlock>;
  130573. /** Gets the list of connected endpoints */
  130574. get endpoints(): NodeMaterialConnectionPoint[];
  130575. /** Gets a boolean indicating if that output point is connected to at least one input */
  130576. get hasEndpoints(): boolean;
  130577. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  130578. get isConnectedInVertexShader(): boolean;
  130579. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  130580. get isConnectedInFragmentShader(): boolean;
  130581. /**
  130582. * Creates a new connection point
  130583. * @param name defines the connection point name
  130584. * @param ownerBlock defines the block hosting this connection point
  130585. * @param direction defines the direction of the connection point
  130586. */
  130587. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  130588. /**
  130589. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  130590. * @returns the class name
  130591. */
  130592. getClassName(): string;
  130593. /**
  130594. * Gets a boolean indicating if the current point can be connected to another point
  130595. * @param connectionPoint defines the other connection point
  130596. * @returns a boolean
  130597. */
  130598. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  130599. /**
  130600. * Gets a number indicating if the current point can be connected to another point
  130601. * @param connectionPoint defines the other connection point
  130602. * @returns a number defining the compatibility state
  130603. */
  130604. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  130605. /**
  130606. * Connect this point to another connection point
  130607. * @param connectionPoint defines the other connection point
  130608. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  130609. * @returns the current connection point
  130610. */
  130611. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  130612. /**
  130613. * Disconnect this point from one of his endpoint
  130614. * @param endpoint defines the other connection point
  130615. * @returns the current connection point
  130616. */
  130617. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  130618. /**
  130619. * Serializes this point in a JSON representation
  130620. * @returns the serialized point object
  130621. */
  130622. serialize(): any;
  130623. /**
  130624. * Release resources
  130625. */
  130626. dispose(): void;
  130627. }
  130628. }
  130629. declare module BABYLON {
  130630. /**
  130631. * Block used to add support for vertex skinning (bones)
  130632. */
  130633. export class BonesBlock extends NodeMaterialBlock {
  130634. /**
  130635. * Creates a new BonesBlock
  130636. * @param name defines the block name
  130637. */
  130638. constructor(name: string);
  130639. /**
  130640. * Initialize the block and prepare the context for build
  130641. * @param state defines the state that will be used for the build
  130642. */
  130643. initialize(state: NodeMaterialBuildState): void;
  130644. /**
  130645. * Gets the current class name
  130646. * @returns the class name
  130647. */
  130648. getClassName(): string;
  130649. /**
  130650. * Gets the matrix indices input component
  130651. */
  130652. get matricesIndices(): NodeMaterialConnectionPoint;
  130653. /**
  130654. * Gets the matrix weights input component
  130655. */
  130656. get matricesWeights(): NodeMaterialConnectionPoint;
  130657. /**
  130658. * Gets the extra matrix indices input component
  130659. */
  130660. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  130661. /**
  130662. * Gets the extra matrix weights input component
  130663. */
  130664. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  130665. /**
  130666. * Gets the world input component
  130667. */
  130668. get world(): NodeMaterialConnectionPoint;
  130669. /**
  130670. * Gets the output component
  130671. */
  130672. get output(): NodeMaterialConnectionPoint;
  130673. autoConfigure(material: NodeMaterial): void;
  130674. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130676. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130677. protected _buildBlock(state: NodeMaterialBuildState): this;
  130678. }
  130679. }
  130680. declare module BABYLON {
  130681. /**
  130682. * Block used to add support for instances
  130683. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  130684. */
  130685. export class InstancesBlock extends NodeMaterialBlock {
  130686. /**
  130687. * Creates a new InstancesBlock
  130688. * @param name defines the block name
  130689. */
  130690. constructor(name: string);
  130691. /**
  130692. * Gets the current class name
  130693. * @returns the class name
  130694. */
  130695. getClassName(): string;
  130696. /**
  130697. * Gets the first world row input component
  130698. */
  130699. get world0(): NodeMaterialConnectionPoint;
  130700. /**
  130701. * Gets the second world row input component
  130702. */
  130703. get world1(): NodeMaterialConnectionPoint;
  130704. /**
  130705. * Gets the third world row input component
  130706. */
  130707. get world2(): NodeMaterialConnectionPoint;
  130708. /**
  130709. * Gets the forth world row input component
  130710. */
  130711. get world3(): NodeMaterialConnectionPoint;
  130712. /**
  130713. * Gets the world input component
  130714. */
  130715. get world(): NodeMaterialConnectionPoint;
  130716. /**
  130717. * Gets the output component
  130718. */
  130719. get output(): NodeMaterialConnectionPoint;
  130720. autoConfigure(material: NodeMaterial): void;
  130721. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130722. protected _buildBlock(state: NodeMaterialBuildState): this;
  130723. }
  130724. }
  130725. declare module BABYLON {
  130726. /**
  130727. * Block used to add morph targets support to vertex shader
  130728. */
  130729. export class MorphTargetsBlock extends NodeMaterialBlock {
  130730. private _repeatableContentAnchor;
  130731. private _repeatebleContentGenerated;
  130732. /**
  130733. * Create a new MorphTargetsBlock
  130734. * @param name defines the block name
  130735. */
  130736. constructor(name: string);
  130737. /**
  130738. * Gets the current class name
  130739. * @returns the class name
  130740. */
  130741. getClassName(): string;
  130742. /**
  130743. * Gets the position input component
  130744. */
  130745. get position(): NodeMaterialConnectionPoint;
  130746. /**
  130747. * Gets the normal input component
  130748. */
  130749. get normal(): NodeMaterialConnectionPoint;
  130750. /**
  130751. * Gets the tangent input component
  130752. */
  130753. get tangent(): NodeMaterialConnectionPoint;
  130754. /**
  130755. * Gets the tangent input component
  130756. */
  130757. get uv(): NodeMaterialConnectionPoint;
  130758. /**
  130759. * Gets the position output component
  130760. */
  130761. get positionOutput(): NodeMaterialConnectionPoint;
  130762. /**
  130763. * Gets the normal output component
  130764. */
  130765. get normalOutput(): NodeMaterialConnectionPoint;
  130766. /**
  130767. * Gets the tangent output component
  130768. */
  130769. get tangentOutput(): NodeMaterialConnectionPoint;
  130770. /**
  130771. * Gets the tangent output component
  130772. */
  130773. get uvOutput(): NodeMaterialConnectionPoint;
  130774. initialize(state: NodeMaterialBuildState): void;
  130775. autoConfigure(material: NodeMaterial): void;
  130776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130777. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130778. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130779. protected _buildBlock(state: NodeMaterialBuildState): this;
  130780. }
  130781. }
  130782. declare module BABYLON {
  130783. /**
  130784. * Block used to get data information from a light
  130785. */
  130786. export class LightInformationBlock extends NodeMaterialBlock {
  130787. private _lightDataUniformName;
  130788. private _lightColorUniformName;
  130789. private _lightTypeDefineName;
  130790. /**
  130791. * Gets or sets the light associated with this block
  130792. */
  130793. light: Nullable<Light>;
  130794. /**
  130795. * Creates a new LightInformationBlock
  130796. * @param name defines the block name
  130797. */
  130798. constructor(name: string);
  130799. /**
  130800. * Gets the current class name
  130801. * @returns the class name
  130802. */
  130803. getClassName(): string;
  130804. /**
  130805. * Gets the world position input component
  130806. */
  130807. get worldPosition(): NodeMaterialConnectionPoint;
  130808. /**
  130809. * Gets the direction output component
  130810. */
  130811. get direction(): NodeMaterialConnectionPoint;
  130812. /**
  130813. * Gets the direction output component
  130814. */
  130815. get color(): NodeMaterialConnectionPoint;
  130816. /**
  130817. * Gets the direction output component
  130818. */
  130819. get intensity(): NodeMaterialConnectionPoint;
  130820. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130821. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130822. protected _buildBlock(state: NodeMaterialBuildState): this;
  130823. serialize(): any;
  130824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130825. }
  130826. }
  130827. declare module BABYLON {
  130828. /**
  130829. * Block used to add image processing support to fragment shader
  130830. */
  130831. export class ImageProcessingBlock extends NodeMaterialBlock {
  130832. /**
  130833. * Create a new ImageProcessingBlock
  130834. * @param name defines the block name
  130835. */
  130836. constructor(name: string);
  130837. /**
  130838. * Gets the current class name
  130839. * @returns the class name
  130840. */
  130841. getClassName(): string;
  130842. /**
  130843. * Gets the color input component
  130844. */
  130845. get color(): NodeMaterialConnectionPoint;
  130846. /**
  130847. * Gets the output component
  130848. */
  130849. get output(): NodeMaterialConnectionPoint;
  130850. /**
  130851. * Initialize the block and prepare the context for build
  130852. * @param state defines the state that will be used for the build
  130853. */
  130854. initialize(state: NodeMaterialBuildState): void;
  130855. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  130856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130858. protected _buildBlock(state: NodeMaterialBuildState): this;
  130859. }
  130860. }
  130861. declare module BABYLON {
  130862. /**
  130863. * Block used to pertub normals based on a normal map
  130864. */
  130865. export class PerturbNormalBlock extends NodeMaterialBlock {
  130866. private _tangentSpaceParameterName;
  130867. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  130868. invertX: boolean;
  130869. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  130870. invertY: boolean;
  130871. /**
  130872. * Create a new PerturbNormalBlock
  130873. * @param name defines the block name
  130874. */
  130875. constructor(name: string);
  130876. /**
  130877. * Gets the current class name
  130878. * @returns the class name
  130879. */
  130880. getClassName(): string;
  130881. /**
  130882. * Gets the world position input component
  130883. */
  130884. get worldPosition(): NodeMaterialConnectionPoint;
  130885. /**
  130886. * Gets the world normal input component
  130887. */
  130888. get worldNormal(): NodeMaterialConnectionPoint;
  130889. /**
  130890. * Gets the uv input component
  130891. */
  130892. get uv(): NodeMaterialConnectionPoint;
  130893. /**
  130894. * Gets the normal map color input component
  130895. */
  130896. get normalMapColor(): NodeMaterialConnectionPoint;
  130897. /**
  130898. * Gets the strength input component
  130899. */
  130900. get strength(): NodeMaterialConnectionPoint;
  130901. /**
  130902. * Gets the output component
  130903. */
  130904. get output(): NodeMaterialConnectionPoint;
  130905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130906. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130907. autoConfigure(material: NodeMaterial): void;
  130908. protected _buildBlock(state: NodeMaterialBuildState): this;
  130909. protected _dumpPropertiesCode(): string;
  130910. serialize(): any;
  130911. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130912. }
  130913. }
  130914. declare module BABYLON {
  130915. /**
  130916. * Block used to discard a pixel if a value is smaller than a cutoff
  130917. */
  130918. export class DiscardBlock extends NodeMaterialBlock {
  130919. /**
  130920. * Create a new DiscardBlock
  130921. * @param name defines the block name
  130922. */
  130923. constructor(name: string);
  130924. /**
  130925. * Gets the current class name
  130926. * @returns the class name
  130927. */
  130928. getClassName(): string;
  130929. /**
  130930. * Gets the color input component
  130931. */
  130932. get value(): NodeMaterialConnectionPoint;
  130933. /**
  130934. * Gets the cutoff input component
  130935. */
  130936. get cutoff(): NodeMaterialConnectionPoint;
  130937. protected _buildBlock(state: NodeMaterialBuildState): this;
  130938. }
  130939. }
  130940. declare module BABYLON {
  130941. /**
  130942. * Block used to test if the fragment shader is front facing
  130943. */
  130944. export class FrontFacingBlock extends NodeMaterialBlock {
  130945. /**
  130946. * Creates a new FrontFacingBlock
  130947. * @param name defines the block name
  130948. */
  130949. constructor(name: string);
  130950. /**
  130951. * Gets the current class name
  130952. * @returns the class name
  130953. */
  130954. getClassName(): string;
  130955. /**
  130956. * Gets the output component
  130957. */
  130958. get output(): NodeMaterialConnectionPoint;
  130959. protected _buildBlock(state: NodeMaterialBuildState): this;
  130960. }
  130961. }
  130962. declare module BABYLON {
  130963. /**
  130964. * Block used to get the derivative value on x and y of a given input
  130965. */
  130966. export class DerivativeBlock extends NodeMaterialBlock {
  130967. /**
  130968. * Create a new DerivativeBlock
  130969. * @param name defines the block name
  130970. */
  130971. constructor(name: string);
  130972. /**
  130973. * Gets the current class name
  130974. * @returns the class name
  130975. */
  130976. getClassName(): string;
  130977. /**
  130978. * Gets the input component
  130979. */
  130980. get input(): NodeMaterialConnectionPoint;
  130981. /**
  130982. * Gets the derivative output on x
  130983. */
  130984. get dx(): NodeMaterialConnectionPoint;
  130985. /**
  130986. * Gets the derivative output on y
  130987. */
  130988. get dy(): NodeMaterialConnectionPoint;
  130989. protected _buildBlock(state: NodeMaterialBuildState): this;
  130990. }
  130991. }
  130992. declare module BABYLON {
  130993. /**
  130994. * Block used to add support for scene fog
  130995. */
  130996. export class FogBlock extends NodeMaterialBlock {
  130997. private _fogDistanceName;
  130998. private _fogParameters;
  130999. /**
  131000. * Create a new FogBlock
  131001. * @param name defines the block name
  131002. */
  131003. constructor(name: string);
  131004. /**
  131005. * Gets the current class name
  131006. * @returns the class name
  131007. */
  131008. getClassName(): string;
  131009. /**
  131010. * Gets the world position input component
  131011. */
  131012. get worldPosition(): NodeMaterialConnectionPoint;
  131013. /**
  131014. * Gets the view input component
  131015. */
  131016. get view(): NodeMaterialConnectionPoint;
  131017. /**
  131018. * Gets the color input component
  131019. */
  131020. get input(): NodeMaterialConnectionPoint;
  131021. /**
  131022. * Gets the fog color input component
  131023. */
  131024. get fogColor(): NodeMaterialConnectionPoint;
  131025. /**
  131026. * Gets the output component
  131027. */
  131028. get output(): NodeMaterialConnectionPoint;
  131029. autoConfigure(material: NodeMaterial): void;
  131030. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131031. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131032. protected _buildBlock(state: NodeMaterialBuildState): this;
  131033. }
  131034. }
  131035. declare module BABYLON {
  131036. /**
  131037. * Block used to add light in the fragment shader
  131038. */
  131039. export class LightBlock extends NodeMaterialBlock {
  131040. private _lightId;
  131041. /**
  131042. * Gets or sets the light associated with this block
  131043. */
  131044. light: Nullable<Light>;
  131045. /**
  131046. * Create a new LightBlock
  131047. * @param name defines the block name
  131048. */
  131049. constructor(name: string);
  131050. /**
  131051. * Gets the current class name
  131052. * @returns the class name
  131053. */
  131054. getClassName(): string;
  131055. /**
  131056. * Gets the world position input component
  131057. */
  131058. get worldPosition(): NodeMaterialConnectionPoint;
  131059. /**
  131060. * Gets the world normal input component
  131061. */
  131062. get worldNormal(): NodeMaterialConnectionPoint;
  131063. /**
  131064. * Gets the camera (or eye) position component
  131065. */
  131066. get cameraPosition(): NodeMaterialConnectionPoint;
  131067. /**
  131068. * Gets the glossiness component
  131069. */
  131070. get glossiness(): NodeMaterialConnectionPoint;
  131071. /**
  131072. * Gets the glossinness power component
  131073. */
  131074. get glossPower(): NodeMaterialConnectionPoint;
  131075. /**
  131076. * Gets the diffuse color component
  131077. */
  131078. get diffuseColor(): NodeMaterialConnectionPoint;
  131079. /**
  131080. * Gets the specular color component
  131081. */
  131082. get specularColor(): NodeMaterialConnectionPoint;
  131083. /**
  131084. * Gets the diffuse output component
  131085. */
  131086. get diffuseOutput(): NodeMaterialConnectionPoint;
  131087. /**
  131088. * Gets the specular output component
  131089. */
  131090. get specularOutput(): NodeMaterialConnectionPoint;
  131091. /**
  131092. * Gets the shadow output component
  131093. */
  131094. get shadow(): NodeMaterialConnectionPoint;
  131095. autoConfigure(material: NodeMaterial): void;
  131096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131097. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131098. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131099. private _injectVertexCode;
  131100. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131101. serialize(): any;
  131102. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131103. }
  131104. }
  131105. declare module BABYLON {
  131106. /**
  131107. * Block used to multiply 2 values
  131108. */
  131109. export class MultiplyBlock extends NodeMaterialBlock {
  131110. /**
  131111. * Creates a new MultiplyBlock
  131112. * @param name defines the block name
  131113. */
  131114. constructor(name: string);
  131115. /**
  131116. * Gets the current class name
  131117. * @returns the class name
  131118. */
  131119. getClassName(): string;
  131120. /**
  131121. * Gets the left operand input component
  131122. */
  131123. get left(): NodeMaterialConnectionPoint;
  131124. /**
  131125. * Gets the right operand input component
  131126. */
  131127. get right(): NodeMaterialConnectionPoint;
  131128. /**
  131129. * Gets the output component
  131130. */
  131131. get output(): NodeMaterialConnectionPoint;
  131132. protected _buildBlock(state: NodeMaterialBuildState): this;
  131133. }
  131134. }
  131135. declare module BABYLON {
  131136. /**
  131137. * Block used to add 2 vectors
  131138. */
  131139. export class AddBlock extends NodeMaterialBlock {
  131140. /**
  131141. * Creates a new AddBlock
  131142. * @param name defines the block name
  131143. */
  131144. constructor(name: string);
  131145. /**
  131146. * Gets the current class name
  131147. * @returns the class name
  131148. */
  131149. getClassName(): string;
  131150. /**
  131151. * Gets the left operand input component
  131152. */
  131153. get left(): NodeMaterialConnectionPoint;
  131154. /**
  131155. * Gets the right operand input component
  131156. */
  131157. get right(): NodeMaterialConnectionPoint;
  131158. /**
  131159. * Gets the output component
  131160. */
  131161. get output(): NodeMaterialConnectionPoint;
  131162. protected _buildBlock(state: NodeMaterialBuildState): this;
  131163. }
  131164. }
  131165. declare module BABYLON {
  131166. /**
  131167. * Block used to scale a vector by a float
  131168. */
  131169. export class ScaleBlock extends NodeMaterialBlock {
  131170. /**
  131171. * Creates a new ScaleBlock
  131172. * @param name defines the block name
  131173. */
  131174. constructor(name: string);
  131175. /**
  131176. * Gets the current class name
  131177. * @returns the class name
  131178. */
  131179. getClassName(): string;
  131180. /**
  131181. * Gets the input component
  131182. */
  131183. get input(): NodeMaterialConnectionPoint;
  131184. /**
  131185. * Gets the factor input component
  131186. */
  131187. get factor(): NodeMaterialConnectionPoint;
  131188. /**
  131189. * Gets the output component
  131190. */
  131191. get output(): NodeMaterialConnectionPoint;
  131192. protected _buildBlock(state: NodeMaterialBuildState): this;
  131193. }
  131194. }
  131195. declare module BABYLON {
  131196. /**
  131197. * Block used to clamp a float
  131198. */
  131199. export class ClampBlock extends NodeMaterialBlock {
  131200. /** Gets or sets the minimum range */
  131201. minimum: number;
  131202. /** Gets or sets the maximum range */
  131203. maximum: number;
  131204. /**
  131205. * Creates a new ClampBlock
  131206. * @param name defines the block name
  131207. */
  131208. constructor(name: string);
  131209. /**
  131210. * Gets the current class name
  131211. * @returns the class name
  131212. */
  131213. getClassName(): string;
  131214. /**
  131215. * Gets the value input component
  131216. */
  131217. get value(): NodeMaterialConnectionPoint;
  131218. /**
  131219. * Gets the output component
  131220. */
  131221. get output(): NodeMaterialConnectionPoint;
  131222. protected _buildBlock(state: NodeMaterialBuildState): this;
  131223. protected _dumpPropertiesCode(): string;
  131224. serialize(): any;
  131225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131226. }
  131227. }
  131228. declare module BABYLON {
  131229. /**
  131230. * Block used to apply a cross product between 2 vectors
  131231. */
  131232. export class CrossBlock extends NodeMaterialBlock {
  131233. /**
  131234. * Creates a new CrossBlock
  131235. * @param name defines the block name
  131236. */
  131237. constructor(name: string);
  131238. /**
  131239. * Gets the current class name
  131240. * @returns the class name
  131241. */
  131242. getClassName(): string;
  131243. /**
  131244. * Gets the left operand input component
  131245. */
  131246. get left(): NodeMaterialConnectionPoint;
  131247. /**
  131248. * Gets the right operand input component
  131249. */
  131250. get right(): NodeMaterialConnectionPoint;
  131251. /**
  131252. * Gets the output component
  131253. */
  131254. get output(): NodeMaterialConnectionPoint;
  131255. protected _buildBlock(state: NodeMaterialBuildState): this;
  131256. }
  131257. }
  131258. declare module BABYLON {
  131259. /**
  131260. * Block used to apply a dot product between 2 vectors
  131261. */
  131262. export class DotBlock extends NodeMaterialBlock {
  131263. /**
  131264. * Creates a new DotBlock
  131265. * @param name defines the block name
  131266. */
  131267. constructor(name: string);
  131268. /**
  131269. * Gets the current class name
  131270. * @returns the class name
  131271. */
  131272. getClassName(): string;
  131273. /**
  131274. * Gets the left operand input component
  131275. */
  131276. get left(): NodeMaterialConnectionPoint;
  131277. /**
  131278. * Gets the right operand input component
  131279. */
  131280. get right(): NodeMaterialConnectionPoint;
  131281. /**
  131282. * Gets the output component
  131283. */
  131284. get output(): NodeMaterialConnectionPoint;
  131285. protected _buildBlock(state: NodeMaterialBuildState): this;
  131286. }
  131287. }
  131288. declare module BABYLON {
  131289. /**
  131290. * Block used to remap a float from a range to a new one
  131291. */
  131292. export class RemapBlock extends NodeMaterialBlock {
  131293. /**
  131294. * Gets or sets the source range
  131295. */
  131296. sourceRange: Vector2;
  131297. /**
  131298. * Gets or sets the target range
  131299. */
  131300. targetRange: Vector2;
  131301. /**
  131302. * Creates a new RemapBlock
  131303. * @param name defines the block name
  131304. */
  131305. constructor(name: string);
  131306. /**
  131307. * Gets the current class name
  131308. * @returns the class name
  131309. */
  131310. getClassName(): string;
  131311. /**
  131312. * Gets the input component
  131313. */
  131314. get input(): NodeMaterialConnectionPoint;
  131315. /**
  131316. * Gets the source min input component
  131317. */
  131318. get sourceMin(): NodeMaterialConnectionPoint;
  131319. /**
  131320. * Gets the source max input component
  131321. */
  131322. get sourceMax(): NodeMaterialConnectionPoint;
  131323. /**
  131324. * Gets the target min input component
  131325. */
  131326. get targetMin(): NodeMaterialConnectionPoint;
  131327. /**
  131328. * Gets the target max input component
  131329. */
  131330. get targetMax(): NodeMaterialConnectionPoint;
  131331. /**
  131332. * Gets the output component
  131333. */
  131334. get output(): NodeMaterialConnectionPoint;
  131335. protected _buildBlock(state: NodeMaterialBuildState): this;
  131336. protected _dumpPropertiesCode(): string;
  131337. serialize(): any;
  131338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131339. }
  131340. }
  131341. declare module BABYLON {
  131342. /**
  131343. * Block used to normalize a vector
  131344. */
  131345. export class NormalizeBlock extends NodeMaterialBlock {
  131346. /**
  131347. * Creates a new NormalizeBlock
  131348. * @param name defines the block name
  131349. */
  131350. constructor(name: string);
  131351. /**
  131352. * Gets the current class name
  131353. * @returns the class name
  131354. */
  131355. getClassName(): string;
  131356. /**
  131357. * Gets the input component
  131358. */
  131359. get input(): NodeMaterialConnectionPoint;
  131360. /**
  131361. * Gets the output component
  131362. */
  131363. get output(): NodeMaterialConnectionPoint;
  131364. protected _buildBlock(state: NodeMaterialBuildState): this;
  131365. }
  131366. }
  131367. declare module BABYLON {
  131368. /**
  131369. * Operations supported by the Trigonometry block
  131370. */
  131371. export enum TrigonometryBlockOperations {
  131372. /** Cos */
  131373. Cos = 0,
  131374. /** Sin */
  131375. Sin = 1,
  131376. /** Abs */
  131377. Abs = 2,
  131378. /** Exp */
  131379. Exp = 3,
  131380. /** Exp2 */
  131381. Exp2 = 4,
  131382. /** Round */
  131383. Round = 5,
  131384. /** Floor */
  131385. Floor = 6,
  131386. /** Ceiling */
  131387. Ceiling = 7,
  131388. /** Square root */
  131389. Sqrt = 8,
  131390. /** Log */
  131391. Log = 9,
  131392. /** Tangent */
  131393. Tan = 10,
  131394. /** Arc tangent */
  131395. ArcTan = 11,
  131396. /** Arc cosinus */
  131397. ArcCos = 12,
  131398. /** Arc sinus */
  131399. ArcSin = 13,
  131400. /** Fraction */
  131401. Fract = 14,
  131402. /** Sign */
  131403. Sign = 15,
  131404. /** To radians (from degrees) */
  131405. Radians = 16,
  131406. /** To degrees (from radians) */
  131407. Degrees = 17
  131408. }
  131409. /**
  131410. * Block used to apply trigonometry operation to floats
  131411. */
  131412. export class TrigonometryBlock extends NodeMaterialBlock {
  131413. /**
  131414. * Gets or sets the operation applied by the block
  131415. */
  131416. operation: TrigonometryBlockOperations;
  131417. /**
  131418. * Creates a new TrigonometryBlock
  131419. * @param name defines the block name
  131420. */
  131421. constructor(name: string);
  131422. /**
  131423. * Gets the current class name
  131424. * @returns the class name
  131425. */
  131426. getClassName(): string;
  131427. /**
  131428. * Gets the input component
  131429. */
  131430. get input(): NodeMaterialConnectionPoint;
  131431. /**
  131432. * Gets the output component
  131433. */
  131434. get output(): NodeMaterialConnectionPoint;
  131435. protected _buildBlock(state: NodeMaterialBuildState): this;
  131436. serialize(): any;
  131437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131438. protected _dumpPropertiesCode(): string;
  131439. }
  131440. }
  131441. declare module BABYLON {
  131442. /**
  131443. * Block used to create a Color3/4 out of individual inputs (one for each component)
  131444. */
  131445. export class ColorMergerBlock extends NodeMaterialBlock {
  131446. /**
  131447. * Create a new ColorMergerBlock
  131448. * @param name defines the block name
  131449. */
  131450. constructor(name: string);
  131451. /**
  131452. * Gets the current class name
  131453. * @returns the class name
  131454. */
  131455. getClassName(): string;
  131456. /**
  131457. * Gets the rgb component (input)
  131458. */
  131459. get rgbIn(): NodeMaterialConnectionPoint;
  131460. /**
  131461. * Gets the r component (input)
  131462. */
  131463. get r(): NodeMaterialConnectionPoint;
  131464. /**
  131465. * Gets the g component (input)
  131466. */
  131467. get g(): NodeMaterialConnectionPoint;
  131468. /**
  131469. * Gets the b component (input)
  131470. */
  131471. get b(): NodeMaterialConnectionPoint;
  131472. /**
  131473. * Gets the a component (input)
  131474. */
  131475. get a(): NodeMaterialConnectionPoint;
  131476. /**
  131477. * Gets the rgba component (output)
  131478. */
  131479. get rgba(): NodeMaterialConnectionPoint;
  131480. /**
  131481. * Gets the rgb component (output)
  131482. */
  131483. get rgbOut(): NodeMaterialConnectionPoint;
  131484. /**
  131485. * Gets the rgb component (output)
  131486. * @deprecated Please use rgbOut instead.
  131487. */
  131488. get rgb(): NodeMaterialConnectionPoint;
  131489. protected _buildBlock(state: NodeMaterialBuildState): this;
  131490. }
  131491. }
  131492. declare module BABYLON {
  131493. /**
  131494. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  131495. */
  131496. export class VectorMergerBlock extends NodeMaterialBlock {
  131497. /**
  131498. * Create a new VectorMergerBlock
  131499. * @param name defines the block name
  131500. */
  131501. constructor(name: string);
  131502. /**
  131503. * Gets the current class name
  131504. * @returns the class name
  131505. */
  131506. getClassName(): string;
  131507. /**
  131508. * Gets the xyz component (input)
  131509. */
  131510. get xyzIn(): NodeMaterialConnectionPoint;
  131511. /**
  131512. * Gets the xy component (input)
  131513. */
  131514. get xyIn(): NodeMaterialConnectionPoint;
  131515. /**
  131516. * Gets the x component (input)
  131517. */
  131518. get x(): NodeMaterialConnectionPoint;
  131519. /**
  131520. * Gets the y component (input)
  131521. */
  131522. get y(): NodeMaterialConnectionPoint;
  131523. /**
  131524. * Gets the z component (input)
  131525. */
  131526. get z(): NodeMaterialConnectionPoint;
  131527. /**
  131528. * Gets the w component (input)
  131529. */
  131530. get w(): NodeMaterialConnectionPoint;
  131531. /**
  131532. * Gets the xyzw component (output)
  131533. */
  131534. get xyzw(): NodeMaterialConnectionPoint;
  131535. /**
  131536. * Gets the xyz component (output)
  131537. */
  131538. get xyzOut(): NodeMaterialConnectionPoint;
  131539. /**
  131540. * Gets the xy component (output)
  131541. */
  131542. get xyOut(): NodeMaterialConnectionPoint;
  131543. /**
  131544. * Gets the xy component (output)
  131545. * @deprecated Please use xyOut instead.
  131546. */
  131547. get xy(): NodeMaterialConnectionPoint;
  131548. /**
  131549. * Gets the xyz component (output)
  131550. * @deprecated Please use xyzOut instead.
  131551. */
  131552. get xyz(): NodeMaterialConnectionPoint;
  131553. protected _buildBlock(state: NodeMaterialBuildState): this;
  131554. }
  131555. }
  131556. declare module BABYLON {
  131557. /**
  131558. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  131559. */
  131560. export class ColorSplitterBlock extends NodeMaterialBlock {
  131561. /**
  131562. * Create a new ColorSplitterBlock
  131563. * @param name defines the block name
  131564. */
  131565. constructor(name: string);
  131566. /**
  131567. * Gets the current class name
  131568. * @returns the class name
  131569. */
  131570. getClassName(): string;
  131571. /**
  131572. * Gets the rgba component (input)
  131573. */
  131574. get rgba(): NodeMaterialConnectionPoint;
  131575. /**
  131576. * Gets the rgb component (input)
  131577. */
  131578. get rgbIn(): NodeMaterialConnectionPoint;
  131579. /**
  131580. * Gets the rgb component (output)
  131581. */
  131582. get rgbOut(): NodeMaterialConnectionPoint;
  131583. /**
  131584. * Gets the r component (output)
  131585. */
  131586. get r(): NodeMaterialConnectionPoint;
  131587. /**
  131588. * Gets the g component (output)
  131589. */
  131590. get g(): NodeMaterialConnectionPoint;
  131591. /**
  131592. * Gets the b component (output)
  131593. */
  131594. get b(): NodeMaterialConnectionPoint;
  131595. /**
  131596. * Gets the a component (output)
  131597. */
  131598. get a(): NodeMaterialConnectionPoint;
  131599. protected _inputRename(name: string): string;
  131600. protected _outputRename(name: string): string;
  131601. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131602. }
  131603. }
  131604. declare module BABYLON {
  131605. /**
  131606. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  131607. */
  131608. export class VectorSplitterBlock extends NodeMaterialBlock {
  131609. /**
  131610. * Create a new VectorSplitterBlock
  131611. * @param name defines the block name
  131612. */
  131613. constructor(name: string);
  131614. /**
  131615. * Gets the current class name
  131616. * @returns the class name
  131617. */
  131618. getClassName(): string;
  131619. /**
  131620. * Gets the xyzw component (input)
  131621. */
  131622. get xyzw(): NodeMaterialConnectionPoint;
  131623. /**
  131624. * Gets the xyz component (input)
  131625. */
  131626. get xyzIn(): NodeMaterialConnectionPoint;
  131627. /**
  131628. * Gets the xy component (input)
  131629. */
  131630. get xyIn(): NodeMaterialConnectionPoint;
  131631. /**
  131632. * Gets the xyz component (output)
  131633. */
  131634. get xyzOut(): NodeMaterialConnectionPoint;
  131635. /**
  131636. * Gets the xy component (output)
  131637. */
  131638. get xyOut(): NodeMaterialConnectionPoint;
  131639. /**
  131640. * Gets the x component (output)
  131641. */
  131642. get x(): NodeMaterialConnectionPoint;
  131643. /**
  131644. * Gets the y component (output)
  131645. */
  131646. get y(): NodeMaterialConnectionPoint;
  131647. /**
  131648. * Gets the z component (output)
  131649. */
  131650. get z(): NodeMaterialConnectionPoint;
  131651. /**
  131652. * Gets the w component (output)
  131653. */
  131654. get w(): NodeMaterialConnectionPoint;
  131655. protected _inputRename(name: string): string;
  131656. protected _outputRename(name: string): string;
  131657. protected _buildBlock(state: NodeMaterialBuildState): this;
  131658. }
  131659. }
  131660. declare module BABYLON {
  131661. /**
  131662. * Block used to lerp between 2 values
  131663. */
  131664. export class LerpBlock extends NodeMaterialBlock {
  131665. /**
  131666. * Creates a new LerpBlock
  131667. * @param name defines the block name
  131668. */
  131669. constructor(name: string);
  131670. /**
  131671. * Gets the current class name
  131672. * @returns the class name
  131673. */
  131674. getClassName(): string;
  131675. /**
  131676. * Gets the left operand input component
  131677. */
  131678. get left(): NodeMaterialConnectionPoint;
  131679. /**
  131680. * Gets the right operand input component
  131681. */
  131682. get right(): NodeMaterialConnectionPoint;
  131683. /**
  131684. * Gets the gradient operand input component
  131685. */
  131686. get gradient(): NodeMaterialConnectionPoint;
  131687. /**
  131688. * Gets the output component
  131689. */
  131690. get output(): NodeMaterialConnectionPoint;
  131691. protected _buildBlock(state: NodeMaterialBuildState): this;
  131692. }
  131693. }
  131694. declare module BABYLON {
  131695. /**
  131696. * Block used to divide 2 vectors
  131697. */
  131698. export class DivideBlock extends NodeMaterialBlock {
  131699. /**
  131700. * Creates a new DivideBlock
  131701. * @param name defines the block name
  131702. */
  131703. constructor(name: string);
  131704. /**
  131705. * Gets the current class name
  131706. * @returns the class name
  131707. */
  131708. getClassName(): string;
  131709. /**
  131710. * Gets the left operand input component
  131711. */
  131712. get left(): NodeMaterialConnectionPoint;
  131713. /**
  131714. * Gets the right operand input component
  131715. */
  131716. get right(): NodeMaterialConnectionPoint;
  131717. /**
  131718. * Gets the output component
  131719. */
  131720. get output(): NodeMaterialConnectionPoint;
  131721. protected _buildBlock(state: NodeMaterialBuildState): this;
  131722. }
  131723. }
  131724. declare module BABYLON {
  131725. /**
  131726. * Block used to subtract 2 vectors
  131727. */
  131728. export class SubtractBlock extends NodeMaterialBlock {
  131729. /**
  131730. * Creates a new SubtractBlock
  131731. * @param name defines the block name
  131732. */
  131733. constructor(name: string);
  131734. /**
  131735. * Gets the current class name
  131736. * @returns the class name
  131737. */
  131738. getClassName(): string;
  131739. /**
  131740. * Gets the left operand input component
  131741. */
  131742. get left(): NodeMaterialConnectionPoint;
  131743. /**
  131744. * Gets the right operand input component
  131745. */
  131746. get right(): NodeMaterialConnectionPoint;
  131747. /**
  131748. * Gets the output component
  131749. */
  131750. get output(): NodeMaterialConnectionPoint;
  131751. protected _buildBlock(state: NodeMaterialBuildState): this;
  131752. }
  131753. }
  131754. declare module BABYLON {
  131755. /**
  131756. * Block used to step a value
  131757. */
  131758. export class StepBlock extends NodeMaterialBlock {
  131759. /**
  131760. * Creates a new StepBlock
  131761. * @param name defines the block name
  131762. */
  131763. constructor(name: string);
  131764. /**
  131765. * Gets the current class name
  131766. * @returns the class name
  131767. */
  131768. getClassName(): string;
  131769. /**
  131770. * Gets the value operand input component
  131771. */
  131772. get value(): NodeMaterialConnectionPoint;
  131773. /**
  131774. * Gets the edge operand input component
  131775. */
  131776. get edge(): NodeMaterialConnectionPoint;
  131777. /**
  131778. * Gets the output component
  131779. */
  131780. get output(): NodeMaterialConnectionPoint;
  131781. protected _buildBlock(state: NodeMaterialBuildState): this;
  131782. }
  131783. }
  131784. declare module BABYLON {
  131785. /**
  131786. * Block used to get the opposite (1 - x) of a value
  131787. */
  131788. export class OneMinusBlock extends NodeMaterialBlock {
  131789. /**
  131790. * Creates a new OneMinusBlock
  131791. * @param name defines the block name
  131792. */
  131793. constructor(name: string);
  131794. /**
  131795. * Gets the current class name
  131796. * @returns the class name
  131797. */
  131798. getClassName(): string;
  131799. /**
  131800. * Gets the input component
  131801. */
  131802. get input(): NodeMaterialConnectionPoint;
  131803. /**
  131804. * Gets the output component
  131805. */
  131806. get output(): NodeMaterialConnectionPoint;
  131807. protected _buildBlock(state: NodeMaterialBuildState): this;
  131808. }
  131809. }
  131810. declare module BABYLON {
  131811. /**
  131812. * Block used to get the view direction
  131813. */
  131814. export class ViewDirectionBlock extends NodeMaterialBlock {
  131815. /**
  131816. * Creates a new ViewDirectionBlock
  131817. * @param name defines the block name
  131818. */
  131819. constructor(name: string);
  131820. /**
  131821. * Gets the current class name
  131822. * @returns the class name
  131823. */
  131824. getClassName(): string;
  131825. /**
  131826. * Gets the world position component
  131827. */
  131828. get worldPosition(): NodeMaterialConnectionPoint;
  131829. /**
  131830. * Gets the camera position component
  131831. */
  131832. get cameraPosition(): NodeMaterialConnectionPoint;
  131833. /**
  131834. * Gets the output component
  131835. */
  131836. get output(): NodeMaterialConnectionPoint;
  131837. autoConfigure(material: NodeMaterial): void;
  131838. protected _buildBlock(state: NodeMaterialBuildState): this;
  131839. }
  131840. }
  131841. declare module BABYLON {
  131842. /**
  131843. * Block used to compute fresnel value
  131844. */
  131845. export class FresnelBlock extends NodeMaterialBlock {
  131846. /**
  131847. * Create a new FresnelBlock
  131848. * @param name defines the block name
  131849. */
  131850. constructor(name: string);
  131851. /**
  131852. * Gets the current class name
  131853. * @returns the class name
  131854. */
  131855. getClassName(): string;
  131856. /**
  131857. * Gets the world normal input component
  131858. */
  131859. get worldNormal(): NodeMaterialConnectionPoint;
  131860. /**
  131861. * Gets the view direction input component
  131862. */
  131863. get viewDirection(): NodeMaterialConnectionPoint;
  131864. /**
  131865. * Gets the bias input component
  131866. */
  131867. get bias(): NodeMaterialConnectionPoint;
  131868. /**
  131869. * Gets the camera (or eye) position component
  131870. */
  131871. get power(): NodeMaterialConnectionPoint;
  131872. /**
  131873. * Gets the fresnel output component
  131874. */
  131875. get fresnel(): NodeMaterialConnectionPoint;
  131876. autoConfigure(material: NodeMaterial): void;
  131877. protected _buildBlock(state: NodeMaterialBuildState): this;
  131878. }
  131879. }
  131880. declare module BABYLON {
  131881. /**
  131882. * Block used to get the max of 2 values
  131883. */
  131884. export class MaxBlock extends NodeMaterialBlock {
  131885. /**
  131886. * Creates a new MaxBlock
  131887. * @param name defines the block name
  131888. */
  131889. constructor(name: string);
  131890. /**
  131891. * Gets the current class name
  131892. * @returns the class name
  131893. */
  131894. getClassName(): string;
  131895. /**
  131896. * Gets the left operand input component
  131897. */
  131898. get left(): NodeMaterialConnectionPoint;
  131899. /**
  131900. * Gets the right operand input component
  131901. */
  131902. get right(): NodeMaterialConnectionPoint;
  131903. /**
  131904. * Gets the output component
  131905. */
  131906. get output(): NodeMaterialConnectionPoint;
  131907. protected _buildBlock(state: NodeMaterialBuildState): this;
  131908. }
  131909. }
  131910. declare module BABYLON {
  131911. /**
  131912. * Block used to get the min of 2 values
  131913. */
  131914. export class MinBlock extends NodeMaterialBlock {
  131915. /**
  131916. * Creates a new MinBlock
  131917. * @param name defines the block name
  131918. */
  131919. constructor(name: string);
  131920. /**
  131921. * Gets the current class name
  131922. * @returns the class name
  131923. */
  131924. getClassName(): string;
  131925. /**
  131926. * Gets the left operand input component
  131927. */
  131928. get left(): NodeMaterialConnectionPoint;
  131929. /**
  131930. * Gets the right operand input component
  131931. */
  131932. get right(): NodeMaterialConnectionPoint;
  131933. /**
  131934. * Gets the output component
  131935. */
  131936. get output(): NodeMaterialConnectionPoint;
  131937. protected _buildBlock(state: NodeMaterialBuildState): this;
  131938. }
  131939. }
  131940. declare module BABYLON {
  131941. /**
  131942. * Block used to get the distance between 2 values
  131943. */
  131944. export class DistanceBlock extends NodeMaterialBlock {
  131945. /**
  131946. * Creates a new DistanceBlock
  131947. * @param name defines the block name
  131948. */
  131949. constructor(name: string);
  131950. /**
  131951. * Gets the current class name
  131952. * @returns the class name
  131953. */
  131954. getClassName(): string;
  131955. /**
  131956. * Gets the left operand input component
  131957. */
  131958. get left(): NodeMaterialConnectionPoint;
  131959. /**
  131960. * Gets the right operand input component
  131961. */
  131962. get right(): NodeMaterialConnectionPoint;
  131963. /**
  131964. * Gets the output component
  131965. */
  131966. get output(): NodeMaterialConnectionPoint;
  131967. protected _buildBlock(state: NodeMaterialBuildState): this;
  131968. }
  131969. }
  131970. declare module BABYLON {
  131971. /**
  131972. * Block used to get the length of a vector
  131973. */
  131974. export class LengthBlock extends NodeMaterialBlock {
  131975. /**
  131976. * Creates a new LengthBlock
  131977. * @param name defines the block name
  131978. */
  131979. constructor(name: string);
  131980. /**
  131981. * Gets the current class name
  131982. * @returns the class name
  131983. */
  131984. getClassName(): string;
  131985. /**
  131986. * Gets the value input component
  131987. */
  131988. get value(): NodeMaterialConnectionPoint;
  131989. /**
  131990. * Gets the output component
  131991. */
  131992. get output(): NodeMaterialConnectionPoint;
  131993. protected _buildBlock(state: NodeMaterialBuildState): this;
  131994. }
  131995. }
  131996. declare module BABYLON {
  131997. /**
  131998. * Block used to get negative version of a value (i.e. x * -1)
  131999. */
  132000. export class NegateBlock extends NodeMaterialBlock {
  132001. /**
  132002. * Creates a new NegateBlock
  132003. * @param name defines the block name
  132004. */
  132005. constructor(name: string);
  132006. /**
  132007. * Gets the current class name
  132008. * @returns the class name
  132009. */
  132010. getClassName(): string;
  132011. /**
  132012. * Gets the value input component
  132013. */
  132014. get value(): NodeMaterialConnectionPoint;
  132015. /**
  132016. * Gets the output component
  132017. */
  132018. get output(): NodeMaterialConnectionPoint;
  132019. protected _buildBlock(state: NodeMaterialBuildState): this;
  132020. }
  132021. }
  132022. declare module BABYLON {
  132023. /**
  132024. * Block used to get the value of the first parameter raised to the power of the second
  132025. */
  132026. export class PowBlock extends NodeMaterialBlock {
  132027. /**
  132028. * Creates a new PowBlock
  132029. * @param name defines the block name
  132030. */
  132031. constructor(name: string);
  132032. /**
  132033. * Gets the current class name
  132034. * @returns the class name
  132035. */
  132036. getClassName(): string;
  132037. /**
  132038. * Gets the value operand input component
  132039. */
  132040. get value(): NodeMaterialConnectionPoint;
  132041. /**
  132042. * Gets the power operand input component
  132043. */
  132044. get power(): NodeMaterialConnectionPoint;
  132045. /**
  132046. * Gets the output component
  132047. */
  132048. get output(): NodeMaterialConnectionPoint;
  132049. protected _buildBlock(state: NodeMaterialBuildState): this;
  132050. }
  132051. }
  132052. declare module BABYLON {
  132053. /**
  132054. * Block used to get a random number
  132055. */
  132056. export class RandomNumberBlock extends NodeMaterialBlock {
  132057. /**
  132058. * Creates a new RandomNumberBlock
  132059. * @param name defines the block name
  132060. */
  132061. constructor(name: string);
  132062. /**
  132063. * Gets the current class name
  132064. * @returns the class name
  132065. */
  132066. getClassName(): string;
  132067. /**
  132068. * Gets the seed input component
  132069. */
  132070. get seed(): NodeMaterialConnectionPoint;
  132071. /**
  132072. * Gets the output component
  132073. */
  132074. get output(): NodeMaterialConnectionPoint;
  132075. protected _buildBlock(state: NodeMaterialBuildState): this;
  132076. }
  132077. }
  132078. declare module BABYLON {
  132079. /**
  132080. * Block used to compute arc tangent of 2 values
  132081. */
  132082. export class ArcTan2Block extends NodeMaterialBlock {
  132083. /**
  132084. * Creates a new ArcTan2Block
  132085. * @param name defines the block name
  132086. */
  132087. constructor(name: string);
  132088. /**
  132089. * Gets the current class name
  132090. * @returns the class name
  132091. */
  132092. getClassName(): string;
  132093. /**
  132094. * Gets the x operand input component
  132095. */
  132096. get x(): NodeMaterialConnectionPoint;
  132097. /**
  132098. * Gets the y operand input component
  132099. */
  132100. get y(): NodeMaterialConnectionPoint;
  132101. /**
  132102. * Gets the output component
  132103. */
  132104. get output(): NodeMaterialConnectionPoint;
  132105. protected _buildBlock(state: NodeMaterialBuildState): this;
  132106. }
  132107. }
  132108. declare module BABYLON {
  132109. /**
  132110. * Block used to smooth step a value
  132111. */
  132112. export class SmoothStepBlock extends NodeMaterialBlock {
  132113. /**
  132114. * Creates a new SmoothStepBlock
  132115. * @param name defines the block name
  132116. */
  132117. constructor(name: string);
  132118. /**
  132119. * Gets the current class name
  132120. * @returns the class name
  132121. */
  132122. getClassName(): string;
  132123. /**
  132124. * Gets the value operand input component
  132125. */
  132126. get value(): NodeMaterialConnectionPoint;
  132127. /**
  132128. * Gets the first edge operand input component
  132129. */
  132130. get edge0(): NodeMaterialConnectionPoint;
  132131. /**
  132132. * Gets the second edge operand input component
  132133. */
  132134. get edge1(): NodeMaterialConnectionPoint;
  132135. /**
  132136. * Gets the output component
  132137. */
  132138. get output(): NodeMaterialConnectionPoint;
  132139. protected _buildBlock(state: NodeMaterialBuildState): this;
  132140. }
  132141. }
  132142. declare module BABYLON {
  132143. /**
  132144. * Block used to get the reciprocal (1 / x) of a value
  132145. */
  132146. export class ReciprocalBlock extends NodeMaterialBlock {
  132147. /**
  132148. * Creates a new ReciprocalBlock
  132149. * @param name defines the block name
  132150. */
  132151. constructor(name: string);
  132152. /**
  132153. * Gets the current class name
  132154. * @returns the class name
  132155. */
  132156. getClassName(): string;
  132157. /**
  132158. * Gets the input component
  132159. */
  132160. get input(): NodeMaterialConnectionPoint;
  132161. /**
  132162. * Gets the output component
  132163. */
  132164. get output(): NodeMaterialConnectionPoint;
  132165. protected _buildBlock(state: NodeMaterialBuildState): this;
  132166. }
  132167. }
  132168. declare module BABYLON {
  132169. /**
  132170. * Block used to replace a color by another one
  132171. */
  132172. export class ReplaceColorBlock extends NodeMaterialBlock {
  132173. /**
  132174. * Creates a new ReplaceColorBlock
  132175. * @param name defines the block name
  132176. */
  132177. constructor(name: string);
  132178. /**
  132179. * Gets the current class name
  132180. * @returns the class name
  132181. */
  132182. getClassName(): string;
  132183. /**
  132184. * Gets the value input component
  132185. */
  132186. get value(): NodeMaterialConnectionPoint;
  132187. /**
  132188. * Gets the reference input component
  132189. */
  132190. get reference(): NodeMaterialConnectionPoint;
  132191. /**
  132192. * Gets the distance input component
  132193. */
  132194. get distance(): NodeMaterialConnectionPoint;
  132195. /**
  132196. * Gets the replacement input component
  132197. */
  132198. get replacement(): NodeMaterialConnectionPoint;
  132199. /**
  132200. * Gets the output component
  132201. */
  132202. get output(): NodeMaterialConnectionPoint;
  132203. protected _buildBlock(state: NodeMaterialBuildState): this;
  132204. }
  132205. }
  132206. declare module BABYLON {
  132207. /**
  132208. * Block used to posterize a value
  132209. * @see https://en.wikipedia.org/wiki/Posterization
  132210. */
  132211. export class PosterizeBlock extends NodeMaterialBlock {
  132212. /**
  132213. * Creates a new PosterizeBlock
  132214. * @param name defines the block name
  132215. */
  132216. constructor(name: string);
  132217. /**
  132218. * Gets the current class name
  132219. * @returns the class name
  132220. */
  132221. getClassName(): string;
  132222. /**
  132223. * Gets the value input component
  132224. */
  132225. get value(): NodeMaterialConnectionPoint;
  132226. /**
  132227. * Gets the steps input component
  132228. */
  132229. get steps(): NodeMaterialConnectionPoint;
  132230. /**
  132231. * Gets the output component
  132232. */
  132233. get output(): NodeMaterialConnectionPoint;
  132234. protected _buildBlock(state: NodeMaterialBuildState): this;
  132235. }
  132236. }
  132237. declare module BABYLON {
  132238. /**
  132239. * Operations supported by the Wave block
  132240. */
  132241. export enum WaveBlockKind {
  132242. /** SawTooth */
  132243. SawTooth = 0,
  132244. /** Square */
  132245. Square = 1,
  132246. /** Triangle */
  132247. Triangle = 2
  132248. }
  132249. /**
  132250. * Block used to apply wave operation to floats
  132251. */
  132252. export class WaveBlock extends NodeMaterialBlock {
  132253. /**
  132254. * Gets or sets the kibnd of wave to be applied by the block
  132255. */
  132256. kind: WaveBlockKind;
  132257. /**
  132258. * Creates a new WaveBlock
  132259. * @param name defines the block name
  132260. */
  132261. constructor(name: string);
  132262. /**
  132263. * Gets the current class name
  132264. * @returns the class name
  132265. */
  132266. getClassName(): string;
  132267. /**
  132268. * Gets the input component
  132269. */
  132270. get input(): NodeMaterialConnectionPoint;
  132271. /**
  132272. * Gets the output component
  132273. */
  132274. get output(): NodeMaterialConnectionPoint;
  132275. protected _buildBlock(state: NodeMaterialBuildState): this;
  132276. serialize(): any;
  132277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132278. }
  132279. }
  132280. declare module BABYLON {
  132281. /**
  132282. * Class used to store a color step for the GradientBlock
  132283. */
  132284. export class GradientBlockColorStep {
  132285. /**
  132286. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132287. */
  132288. step: number;
  132289. /**
  132290. * Gets or sets the color associated with this step
  132291. */
  132292. color: Color3;
  132293. /**
  132294. * Creates a new GradientBlockColorStep
  132295. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132296. * @param color defines the color associated with this step
  132297. */
  132298. constructor(
  132299. /**
  132300. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132301. */
  132302. step: number,
  132303. /**
  132304. * Gets or sets the color associated with this step
  132305. */
  132306. color: Color3);
  132307. }
  132308. /**
  132309. * Block used to return a color from a gradient based on an input value between 0 and 1
  132310. */
  132311. export class GradientBlock extends NodeMaterialBlock {
  132312. /**
  132313. * Gets or sets the list of color steps
  132314. */
  132315. colorSteps: GradientBlockColorStep[];
  132316. /**
  132317. * Creates a new GradientBlock
  132318. * @param name defines the block name
  132319. */
  132320. constructor(name: string);
  132321. /**
  132322. * Gets the current class name
  132323. * @returns the class name
  132324. */
  132325. getClassName(): string;
  132326. /**
  132327. * Gets the gradient input component
  132328. */
  132329. get gradient(): NodeMaterialConnectionPoint;
  132330. /**
  132331. * Gets the output component
  132332. */
  132333. get output(): NodeMaterialConnectionPoint;
  132334. private _writeColorConstant;
  132335. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132336. serialize(): any;
  132337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132338. protected _dumpPropertiesCode(): string;
  132339. }
  132340. }
  132341. declare module BABYLON {
  132342. /**
  132343. * Block used to normalize lerp between 2 values
  132344. */
  132345. export class NLerpBlock extends NodeMaterialBlock {
  132346. /**
  132347. * Creates a new NLerpBlock
  132348. * @param name defines the block name
  132349. */
  132350. constructor(name: string);
  132351. /**
  132352. * Gets the current class name
  132353. * @returns the class name
  132354. */
  132355. getClassName(): string;
  132356. /**
  132357. * Gets the left operand input component
  132358. */
  132359. get left(): NodeMaterialConnectionPoint;
  132360. /**
  132361. * Gets the right operand input component
  132362. */
  132363. get right(): NodeMaterialConnectionPoint;
  132364. /**
  132365. * Gets the gradient operand input component
  132366. */
  132367. get gradient(): NodeMaterialConnectionPoint;
  132368. /**
  132369. * Gets the output component
  132370. */
  132371. get output(): NodeMaterialConnectionPoint;
  132372. protected _buildBlock(state: NodeMaterialBuildState): this;
  132373. }
  132374. }
  132375. declare module BABYLON {
  132376. /**
  132377. * block used to Generate a Worley Noise 3D Noise Pattern
  132378. */
  132379. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  132380. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132381. manhattanDistance: boolean;
  132382. /**
  132383. * Creates a new WorleyNoise3DBlock
  132384. * @param name defines the block name
  132385. */
  132386. constructor(name: string);
  132387. /**
  132388. * Gets the current class name
  132389. * @returns the class name
  132390. */
  132391. getClassName(): string;
  132392. /**
  132393. * Gets the seed input component
  132394. */
  132395. get seed(): NodeMaterialConnectionPoint;
  132396. /**
  132397. * Gets the jitter input component
  132398. */
  132399. get jitter(): NodeMaterialConnectionPoint;
  132400. /**
  132401. * Gets the output component
  132402. */
  132403. get output(): NodeMaterialConnectionPoint;
  132404. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132405. /**
  132406. * Exposes the properties to the UI?
  132407. */
  132408. protected _dumpPropertiesCode(): string;
  132409. /**
  132410. * Exposes the properties to the Seralize?
  132411. */
  132412. serialize(): any;
  132413. /**
  132414. * Exposes the properties to the deseralize?
  132415. */
  132416. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132417. }
  132418. }
  132419. declare module BABYLON {
  132420. /**
  132421. * block used to Generate a Simplex Perlin 3d Noise Pattern
  132422. */
  132423. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  132424. /**
  132425. * Creates a new SimplexPerlin3DBlock
  132426. * @param name defines the block name
  132427. */
  132428. constructor(name: string);
  132429. /**
  132430. * Gets the current class name
  132431. * @returns the class name
  132432. */
  132433. getClassName(): string;
  132434. /**
  132435. * Gets the seed operand input component
  132436. */
  132437. get seed(): NodeMaterialConnectionPoint;
  132438. /**
  132439. * Gets the output component
  132440. */
  132441. get output(): NodeMaterialConnectionPoint;
  132442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132443. }
  132444. }
  132445. declare module BABYLON {
  132446. /**
  132447. * Block used to blend normals
  132448. */
  132449. export class NormalBlendBlock extends NodeMaterialBlock {
  132450. /**
  132451. * Creates a new NormalBlendBlock
  132452. * @param name defines the block name
  132453. */
  132454. constructor(name: string);
  132455. /**
  132456. * Gets the current class name
  132457. * @returns the class name
  132458. */
  132459. getClassName(): string;
  132460. /**
  132461. * Gets the first input component
  132462. */
  132463. get normalMap0(): NodeMaterialConnectionPoint;
  132464. /**
  132465. * Gets the second input component
  132466. */
  132467. get normalMap1(): NodeMaterialConnectionPoint;
  132468. /**
  132469. * Gets the output component
  132470. */
  132471. get output(): NodeMaterialConnectionPoint;
  132472. protected _buildBlock(state: NodeMaterialBuildState): this;
  132473. }
  132474. }
  132475. declare module BABYLON {
  132476. /**
  132477. * Block used to rotate a 2d vector by a given angle
  132478. */
  132479. export class Rotate2dBlock extends NodeMaterialBlock {
  132480. /**
  132481. * Creates a new Rotate2dBlock
  132482. * @param name defines the block name
  132483. */
  132484. constructor(name: string);
  132485. /**
  132486. * Gets the current class name
  132487. * @returns the class name
  132488. */
  132489. getClassName(): string;
  132490. /**
  132491. * Gets the input vector
  132492. */
  132493. get input(): NodeMaterialConnectionPoint;
  132494. /**
  132495. * Gets the input angle
  132496. */
  132497. get angle(): NodeMaterialConnectionPoint;
  132498. /**
  132499. * Gets the output component
  132500. */
  132501. get output(): NodeMaterialConnectionPoint;
  132502. autoConfigure(material: NodeMaterial): void;
  132503. protected _buildBlock(state: NodeMaterialBuildState): this;
  132504. }
  132505. }
  132506. declare module BABYLON {
  132507. /**
  132508. * Block used to get the reflected vector from a direction and a normal
  132509. */
  132510. export class ReflectBlock extends NodeMaterialBlock {
  132511. /**
  132512. * Creates a new ReflectBlock
  132513. * @param name defines the block name
  132514. */
  132515. constructor(name: string);
  132516. /**
  132517. * Gets the current class name
  132518. * @returns the class name
  132519. */
  132520. getClassName(): string;
  132521. /**
  132522. * Gets the incident component
  132523. */
  132524. get incident(): NodeMaterialConnectionPoint;
  132525. /**
  132526. * Gets the normal component
  132527. */
  132528. get normal(): NodeMaterialConnectionPoint;
  132529. /**
  132530. * Gets the output component
  132531. */
  132532. get output(): NodeMaterialConnectionPoint;
  132533. protected _buildBlock(state: NodeMaterialBuildState): this;
  132534. }
  132535. }
  132536. declare module BABYLON {
  132537. /**
  132538. * Block used to get the refracted vector from a direction and a normal
  132539. */
  132540. export class RefractBlock extends NodeMaterialBlock {
  132541. /**
  132542. * Creates a new RefractBlock
  132543. * @param name defines the block name
  132544. */
  132545. constructor(name: string);
  132546. /**
  132547. * Gets the current class name
  132548. * @returns the class name
  132549. */
  132550. getClassName(): string;
  132551. /**
  132552. * Gets the incident component
  132553. */
  132554. get incident(): NodeMaterialConnectionPoint;
  132555. /**
  132556. * Gets the normal component
  132557. */
  132558. get normal(): NodeMaterialConnectionPoint;
  132559. /**
  132560. * Gets the index of refraction component
  132561. */
  132562. get ior(): NodeMaterialConnectionPoint;
  132563. /**
  132564. * Gets the output component
  132565. */
  132566. get output(): NodeMaterialConnectionPoint;
  132567. protected _buildBlock(state: NodeMaterialBuildState): this;
  132568. }
  132569. }
  132570. declare module BABYLON {
  132571. /**
  132572. * Block used to desaturate a color
  132573. */
  132574. export class DesaturateBlock extends NodeMaterialBlock {
  132575. /**
  132576. * Creates a new DesaturateBlock
  132577. * @param name defines the block name
  132578. */
  132579. constructor(name: string);
  132580. /**
  132581. * Gets the current class name
  132582. * @returns the class name
  132583. */
  132584. getClassName(): string;
  132585. /**
  132586. * Gets the color operand input component
  132587. */
  132588. get color(): NodeMaterialConnectionPoint;
  132589. /**
  132590. * Gets the level operand input component
  132591. */
  132592. get level(): NodeMaterialConnectionPoint;
  132593. /**
  132594. * Gets the output component
  132595. */
  132596. get output(): NodeMaterialConnectionPoint;
  132597. protected _buildBlock(state: NodeMaterialBuildState): this;
  132598. }
  132599. }
  132600. declare module BABYLON {
  132601. /**
  132602. * Effect Render Options
  132603. */
  132604. export interface IEffectRendererOptions {
  132605. /**
  132606. * Defines the vertices positions.
  132607. */
  132608. positions?: number[];
  132609. /**
  132610. * Defines the indices.
  132611. */
  132612. indices?: number[];
  132613. }
  132614. /**
  132615. * Helper class to render one or more effects
  132616. */
  132617. export class EffectRenderer {
  132618. private engine;
  132619. private static _DefaultOptions;
  132620. private _vertexBuffers;
  132621. private _indexBuffer;
  132622. private _ringBufferIndex;
  132623. private _ringScreenBuffer;
  132624. private _fullscreenViewport;
  132625. private _getNextFrameBuffer;
  132626. /**
  132627. * Creates an effect renderer
  132628. * @param engine the engine to use for rendering
  132629. * @param options defines the options of the effect renderer
  132630. */
  132631. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  132632. /**
  132633. * Sets the current viewport in normalized coordinates 0-1
  132634. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  132635. */
  132636. setViewport(viewport?: Viewport): void;
  132637. /**
  132638. * Binds the embedded attributes buffer to the effect.
  132639. * @param effect Defines the effect to bind the attributes for
  132640. */
  132641. bindBuffers(effect: Effect): void;
  132642. /**
  132643. * Sets the current effect wrapper to use during draw.
  132644. * The effect needs to be ready before calling this api.
  132645. * This also sets the default full screen position attribute.
  132646. * @param effectWrapper Defines the effect to draw with
  132647. */
  132648. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  132649. /**
  132650. * Draws a full screen quad.
  132651. */
  132652. draw(): void;
  132653. /**
  132654. * renders one or more effects to a specified texture
  132655. * @param effectWrappers list of effects to renderer
  132656. * @param outputTexture texture to draw to, if null it will render to the screen
  132657. */
  132658. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  132659. /**
  132660. * Disposes of the effect renderer
  132661. */
  132662. dispose(): void;
  132663. }
  132664. /**
  132665. * Options to create an EffectWrapper
  132666. */
  132667. interface EffectWrapperCreationOptions {
  132668. /**
  132669. * Engine to use to create the effect
  132670. */
  132671. engine: ThinEngine;
  132672. /**
  132673. * Fragment shader for the effect
  132674. */
  132675. fragmentShader: string;
  132676. /**
  132677. * Vertex shader for the effect
  132678. */
  132679. vertexShader?: string;
  132680. /**
  132681. * Attributes to use in the shader
  132682. */
  132683. attributeNames?: Array<string>;
  132684. /**
  132685. * Uniforms to use in the shader
  132686. */
  132687. uniformNames?: Array<string>;
  132688. /**
  132689. * Texture sampler names to use in the shader
  132690. */
  132691. samplerNames?: Array<string>;
  132692. /**
  132693. * The friendly name of the effect displayed in Spector.
  132694. */
  132695. name?: string;
  132696. }
  132697. /**
  132698. * Wraps an effect to be used for rendering
  132699. */
  132700. export class EffectWrapper {
  132701. /**
  132702. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  132703. */
  132704. onApplyObservable: Observable<{}>;
  132705. /**
  132706. * The underlying effect
  132707. */
  132708. effect: Effect;
  132709. /**
  132710. * Creates an effect to be renderer
  132711. * @param creationOptions options to create the effect
  132712. */
  132713. constructor(creationOptions: EffectWrapperCreationOptions);
  132714. /**
  132715. * Disposes of the effect wrapper
  132716. */
  132717. dispose(): void;
  132718. }
  132719. }
  132720. declare module BABYLON {
  132721. /**
  132722. * Helper class to push actions to a pool of workers.
  132723. */
  132724. export class WorkerPool implements IDisposable {
  132725. private _workerInfos;
  132726. private _pendingActions;
  132727. /**
  132728. * Constructor
  132729. * @param workers Array of workers to use for actions
  132730. */
  132731. constructor(workers: Array<Worker>);
  132732. /**
  132733. * Terminates all workers and clears any pending actions.
  132734. */
  132735. dispose(): void;
  132736. /**
  132737. * Pushes an action to the worker pool. If all the workers are active, the action will be
  132738. * pended until a worker has completed its action.
  132739. * @param action The action to perform. Call onComplete when the action is complete.
  132740. */
  132741. push(action: (worker: Worker, onComplete: () => void) => void): void;
  132742. private _execute;
  132743. }
  132744. }
  132745. declare module BABYLON {
  132746. /**
  132747. * Configuration for Draco compression
  132748. */
  132749. export interface IDracoCompressionConfiguration {
  132750. /**
  132751. * Configuration for the decoder.
  132752. */
  132753. decoder: {
  132754. /**
  132755. * The url to the WebAssembly module.
  132756. */
  132757. wasmUrl?: string;
  132758. /**
  132759. * The url to the WebAssembly binary.
  132760. */
  132761. wasmBinaryUrl?: string;
  132762. /**
  132763. * The url to the fallback JavaScript module.
  132764. */
  132765. fallbackUrl?: string;
  132766. };
  132767. }
  132768. /**
  132769. * Draco compression (https://google.github.io/draco/)
  132770. *
  132771. * This class wraps the Draco module.
  132772. *
  132773. * **Encoder**
  132774. *
  132775. * The encoder is not currently implemented.
  132776. *
  132777. * **Decoder**
  132778. *
  132779. * 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.
  132780. *
  132781. * To update the configuration, use the following code:
  132782. * ```javascript
  132783. * DracoCompression.Configuration = {
  132784. * decoder: {
  132785. * wasmUrl: "<url to the WebAssembly library>",
  132786. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  132787. * fallbackUrl: "<url to the fallback JavaScript library>",
  132788. * }
  132789. * };
  132790. * ```
  132791. *
  132792. * 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.
  132793. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  132794. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  132795. *
  132796. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  132797. * ```javascript
  132798. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  132799. * ```
  132800. *
  132801. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  132802. */
  132803. export class DracoCompression implements IDisposable {
  132804. private _workerPoolPromise?;
  132805. private _decoderModulePromise?;
  132806. /**
  132807. * The configuration. Defaults to the following urls:
  132808. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  132809. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  132810. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  132811. */
  132812. static Configuration: IDracoCompressionConfiguration;
  132813. /**
  132814. * Returns true if the decoder configuration is available.
  132815. */
  132816. static get DecoderAvailable(): boolean;
  132817. /**
  132818. * Default number of workers to create when creating the draco compression object.
  132819. */
  132820. static DefaultNumWorkers: number;
  132821. private static GetDefaultNumWorkers;
  132822. private static _Default;
  132823. /**
  132824. * Default instance for the draco compression object.
  132825. */
  132826. static get Default(): DracoCompression;
  132827. /**
  132828. * Constructor
  132829. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  132830. */
  132831. constructor(numWorkers?: number);
  132832. /**
  132833. * Stop all async operations and release resources.
  132834. */
  132835. dispose(): void;
  132836. /**
  132837. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  132838. * @returns a promise that resolves when ready
  132839. */
  132840. whenReadyAsync(): Promise<void>;
  132841. /**
  132842. * Decode Draco compressed mesh data to vertex data.
  132843. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  132844. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  132845. * @returns A promise that resolves with the decoded vertex data
  132846. */
  132847. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  132848. [kind: string]: number;
  132849. }): Promise<VertexData>;
  132850. }
  132851. }
  132852. declare module BABYLON {
  132853. /**
  132854. * Class for building Constructive Solid Geometry
  132855. */
  132856. export class CSG {
  132857. private polygons;
  132858. /**
  132859. * The world matrix
  132860. */
  132861. matrix: Matrix;
  132862. /**
  132863. * Stores the position
  132864. */
  132865. position: Vector3;
  132866. /**
  132867. * Stores the rotation
  132868. */
  132869. rotation: Vector3;
  132870. /**
  132871. * Stores the rotation quaternion
  132872. */
  132873. rotationQuaternion: Nullable<Quaternion>;
  132874. /**
  132875. * Stores the scaling vector
  132876. */
  132877. scaling: Vector3;
  132878. /**
  132879. * Convert the Mesh to CSG
  132880. * @param mesh The Mesh to convert to CSG
  132881. * @returns A new CSG from the Mesh
  132882. */
  132883. static FromMesh(mesh: Mesh): CSG;
  132884. /**
  132885. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  132886. * @param polygons Polygons used to construct a CSG solid
  132887. */
  132888. private static FromPolygons;
  132889. /**
  132890. * Clones, or makes a deep copy, of the CSG
  132891. * @returns A new CSG
  132892. */
  132893. clone(): CSG;
  132894. /**
  132895. * Unions this CSG with another CSG
  132896. * @param csg The CSG to union against this CSG
  132897. * @returns The unioned CSG
  132898. */
  132899. union(csg: CSG): CSG;
  132900. /**
  132901. * Unions this CSG with another CSG in place
  132902. * @param csg The CSG to union against this CSG
  132903. */
  132904. unionInPlace(csg: CSG): void;
  132905. /**
  132906. * Subtracts this CSG with another CSG
  132907. * @param csg The CSG to subtract against this CSG
  132908. * @returns A new CSG
  132909. */
  132910. subtract(csg: CSG): CSG;
  132911. /**
  132912. * Subtracts this CSG with another CSG in place
  132913. * @param csg The CSG to subtact against this CSG
  132914. */
  132915. subtractInPlace(csg: CSG): void;
  132916. /**
  132917. * Intersect this CSG with another CSG
  132918. * @param csg The CSG to intersect against this CSG
  132919. * @returns A new CSG
  132920. */
  132921. intersect(csg: CSG): CSG;
  132922. /**
  132923. * Intersects this CSG with another CSG in place
  132924. * @param csg The CSG to intersect against this CSG
  132925. */
  132926. intersectInPlace(csg: CSG): void;
  132927. /**
  132928. * Return a new CSG solid with solid and empty space switched. This solid is
  132929. * not modified.
  132930. * @returns A new CSG solid with solid and empty space switched
  132931. */
  132932. inverse(): CSG;
  132933. /**
  132934. * Inverses the CSG in place
  132935. */
  132936. inverseInPlace(): void;
  132937. /**
  132938. * This is used to keep meshes transformations so they can be restored
  132939. * when we build back a Babylon Mesh
  132940. * NB : All CSG operations are performed in world coordinates
  132941. * @param csg The CSG to copy the transform attributes from
  132942. * @returns This CSG
  132943. */
  132944. copyTransformAttributes(csg: CSG): CSG;
  132945. /**
  132946. * Build Raw mesh from CSG
  132947. * Coordinates here are in world space
  132948. * @param name The name of the mesh geometry
  132949. * @param scene The Scene
  132950. * @param keepSubMeshes Specifies if the submeshes should be kept
  132951. * @returns A new Mesh
  132952. */
  132953. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132954. /**
  132955. * Build Mesh from CSG taking material and transforms into account
  132956. * @param name The name of the Mesh
  132957. * @param material The material of the Mesh
  132958. * @param scene The Scene
  132959. * @param keepSubMeshes Specifies if submeshes should be kept
  132960. * @returns The new Mesh
  132961. */
  132962. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132963. }
  132964. }
  132965. declare module BABYLON {
  132966. /**
  132967. * Class used to create a trail following a mesh
  132968. */
  132969. export class TrailMesh extends Mesh {
  132970. private _generator;
  132971. private _autoStart;
  132972. private _running;
  132973. private _diameter;
  132974. private _length;
  132975. private _sectionPolygonPointsCount;
  132976. private _sectionVectors;
  132977. private _sectionNormalVectors;
  132978. private _beforeRenderObserver;
  132979. /**
  132980. * @constructor
  132981. * @param name The value used by scene.getMeshByName() to do a lookup.
  132982. * @param generator The mesh to generate a trail.
  132983. * @param scene The scene to add this mesh to.
  132984. * @param diameter Diameter of trailing mesh. Default is 1.
  132985. * @param length Length of trailing mesh. Default is 60.
  132986. * @param autoStart Automatically start trailing mesh. Default true.
  132987. */
  132988. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  132989. /**
  132990. * "TrailMesh"
  132991. * @returns "TrailMesh"
  132992. */
  132993. getClassName(): string;
  132994. private _createMesh;
  132995. /**
  132996. * Start trailing mesh.
  132997. */
  132998. start(): void;
  132999. /**
  133000. * Stop trailing mesh.
  133001. */
  133002. stop(): void;
  133003. /**
  133004. * Update trailing mesh geometry.
  133005. */
  133006. update(): void;
  133007. /**
  133008. * Returns a new TrailMesh object.
  133009. * @param name is a string, the name given to the new mesh
  133010. * @param newGenerator use new generator object for cloned trail mesh
  133011. * @returns a new mesh
  133012. */
  133013. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  133014. /**
  133015. * Serializes this trail mesh
  133016. * @param serializationObject object to write serialization to
  133017. */
  133018. serialize(serializationObject: any): void;
  133019. /**
  133020. * Parses a serialized trail mesh
  133021. * @param parsedMesh the serialized mesh
  133022. * @param scene the scene to create the trail mesh in
  133023. * @returns the created trail mesh
  133024. */
  133025. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133026. }
  133027. }
  133028. declare module BABYLON {
  133029. /**
  133030. * Class containing static functions to help procedurally build meshes
  133031. */
  133032. export class TiledBoxBuilder {
  133033. /**
  133034. * Creates a box mesh
  133035. * 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)
  133036. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133040. * @param name defines the name of the mesh
  133041. * @param options defines the options used to create the mesh
  133042. * @param scene defines the hosting scene
  133043. * @returns the box mesh
  133044. */
  133045. static CreateTiledBox(name: string, options: {
  133046. pattern?: number;
  133047. width?: number;
  133048. height?: number;
  133049. depth?: number;
  133050. tileSize?: number;
  133051. tileWidth?: number;
  133052. tileHeight?: number;
  133053. alignHorizontal?: number;
  133054. alignVertical?: number;
  133055. faceUV?: Vector4[];
  133056. faceColors?: Color4[];
  133057. sideOrientation?: number;
  133058. updatable?: boolean;
  133059. }, scene?: Nullable<Scene>): Mesh;
  133060. }
  133061. }
  133062. declare module BABYLON {
  133063. /**
  133064. * Class containing static functions to help procedurally build meshes
  133065. */
  133066. export class TorusKnotBuilder {
  133067. /**
  133068. * Creates a torus knot mesh
  133069. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133070. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133071. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133072. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133076. * @param name defines the name of the mesh
  133077. * @param options defines the options used to create the mesh
  133078. * @param scene defines the hosting scene
  133079. * @returns the torus knot mesh
  133080. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133081. */
  133082. static CreateTorusKnot(name: string, options: {
  133083. radius?: number;
  133084. tube?: number;
  133085. radialSegments?: number;
  133086. tubularSegments?: number;
  133087. p?: number;
  133088. q?: number;
  133089. updatable?: boolean;
  133090. sideOrientation?: number;
  133091. frontUVs?: Vector4;
  133092. backUVs?: Vector4;
  133093. }, scene: any): Mesh;
  133094. }
  133095. }
  133096. declare module BABYLON {
  133097. /**
  133098. * Polygon
  133099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133100. */
  133101. export class Polygon {
  133102. /**
  133103. * Creates a rectangle
  133104. * @param xmin bottom X coord
  133105. * @param ymin bottom Y coord
  133106. * @param xmax top X coord
  133107. * @param ymax top Y coord
  133108. * @returns points that make the resulting rectation
  133109. */
  133110. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133111. /**
  133112. * Creates a circle
  133113. * @param radius radius of circle
  133114. * @param cx scale in x
  133115. * @param cy scale in y
  133116. * @param numberOfSides number of sides that make up the circle
  133117. * @returns points that make the resulting circle
  133118. */
  133119. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133120. /**
  133121. * Creates a polygon from input string
  133122. * @param input Input polygon data
  133123. * @returns the parsed points
  133124. */
  133125. static Parse(input: string): Vector2[];
  133126. /**
  133127. * Starts building a polygon from x and y coordinates
  133128. * @param x x coordinate
  133129. * @param y y coordinate
  133130. * @returns the started path2
  133131. */
  133132. static StartingAt(x: number, y: number): Path2;
  133133. }
  133134. /**
  133135. * Builds a polygon
  133136. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133137. */
  133138. export class PolygonMeshBuilder {
  133139. private _points;
  133140. private _outlinepoints;
  133141. private _holes;
  133142. private _name;
  133143. private _scene;
  133144. private _epoints;
  133145. private _eholes;
  133146. private _addToepoint;
  133147. /**
  133148. * Babylon reference to the earcut plugin.
  133149. */
  133150. bjsEarcut: any;
  133151. /**
  133152. * Creates a PolygonMeshBuilder
  133153. * @param name name of the builder
  133154. * @param contours Path of the polygon
  133155. * @param scene scene to add to when creating the mesh
  133156. * @param earcutInjection can be used to inject your own earcut reference
  133157. */
  133158. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133159. /**
  133160. * Adds a whole within the polygon
  133161. * @param hole Array of points defining the hole
  133162. * @returns this
  133163. */
  133164. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133165. /**
  133166. * Creates the polygon
  133167. * @param updatable If the mesh should be updatable
  133168. * @param depth The depth of the mesh created
  133169. * @returns the created mesh
  133170. */
  133171. build(updatable?: boolean, depth?: number): Mesh;
  133172. /**
  133173. * Creates the polygon
  133174. * @param depth The depth of the mesh created
  133175. * @returns the created VertexData
  133176. */
  133177. buildVertexData(depth?: number): VertexData;
  133178. /**
  133179. * Adds a side to the polygon
  133180. * @param positions points that make the polygon
  133181. * @param normals normals of the polygon
  133182. * @param uvs uvs of the polygon
  133183. * @param indices indices of the polygon
  133184. * @param bounds bounds of the polygon
  133185. * @param points points of the polygon
  133186. * @param depth depth of the polygon
  133187. * @param flip flip of the polygon
  133188. */
  133189. private addSide;
  133190. }
  133191. }
  133192. declare module BABYLON {
  133193. /**
  133194. * Class containing static functions to help procedurally build meshes
  133195. */
  133196. export class PolygonBuilder {
  133197. /**
  133198. * Creates a polygon mesh
  133199. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133200. * * 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
  133201. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133204. * * Remember you can only change the shape positions, not their number when updating a polygon
  133205. * @param name defines the name of the mesh
  133206. * @param options defines the options used to create the mesh
  133207. * @param scene defines the hosting scene
  133208. * @param earcutInjection can be used to inject your own earcut reference
  133209. * @returns the polygon mesh
  133210. */
  133211. static CreatePolygon(name: string, options: {
  133212. shape: Vector3[];
  133213. holes?: Vector3[][];
  133214. depth?: number;
  133215. faceUV?: Vector4[];
  133216. faceColors?: Color4[];
  133217. updatable?: boolean;
  133218. sideOrientation?: number;
  133219. frontUVs?: Vector4;
  133220. backUVs?: Vector4;
  133221. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133222. /**
  133223. * Creates an extruded polygon mesh, with depth in the Y direction.
  133224. * * 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)
  133225. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133226. * @param name defines the name of the mesh
  133227. * @param options defines the options used to create the mesh
  133228. * @param scene defines the hosting scene
  133229. * @param earcutInjection can be used to inject your own earcut reference
  133230. * @returns the polygon mesh
  133231. */
  133232. static ExtrudePolygon(name: string, options: {
  133233. shape: Vector3[];
  133234. holes?: Vector3[][];
  133235. depth?: number;
  133236. faceUV?: Vector4[];
  133237. faceColors?: Color4[];
  133238. updatable?: boolean;
  133239. sideOrientation?: number;
  133240. frontUVs?: Vector4;
  133241. backUVs?: Vector4;
  133242. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133243. }
  133244. }
  133245. declare module BABYLON {
  133246. /**
  133247. * Class containing static functions to help procedurally build meshes
  133248. */
  133249. export class LatheBuilder {
  133250. /**
  133251. * Creates lathe mesh.
  133252. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133253. * * 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
  133254. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133255. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133256. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133257. * * 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
  133258. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133259. * * 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
  133260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133262. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133264. * @param name defines the name of the mesh
  133265. * @param options defines the options used to create the mesh
  133266. * @param scene defines the hosting scene
  133267. * @returns the lathe mesh
  133268. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133269. */
  133270. static CreateLathe(name: string, options: {
  133271. shape: Vector3[];
  133272. radius?: number;
  133273. tessellation?: number;
  133274. clip?: number;
  133275. arc?: number;
  133276. closed?: boolean;
  133277. updatable?: boolean;
  133278. sideOrientation?: number;
  133279. frontUVs?: Vector4;
  133280. backUVs?: Vector4;
  133281. cap?: number;
  133282. invertUV?: boolean;
  133283. }, scene?: Nullable<Scene>): Mesh;
  133284. }
  133285. }
  133286. declare module BABYLON {
  133287. /**
  133288. * Class containing static functions to help procedurally build meshes
  133289. */
  133290. export class TiledPlaneBuilder {
  133291. /**
  133292. * Creates a tiled plane mesh
  133293. * * The parameter `pattern` will, depending on value, do nothing or
  133294. * * * flip (reflect about central vertical) alternate tiles across and up
  133295. * * * flip every tile on alternate rows
  133296. * * * rotate (180 degs) alternate tiles across and up
  133297. * * * rotate every tile on alternate rows
  133298. * * * flip and rotate alternate tiles across and up
  133299. * * * flip and rotate every tile on alternate rows
  133300. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133301. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133304. * * 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)
  133305. * * 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)
  133306. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133307. * @param name defines the name of the mesh
  133308. * @param options defines the options used to create the mesh
  133309. * @param scene defines the hosting scene
  133310. * @returns the box mesh
  133311. */
  133312. static CreateTiledPlane(name: string, options: {
  133313. pattern?: number;
  133314. tileSize?: number;
  133315. tileWidth?: number;
  133316. tileHeight?: number;
  133317. size?: number;
  133318. width?: number;
  133319. height?: number;
  133320. alignHorizontal?: number;
  133321. alignVertical?: number;
  133322. sideOrientation?: number;
  133323. frontUVs?: Vector4;
  133324. backUVs?: Vector4;
  133325. updatable?: boolean;
  133326. }, scene?: Nullable<Scene>): Mesh;
  133327. }
  133328. }
  133329. declare module BABYLON {
  133330. /**
  133331. * Class containing static functions to help procedurally build meshes
  133332. */
  133333. export class TubeBuilder {
  133334. /**
  133335. * Creates a tube mesh.
  133336. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133337. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  133338. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  133339. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  133340. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  133341. * * 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)
  133342. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  133343. * * 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
  133344. * * 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
  133345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133347. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133349. * @param name defines the name of the mesh
  133350. * @param options defines the options used to create the mesh
  133351. * @param scene defines the hosting scene
  133352. * @returns the tube mesh
  133353. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133354. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  133355. */
  133356. static CreateTube(name: string, options: {
  133357. path: Vector3[];
  133358. radius?: number;
  133359. tessellation?: number;
  133360. radiusFunction?: {
  133361. (i: number, distance: number): number;
  133362. };
  133363. cap?: number;
  133364. arc?: number;
  133365. updatable?: boolean;
  133366. sideOrientation?: number;
  133367. frontUVs?: Vector4;
  133368. backUVs?: Vector4;
  133369. instance?: Mesh;
  133370. invertUV?: boolean;
  133371. }, scene?: Nullable<Scene>): Mesh;
  133372. }
  133373. }
  133374. declare module BABYLON {
  133375. /**
  133376. * Class containing static functions to help procedurally build meshes
  133377. */
  133378. export class IcoSphereBuilder {
  133379. /**
  133380. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133381. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133382. * * 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`)
  133383. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133384. * * 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
  133385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133388. * @param name defines the name of the mesh
  133389. * @param options defines the options used to create the mesh
  133390. * @param scene defines the hosting scene
  133391. * @returns the icosahedron mesh
  133392. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133393. */
  133394. static CreateIcoSphere(name: string, options: {
  133395. radius?: number;
  133396. radiusX?: number;
  133397. radiusY?: number;
  133398. radiusZ?: number;
  133399. flat?: boolean;
  133400. subdivisions?: number;
  133401. sideOrientation?: number;
  133402. frontUVs?: Vector4;
  133403. backUVs?: Vector4;
  133404. updatable?: boolean;
  133405. }, scene?: Nullable<Scene>): Mesh;
  133406. }
  133407. }
  133408. declare module BABYLON {
  133409. /**
  133410. * Class containing static functions to help procedurally build meshes
  133411. */
  133412. export class DecalBuilder {
  133413. /**
  133414. * Creates a decal mesh.
  133415. * 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
  133416. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  133417. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  133418. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  133419. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  133420. * @param name defines the name of the mesh
  133421. * @param sourceMesh defines the mesh where the decal must be applied
  133422. * @param options defines the options used to create the mesh
  133423. * @param scene defines the hosting scene
  133424. * @returns the decal mesh
  133425. * @see https://doc.babylonjs.com/how_to/decals
  133426. */
  133427. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  133428. position?: Vector3;
  133429. normal?: Vector3;
  133430. size?: Vector3;
  133431. angle?: number;
  133432. }): Mesh;
  133433. }
  133434. }
  133435. declare module BABYLON {
  133436. /**
  133437. * Class containing static functions to help procedurally build meshes
  133438. */
  133439. export class MeshBuilder {
  133440. /**
  133441. * Creates a box mesh
  133442. * * The parameter `size` sets the size (float) of each box side (default 1)
  133443. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  133444. * * 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)
  133445. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133449. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133450. * @param name defines the name of the mesh
  133451. * @param options defines the options used to create the mesh
  133452. * @param scene defines the hosting scene
  133453. * @returns the box mesh
  133454. */
  133455. static CreateBox(name: string, options: {
  133456. size?: number;
  133457. width?: number;
  133458. height?: number;
  133459. depth?: number;
  133460. faceUV?: Vector4[];
  133461. faceColors?: Color4[];
  133462. sideOrientation?: number;
  133463. frontUVs?: Vector4;
  133464. backUVs?: Vector4;
  133465. updatable?: boolean;
  133466. }, scene?: Nullable<Scene>): Mesh;
  133467. /**
  133468. * Creates a tiled box mesh
  133469. * * faceTiles sets the pattern, tile size and number of tiles for a face
  133470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133471. * @param name defines the name of the mesh
  133472. * @param options defines the options used to create the mesh
  133473. * @param scene defines the hosting scene
  133474. * @returns the tiled box mesh
  133475. */
  133476. static CreateTiledBox(name: string, options: {
  133477. pattern?: number;
  133478. size?: number;
  133479. width?: number;
  133480. height?: number;
  133481. depth: number;
  133482. tileSize?: number;
  133483. tileWidth?: number;
  133484. tileHeight?: number;
  133485. faceUV?: Vector4[];
  133486. faceColors?: Color4[];
  133487. alignHorizontal?: number;
  133488. alignVertical?: number;
  133489. sideOrientation?: number;
  133490. updatable?: boolean;
  133491. }, scene?: Nullable<Scene>): Mesh;
  133492. /**
  133493. * Creates a sphere mesh
  133494. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133495. * * 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`)
  133496. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133497. * * 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
  133498. * * 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)
  133499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133502. * @param name defines the name of the mesh
  133503. * @param options defines the options used to create the mesh
  133504. * @param scene defines the hosting scene
  133505. * @returns the sphere mesh
  133506. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133507. */
  133508. static CreateSphere(name: string, options: {
  133509. segments?: number;
  133510. diameter?: number;
  133511. diameterX?: number;
  133512. diameterY?: number;
  133513. diameterZ?: number;
  133514. arc?: number;
  133515. slice?: number;
  133516. sideOrientation?: number;
  133517. frontUVs?: Vector4;
  133518. backUVs?: Vector4;
  133519. updatable?: boolean;
  133520. }, scene?: Nullable<Scene>): Mesh;
  133521. /**
  133522. * Creates a plane polygonal mesh. By default, this is a disc
  133523. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  133524. * * 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
  133525. * * 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
  133526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133529. * @param name defines the name of the mesh
  133530. * @param options defines the options used to create the mesh
  133531. * @param scene defines the hosting scene
  133532. * @returns the plane polygonal mesh
  133533. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  133534. */
  133535. static CreateDisc(name: string, options: {
  133536. radius?: number;
  133537. tessellation?: number;
  133538. arc?: number;
  133539. updatable?: boolean;
  133540. sideOrientation?: number;
  133541. frontUVs?: Vector4;
  133542. backUVs?: Vector4;
  133543. }, scene?: Nullable<Scene>): Mesh;
  133544. /**
  133545. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133546. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133547. * * 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`)
  133548. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133549. * * 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
  133550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133553. * @param name defines the name of the mesh
  133554. * @param options defines the options used to create the mesh
  133555. * @param scene defines the hosting scene
  133556. * @returns the icosahedron mesh
  133557. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133558. */
  133559. static CreateIcoSphere(name: string, options: {
  133560. radius?: number;
  133561. radiusX?: number;
  133562. radiusY?: number;
  133563. radiusZ?: number;
  133564. flat?: boolean;
  133565. subdivisions?: number;
  133566. sideOrientation?: number;
  133567. frontUVs?: Vector4;
  133568. backUVs?: Vector4;
  133569. updatable?: boolean;
  133570. }, scene?: Nullable<Scene>): Mesh;
  133571. /**
  133572. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133573. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  133574. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  133575. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  133576. * * 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
  133577. * * 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
  133578. * * 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
  133579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133582. * * 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
  133583. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  133584. * * 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
  133585. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  133586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133587. * @param name defines the name of the mesh
  133588. * @param options defines the options used to create the mesh
  133589. * @param scene defines the hosting scene
  133590. * @returns the ribbon mesh
  133591. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  133592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133593. */
  133594. static CreateRibbon(name: string, options: {
  133595. pathArray: Vector3[][];
  133596. closeArray?: boolean;
  133597. closePath?: boolean;
  133598. offset?: number;
  133599. updatable?: boolean;
  133600. sideOrientation?: number;
  133601. frontUVs?: Vector4;
  133602. backUVs?: Vector4;
  133603. instance?: Mesh;
  133604. invertUV?: boolean;
  133605. uvs?: Vector2[];
  133606. colors?: Color4[];
  133607. }, scene?: Nullable<Scene>): Mesh;
  133608. /**
  133609. * Creates a cylinder or a cone mesh
  133610. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  133611. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  133612. * * 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.
  133613. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  133614. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  133615. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  133616. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  133617. * * 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).
  133618. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  133619. * * 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).
  133620. * * 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
  133621. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  133622. * * 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
  133623. * * 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.
  133624. * * If `enclose` is false, a ring surface is one element.
  133625. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  133626. * * 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
  133627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133630. * @param name defines the name of the mesh
  133631. * @param options defines the options used to create the mesh
  133632. * @param scene defines the hosting scene
  133633. * @returns the cylinder mesh
  133634. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  133635. */
  133636. static CreateCylinder(name: string, options: {
  133637. height?: number;
  133638. diameterTop?: number;
  133639. diameterBottom?: number;
  133640. diameter?: number;
  133641. tessellation?: number;
  133642. subdivisions?: number;
  133643. arc?: number;
  133644. faceColors?: Color4[];
  133645. faceUV?: Vector4[];
  133646. updatable?: boolean;
  133647. hasRings?: boolean;
  133648. enclose?: boolean;
  133649. cap?: number;
  133650. sideOrientation?: number;
  133651. frontUVs?: Vector4;
  133652. backUVs?: Vector4;
  133653. }, scene?: Nullable<Scene>): Mesh;
  133654. /**
  133655. * Creates a torus mesh
  133656. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  133657. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  133658. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  133659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133662. * @param name defines the name of the mesh
  133663. * @param options defines the options used to create the mesh
  133664. * @param scene defines the hosting scene
  133665. * @returns the torus mesh
  133666. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  133667. */
  133668. static CreateTorus(name: string, options: {
  133669. diameter?: number;
  133670. thickness?: number;
  133671. tessellation?: number;
  133672. updatable?: boolean;
  133673. sideOrientation?: number;
  133674. frontUVs?: Vector4;
  133675. backUVs?: Vector4;
  133676. }, scene?: Nullable<Scene>): Mesh;
  133677. /**
  133678. * Creates a torus knot mesh
  133679. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133680. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133681. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133682. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133686. * @param name defines the name of the mesh
  133687. * @param options defines the options used to create the mesh
  133688. * @param scene defines the hosting scene
  133689. * @returns the torus knot mesh
  133690. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133691. */
  133692. static CreateTorusKnot(name: string, options: {
  133693. radius?: number;
  133694. tube?: number;
  133695. radialSegments?: number;
  133696. tubularSegments?: number;
  133697. p?: number;
  133698. q?: number;
  133699. updatable?: boolean;
  133700. sideOrientation?: number;
  133701. frontUVs?: Vector4;
  133702. backUVs?: Vector4;
  133703. }, scene?: Nullable<Scene>): Mesh;
  133704. /**
  133705. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133706. * * 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
  133707. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133708. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133709. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133710. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133711. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133712. * * 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
  133713. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133716. * @param name defines the name of the new line system
  133717. * @param options defines the options used to create the line system
  133718. * @param scene defines the hosting scene
  133719. * @returns a new line system mesh
  133720. */
  133721. static CreateLineSystem(name: string, options: {
  133722. lines: Vector3[][];
  133723. updatable?: boolean;
  133724. instance?: Nullable<LinesMesh>;
  133725. colors?: Nullable<Color4[][]>;
  133726. useVertexAlpha?: boolean;
  133727. }, scene: Nullable<Scene>): LinesMesh;
  133728. /**
  133729. * Creates a line mesh
  133730. * 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
  133731. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133732. * * The parameter `points` is an array successive Vector3
  133733. * * 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
  133734. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133735. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133736. * * When updating an instance, remember that only point positions can change, not the number of points
  133737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133739. * @param name defines the name of the new line system
  133740. * @param options defines the options used to create the line system
  133741. * @param scene defines the hosting scene
  133742. * @returns a new line mesh
  133743. */
  133744. static CreateLines(name: string, options: {
  133745. points: Vector3[];
  133746. updatable?: boolean;
  133747. instance?: Nullable<LinesMesh>;
  133748. colors?: Color4[];
  133749. useVertexAlpha?: boolean;
  133750. }, scene?: Nullable<Scene>): LinesMesh;
  133751. /**
  133752. * Creates a dashed line mesh
  133753. * * 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
  133754. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133755. * * The parameter `points` is an array successive Vector3
  133756. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133757. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133758. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133759. * * 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
  133760. * * When updating an instance, remember that only point positions can change, not the number of points
  133761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133762. * @param name defines the name of the mesh
  133763. * @param options defines the options used to create the mesh
  133764. * @param scene defines the hosting scene
  133765. * @returns the dashed line mesh
  133766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133767. */
  133768. static CreateDashedLines(name: string, options: {
  133769. points: Vector3[];
  133770. dashSize?: number;
  133771. gapSize?: number;
  133772. dashNb?: number;
  133773. updatable?: boolean;
  133774. instance?: LinesMesh;
  133775. }, scene?: Nullable<Scene>): LinesMesh;
  133776. /**
  133777. * 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.
  133778. * * 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.
  133779. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133780. * * 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.
  133781. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  133782. * * 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
  133783. * * 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
  133784. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  133785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  133788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133789. * @param name defines the name of the mesh
  133790. * @param options defines the options used to create the mesh
  133791. * @param scene defines the hosting scene
  133792. * @returns the extruded shape mesh
  133793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133795. */
  133796. static ExtrudeShape(name: string, options: {
  133797. shape: Vector3[];
  133798. path: Vector3[];
  133799. scale?: number;
  133800. rotation?: number;
  133801. cap?: number;
  133802. updatable?: boolean;
  133803. sideOrientation?: number;
  133804. frontUVs?: Vector4;
  133805. backUVs?: Vector4;
  133806. instance?: Mesh;
  133807. invertUV?: boolean;
  133808. }, scene?: Nullable<Scene>): Mesh;
  133809. /**
  133810. * Creates an custom extruded shape mesh.
  133811. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  133812. * * 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.
  133813. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133814. * * 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
  133815. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  133816. * * 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
  133817. * * It must returns a float value that will be the scale value applied to the shape on each path point
  133818. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  133819. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  133820. * * 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
  133821. * * 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
  133822. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  133823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133827. * @param name defines the name of the mesh
  133828. * @param options defines the options used to create the mesh
  133829. * @param scene defines the hosting scene
  133830. * @returns the custom extruded shape mesh
  133831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  133832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133834. */
  133835. static ExtrudeShapeCustom(name: string, options: {
  133836. shape: Vector3[];
  133837. path: Vector3[];
  133838. scaleFunction?: any;
  133839. rotationFunction?: any;
  133840. ribbonCloseArray?: boolean;
  133841. ribbonClosePath?: boolean;
  133842. cap?: number;
  133843. updatable?: boolean;
  133844. sideOrientation?: number;
  133845. frontUVs?: Vector4;
  133846. backUVs?: Vector4;
  133847. instance?: Mesh;
  133848. invertUV?: boolean;
  133849. }, scene?: Nullable<Scene>): Mesh;
  133850. /**
  133851. * Creates lathe mesh.
  133852. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133853. * * 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
  133854. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133855. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133856. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133857. * * 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
  133858. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133859. * * 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
  133860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133864. * @param name defines the name of the mesh
  133865. * @param options defines the options used to create the mesh
  133866. * @param scene defines the hosting scene
  133867. * @returns the lathe mesh
  133868. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133869. */
  133870. static CreateLathe(name: string, options: {
  133871. shape: Vector3[];
  133872. radius?: number;
  133873. tessellation?: number;
  133874. clip?: number;
  133875. arc?: number;
  133876. closed?: boolean;
  133877. updatable?: boolean;
  133878. sideOrientation?: number;
  133879. frontUVs?: Vector4;
  133880. backUVs?: Vector4;
  133881. cap?: number;
  133882. invertUV?: boolean;
  133883. }, scene?: Nullable<Scene>): Mesh;
  133884. /**
  133885. * Creates a tiled plane mesh
  133886. * * You can set a limited pattern arrangement with the tiles
  133887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133890. * @param name defines the name of the mesh
  133891. * @param options defines the options used to create the mesh
  133892. * @param scene defines the hosting scene
  133893. * @returns the plane mesh
  133894. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133895. */
  133896. static CreateTiledPlane(name: string, options: {
  133897. pattern?: number;
  133898. tileSize?: number;
  133899. tileWidth?: number;
  133900. tileHeight?: number;
  133901. size?: number;
  133902. width?: number;
  133903. height?: number;
  133904. alignHorizontal?: number;
  133905. alignVertical?: number;
  133906. sideOrientation?: number;
  133907. frontUVs?: Vector4;
  133908. backUVs?: Vector4;
  133909. updatable?: boolean;
  133910. }, scene?: Nullable<Scene>): Mesh;
  133911. /**
  133912. * Creates a plane mesh
  133913. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  133914. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  133915. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  133916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133919. * @param name defines the name of the mesh
  133920. * @param options defines the options used to create the mesh
  133921. * @param scene defines the hosting scene
  133922. * @returns the plane mesh
  133923. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133924. */
  133925. static CreatePlane(name: string, options: {
  133926. size?: number;
  133927. width?: number;
  133928. height?: number;
  133929. sideOrientation?: number;
  133930. frontUVs?: Vector4;
  133931. backUVs?: Vector4;
  133932. updatable?: boolean;
  133933. sourcePlane?: Plane;
  133934. }, scene?: Nullable<Scene>): Mesh;
  133935. /**
  133936. * Creates a ground mesh
  133937. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  133938. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  133939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133940. * @param name defines the name of the mesh
  133941. * @param options defines the options used to create the mesh
  133942. * @param scene defines the hosting scene
  133943. * @returns the ground mesh
  133944. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  133945. */
  133946. static CreateGround(name: string, options: {
  133947. width?: number;
  133948. height?: number;
  133949. subdivisions?: number;
  133950. subdivisionsX?: number;
  133951. subdivisionsY?: number;
  133952. updatable?: boolean;
  133953. }, scene?: Nullable<Scene>): Mesh;
  133954. /**
  133955. * Creates a tiled ground mesh
  133956. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  133957. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  133958. * * 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
  133959. * * 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
  133960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133961. * @param name defines the name of the mesh
  133962. * @param options defines the options used to create the mesh
  133963. * @param scene defines the hosting scene
  133964. * @returns the tiled ground mesh
  133965. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  133966. */
  133967. static CreateTiledGround(name: string, options: {
  133968. xmin: number;
  133969. zmin: number;
  133970. xmax: number;
  133971. zmax: number;
  133972. subdivisions?: {
  133973. w: number;
  133974. h: number;
  133975. };
  133976. precision?: {
  133977. w: number;
  133978. h: number;
  133979. };
  133980. updatable?: boolean;
  133981. }, scene?: Nullable<Scene>): Mesh;
  133982. /**
  133983. * Creates a ground mesh from a height map
  133984. * * The parameter `url` sets the URL of the height map image resource.
  133985. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  133986. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  133987. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  133988. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  133989. * * 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.
  133990. * * 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).
  133991. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  133992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133993. * @param name defines the name of the mesh
  133994. * @param url defines the url to the height map
  133995. * @param options defines the options used to create the mesh
  133996. * @param scene defines the hosting scene
  133997. * @returns the ground mesh
  133998. * @see https://doc.babylonjs.com/babylon101/height_map
  133999. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134000. */
  134001. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134002. width?: number;
  134003. height?: number;
  134004. subdivisions?: number;
  134005. minHeight?: number;
  134006. maxHeight?: number;
  134007. colorFilter?: Color3;
  134008. alphaFilter?: number;
  134009. updatable?: boolean;
  134010. onReady?: (mesh: GroundMesh) => void;
  134011. }, scene?: Nullable<Scene>): GroundMesh;
  134012. /**
  134013. * Creates a polygon mesh
  134014. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134015. * * 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
  134016. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134019. * * Remember you can only change the shape positions, not their number when updating a polygon
  134020. * @param name defines the name of the mesh
  134021. * @param options defines the options used to create the mesh
  134022. * @param scene defines the hosting scene
  134023. * @param earcutInjection can be used to inject your own earcut reference
  134024. * @returns the polygon mesh
  134025. */
  134026. static CreatePolygon(name: string, options: {
  134027. shape: Vector3[];
  134028. holes?: Vector3[][];
  134029. depth?: number;
  134030. faceUV?: Vector4[];
  134031. faceColors?: Color4[];
  134032. updatable?: boolean;
  134033. sideOrientation?: number;
  134034. frontUVs?: Vector4;
  134035. backUVs?: Vector4;
  134036. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134037. /**
  134038. * Creates an extruded polygon mesh, with depth in the Y direction.
  134039. * * 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)
  134040. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134041. * @param name defines the name of the mesh
  134042. * @param options defines the options used to create the mesh
  134043. * @param scene defines the hosting scene
  134044. * @param earcutInjection can be used to inject your own earcut reference
  134045. * @returns the polygon mesh
  134046. */
  134047. static ExtrudePolygon(name: string, options: {
  134048. shape: Vector3[];
  134049. holes?: Vector3[][];
  134050. depth?: number;
  134051. faceUV?: Vector4[];
  134052. faceColors?: Color4[];
  134053. updatable?: boolean;
  134054. sideOrientation?: number;
  134055. frontUVs?: Vector4;
  134056. backUVs?: Vector4;
  134057. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134058. /**
  134059. * Creates a tube mesh.
  134060. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134061. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134062. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134063. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134064. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134065. * * 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)
  134066. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134067. * * 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
  134068. * * 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
  134069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134071. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134073. * @param name defines the name of the mesh
  134074. * @param options defines the options used to create the mesh
  134075. * @param scene defines the hosting scene
  134076. * @returns the tube mesh
  134077. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134078. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134079. */
  134080. static CreateTube(name: string, options: {
  134081. path: Vector3[];
  134082. radius?: number;
  134083. tessellation?: number;
  134084. radiusFunction?: {
  134085. (i: number, distance: number): number;
  134086. };
  134087. cap?: number;
  134088. arc?: number;
  134089. updatable?: boolean;
  134090. sideOrientation?: number;
  134091. frontUVs?: Vector4;
  134092. backUVs?: Vector4;
  134093. instance?: Mesh;
  134094. invertUV?: boolean;
  134095. }, scene?: Nullable<Scene>): Mesh;
  134096. /**
  134097. * Creates a polyhedron mesh
  134098. * * 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
  134099. * * The parameter `size` (positive float, default 1) sets the polygon size
  134100. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134101. * * 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`
  134102. * * 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
  134103. * * 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)`)
  134104. * * 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
  134105. * * 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
  134106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134109. * @param name defines the name of the mesh
  134110. * @param options defines the options used to create the mesh
  134111. * @param scene defines the hosting scene
  134112. * @returns the polyhedron mesh
  134113. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134114. */
  134115. static CreatePolyhedron(name: string, options: {
  134116. type?: number;
  134117. size?: number;
  134118. sizeX?: number;
  134119. sizeY?: number;
  134120. sizeZ?: number;
  134121. custom?: any;
  134122. faceUV?: Vector4[];
  134123. faceColors?: Color4[];
  134124. flat?: boolean;
  134125. updatable?: boolean;
  134126. sideOrientation?: number;
  134127. frontUVs?: Vector4;
  134128. backUVs?: Vector4;
  134129. }, scene?: Nullable<Scene>): Mesh;
  134130. /**
  134131. * Creates a decal mesh.
  134132. * 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
  134133. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134134. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134135. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134136. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134137. * @param name defines the name of the mesh
  134138. * @param sourceMesh defines the mesh where the decal must be applied
  134139. * @param options defines the options used to create the mesh
  134140. * @param scene defines the hosting scene
  134141. * @returns the decal mesh
  134142. * @see https://doc.babylonjs.com/how_to/decals
  134143. */
  134144. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134145. position?: Vector3;
  134146. normal?: Vector3;
  134147. size?: Vector3;
  134148. angle?: number;
  134149. }): Mesh;
  134150. }
  134151. }
  134152. declare module BABYLON {
  134153. /**
  134154. * A simplifier interface for future simplification implementations
  134155. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134156. */
  134157. export interface ISimplifier {
  134158. /**
  134159. * Simplification of a given mesh according to the given settings.
  134160. * Since this requires computation, it is assumed that the function runs async.
  134161. * @param settings The settings of the simplification, including quality and distance
  134162. * @param successCallback A callback that will be called after the mesh was simplified.
  134163. * @param errorCallback in case of an error, this callback will be called. optional.
  134164. */
  134165. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134166. }
  134167. /**
  134168. * Expected simplification settings.
  134169. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134170. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134171. */
  134172. export interface ISimplificationSettings {
  134173. /**
  134174. * Gets or sets the expected quality
  134175. */
  134176. quality: number;
  134177. /**
  134178. * Gets or sets the distance when this optimized version should be used
  134179. */
  134180. distance: number;
  134181. /**
  134182. * Gets an already optimized mesh
  134183. */
  134184. optimizeMesh?: boolean;
  134185. }
  134186. /**
  134187. * Class used to specify simplification options
  134188. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134189. */
  134190. export class SimplificationSettings implements ISimplificationSettings {
  134191. /** expected quality */
  134192. quality: number;
  134193. /** distance when this optimized version should be used */
  134194. distance: number;
  134195. /** already optimized mesh */
  134196. optimizeMesh?: boolean | undefined;
  134197. /**
  134198. * Creates a SimplificationSettings
  134199. * @param quality expected quality
  134200. * @param distance distance when this optimized version should be used
  134201. * @param optimizeMesh already optimized mesh
  134202. */
  134203. constructor(
  134204. /** expected quality */
  134205. quality: number,
  134206. /** distance when this optimized version should be used */
  134207. distance: number,
  134208. /** already optimized mesh */
  134209. optimizeMesh?: boolean | undefined);
  134210. }
  134211. /**
  134212. * Interface used to define a simplification task
  134213. */
  134214. export interface ISimplificationTask {
  134215. /**
  134216. * Array of settings
  134217. */
  134218. settings: Array<ISimplificationSettings>;
  134219. /**
  134220. * Simplification type
  134221. */
  134222. simplificationType: SimplificationType;
  134223. /**
  134224. * Mesh to simplify
  134225. */
  134226. mesh: Mesh;
  134227. /**
  134228. * Callback called on success
  134229. */
  134230. successCallback?: () => void;
  134231. /**
  134232. * Defines if parallel processing can be used
  134233. */
  134234. parallelProcessing: boolean;
  134235. }
  134236. /**
  134237. * Queue used to order the simplification tasks
  134238. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134239. */
  134240. export class SimplificationQueue {
  134241. private _simplificationArray;
  134242. /**
  134243. * Gets a boolean indicating that the process is still running
  134244. */
  134245. running: boolean;
  134246. /**
  134247. * Creates a new queue
  134248. */
  134249. constructor();
  134250. /**
  134251. * Adds a new simplification task
  134252. * @param task defines a task to add
  134253. */
  134254. addTask(task: ISimplificationTask): void;
  134255. /**
  134256. * Execute next task
  134257. */
  134258. executeNext(): void;
  134259. /**
  134260. * Execute a simplification task
  134261. * @param task defines the task to run
  134262. */
  134263. runSimplification(task: ISimplificationTask): void;
  134264. private getSimplifier;
  134265. }
  134266. /**
  134267. * The implemented types of simplification
  134268. * At the moment only Quadratic Error Decimation is implemented
  134269. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134270. */
  134271. export enum SimplificationType {
  134272. /** Quadratic error decimation */
  134273. QUADRATIC = 0
  134274. }
  134275. }
  134276. declare module BABYLON {
  134277. interface Scene {
  134278. /** @hidden (Backing field) */
  134279. _simplificationQueue: SimplificationQueue;
  134280. /**
  134281. * Gets or sets the simplification queue attached to the scene
  134282. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134283. */
  134284. simplificationQueue: SimplificationQueue;
  134285. }
  134286. interface Mesh {
  134287. /**
  134288. * Simplify the mesh according to the given array of settings.
  134289. * Function will return immediately and will simplify async
  134290. * @param settings a collection of simplification settings
  134291. * @param parallelProcessing should all levels calculate parallel or one after the other
  134292. * @param simplificationType the type of simplification to run
  134293. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134294. * @returns the current mesh
  134295. */
  134296. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134297. }
  134298. /**
  134299. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134300. * created in a scene
  134301. */
  134302. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134303. /**
  134304. * The component name helpfull to identify the component in the list of scene components.
  134305. */
  134306. readonly name: string;
  134307. /**
  134308. * The scene the component belongs to.
  134309. */
  134310. scene: Scene;
  134311. /**
  134312. * Creates a new instance of the component for the given scene
  134313. * @param scene Defines the scene to register the component in
  134314. */
  134315. constructor(scene: Scene);
  134316. /**
  134317. * Registers the component in a given scene
  134318. */
  134319. register(): void;
  134320. /**
  134321. * Rebuilds the elements related to this component in case of
  134322. * context lost for instance.
  134323. */
  134324. rebuild(): void;
  134325. /**
  134326. * Disposes the component and the associated ressources
  134327. */
  134328. dispose(): void;
  134329. private _beforeCameraUpdate;
  134330. }
  134331. }
  134332. declare module BABYLON {
  134333. /**
  134334. * Navigation plugin interface to add navigation constrained by a navigation mesh
  134335. */
  134336. export interface INavigationEnginePlugin {
  134337. /**
  134338. * plugin name
  134339. */
  134340. name: string;
  134341. /**
  134342. * Creates a navigation mesh
  134343. * @param meshes array of all the geometry used to compute the navigatio mesh
  134344. * @param parameters bunch of parameters used to filter geometry
  134345. */
  134346. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134347. /**
  134348. * Create a navigation mesh debug mesh
  134349. * @param scene is where the mesh will be added
  134350. * @returns debug display mesh
  134351. */
  134352. createDebugNavMesh(scene: Scene): Mesh;
  134353. /**
  134354. * Get a navigation mesh constrained position, closest to the parameter position
  134355. * @param position world position
  134356. * @returns the closest point to position constrained by the navigation mesh
  134357. */
  134358. getClosestPoint(position: Vector3): Vector3;
  134359. /**
  134360. * Get a navigation mesh constrained position, within a particular radius
  134361. * @param position world position
  134362. * @param maxRadius the maximum distance to the constrained world position
  134363. * @returns the closest point to position constrained by the navigation mesh
  134364. */
  134365. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134366. /**
  134367. * Compute the final position from a segment made of destination-position
  134368. * @param position world position
  134369. * @param destination world position
  134370. * @returns the resulting point along the navmesh
  134371. */
  134372. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134373. /**
  134374. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134375. * @param start world position
  134376. * @param end world position
  134377. * @returns array containing world position composing the path
  134378. */
  134379. computePath(start: Vector3, end: Vector3): Vector3[];
  134380. /**
  134381. * If this plugin is supported
  134382. * @returns true if plugin is supported
  134383. */
  134384. isSupported(): boolean;
  134385. /**
  134386. * Create a new Crowd so you can add agents
  134387. * @param maxAgents the maximum agent count in the crowd
  134388. * @param maxAgentRadius the maximum radius an agent can have
  134389. * @param scene to attach the crowd to
  134390. * @returns the crowd you can add agents to
  134391. */
  134392. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134393. /**
  134394. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134395. * The queries will try to find a solution within those bounds
  134396. * default is (1,1,1)
  134397. * @param extent x,y,z value that define the extent around the queries point of reference
  134398. */
  134399. setDefaultQueryExtent(extent: Vector3): void;
  134400. /**
  134401. * Get the Bounding box extent specified by setDefaultQueryExtent
  134402. * @returns the box extent values
  134403. */
  134404. getDefaultQueryExtent(): Vector3;
  134405. /**
  134406. * Release all resources
  134407. */
  134408. dispose(): void;
  134409. }
  134410. /**
  134411. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  134412. */
  134413. export interface ICrowd {
  134414. /**
  134415. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134416. * You can attach anything to that node. The node position is updated in the scene update tick.
  134417. * @param pos world position that will be constrained by the navigation mesh
  134418. * @param parameters agent parameters
  134419. * @param transform hooked to the agent that will be update by the scene
  134420. * @returns agent index
  134421. */
  134422. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134423. /**
  134424. * Returns the agent position in world space
  134425. * @param index agent index returned by addAgent
  134426. * @returns world space position
  134427. */
  134428. getAgentPosition(index: number): Vector3;
  134429. /**
  134430. * Gets the agent velocity in world space
  134431. * @param index agent index returned by addAgent
  134432. * @returns world space velocity
  134433. */
  134434. getAgentVelocity(index: number): Vector3;
  134435. /**
  134436. * remove a particular agent previously created
  134437. * @param index agent index returned by addAgent
  134438. */
  134439. removeAgent(index: number): void;
  134440. /**
  134441. * get the list of all agents attached to this crowd
  134442. * @returns list of agent indices
  134443. */
  134444. getAgents(): number[];
  134445. /**
  134446. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134447. * @param deltaTime in seconds
  134448. */
  134449. update(deltaTime: number): void;
  134450. /**
  134451. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134452. * @param index agent index returned by addAgent
  134453. * @param destination targeted world position
  134454. */
  134455. agentGoto(index: number, destination: Vector3): void;
  134456. /**
  134457. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134458. * The queries will try to find a solution within those bounds
  134459. * default is (1,1,1)
  134460. * @param extent x,y,z value that define the extent around the queries point of reference
  134461. */
  134462. setDefaultQueryExtent(extent: Vector3): void;
  134463. /**
  134464. * Get the Bounding box extent specified by setDefaultQueryExtent
  134465. * @returns the box extent values
  134466. */
  134467. getDefaultQueryExtent(): Vector3;
  134468. /**
  134469. * Release all resources
  134470. */
  134471. dispose(): void;
  134472. }
  134473. /**
  134474. * Configures an agent
  134475. */
  134476. export interface IAgentParameters {
  134477. /**
  134478. * Agent radius. [Limit: >= 0]
  134479. */
  134480. radius: number;
  134481. /**
  134482. * Agent height. [Limit: > 0]
  134483. */
  134484. height: number;
  134485. /**
  134486. * Maximum allowed acceleration. [Limit: >= 0]
  134487. */
  134488. maxAcceleration: number;
  134489. /**
  134490. * Maximum allowed speed. [Limit: >= 0]
  134491. */
  134492. maxSpeed: number;
  134493. /**
  134494. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  134495. */
  134496. collisionQueryRange: number;
  134497. /**
  134498. * The path visibility optimization range. [Limit: > 0]
  134499. */
  134500. pathOptimizationRange: number;
  134501. /**
  134502. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  134503. */
  134504. separationWeight: number;
  134505. }
  134506. /**
  134507. * Configures the navigation mesh creation
  134508. */
  134509. export interface INavMeshParameters {
  134510. /**
  134511. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  134512. */
  134513. cs: number;
  134514. /**
  134515. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  134516. */
  134517. ch: number;
  134518. /**
  134519. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  134520. */
  134521. walkableSlopeAngle: number;
  134522. /**
  134523. * Minimum floor to 'ceiling' height that will still allow the floor area to
  134524. * be considered walkable. [Limit: >= 3] [Units: vx]
  134525. */
  134526. walkableHeight: number;
  134527. /**
  134528. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  134529. */
  134530. walkableClimb: number;
  134531. /**
  134532. * The distance to erode/shrink the walkable area of the heightfield away from
  134533. * obstructions. [Limit: >=0] [Units: vx]
  134534. */
  134535. walkableRadius: number;
  134536. /**
  134537. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  134538. */
  134539. maxEdgeLen: number;
  134540. /**
  134541. * The maximum distance a simplfied contour's border edges should deviate
  134542. * the original raw contour. [Limit: >=0] [Units: vx]
  134543. */
  134544. maxSimplificationError: number;
  134545. /**
  134546. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  134547. */
  134548. minRegionArea: number;
  134549. /**
  134550. * Any regions with a span count smaller than this value will, if possible,
  134551. * be merged with larger regions. [Limit: >=0] [Units: vx]
  134552. */
  134553. mergeRegionArea: number;
  134554. /**
  134555. * The maximum number of vertices allowed for polygons generated during the
  134556. * contour to polygon conversion process. [Limit: >= 3]
  134557. */
  134558. maxVertsPerPoly: number;
  134559. /**
  134560. * Sets the sampling distance to use when generating the detail mesh.
  134561. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  134562. */
  134563. detailSampleDist: number;
  134564. /**
  134565. * The maximum distance the detail mesh surface should deviate from heightfield
  134566. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  134567. */
  134568. detailSampleMaxError: number;
  134569. }
  134570. }
  134571. declare module BABYLON {
  134572. /**
  134573. * RecastJS navigation plugin
  134574. */
  134575. export class RecastJSPlugin implements INavigationEnginePlugin {
  134576. /**
  134577. * Reference to the Recast library
  134578. */
  134579. bjsRECAST: any;
  134580. /**
  134581. * plugin name
  134582. */
  134583. name: string;
  134584. /**
  134585. * the first navmesh created. We might extend this to support multiple navmeshes
  134586. */
  134587. navMesh: any;
  134588. /**
  134589. * Initializes the recastJS plugin
  134590. * @param recastInjection can be used to inject your own recast reference
  134591. */
  134592. constructor(recastInjection?: any);
  134593. /**
  134594. * Creates a navigation mesh
  134595. * @param meshes array of all the geometry used to compute the navigatio mesh
  134596. * @param parameters bunch of parameters used to filter geometry
  134597. */
  134598. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134599. /**
  134600. * Create a navigation mesh debug mesh
  134601. * @param scene is where the mesh will be added
  134602. * @returns debug display mesh
  134603. */
  134604. createDebugNavMesh(scene: Scene): Mesh;
  134605. /**
  134606. * Get a navigation mesh constrained position, closest to the parameter position
  134607. * @param position world position
  134608. * @returns the closest point to position constrained by the navigation mesh
  134609. */
  134610. getClosestPoint(position: Vector3): Vector3;
  134611. /**
  134612. * Get a navigation mesh constrained position, within a particular radius
  134613. * @param position world position
  134614. * @param maxRadius the maximum distance to the constrained world position
  134615. * @returns the closest point to position constrained by the navigation mesh
  134616. */
  134617. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134618. /**
  134619. * Compute the final position from a segment made of destination-position
  134620. * @param position world position
  134621. * @param destination world position
  134622. * @returns the resulting point along the navmesh
  134623. */
  134624. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134625. /**
  134626. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134627. * @param start world position
  134628. * @param end world position
  134629. * @returns array containing world position composing the path
  134630. */
  134631. computePath(start: Vector3, end: Vector3): Vector3[];
  134632. /**
  134633. * Create a new Crowd so you can add agents
  134634. * @param maxAgents the maximum agent count in the crowd
  134635. * @param maxAgentRadius the maximum radius an agent can have
  134636. * @param scene to attach the crowd to
  134637. * @returns the crowd you can add agents to
  134638. */
  134639. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134640. /**
  134641. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134642. * The queries will try to find a solution within those bounds
  134643. * default is (1,1,1)
  134644. * @param extent x,y,z value that define the extent around the queries point of reference
  134645. */
  134646. setDefaultQueryExtent(extent: Vector3): void;
  134647. /**
  134648. * Get the Bounding box extent specified by setDefaultQueryExtent
  134649. * @returns the box extent values
  134650. */
  134651. getDefaultQueryExtent(): Vector3;
  134652. /**
  134653. * Disposes
  134654. */
  134655. dispose(): void;
  134656. /**
  134657. * If this plugin is supported
  134658. * @returns true if plugin is supported
  134659. */
  134660. isSupported(): boolean;
  134661. }
  134662. /**
  134663. * Recast detour crowd implementation
  134664. */
  134665. export class RecastJSCrowd implements ICrowd {
  134666. /**
  134667. * Recast/detour plugin
  134668. */
  134669. bjsRECASTPlugin: RecastJSPlugin;
  134670. /**
  134671. * Link to the detour crowd
  134672. */
  134673. recastCrowd: any;
  134674. /**
  134675. * One transform per agent
  134676. */
  134677. transforms: TransformNode[];
  134678. /**
  134679. * All agents created
  134680. */
  134681. agents: number[];
  134682. /**
  134683. * Link to the scene is kept to unregister the crowd from the scene
  134684. */
  134685. private _scene;
  134686. /**
  134687. * Observer for crowd updates
  134688. */
  134689. private _onBeforeAnimationsObserver;
  134690. /**
  134691. * Constructor
  134692. * @param plugin recastJS plugin
  134693. * @param maxAgents the maximum agent count in the crowd
  134694. * @param maxAgentRadius the maximum radius an agent can have
  134695. * @param scene to attach the crowd to
  134696. * @returns the crowd you can add agents to
  134697. */
  134698. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  134699. /**
  134700. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134701. * You can attach anything to that node. The node position is updated in the scene update tick.
  134702. * @param pos world position that will be constrained by the navigation mesh
  134703. * @param parameters agent parameters
  134704. * @param transform hooked to the agent that will be update by the scene
  134705. * @returns agent index
  134706. */
  134707. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134708. /**
  134709. * Returns the agent position in world space
  134710. * @param index agent index returned by addAgent
  134711. * @returns world space position
  134712. */
  134713. getAgentPosition(index: number): Vector3;
  134714. /**
  134715. * Returns the agent velocity in world space
  134716. * @param index agent index returned by addAgent
  134717. * @returns world space velocity
  134718. */
  134719. getAgentVelocity(index: number): Vector3;
  134720. /**
  134721. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134722. * @param index agent index returned by addAgent
  134723. * @param destination targeted world position
  134724. */
  134725. agentGoto(index: number, destination: Vector3): void;
  134726. /**
  134727. * remove a particular agent previously created
  134728. * @param index agent index returned by addAgent
  134729. */
  134730. removeAgent(index: number): void;
  134731. /**
  134732. * get the list of all agents attached to this crowd
  134733. * @returns list of agent indices
  134734. */
  134735. getAgents(): number[];
  134736. /**
  134737. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134738. * @param deltaTime in seconds
  134739. */
  134740. update(deltaTime: number): void;
  134741. /**
  134742. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134743. * The queries will try to find a solution within those bounds
  134744. * default is (1,1,1)
  134745. * @param extent x,y,z value that define the extent around the queries point of reference
  134746. */
  134747. setDefaultQueryExtent(extent: Vector3): void;
  134748. /**
  134749. * Get the Bounding box extent specified by setDefaultQueryExtent
  134750. * @returns the box extent values
  134751. */
  134752. getDefaultQueryExtent(): Vector3;
  134753. /**
  134754. * Release all resources
  134755. */
  134756. dispose(): void;
  134757. }
  134758. }
  134759. declare module BABYLON {
  134760. /**
  134761. * Class used to enable access to IndexedDB
  134762. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  134763. */
  134764. export class Database implements IOfflineProvider {
  134765. private _callbackManifestChecked;
  134766. private _currentSceneUrl;
  134767. private _db;
  134768. private _enableSceneOffline;
  134769. private _enableTexturesOffline;
  134770. private _manifestVersionFound;
  134771. private _mustUpdateRessources;
  134772. private _hasReachedQuota;
  134773. private _isSupported;
  134774. private _idbFactory;
  134775. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  134776. private static IsUASupportingBlobStorage;
  134777. /**
  134778. * Gets a boolean indicating if Database storate is enabled (off by default)
  134779. */
  134780. static IDBStorageEnabled: boolean;
  134781. /**
  134782. * Gets a boolean indicating if scene must be saved in the database
  134783. */
  134784. get enableSceneOffline(): boolean;
  134785. /**
  134786. * Gets a boolean indicating if textures must be saved in the database
  134787. */
  134788. get enableTexturesOffline(): boolean;
  134789. /**
  134790. * Creates a new Database
  134791. * @param urlToScene defines the url to load the scene
  134792. * @param callbackManifestChecked defines the callback to use when manifest is checked
  134793. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  134794. */
  134795. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  134796. private static _ParseURL;
  134797. private static _ReturnFullUrlLocation;
  134798. private _checkManifestFile;
  134799. /**
  134800. * Open the database and make it available
  134801. * @param successCallback defines the callback to call on success
  134802. * @param errorCallback defines the callback to call on error
  134803. */
  134804. open(successCallback: () => void, errorCallback: () => void): void;
  134805. /**
  134806. * Loads an image from the database
  134807. * @param url defines the url to load from
  134808. * @param image defines the target DOM image
  134809. */
  134810. loadImage(url: string, image: HTMLImageElement): void;
  134811. private _loadImageFromDBAsync;
  134812. private _saveImageIntoDBAsync;
  134813. private _checkVersionFromDB;
  134814. private _loadVersionFromDBAsync;
  134815. private _saveVersionIntoDBAsync;
  134816. /**
  134817. * Loads a file from database
  134818. * @param url defines the URL to load from
  134819. * @param sceneLoaded defines a callback to call on success
  134820. * @param progressCallBack defines a callback to call when progress changed
  134821. * @param errorCallback defines a callback to call on error
  134822. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  134823. */
  134824. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  134825. private _loadFileAsync;
  134826. private _saveFileAsync;
  134827. /**
  134828. * Validates if xhr data is correct
  134829. * @param xhr defines the request to validate
  134830. * @param dataType defines the expected data type
  134831. * @returns true if data is correct
  134832. */
  134833. private static _ValidateXHRData;
  134834. }
  134835. }
  134836. declare module BABYLON {
  134837. /** @hidden */
  134838. export var gpuUpdateParticlesPixelShader: {
  134839. name: string;
  134840. shader: string;
  134841. };
  134842. }
  134843. declare module BABYLON {
  134844. /** @hidden */
  134845. export var gpuUpdateParticlesVertexShader: {
  134846. name: string;
  134847. shader: string;
  134848. };
  134849. }
  134850. declare module BABYLON {
  134851. /** @hidden */
  134852. export var clipPlaneFragmentDeclaration2: {
  134853. name: string;
  134854. shader: string;
  134855. };
  134856. }
  134857. declare module BABYLON {
  134858. /** @hidden */
  134859. export var gpuRenderParticlesPixelShader: {
  134860. name: string;
  134861. shader: string;
  134862. };
  134863. }
  134864. declare module BABYLON {
  134865. /** @hidden */
  134866. export var clipPlaneVertexDeclaration2: {
  134867. name: string;
  134868. shader: string;
  134869. };
  134870. }
  134871. declare module BABYLON {
  134872. /** @hidden */
  134873. export var gpuRenderParticlesVertexShader: {
  134874. name: string;
  134875. shader: string;
  134876. };
  134877. }
  134878. declare module BABYLON {
  134879. /**
  134880. * This represents a GPU particle system in Babylon
  134881. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  134882. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  134883. */
  134884. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  134885. /**
  134886. * The layer mask we are rendering the particles through.
  134887. */
  134888. layerMask: number;
  134889. private _capacity;
  134890. private _activeCount;
  134891. private _currentActiveCount;
  134892. private _accumulatedCount;
  134893. private _renderEffect;
  134894. private _updateEffect;
  134895. private _buffer0;
  134896. private _buffer1;
  134897. private _spriteBuffer;
  134898. private _updateVAO;
  134899. private _renderVAO;
  134900. private _targetIndex;
  134901. private _sourceBuffer;
  134902. private _targetBuffer;
  134903. private _engine;
  134904. private _currentRenderId;
  134905. private _started;
  134906. private _stopped;
  134907. private _timeDelta;
  134908. private _randomTexture;
  134909. private _randomTexture2;
  134910. private _attributesStrideSize;
  134911. private _updateEffectOptions;
  134912. private _randomTextureSize;
  134913. private _actualFrame;
  134914. private readonly _rawTextureWidth;
  134915. /**
  134916. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  134917. */
  134918. static get IsSupported(): boolean;
  134919. /**
  134920. * An event triggered when the system is disposed.
  134921. */
  134922. onDisposeObservable: Observable<GPUParticleSystem>;
  134923. /**
  134924. * Gets the maximum number of particles active at the same time.
  134925. * @returns The max number of active particles.
  134926. */
  134927. getCapacity(): number;
  134928. /**
  134929. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  134930. * to override the particles.
  134931. */
  134932. forceDepthWrite: boolean;
  134933. /**
  134934. * Gets or set the number of active particles
  134935. */
  134936. get activeParticleCount(): number;
  134937. set activeParticleCount(value: number);
  134938. private _preWarmDone;
  134939. /**
  134940. * Is this system ready to be used/rendered
  134941. * @return true if the system is ready
  134942. */
  134943. isReady(): boolean;
  134944. /**
  134945. * Gets if the system has been started. (Note: this will still be true after stop is called)
  134946. * @returns True if it has been started, otherwise false.
  134947. */
  134948. isStarted(): boolean;
  134949. /**
  134950. * Starts the particle system and begins to emit
  134951. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  134952. */
  134953. start(delay?: number): void;
  134954. /**
  134955. * Stops the particle system.
  134956. */
  134957. stop(): void;
  134958. /**
  134959. * Remove all active particles
  134960. */
  134961. reset(): void;
  134962. /**
  134963. * Returns the string "GPUParticleSystem"
  134964. * @returns a string containing the class name
  134965. */
  134966. getClassName(): string;
  134967. private _colorGradientsTexture;
  134968. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  134969. /**
  134970. * Adds a new color gradient
  134971. * @param gradient defines the gradient to use (between 0 and 1)
  134972. * @param color1 defines the color to affect to the specified gradient
  134973. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  134974. * @returns the current particle system
  134975. */
  134976. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  134977. /**
  134978. * Remove a specific color gradient
  134979. * @param gradient defines the gradient to remove
  134980. * @returns the current particle system
  134981. */
  134982. removeColorGradient(gradient: number): GPUParticleSystem;
  134983. private _angularSpeedGradientsTexture;
  134984. private _sizeGradientsTexture;
  134985. private _velocityGradientsTexture;
  134986. private _limitVelocityGradientsTexture;
  134987. private _dragGradientsTexture;
  134988. private _addFactorGradient;
  134989. /**
  134990. * Adds a new size gradient
  134991. * @param gradient defines the gradient to use (between 0 and 1)
  134992. * @param factor defines the size factor to affect to the specified gradient
  134993. * @returns the current particle system
  134994. */
  134995. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  134996. /**
  134997. * Remove a specific size gradient
  134998. * @param gradient defines the gradient to remove
  134999. * @returns the current particle system
  135000. */
  135001. removeSizeGradient(gradient: number): GPUParticleSystem;
  135002. /**
  135003. * Adds a new angular speed gradient
  135004. * @param gradient defines the gradient to use (between 0 and 1)
  135005. * @param factor defines the angular speed to affect to the specified gradient
  135006. * @returns the current particle system
  135007. */
  135008. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135009. /**
  135010. * Remove a specific angular speed gradient
  135011. * @param gradient defines the gradient to remove
  135012. * @returns the current particle system
  135013. */
  135014. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135015. /**
  135016. * Adds a new velocity gradient
  135017. * @param gradient defines the gradient to use (between 0 and 1)
  135018. * @param factor defines the velocity to affect to the specified gradient
  135019. * @returns the current particle system
  135020. */
  135021. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135022. /**
  135023. * Remove a specific velocity gradient
  135024. * @param gradient defines the gradient to remove
  135025. * @returns the current particle system
  135026. */
  135027. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135028. /**
  135029. * Adds a new limit velocity gradient
  135030. * @param gradient defines the gradient to use (between 0 and 1)
  135031. * @param factor defines the limit velocity value to affect to the specified gradient
  135032. * @returns the current particle system
  135033. */
  135034. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135035. /**
  135036. * Remove a specific limit velocity gradient
  135037. * @param gradient defines the gradient to remove
  135038. * @returns the current particle system
  135039. */
  135040. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135041. /**
  135042. * Adds a new drag gradient
  135043. * @param gradient defines the gradient to use (between 0 and 1)
  135044. * @param factor defines the drag value to affect to the specified gradient
  135045. * @returns the current particle system
  135046. */
  135047. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135048. /**
  135049. * Remove a specific drag gradient
  135050. * @param gradient defines the gradient to remove
  135051. * @returns the current particle system
  135052. */
  135053. removeDragGradient(gradient: number): GPUParticleSystem;
  135054. /**
  135055. * Not supported by GPUParticleSystem
  135056. * @param gradient defines the gradient to use (between 0 and 1)
  135057. * @param factor defines the emit rate value to affect to the specified gradient
  135058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135059. * @returns the current particle system
  135060. */
  135061. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135062. /**
  135063. * Not supported by GPUParticleSystem
  135064. * @param gradient defines the gradient to remove
  135065. * @returns the current particle system
  135066. */
  135067. removeEmitRateGradient(gradient: number): IParticleSystem;
  135068. /**
  135069. * Not supported by GPUParticleSystem
  135070. * @param gradient defines the gradient to use (between 0 and 1)
  135071. * @param factor defines the start size value to affect to the specified gradient
  135072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135073. * @returns the current particle system
  135074. */
  135075. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135076. /**
  135077. * Not supported by GPUParticleSystem
  135078. * @param gradient defines the gradient to remove
  135079. * @returns the current particle system
  135080. */
  135081. removeStartSizeGradient(gradient: number): IParticleSystem;
  135082. /**
  135083. * Not supported by GPUParticleSystem
  135084. * @param gradient defines the gradient to use (between 0 and 1)
  135085. * @param min defines the color remap minimal range
  135086. * @param max defines the color remap maximal range
  135087. * @returns the current particle system
  135088. */
  135089. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135090. /**
  135091. * Not supported by GPUParticleSystem
  135092. * @param gradient defines the gradient to remove
  135093. * @returns the current particle system
  135094. */
  135095. removeColorRemapGradient(): IParticleSystem;
  135096. /**
  135097. * Not supported by GPUParticleSystem
  135098. * @param gradient defines the gradient to use (between 0 and 1)
  135099. * @param min defines the alpha remap minimal range
  135100. * @param max defines the alpha remap maximal range
  135101. * @returns the current particle system
  135102. */
  135103. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135104. /**
  135105. * Not supported by GPUParticleSystem
  135106. * @param gradient defines the gradient to remove
  135107. * @returns the current particle system
  135108. */
  135109. removeAlphaRemapGradient(): IParticleSystem;
  135110. /**
  135111. * Not supported by GPUParticleSystem
  135112. * @param gradient defines the gradient to use (between 0 and 1)
  135113. * @param color defines the color to affect to the specified gradient
  135114. * @returns the current particle system
  135115. */
  135116. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135117. /**
  135118. * Not supported by GPUParticleSystem
  135119. * @param gradient defines the gradient to remove
  135120. * @returns the current particle system
  135121. */
  135122. removeRampGradient(): IParticleSystem;
  135123. /**
  135124. * Not supported by GPUParticleSystem
  135125. * @returns the list of ramp gradients
  135126. */
  135127. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135128. /**
  135129. * Not supported by GPUParticleSystem
  135130. * Gets or sets a boolean indicating that ramp gradients must be used
  135131. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135132. */
  135133. get useRampGradients(): boolean;
  135134. set useRampGradients(value: boolean);
  135135. /**
  135136. * Not supported by GPUParticleSystem
  135137. * @param gradient defines the gradient to use (between 0 and 1)
  135138. * @param factor defines the life time factor to affect to the specified gradient
  135139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135140. * @returns the current particle system
  135141. */
  135142. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135143. /**
  135144. * Not supported by GPUParticleSystem
  135145. * @param gradient defines the gradient to remove
  135146. * @returns the current particle system
  135147. */
  135148. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135149. /**
  135150. * Instantiates a GPU particle system.
  135151. * 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.
  135152. * @param name The name of the particle system
  135153. * @param options The options used to create the system
  135154. * @param scene The scene the particle system belongs to
  135155. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135156. */
  135157. constructor(name: string, options: Partial<{
  135158. capacity: number;
  135159. randomTextureSize: number;
  135160. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135161. protected _reset(): void;
  135162. private _createUpdateVAO;
  135163. private _createRenderVAO;
  135164. private _initialize;
  135165. /** @hidden */
  135166. _recreateUpdateEffect(): void;
  135167. /** @hidden */
  135168. _recreateRenderEffect(): void;
  135169. /**
  135170. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135171. * @param preWarm defines if we are in the pre-warmimg phase
  135172. */
  135173. animate(preWarm?: boolean): void;
  135174. private _createFactorGradientTexture;
  135175. private _createSizeGradientTexture;
  135176. private _createAngularSpeedGradientTexture;
  135177. private _createVelocityGradientTexture;
  135178. private _createLimitVelocityGradientTexture;
  135179. private _createDragGradientTexture;
  135180. private _createColorGradientTexture;
  135181. /**
  135182. * Renders the particle system in its current state
  135183. * @param preWarm defines if the system should only update the particles but not render them
  135184. * @returns the current number of particles
  135185. */
  135186. render(preWarm?: boolean): number;
  135187. /**
  135188. * Rebuilds the particle system
  135189. */
  135190. rebuild(): void;
  135191. private _releaseBuffers;
  135192. private _releaseVAOs;
  135193. /**
  135194. * Disposes the particle system and free the associated resources
  135195. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135196. */
  135197. dispose(disposeTexture?: boolean): void;
  135198. /**
  135199. * Clones the particle system.
  135200. * @param name The name of the cloned object
  135201. * @param newEmitter The new emitter to use
  135202. * @returns the cloned particle system
  135203. */
  135204. clone(name: string, newEmitter: any): GPUParticleSystem;
  135205. /**
  135206. * Serializes the particle system to a JSON object.
  135207. * @returns the JSON object
  135208. */
  135209. serialize(): any;
  135210. /**
  135211. * Parses a JSON object to create a GPU particle system.
  135212. * @param parsedParticleSystem The JSON object to parse
  135213. * @param scene The scene to create the particle system in
  135214. * @param rootUrl The root url to use to load external dependencies like texture
  135215. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135216. * @returns the parsed GPU particle system
  135217. */
  135218. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135219. }
  135220. }
  135221. declare module BABYLON {
  135222. /**
  135223. * Represents a set of particle systems working together to create a specific effect
  135224. */
  135225. export class ParticleSystemSet implements IDisposable {
  135226. /**
  135227. * Gets or sets base Assets URL
  135228. */
  135229. static BaseAssetsUrl: string;
  135230. private _emitterCreationOptions;
  135231. private _emitterNode;
  135232. /**
  135233. * Gets the particle system list
  135234. */
  135235. systems: IParticleSystem[];
  135236. /**
  135237. * Gets the emitter node used with this set
  135238. */
  135239. get emitterNode(): Nullable<TransformNode>;
  135240. /**
  135241. * Creates a new emitter mesh as a sphere
  135242. * @param options defines the options used to create the sphere
  135243. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135244. * @param scene defines the hosting scene
  135245. */
  135246. setEmitterAsSphere(options: {
  135247. diameter: number;
  135248. segments: number;
  135249. color: Color3;
  135250. }, renderingGroupId: number, scene: Scene): void;
  135251. /**
  135252. * Starts all particle systems of the set
  135253. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135254. */
  135255. start(emitter?: AbstractMesh): void;
  135256. /**
  135257. * Release all associated resources
  135258. */
  135259. dispose(): void;
  135260. /**
  135261. * Serialize the set into a JSON compatible object
  135262. * @returns a JSON compatible representation of the set
  135263. */
  135264. serialize(): any;
  135265. /**
  135266. * Parse a new ParticleSystemSet from a serialized source
  135267. * @param data defines a JSON compatible representation of the set
  135268. * @param scene defines the hosting scene
  135269. * @param gpu defines if we want GPU particles or CPU particles
  135270. * @returns a new ParticleSystemSet
  135271. */
  135272. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135273. }
  135274. }
  135275. declare module BABYLON {
  135276. /**
  135277. * This class is made for on one-liner static method to help creating particle system set.
  135278. */
  135279. export class ParticleHelper {
  135280. /**
  135281. * Gets or sets base Assets URL
  135282. */
  135283. static BaseAssetsUrl: string;
  135284. /**
  135285. * Create a default particle system that you can tweak
  135286. * @param emitter defines the emitter to use
  135287. * @param capacity defines the system capacity (default is 500 particles)
  135288. * @param scene defines the hosting scene
  135289. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135290. * @returns the new Particle system
  135291. */
  135292. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135293. /**
  135294. * This is the main static method (one-liner) of this helper to create different particle systems
  135295. * @param type This string represents the type to the particle system to create
  135296. * @param scene The scene where the particle system should live
  135297. * @param gpu If the system will use gpu
  135298. * @returns the ParticleSystemSet created
  135299. */
  135300. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  135301. /**
  135302. * Static function used to export a particle system to a ParticleSystemSet variable.
  135303. * Please note that the emitter shape is not exported
  135304. * @param systems defines the particle systems to export
  135305. * @returns the created particle system set
  135306. */
  135307. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  135308. }
  135309. }
  135310. declare module BABYLON {
  135311. interface Engine {
  135312. /**
  135313. * Create an effect to use with particle systems.
  135314. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  135315. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  135316. * @param uniformsNames defines a list of attribute names
  135317. * @param samplers defines an array of string used to represent textures
  135318. * @param defines defines the string containing the defines to use to compile the shaders
  135319. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  135320. * @param onCompiled defines a function to call when the effect creation is successful
  135321. * @param onError defines a function to call when the effect creation has failed
  135322. * @returns the new Effect
  135323. */
  135324. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  135325. }
  135326. interface Mesh {
  135327. /**
  135328. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  135329. * @returns an array of IParticleSystem
  135330. */
  135331. getEmittedParticleSystems(): IParticleSystem[];
  135332. /**
  135333. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  135334. * @returns an array of IParticleSystem
  135335. */
  135336. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  135337. }
  135338. /**
  135339. * @hidden
  135340. */
  135341. export var _IDoNeedToBeInTheBuild: number;
  135342. }
  135343. declare module BABYLON {
  135344. /** Defines the 4 color options */
  135345. export enum PointColor {
  135346. /** color value */
  135347. Color = 2,
  135348. /** uv value */
  135349. UV = 1,
  135350. /** random value */
  135351. Random = 0,
  135352. /** stated value */
  135353. Stated = 3
  135354. }
  135355. /**
  135356. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  135357. * 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.
  135358. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  135359. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  135360. *
  135361. * Full documentation here : TO BE ENTERED
  135362. */
  135363. export class PointsCloudSystem implements IDisposable {
  135364. /**
  135365. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  135366. * Example : var p = SPS.particles[i];
  135367. */
  135368. particles: CloudPoint[];
  135369. /**
  135370. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  135371. */
  135372. nbParticles: number;
  135373. /**
  135374. * This a counter for your own usage. It's not set by any SPS functions.
  135375. */
  135376. counter: number;
  135377. /**
  135378. * The PCS name. This name is also given to the underlying mesh.
  135379. */
  135380. name: string;
  135381. /**
  135382. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  135383. */
  135384. mesh: Mesh;
  135385. /**
  135386. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  135387. * Please read :
  135388. */
  135389. vars: any;
  135390. /**
  135391. * @hidden
  135392. */
  135393. _size: number;
  135394. private _scene;
  135395. private _promises;
  135396. private _positions;
  135397. private _indices;
  135398. private _normals;
  135399. private _colors;
  135400. private _uvs;
  135401. private _indices32;
  135402. private _positions32;
  135403. private _colors32;
  135404. private _uvs32;
  135405. private _updatable;
  135406. private _isVisibilityBoxLocked;
  135407. private _alwaysVisible;
  135408. private _groups;
  135409. private _groupCounter;
  135410. private _computeParticleColor;
  135411. private _computeParticleTexture;
  135412. private _computeParticleRotation;
  135413. private _computeBoundingBox;
  135414. private _isReady;
  135415. /**
  135416. * Creates a PCS (Points Cloud System) object
  135417. * @param name (String) is the PCS name, this will be the underlying mesh name
  135418. * @param pointSize (number) is the size for each point
  135419. * @param scene (Scene) is the scene in which the PCS is added
  135420. * @param options defines the options of the PCS e.g.
  135421. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  135422. */
  135423. constructor(name: string, pointSize: number, scene: Scene, options?: {
  135424. updatable?: boolean;
  135425. });
  135426. /**
  135427. * Builds the PCS underlying mesh. Returns a standard Mesh.
  135428. * If no points were added to the PCS, the returned mesh is just a single point.
  135429. * @returns a promise for the created mesh
  135430. */
  135431. buildMeshAsync(): Promise<Mesh>;
  135432. /**
  135433. * @hidden
  135434. */
  135435. private _buildMesh;
  135436. private _addParticle;
  135437. private _randomUnitVector;
  135438. private _getColorIndicesForCoord;
  135439. private _setPointsColorOrUV;
  135440. private _colorFromTexture;
  135441. private _calculateDensity;
  135442. /**
  135443. * Adds points to the PCS in random positions within a unit sphere
  135444. * @param nb (positive integer) the number of particles to be created from this model
  135445. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  135446. * @returns the number of groups in the system
  135447. */
  135448. addPoints(nb: number, pointFunction?: any): number;
  135449. /**
  135450. * Adds points to the PCS from the surface of the model shape
  135451. * @param mesh is any Mesh object that will be used as a surface model for the points
  135452. * @param nb (positive integer) the number of particles to be created from this model
  135453. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135454. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135455. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135456. * @returns the number of groups in the system
  135457. */
  135458. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135459. /**
  135460. * Adds points to the PCS inside the model shape
  135461. * @param mesh is any Mesh object that will be used as a surface model for the points
  135462. * @param nb (positive integer) the number of particles to be created from this model
  135463. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135464. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135465. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135466. * @returns the number of groups in the system
  135467. */
  135468. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135469. /**
  135470. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  135471. * This method calls `updateParticle()` for each particle of the SPS.
  135472. * For an animated SPS, it is usually called within the render loop.
  135473. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  135474. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  135475. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  135476. * @returns the PCS.
  135477. */
  135478. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  135479. /**
  135480. * Disposes the PCS.
  135481. */
  135482. dispose(): void;
  135483. /**
  135484. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  135485. * doc :
  135486. * @returns the PCS.
  135487. */
  135488. refreshVisibleSize(): PointsCloudSystem;
  135489. /**
  135490. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  135491. * @param size the size (float) of the visibility box
  135492. * note : this doesn't lock the PCS mesh bounding box.
  135493. * doc :
  135494. */
  135495. setVisibilityBox(size: number): void;
  135496. /**
  135497. * Gets whether the PCS is always visible or not
  135498. * doc :
  135499. */
  135500. get isAlwaysVisible(): boolean;
  135501. /**
  135502. * Sets the PCS as always visible or not
  135503. * doc :
  135504. */
  135505. set isAlwaysVisible(val: boolean);
  135506. /**
  135507. * Tells to `setParticles()` to compute the particle rotations or not
  135508. * Default value : false. The PCS is faster when it's set to false
  135509. * Note : particle rotations are only applied to parent particles
  135510. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  135511. */
  135512. set computeParticleRotation(val: boolean);
  135513. /**
  135514. * Tells to `setParticles()` to compute the particle colors or not.
  135515. * Default value : true. The PCS is faster when it's set to false.
  135516. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135517. */
  135518. set computeParticleColor(val: boolean);
  135519. set computeParticleTexture(val: boolean);
  135520. /**
  135521. * Gets if `setParticles()` computes the particle colors or not.
  135522. * Default value : false. The PCS is faster when it's set to false.
  135523. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135524. */
  135525. get computeParticleColor(): boolean;
  135526. /**
  135527. * Gets if `setParticles()` computes the particle textures or not.
  135528. * Default value : false. The PCS is faster when it's set to false.
  135529. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  135530. */
  135531. get computeParticleTexture(): boolean;
  135532. /**
  135533. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  135534. */
  135535. set computeBoundingBox(val: boolean);
  135536. /**
  135537. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  135538. */
  135539. get computeBoundingBox(): boolean;
  135540. /**
  135541. * This function does nothing. It may be overwritten to set all the particle first values.
  135542. * The PCS doesn't call this function, you may have to call it by your own.
  135543. * doc :
  135544. */
  135545. initParticles(): void;
  135546. /**
  135547. * This function does nothing. It may be overwritten to recycle a particle
  135548. * The PCS doesn't call this function, you can to call it
  135549. * doc :
  135550. * @param particle The particle to recycle
  135551. * @returns the recycled particle
  135552. */
  135553. recycleParticle(particle: CloudPoint): CloudPoint;
  135554. /**
  135555. * Updates a particle : this function should be overwritten by the user.
  135556. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  135557. * doc :
  135558. * @example : just set a particle position or velocity and recycle conditions
  135559. * @param particle The particle to update
  135560. * @returns the updated particle
  135561. */
  135562. updateParticle(particle: CloudPoint): CloudPoint;
  135563. /**
  135564. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  135565. * This does nothing and may be overwritten by the user.
  135566. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135567. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135568. * @param update the boolean update value actually passed to setParticles()
  135569. */
  135570. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135571. /**
  135572. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  135573. * This will be passed three parameters.
  135574. * This does nothing and may be overwritten by the user.
  135575. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135576. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135577. * @param update the boolean update value actually passed to setParticles()
  135578. */
  135579. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135580. }
  135581. }
  135582. declare module BABYLON {
  135583. /**
  135584. * Represents one particle of a points cloud system.
  135585. */
  135586. export class CloudPoint {
  135587. /**
  135588. * particle global index
  135589. */
  135590. idx: number;
  135591. /**
  135592. * The color of the particle
  135593. */
  135594. color: Nullable<Color4>;
  135595. /**
  135596. * The world space position of the particle.
  135597. */
  135598. position: Vector3;
  135599. /**
  135600. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  135601. */
  135602. rotation: Vector3;
  135603. /**
  135604. * The world space rotation quaternion of the particle.
  135605. */
  135606. rotationQuaternion: Nullable<Quaternion>;
  135607. /**
  135608. * The uv of the particle.
  135609. */
  135610. uv: Nullable<Vector2>;
  135611. /**
  135612. * The current speed of the particle.
  135613. */
  135614. velocity: Vector3;
  135615. /**
  135616. * The pivot point in the particle local space.
  135617. */
  135618. pivot: Vector3;
  135619. /**
  135620. * Must the particle be translated from its pivot point in its local space ?
  135621. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  135622. * Default : false
  135623. */
  135624. translateFromPivot: boolean;
  135625. /**
  135626. * Index of this particle in the global "positions" array (Internal use)
  135627. * @hidden
  135628. */
  135629. _pos: number;
  135630. /**
  135631. * @hidden Index of this particle in the global "indices" array (Internal use)
  135632. */
  135633. _ind: number;
  135634. /**
  135635. * Group this particle belongs to
  135636. */
  135637. _group: PointsGroup;
  135638. /**
  135639. * Group id of this particle
  135640. */
  135641. groupId: number;
  135642. /**
  135643. * Index of the particle in its group id (Internal use)
  135644. */
  135645. idxInGroup: number;
  135646. /**
  135647. * @hidden Particle BoundingInfo object (Internal use)
  135648. */
  135649. _boundingInfo: BoundingInfo;
  135650. /**
  135651. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  135652. */
  135653. _pcs: PointsCloudSystem;
  135654. /**
  135655. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  135656. */
  135657. _stillInvisible: boolean;
  135658. /**
  135659. * @hidden Last computed particle rotation matrix
  135660. */
  135661. _rotationMatrix: number[];
  135662. /**
  135663. * Parent particle Id, if any.
  135664. * Default null.
  135665. */
  135666. parentId: Nullable<number>;
  135667. /**
  135668. * @hidden Internal global position in the PCS.
  135669. */
  135670. _globalPosition: Vector3;
  135671. /**
  135672. * Creates a Point Cloud object.
  135673. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  135674. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  135675. * @param group (PointsGroup) is the group the particle belongs to
  135676. * @param groupId (integer) is the group identifier in the PCS.
  135677. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  135678. * @param pcs defines the PCS it is associated to
  135679. */
  135680. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  135681. /**
  135682. * get point size
  135683. */
  135684. get size(): Vector3;
  135685. /**
  135686. * Set point size
  135687. */
  135688. set size(scale: Vector3);
  135689. /**
  135690. * Legacy support, changed quaternion to rotationQuaternion
  135691. */
  135692. get quaternion(): Nullable<Quaternion>;
  135693. /**
  135694. * Legacy support, changed quaternion to rotationQuaternion
  135695. */
  135696. set quaternion(q: Nullable<Quaternion>);
  135697. /**
  135698. * Returns a boolean. True if the particle intersects a mesh, else false
  135699. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  135700. * @param target is the object (point or mesh) what the intersection is computed against
  135701. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  135702. * @returns true if it intersects
  135703. */
  135704. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  135705. /**
  135706. * get the rotation matrix of the particle
  135707. * @hidden
  135708. */
  135709. getRotationMatrix(m: Matrix): void;
  135710. }
  135711. /**
  135712. * Represents a group of points in a points cloud system
  135713. * * PCS internal tool, don't use it manually.
  135714. */
  135715. export class PointsGroup {
  135716. /**
  135717. * The group id
  135718. * @hidden
  135719. */
  135720. groupID: number;
  135721. /**
  135722. * image data for group (internal use)
  135723. * @hidden
  135724. */
  135725. _groupImageData: Nullable<ArrayBufferView>;
  135726. /**
  135727. * Image Width (internal use)
  135728. * @hidden
  135729. */
  135730. _groupImgWidth: number;
  135731. /**
  135732. * Image Height (internal use)
  135733. * @hidden
  135734. */
  135735. _groupImgHeight: number;
  135736. /**
  135737. * Custom position function (internal use)
  135738. * @hidden
  135739. */
  135740. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  135741. /**
  135742. * density per facet for surface points
  135743. * @hidden
  135744. */
  135745. _groupDensity: number[];
  135746. /**
  135747. * Only when points are colored by texture carries pointer to texture list array
  135748. * @hidden
  135749. */
  135750. _textureNb: number;
  135751. /**
  135752. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  135753. * PCS internal tool, don't use it manually.
  135754. * @hidden
  135755. */
  135756. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  135757. }
  135758. }
  135759. declare module BABYLON {
  135760. interface Scene {
  135761. /** @hidden (Backing field) */
  135762. _physicsEngine: Nullable<IPhysicsEngine>;
  135763. /** @hidden */
  135764. _physicsTimeAccumulator: number;
  135765. /**
  135766. * Gets the current physics engine
  135767. * @returns a IPhysicsEngine or null if none attached
  135768. */
  135769. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  135770. /**
  135771. * Enables physics to the current scene
  135772. * @param gravity defines the scene's gravity for the physics engine
  135773. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  135774. * @return a boolean indicating if the physics engine was initialized
  135775. */
  135776. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  135777. /**
  135778. * Disables and disposes the physics engine associated with the scene
  135779. */
  135780. disablePhysicsEngine(): void;
  135781. /**
  135782. * Gets a boolean indicating if there is an active physics engine
  135783. * @returns a boolean indicating if there is an active physics engine
  135784. */
  135785. isPhysicsEnabled(): boolean;
  135786. /**
  135787. * Deletes a physics compound impostor
  135788. * @param compound defines the compound to delete
  135789. */
  135790. deleteCompoundImpostor(compound: any): void;
  135791. /**
  135792. * An event triggered when physic simulation is about to be run
  135793. */
  135794. onBeforePhysicsObservable: Observable<Scene>;
  135795. /**
  135796. * An event triggered when physic simulation has been done
  135797. */
  135798. onAfterPhysicsObservable: Observable<Scene>;
  135799. }
  135800. interface AbstractMesh {
  135801. /** @hidden */
  135802. _physicsImpostor: Nullable<PhysicsImpostor>;
  135803. /**
  135804. * Gets or sets impostor used for physic simulation
  135805. * @see http://doc.babylonjs.com/features/physics_engine
  135806. */
  135807. physicsImpostor: Nullable<PhysicsImpostor>;
  135808. /**
  135809. * Gets the current physics impostor
  135810. * @see http://doc.babylonjs.com/features/physics_engine
  135811. * @returns a physics impostor or null
  135812. */
  135813. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  135814. /** Apply a physic impulse to the mesh
  135815. * @param force defines the force to apply
  135816. * @param contactPoint defines where to apply the force
  135817. * @returns the current mesh
  135818. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135819. */
  135820. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  135821. /**
  135822. * Creates a physic joint between two meshes
  135823. * @param otherMesh defines the other mesh to use
  135824. * @param pivot1 defines the pivot to use on this mesh
  135825. * @param pivot2 defines the pivot to use on the other mesh
  135826. * @param options defines additional options (can be plugin dependent)
  135827. * @returns the current mesh
  135828. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  135829. */
  135830. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  135831. /** @hidden */
  135832. _disposePhysicsObserver: Nullable<Observer<Node>>;
  135833. }
  135834. /**
  135835. * Defines the physics engine scene component responsible to manage a physics engine
  135836. */
  135837. export class PhysicsEngineSceneComponent implements ISceneComponent {
  135838. /**
  135839. * The component name helpful to identify the component in the list of scene components.
  135840. */
  135841. readonly name: string;
  135842. /**
  135843. * The scene the component belongs to.
  135844. */
  135845. scene: Scene;
  135846. /**
  135847. * Creates a new instance of the component for the given scene
  135848. * @param scene Defines the scene to register the component in
  135849. */
  135850. constructor(scene: Scene);
  135851. /**
  135852. * Registers the component in a given scene
  135853. */
  135854. register(): void;
  135855. /**
  135856. * Rebuilds the elements related to this component in case of
  135857. * context lost for instance.
  135858. */
  135859. rebuild(): void;
  135860. /**
  135861. * Disposes the component and the associated ressources
  135862. */
  135863. dispose(): void;
  135864. }
  135865. }
  135866. declare module BABYLON {
  135867. /**
  135868. * A helper for physics simulations
  135869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  135870. */
  135871. export class PhysicsHelper {
  135872. private _scene;
  135873. private _physicsEngine;
  135874. /**
  135875. * Initializes the Physics helper
  135876. * @param scene Babylon.js scene
  135877. */
  135878. constructor(scene: Scene);
  135879. /**
  135880. * Applies a radial explosion impulse
  135881. * @param origin the origin of the explosion
  135882. * @param radiusOrEventOptions the radius or the options of radial explosion
  135883. * @param strength the explosion strength
  135884. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135885. * @returns A physics radial explosion event, or null
  135886. */
  135887. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135888. /**
  135889. * Applies a radial explosion force
  135890. * @param origin the origin of the explosion
  135891. * @param radiusOrEventOptions the radius or the options of radial explosion
  135892. * @param strength the explosion strength
  135893. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135894. * @returns A physics radial explosion event, or null
  135895. */
  135896. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135897. /**
  135898. * Creates a gravitational field
  135899. * @param origin the origin of the explosion
  135900. * @param radiusOrEventOptions the radius or the options of radial explosion
  135901. * @param strength the explosion strength
  135902. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135903. * @returns A physics gravitational field event, or null
  135904. */
  135905. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  135906. /**
  135907. * Creates a physics updraft event
  135908. * @param origin the origin of the updraft
  135909. * @param radiusOrEventOptions the radius or the options of the updraft
  135910. * @param strength the strength of the updraft
  135911. * @param height the height of the updraft
  135912. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  135913. * @returns A physics updraft event, or null
  135914. */
  135915. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  135916. /**
  135917. * Creates a physics vortex event
  135918. * @param origin the of the vortex
  135919. * @param radiusOrEventOptions the radius or the options of the vortex
  135920. * @param strength the strength of the vortex
  135921. * @param height the height of the vortex
  135922. * @returns a Physics vortex event, or null
  135923. * A physics vortex event or null
  135924. */
  135925. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  135926. }
  135927. /**
  135928. * Represents a physics radial explosion event
  135929. */
  135930. class PhysicsRadialExplosionEvent {
  135931. private _scene;
  135932. private _options;
  135933. private _sphere;
  135934. private _dataFetched;
  135935. /**
  135936. * Initializes a radial explosioin event
  135937. * @param _scene BabylonJS scene
  135938. * @param _options The options for the vortex event
  135939. */
  135940. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  135941. /**
  135942. * Returns the data related to the radial explosion event (sphere).
  135943. * @returns The radial explosion event data
  135944. */
  135945. getData(): PhysicsRadialExplosionEventData;
  135946. /**
  135947. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  135948. * @param impostor A physics imposter
  135949. * @param origin the origin of the explosion
  135950. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  135951. */
  135952. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  135953. /**
  135954. * Triggers affecterd impostors callbacks
  135955. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  135956. */
  135957. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  135958. /**
  135959. * Disposes the sphere.
  135960. * @param force Specifies if the sphere should be disposed by force
  135961. */
  135962. dispose(force?: boolean): void;
  135963. /*** Helpers ***/
  135964. private _prepareSphere;
  135965. private _intersectsWithSphere;
  135966. }
  135967. /**
  135968. * Represents a gravitational field event
  135969. */
  135970. class PhysicsGravitationalFieldEvent {
  135971. private _physicsHelper;
  135972. private _scene;
  135973. private _origin;
  135974. private _options;
  135975. private _tickCallback;
  135976. private _sphere;
  135977. private _dataFetched;
  135978. /**
  135979. * Initializes the physics gravitational field event
  135980. * @param _physicsHelper A physics helper
  135981. * @param _scene BabylonJS scene
  135982. * @param _origin The origin position of the gravitational field event
  135983. * @param _options The options for the vortex event
  135984. */
  135985. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  135986. /**
  135987. * Returns the data related to the gravitational field event (sphere).
  135988. * @returns A gravitational field event
  135989. */
  135990. getData(): PhysicsGravitationalFieldEventData;
  135991. /**
  135992. * Enables the gravitational field.
  135993. */
  135994. enable(): void;
  135995. /**
  135996. * Disables the gravitational field.
  135997. */
  135998. disable(): void;
  135999. /**
  136000. * Disposes the sphere.
  136001. * @param force The force to dispose from the gravitational field event
  136002. */
  136003. dispose(force?: boolean): void;
  136004. private _tick;
  136005. }
  136006. /**
  136007. * Represents a physics updraft event
  136008. */
  136009. class PhysicsUpdraftEvent {
  136010. private _scene;
  136011. private _origin;
  136012. private _options;
  136013. private _physicsEngine;
  136014. private _originTop;
  136015. private _originDirection;
  136016. private _tickCallback;
  136017. private _cylinder;
  136018. private _cylinderPosition;
  136019. private _dataFetched;
  136020. /**
  136021. * Initializes the physics updraft event
  136022. * @param _scene BabylonJS scene
  136023. * @param _origin The origin position of the updraft
  136024. * @param _options The options for the updraft event
  136025. */
  136026. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136027. /**
  136028. * Returns the data related to the updraft event (cylinder).
  136029. * @returns A physics updraft event
  136030. */
  136031. getData(): PhysicsUpdraftEventData;
  136032. /**
  136033. * Enables the updraft.
  136034. */
  136035. enable(): void;
  136036. /**
  136037. * Disables the updraft.
  136038. */
  136039. disable(): void;
  136040. /**
  136041. * Disposes the cylinder.
  136042. * @param force Specifies if the updraft should be disposed by force
  136043. */
  136044. dispose(force?: boolean): void;
  136045. private getImpostorHitData;
  136046. private _tick;
  136047. /*** Helpers ***/
  136048. private _prepareCylinder;
  136049. private _intersectsWithCylinder;
  136050. }
  136051. /**
  136052. * Represents a physics vortex event
  136053. */
  136054. class PhysicsVortexEvent {
  136055. private _scene;
  136056. private _origin;
  136057. private _options;
  136058. private _physicsEngine;
  136059. private _originTop;
  136060. private _tickCallback;
  136061. private _cylinder;
  136062. private _cylinderPosition;
  136063. private _dataFetched;
  136064. /**
  136065. * Initializes the physics vortex event
  136066. * @param _scene The BabylonJS scene
  136067. * @param _origin The origin position of the vortex
  136068. * @param _options The options for the vortex event
  136069. */
  136070. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136071. /**
  136072. * Returns the data related to the vortex event (cylinder).
  136073. * @returns The physics vortex event data
  136074. */
  136075. getData(): PhysicsVortexEventData;
  136076. /**
  136077. * Enables the vortex.
  136078. */
  136079. enable(): void;
  136080. /**
  136081. * Disables the cortex.
  136082. */
  136083. disable(): void;
  136084. /**
  136085. * Disposes the sphere.
  136086. * @param force
  136087. */
  136088. dispose(force?: boolean): void;
  136089. private getImpostorHitData;
  136090. private _tick;
  136091. /*** Helpers ***/
  136092. private _prepareCylinder;
  136093. private _intersectsWithCylinder;
  136094. }
  136095. /**
  136096. * Options fot the radial explosion event
  136097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136098. */
  136099. export class PhysicsRadialExplosionEventOptions {
  136100. /**
  136101. * The radius of the sphere for the radial explosion.
  136102. */
  136103. radius: number;
  136104. /**
  136105. * The strenth of the explosion.
  136106. */
  136107. strength: number;
  136108. /**
  136109. * The strenght of the force in correspondence to the distance of the affected object
  136110. */
  136111. falloff: PhysicsRadialImpulseFalloff;
  136112. /**
  136113. * Sphere options for the radial explosion.
  136114. */
  136115. sphere: {
  136116. segments: number;
  136117. diameter: number;
  136118. };
  136119. /**
  136120. * Sphere options for the radial explosion.
  136121. */
  136122. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136123. }
  136124. /**
  136125. * Options fot the updraft event
  136126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136127. */
  136128. export class PhysicsUpdraftEventOptions {
  136129. /**
  136130. * The radius of the cylinder for the vortex
  136131. */
  136132. radius: number;
  136133. /**
  136134. * The strenth of the updraft.
  136135. */
  136136. strength: number;
  136137. /**
  136138. * The height of the cylinder for the updraft.
  136139. */
  136140. height: number;
  136141. /**
  136142. * The mode for the the updraft.
  136143. */
  136144. updraftMode: PhysicsUpdraftMode;
  136145. }
  136146. /**
  136147. * Options fot the vortex event
  136148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136149. */
  136150. export class PhysicsVortexEventOptions {
  136151. /**
  136152. * The radius of the cylinder for the vortex
  136153. */
  136154. radius: number;
  136155. /**
  136156. * The strenth of the vortex.
  136157. */
  136158. strength: number;
  136159. /**
  136160. * The height of the cylinder for the vortex.
  136161. */
  136162. height: number;
  136163. /**
  136164. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136165. */
  136166. centripetalForceThreshold: number;
  136167. /**
  136168. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136169. */
  136170. centripetalForceMultiplier: number;
  136171. /**
  136172. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136173. */
  136174. centrifugalForceMultiplier: number;
  136175. /**
  136176. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136177. */
  136178. updraftForceMultiplier: number;
  136179. }
  136180. /**
  136181. * The strenght of the force in correspondence to the distance of the affected object
  136182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136183. */
  136184. export enum PhysicsRadialImpulseFalloff {
  136185. /** Defines that impulse is constant in strength across it's whole radius */
  136186. Constant = 0,
  136187. /** Defines that impulse gets weaker if it's further from the origin */
  136188. Linear = 1
  136189. }
  136190. /**
  136191. * The strength of the force in correspondence to the distance of the affected object
  136192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136193. */
  136194. export enum PhysicsUpdraftMode {
  136195. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136196. Center = 0,
  136197. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136198. Perpendicular = 1
  136199. }
  136200. /**
  136201. * Interface for a physics hit data
  136202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136203. */
  136204. export interface PhysicsHitData {
  136205. /**
  136206. * The force applied at the contact point
  136207. */
  136208. force: Vector3;
  136209. /**
  136210. * The contact point
  136211. */
  136212. contactPoint: Vector3;
  136213. /**
  136214. * The distance from the origin to the contact point
  136215. */
  136216. distanceFromOrigin: number;
  136217. }
  136218. /**
  136219. * Interface for radial explosion event data
  136220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136221. */
  136222. export interface PhysicsRadialExplosionEventData {
  136223. /**
  136224. * A sphere used for the radial explosion event
  136225. */
  136226. sphere: Mesh;
  136227. }
  136228. /**
  136229. * Interface for gravitational field event data
  136230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136231. */
  136232. export interface PhysicsGravitationalFieldEventData {
  136233. /**
  136234. * A sphere mesh used for the gravitational field event
  136235. */
  136236. sphere: Mesh;
  136237. }
  136238. /**
  136239. * Interface for updraft event data
  136240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136241. */
  136242. export interface PhysicsUpdraftEventData {
  136243. /**
  136244. * A cylinder used for the updraft event
  136245. */
  136246. cylinder: Mesh;
  136247. }
  136248. /**
  136249. * Interface for vortex event data
  136250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136251. */
  136252. export interface PhysicsVortexEventData {
  136253. /**
  136254. * A cylinder used for the vortex event
  136255. */
  136256. cylinder: Mesh;
  136257. }
  136258. /**
  136259. * Interface for an affected physics impostor
  136260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136261. */
  136262. export interface PhysicsAffectedImpostorWithData {
  136263. /**
  136264. * The impostor affected by the effect
  136265. */
  136266. impostor: PhysicsImpostor;
  136267. /**
  136268. * The data about the hit/horce from the explosion
  136269. */
  136270. hitData: PhysicsHitData;
  136271. }
  136272. }
  136273. declare module BABYLON {
  136274. /** @hidden */
  136275. export var blackAndWhitePixelShader: {
  136276. name: string;
  136277. shader: string;
  136278. };
  136279. }
  136280. declare module BABYLON {
  136281. /**
  136282. * Post process used to render in black and white
  136283. */
  136284. export class BlackAndWhitePostProcess extends PostProcess {
  136285. /**
  136286. * Linear about to convert he result to black and white (default: 1)
  136287. */
  136288. degree: number;
  136289. /**
  136290. * Creates a black and white post process
  136291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136292. * @param name The name of the effect.
  136293. * @param options The required width/height ratio to downsize to before computing the render pass.
  136294. * @param camera The camera to apply the render pass to.
  136295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136296. * @param engine The engine which the post process will be applied. (default: current engine)
  136297. * @param reusable If the post process can be reused on the same frame. (default: false)
  136298. */
  136299. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136300. }
  136301. }
  136302. declare module BABYLON {
  136303. /**
  136304. * This represents a set of one or more post processes in Babylon.
  136305. * A post process can be used to apply a shader to a texture after it is rendered.
  136306. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  136307. */
  136308. export class PostProcessRenderEffect {
  136309. private _postProcesses;
  136310. private _getPostProcesses;
  136311. private _singleInstance;
  136312. private _cameras;
  136313. private _indicesForCamera;
  136314. /**
  136315. * Name of the effect
  136316. * @hidden
  136317. */
  136318. _name: string;
  136319. /**
  136320. * Instantiates a post process render effect.
  136321. * A post process can be used to apply a shader to a texture after it is rendered.
  136322. * @param engine The engine the effect is tied to
  136323. * @param name The name of the effect
  136324. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  136325. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  136326. */
  136327. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  136328. /**
  136329. * Checks if all the post processes in the effect are supported.
  136330. */
  136331. get isSupported(): boolean;
  136332. /**
  136333. * Updates the current state of the effect
  136334. * @hidden
  136335. */
  136336. _update(): void;
  136337. /**
  136338. * Attaches the effect on cameras
  136339. * @param cameras The camera to attach to.
  136340. * @hidden
  136341. */
  136342. _attachCameras(cameras: Camera): void;
  136343. /**
  136344. * Attaches the effect on cameras
  136345. * @param cameras The camera to attach to.
  136346. * @hidden
  136347. */
  136348. _attachCameras(cameras: Camera[]): void;
  136349. /**
  136350. * Detaches the effect on cameras
  136351. * @param cameras The camera to detatch from.
  136352. * @hidden
  136353. */
  136354. _detachCameras(cameras: Camera): void;
  136355. /**
  136356. * Detatches the effect on cameras
  136357. * @param cameras The camera to detatch from.
  136358. * @hidden
  136359. */
  136360. _detachCameras(cameras: Camera[]): void;
  136361. /**
  136362. * Enables the effect on given cameras
  136363. * @param cameras The camera to enable.
  136364. * @hidden
  136365. */
  136366. _enable(cameras: Camera): void;
  136367. /**
  136368. * Enables the effect on given cameras
  136369. * @param cameras The camera to enable.
  136370. * @hidden
  136371. */
  136372. _enable(cameras: Nullable<Camera[]>): void;
  136373. /**
  136374. * Disables the effect on the given cameras
  136375. * @param cameras The camera to disable.
  136376. * @hidden
  136377. */
  136378. _disable(cameras: Camera): void;
  136379. /**
  136380. * Disables the effect on the given cameras
  136381. * @param cameras The camera to disable.
  136382. * @hidden
  136383. */
  136384. _disable(cameras: Nullable<Camera[]>): void;
  136385. /**
  136386. * Gets a list of the post processes contained in the effect.
  136387. * @param camera The camera to get the post processes on.
  136388. * @returns The list of the post processes in the effect.
  136389. */
  136390. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  136391. }
  136392. }
  136393. declare module BABYLON {
  136394. /** @hidden */
  136395. export var extractHighlightsPixelShader: {
  136396. name: string;
  136397. shader: string;
  136398. };
  136399. }
  136400. declare module BABYLON {
  136401. /**
  136402. * 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.
  136403. */
  136404. export class ExtractHighlightsPostProcess extends PostProcess {
  136405. /**
  136406. * The luminance threshold, pixels below this value will be set to black.
  136407. */
  136408. threshold: number;
  136409. /** @hidden */
  136410. _exposure: number;
  136411. /**
  136412. * Post process which has the input texture to be used when performing highlight extraction
  136413. * @hidden
  136414. */
  136415. _inputPostProcess: Nullable<PostProcess>;
  136416. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136417. }
  136418. }
  136419. declare module BABYLON {
  136420. /** @hidden */
  136421. export var bloomMergePixelShader: {
  136422. name: string;
  136423. shader: string;
  136424. };
  136425. }
  136426. declare module BABYLON {
  136427. /**
  136428. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136429. */
  136430. export class BloomMergePostProcess extends PostProcess {
  136431. /** Weight of the bloom to be added to the original input. */
  136432. weight: number;
  136433. /**
  136434. * Creates a new instance of @see BloomMergePostProcess
  136435. * @param name The name of the effect.
  136436. * @param originalFromInput Post process which's input will be used for the merge.
  136437. * @param blurred Blurred highlights post process which's output will be used.
  136438. * @param weight Weight of the bloom to be added to the original input.
  136439. * @param options The required width/height ratio to downsize to before computing the render pass.
  136440. * @param camera The camera to apply the render pass to.
  136441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136442. * @param engine The engine which the post process will be applied. (default: current engine)
  136443. * @param reusable If the post process can be reused on the same frame. (default: false)
  136444. * @param textureType Type of textures used when performing the post process. (default: 0)
  136445. * @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)
  136446. */
  136447. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  136448. /** Weight of the bloom to be added to the original input. */
  136449. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136450. }
  136451. }
  136452. declare module BABYLON {
  136453. /**
  136454. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  136455. */
  136456. export class BloomEffect extends PostProcessRenderEffect {
  136457. private bloomScale;
  136458. /**
  136459. * @hidden Internal
  136460. */
  136461. _effects: Array<PostProcess>;
  136462. /**
  136463. * @hidden Internal
  136464. */
  136465. _downscale: ExtractHighlightsPostProcess;
  136466. private _blurX;
  136467. private _blurY;
  136468. private _merge;
  136469. /**
  136470. * The luminance threshold to find bright areas of the image to bloom.
  136471. */
  136472. get threshold(): number;
  136473. set threshold(value: number);
  136474. /**
  136475. * The strength of the bloom.
  136476. */
  136477. get weight(): number;
  136478. set weight(value: number);
  136479. /**
  136480. * Specifies the size of the bloom blur kernel, relative to the final output size
  136481. */
  136482. get kernel(): number;
  136483. set kernel(value: number);
  136484. /**
  136485. * Creates a new instance of @see BloomEffect
  136486. * @param scene The scene the effect belongs to.
  136487. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  136488. * @param bloomKernel The size of the kernel to be used when applying the blur.
  136489. * @param bloomWeight The the strength of bloom.
  136490. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136491. * @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)
  136492. */
  136493. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  136494. /**
  136495. * Disposes each of the internal effects for a given camera.
  136496. * @param camera The camera to dispose the effect on.
  136497. */
  136498. disposeEffects(camera: Camera): void;
  136499. /**
  136500. * @hidden Internal
  136501. */
  136502. _updateEffects(): void;
  136503. /**
  136504. * Internal
  136505. * @returns if all the contained post processes are ready.
  136506. * @hidden
  136507. */
  136508. _isReady(): boolean;
  136509. }
  136510. }
  136511. declare module BABYLON {
  136512. /** @hidden */
  136513. export var chromaticAberrationPixelShader: {
  136514. name: string;
  136515. shader: string;
  136516. };
  136517. }
  136518. declare module BABYLON {
  136519. /**
  136520. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  136521. */
  136522. export class ChromaticAberrationPostProcess extends PostProcess {
  136523. /**
  136524. * The amount of seperation of rgb channels (default: 30)
  136525. */
  136526. aberrationAmount: number;
  136527. /**
  136528. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  136529. */
  136530. radialIntensity: number;
  136531. /**
  136532. * 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))
  136533. */
  136534. direction: Vector2;
  136535. /**
  136536. * 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))
  136537. */
  136538. centerPosition: Vector2;
  136539. /**
  136540. * Creates a new instance ChromaticAberrationPostProcess
  136541. * @param name The name of the effect.
  136542. * @param screenWidth The width of the screen to apply the effect on.
  136543. * @param screenHeight The height of the screen to apply the effect on.
  136544. * @param options The required width/height ratio to downsize to before computing the render pass.
  136545. * @param camera The camera to apply the render pass to.
  136546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136547. * @param engine The engine which the post process will be applied. (default: current engine)
  136548. * @param reusable If the post process can be reused on the same frame. (default: false)
  136549. * @param textureType Type of textures used when performing the post process. (default: 0)
  136550. * @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)
  136551. */
  136552. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136553. }
  136554. }
  136555. declare module BABYLON {
  136556. /** @hidden */
  136557. export var circleOfConfusionPixelShader: {
  136558. name: string;
  136559. shader: string;
  136560. };
  136561. }
  136562. declare module BABYLON {
  136563. /**
  136564. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  136565. */
  136566. export class CircleOfConfusionPostProcess extends PostProcess {
  136567. /**
  136568. * 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.
  136569. */
  136570. lensSize: number;
  136571. /**
  136572. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136573. */
  136574. fStop: number;
  136575. /**
  136576. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136577. */
  136578. focusDistance: number;
  136579. /**
  136580. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  136581. */
  136582. focalLength: number;
  136583. private _depthTexture;
  136584. /**
  136585. * Creates a new instance CircleOfConfusionPostProcess
  136586. * @param name The name of the effect.
  136587. * @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.
  136588. * @param options The required width/height ratio to downsize to before computing the render pass.
  136589. * @param camera The camera to apply the render pass to.
  136590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136591. * @param engine The engine which the post process will be applied. (default: current engine)
  136592. * @param reusable If the post process can be reused on the same frame. (default: false)
  136593. * @param textureType Type of textures used when performing the post process. (default: 0)
  136594. * @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)
  136595. */
  136596. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136597. /**
  136598. * 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.
  136599. */
  136600. set depthTexture(value: RenderTargetTexture);
  136601. }
  136602. }
  136603. declare module BABYLON {
  136604. /** @hidden */
  136605. export var colorCorrectionPixelShader: {
  136606. name: string;
  136607. shader: string;
  136608. };
  136609. }
  136610. declare module BABYLON {
  136611. /**
  136612. *
  136613. * This post-process allows the modification of rendered colors by using
  136614. * a 'look-up table' (LUT). This effect is also called Color Grading.
  136615. *
  136616. * The object needs to be provided an url to a texture containing the color
  136617. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  136618. * Use an image editing software to tweak the LUT to match your needs.
  136619. *
  136620. * For an example of a color LUT, see here:
  136621. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  136622. * For explanations on color grading, see here:
  136623. * @see http://udn.epicgames.com/Three/ColorGrading.html
  136624. *
  136625. */
  136626. export class ColorCorrectionPostProcess extends PostProcess {
  136627. private _colorTableTexture;
  136628. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136629. }
  136630. }
  136631. declare module BABYLON {
  136632. /** @hidden */
  136633. export var convolutionPixelShader: {
  136634. name: string;
  136635. shader: string;
  136636. };
  136637. }
  136638. declare module BABYLON {
  136639. /**
  136640. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  136641. * input texture to perform effects such as edge detection or sharpening
  136642. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  136643. */
  136644. export class ConvolutionPostProcess extends PostProcess {
  136645. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136646. kernel: number[];
  136647. /**
  136648. * Creates a new instance ConvolutionPostProcess
  136649. * @param name The name of the effect.
  136650. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  136651. * @param options The required width/height ratio to downsize to before computing the render pass.
  136652. * @param camera The camera to apply the render pass to.
  136653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136654. * @param engine The engine which the post process will be applied. (default: current engine)
  136655. * @param reusable If the post process can be reused on the same frame. (default: false)
  136656. * @param textureType Type of textures used when performing the post process. (default: 0)
  136657. */
  136658. constructor(name: string,
  136659. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136660. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136661. /**
  136662. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136663. */
  136664. static EdgeDetect0Kernel: number[];
  136665. /**
  136666. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136667. */
  136668. static EdgeDetect1Kernel: number[];
  136669. /**
  136670. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136671. */
  136672. static EdgeDetect2Kernel: number[];
  136673. /**
  136674. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136675. */
  136676. static SharpenKernel: number[];
  136677. /**
  136678. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136679. */
  136680. static EmbossKernel: number[];
  136681. /**
  136682. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136683. */
  136684. static GaussianKernel: number[];
  136685. }
  136686. }
  136687. declare module BABYLON {
  136688. /**
  136689. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  136690. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  136691. * based on samples that have a large difference in distance than the center pixel.
  136692. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  136693. */
  136694. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  136695. direction: Vector2;
  136696. /**
  136697. * Creates a new instance CircleOfConfusionPostProcess
  136698. * @param name The name of the effect.
  136699. * @param scene The scene the effect belongs to.
  136700. * @param direction The direction the blur should be applied.
  136701. * @param kernel The size of the kernel used to blur.
  136702. * @param options The required width/height ratio to downsize to before computing the render pass.
  136703. * @param camera The camera to apply the render pass to.
  136704. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  136705. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  136706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136707. * @param engine The engine which the post process will be applied. (default: current engine)
  136708. * @param reusable If the post process can be reused on the same frame. (default: false)
  136709. * @param textureType Type of textures used when performing the post process. (default: 0)
  136710. * @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)
  136711. */
  136712. 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);
  136713. }
  136714. }
  136715. declare module BABYLON {
  136716. /** @hidden */
  136717. export var depthOfFieldMergePixelShader: {
  136718. name: string;
  136719. shader: string;
  136720. };
  136721. }
  136722. declare module BABYLON {
  136723. /**
  136724. * Options to be set when merging outputs from the default pipeline.
  136725. */
  136726. export class DepthOfFieldMergePostProcessOptions {
  136727. /**
  136728. * The original image to merge on top of
  136729. */
  136730. originalFromInput: PostProcess;
  136731. /**
  136732. * Parameters to perform the merge of the depth of field effect
  136733. */
  136734. depthOfField?: {
  136735. circleOfConfusion: PostProcess;
  136736. blurSteps: Array<PostProcess>;
  136737. };
  136738. /**
  136739. * Parameters to perform the merge of bloom effect
  136740. */
  136741. bloom?: {
  136742. blurred: PostProcess;
  136743. weight: number;
  136744. };
  136745. }
  136746. /**
  136747. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136748. */
  136749. export class DepthOfFieldMergePostProcess extends PostProcess {
  136750. private blurSteps;
  136751. /**
  136752. * Creates a new instance of DepthOfFieldMergePostProcess
  136753. * @param name The name of the effect.
  136754. * @param originalFromInput Post process which's input will be used for the merge.
  136755. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  136756. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  136757. * @param options The required width/height ratio to downsize to before computing the render pass.
  136758. * @param camera The camera to apply the render pass to.
  136759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136760. * @param engine The engine which the post process will be applied. (default: current engine)
  136761. * @param reusable If the post process can be reused on the same frame. (default: false)
  136762. * @param textureType Type of textures used when performing the post process. (default: 0)
  136763. * @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)
  136764. */
  136765. 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);
  136766. /**
  136767. * Updates the effect with the current post process compile time values and recompiles the shader.
  136768. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  136769. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  136770. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  136771. * @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
  136772. * @param onCompiled Called when the shader has been compiled.
  136773. * @param onError Called if there is an error when compiling a shader.
  136774. */
  136775. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  136776. }
  136777. }
  136778. declare module BABYLON {
  136779. /**
  136780. * Specifies the level of max blur that should be applied when using the depth of field effect
  136781. */
  136782. export enum DepthOfFieldEffectBlurLevel {
  136783. /**
  136784. * Subtle blur
  136785. */
  136786. Low = 0,
  136787. /**
  136788. * Medium blur
  136789. */
  136790. Medium = 1,
  136791. /**
  136792. * Large blur
  136793. */
  136794. High = 2
  136795. }
  136796. /**
  136797. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  136798. */
  136799. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  136800. private _circleOfConfusion;
  136801. /**
  136802. * @hidden Internal, blurs from high to low
  136803. */
  136804. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  136805. private _depthOfFieldBlurY;
  136806. private _dofMerge;
  136807. /**
  136808. * @hidden Internal post processes in depth of field effect
  136809. */
  136810. _effects: Array<PostProcess>;
  136811. /**
  136812. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  136813. */
  136814. set focalLength(value: number);
  136815. get focalLength(): number;
  136816. /**
  136817. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136818. */
  136819. set fStop(value: number);
  136820. get fStop(): number;
  136821. /**
  136822. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136823. */
  136824. set focusDistance(value: number);
  136825. get focusDistance(): number;
  136826. /**
  136827. * 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.
  136828. */
  136829. set lensSize(value: number);
  136830. get lensSize(): number;
  136831. /**
  136832. * Creates a new instance DepthOfFieldEffect
  136833. * @param scene The scene the effect belongs to.
  136834. * @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.
  136835. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136836. * @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)
  136837. */
  136838. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  136839. /**
  136840. * Get the current class name of the current effet
  136841. * @returns "DepthOfFieldEffect"
  136842. */
  136843. getClassName(): string;
  136844. /**
  136845. * 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.
  136846. */
  136847. set depthTexture(value: RenderTargetTexture);
  136848. /**
  136849. * Disposes each of the internal effects for a given camera.
  136850. * @param camera The camera to dispose the effect on.
  136851. */
  136852. disposeEffects(camera: Camera): void;
  136853. /**
  136854. * @hidden Internal
  136855. */
  136856. _updateEffects(): void;
  136857. /**
  136858. * Internal
  136859. * @returns if all the contained post processes are ready.
  136860. * @hidden
  136861. */
  136862. _isReady(): boolean;
  136863. }
  136864. }
  136865. declare module BABYLON {
  136866. /** @hidden */
  136867. export var displayPassPixelShader: {
  136868. name: string;
  136869. shader: string;
  136870. };
  136871. }
  136872. declare module BABYLON {
  136873. /**
  136874. * DisplayPassPostProcess which produces an output the same as it's input
  136875. */
  136876. export class DisplayPassPostProcess extends PostProcess {
  136877. /**
  136878. * Creates the DisplayPassPostProcess
  136879. * @param name The name of the effect.
  136880. * @param options The required width/height ratio to downsize to before computing the render pass.
  136881. * @param camera The camera to apply the render pass to.
  136882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136883. * @param engine The engine which the post process will be applied. (default: current engine)
  136884. * @param reusable If the post process can be reused on the same frame. (default: false)
  136885. */
  136886. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136887. }
  136888. }
  136889. declare module BABYLON {
  136890. /** @hidden */
  136891. export var filterPixelShader: {
  136892. name: string;
  136893. shader: string;
  136894. };
  136895. }
  136896. declare module BABYLON {
  136897. /**
  136898. * Applies a kernel filter to the image
  136899. */
  136900. export class FilterPostProcess extends PostProcess {
  136901. /** The matrix to be applied to the image */
  136902. kernelMatrix: Matrix;
  136903. /**
  136904. *
  136905. * @param name The name of the effect.
  136906. * @param kernelMatrix The matrix to be applied to the image
  136907. * @param options The required width/height ratio to downsize to before computing the render pass.
  136908. * @param camera The camera to apply the render pass to.
  136909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136910. * @param engine The engine which the post process will be applied. (default: current engine)
  136911. * @param reusable If the post process can be reused on the same frame. (default: false)
  136912. */
  136913. constructor(name: string,
  136914. /** The matrix to be applied to the image */
  136915. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136916. }
  136917. }
  136918. declare module BABYLON {
  136919. /** @hidden */
  136920. export var fxaaPixelShader: {
  136921. name: string;
  136922. shader: string;
  136923. };
  136924. }
  136925. declare module BABYLON {
  136926. /** @hidden */
  136927. export var fxaaVertexShader: {
  136928. name: string;
  136929. shader: string;
  136930. };
  136931. }
  136932. declare module BABYLON {
  136933. /**
  136934. * Fxaa post process
  136935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  136936. */
  136937. export class FxaaPostProcess extends PostProcess {
  136938. /** @hidden */
  136939. texelWidth: number;
  136940. /** @hidden */
  136941. texelHeight: number;
  136942. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136943. private _getDefines;
  136944. }
  136945. }
  136946. declare module BABYLON {
  136947. /** @hidden */
  136948. export var grainPixelShader: {
  136949. name: string;
  136950. shader: string;
  136951. };
  136952. }
  136953. declare module BABYLON {
  136954. /**
  136955. * The GrainPostProcess adds noise to the image at mid luminance levels
  136956. */
  136957. export class GrainPostProcess extends PostProcess {
  136958. /**
  136959. * The intensity of the grain added (default: 30)
  136960. */
  136961. intensity: number;
  136962. /**
  136963. * If the grain should be randomized on every frame
  136964. */
  136965. animated: boolean;
  136966. /**
  136967. * Creates a new instance of @see GrainPostProcess
  136968. * @param name The name of the effect.
  136969. * @param options The required width/height ratio to downsize to before computing the render pass.
  136970. * @param camera The camera to apply the render pass to.
  136971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136972. * @param engine The engine which the post process will be applied. (default: current engine)
  136973. * @param reusable If the post process can be reused on the same frame. (default: false)
  136974. * @param textureType Type of textures used when performing the post process. (default: 0)
  136975. * @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)
  136976. */
  136977. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136978. }
  136979. }
  136980. declare module BABYLON {
  136981. /** @hidden */
  136982. export var highlightsPixelShader: {
  136983. name: string;
  136984. shader: string;
  136985. };
  136986. }
  136987. declare module BABYLON {
  136988. /**
  136989. * Extracts highlights from the image
  136990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  136991. */
  136992. export class HighlightsPostProcess extends PostProcess {
  136993. /**
  136994. * Extracts highlights from the image
  136995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  136996. * @param name The name of the effect.
  136997. * @param options The required width/height ratio to downsize to before computing the render pass.
  136998. * @param camera The camera to apply the render pass to.
  136999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137000. * @param engine The engine which the post process will be applied. (default: current engine)
  137001. * @param reusable If the post process can be reused on the same frame. (default: false)
  137002. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137003. */
  137004. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137005. }
  137006. }
  137007. declare module BABYLON {
  137008. /** @hidden */
  137009. export var mrtFragmentDeclaration: {
  137010. name: string;
  137011. shader: string;
  137012. };
  137013. }
  137014. declare module BABYLON {
  137015. /** @hidden */
  137016. export var geometryPixelShader: {
  137017. name: string;
  137018. shader: string;
  137019. };
  137020. }
  137021. declare module BABYLON {
  137022. /** @hidden */
  137023. export var geometryVertexShader: {
  137024. name: string;
  137025. shader: string;
  137026. };
  137027. }
  137028. declare module BABYLON {
  137029. /** @hidden */
  137030. interface ISavedTransformationMatrix {
  137031. world: Matrix;
  137032. viewProjection: Matrix;
  137033. }
  137034. /**
  137035. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137036. */
  137037. export class GeometryBufferRenderer {
  137038. /**
  137039. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137040. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137041. */
  137042. static readonly POSITION_TEXTURE_TYPE: number;
  137043. /**
  137044. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137045. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137046. */
  137047. static readonly VELOCITY_TEXTURE_TYPE: number;
  137048. /**
  137049. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137050. * in order to compute objects velocities when enableVelocity is set to "true"
  137051. * @hidden
  137052. */
  137053. _previousTransformationMatrices: {
  137054. [index: number]: ISavedTransformationMatrix;
  137055. };
  137056. /**
  137057. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137058. * in order to compute objects velocities when enableVelocity is set to "true"
  137059. * @hidden
  137060. */
  137061. _previousBonesTransformationMatrices: {
  137062. [index: number]: Float32Array;
  137063. };
  137064. /**
  137065. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137066. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137067. */
  137068. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137069. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137070. renderTransparentMeshes: boolean;
  137071. private _scene;
  137072. private _multiRenderTarget;
  137073. private _ratio;
  137074. private _enablePosition;
  137075. private _enableVelocity;
  137076. private _positionIndex;
  137077. private _velocityIndex;
  137078. protected _effect: Effect;
  137079. protected _cachedDefines: string;
  137080. /**
  137081. * Set the render list (meshes to be rendered) used in the G buffer.
  137082. */
  137083. set renderList(meshes: Mesh[]);
  137084. /**
  137085. * Gets wether or not G buffer are supported by the running hardware.
  137086. * This requires draw buffer supports
  137087. */
  137088. get isSupported(): boolean;
  137089. /**
  137090. * Returns the index of the given texture type in the G-Buffer textures array
  137091. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137092. * @returns the index of the given texture type in the G-Buffer textures array
  137093. */
  137094. getTextureIndex(textureType: number): number;
  137095. /**
  137096. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137097. */
  137098. get enablePosition(): boolean;
  137099. /**
  137100. * Sets whether or not objects positions are enabled for the G buffer.
  137101. */
  137102. set enablePosition(enable: boolean);
  137103. /**
  137104. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137105. */
  137106. get enableVelocity(): boolean;
  137107. /**
  137108. * Sets wether or not objects velocities are enabled for the G buffer.
  137109. */
  137110. set enableVelocity(enable: boolean);
  137111. /**
  137112. * Gets the scene associated with the buffer.
  137113. */
  137114. get scene(): Scene;
  137115. /**
  137116. * Gets the ratio used by the buffer during its creation.
  137117. * How big is the buffer related to the main canvas.
  137118. */
  137119. get ratio(): number;
  137120. /** @hidden */
  137121. static _SceneComponentInitialization: (scene: Scene) => void;
  137122. /**
  137123. * Creates a new G Buffer for the scene
  137124. * @param scene The scene the buffer belongs to
  137125. * @param ratio How big is the buffer related to the main canvas.
  137126. */
  137127. constructor(scene: Scene, ratio?: number);
  137128. /**
  137129. * Checks wether everything is ready to render a submesh to the G buffer.
  137130. * @param subMesh the submesh to check readiness for
  137131. * @param useInstances is the mesh drawn using instance or not
  137132. * @returns true if ready otherwise false
  137133. */
  137134. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137135. /**
  137136. * Gets the current underlying G Buffer.
  137137. * @returns the buffer
  137138. */
  137139. getGBuffer(): MultiRenderTarget;
  137140. /**
  137141. * Gets the number of samples used to render the buffer (anti aliasing).
  137142. */
  137143. get samples(): number;
  137144. /**
  137145. * Sets the number of samples used to render the buffer (anti aliasing).
  137146. */
  137147. set samples(value: number);
  137148. /**
  137149. * Disposes the renderer and frees up associated resources.
  137150. */
  137151. dispose(): void;
  137152. protected _createRenderTargets(): void;
  137153. private _copyBonesTransformationMatrices;
  137154. }
  137155. }
  137156. declare module BABYLON {
  137157. interface Scene {
  137158. /** @hidden (Backing field) */
  137159. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137160. /**
  137161. * Gets or Sets the current geometry buffer associated to the scene.
  137162. */
  137163. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137164. /**
  137165. * Enables a GeometryBufferRender and associates it with the scene
  137166. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137167. * @returns the GeometryBufferRenderer
  137168. */
  137169. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137170. /**
  137171. * Disables the GeometryBufferRender associated with the scene
  137172. */
  137173. disableGeometryBufferRenderer(): void;
  137174. }
  137175. /**
  137176. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137177. * in several rendering techniques.
  137178. */
  137179. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137180. /**
  137181. * The component name helpful to identify the component in the list of scene components.
  137182. */
  137183. readonly name: string;
  137184. /**
  137185. * The scene the component belongs to.
  137186. */
  137187. scene: Scene;
  137188. /**
  137189. * Creates a new instance of the component for the given scene
  137190. * @param scene Defines the scene to register the component in
  137191. */
  137192. constructor(scene: Scene);
  137193. /**
  137194. * Registers the component in a given scene
  137195. */
  137196. register(): void;
  137197. /**
  137198. * Rebuilds the elements related to this component in case of
  137199. * context lost for instance.
  137200. */
  137201. rebuild(): void;
  137202. /**
  137203. * Disposes the component and the associated ressources
  137204. */
  137205. dispose(): void;
  137206. private _gatherRenderTargets;
  137207. }
  137208. }
  137209. declare module BABYLON {
  137210. /** @hidden */
  137211. export var motionBlurPixelShader: {
  137212. name: string;
  137213. shader: string;
  137214. };
  137215. }
  137216. declare module BABYLON {
  137217. /**
  137218. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137219. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137220. * As an example, all you have to do is to create the post-process:
  137221. * var mb = new BABYLON.MotionBlurPostProcess(
  137222. * 'mb', // The name of the effect.
  137223. * scene, // The scene containing the objects to blur according to their velocity.
  137224. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137225. * camera // The camera to apply the render pass to.
  137226. * );
  137227. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137228. */
  137229. export class MotionBlurPostProcess extends PostProcess {
  137230. /**
  137231. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137232. */
  137233. motionStrength: number;
  137234. /**
  137235. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137236. */
  137237. get motionBlurSamples(): number;
  137238. /**
  137239. * Sets the number of iterations to be used for motion blur quality
  137240. */
  137241. set motionBlurSamples(samples: number);
  137242. private _motionBlurSamples;
  137243. private _geometryBufferRenderer;
  137244. /**
  137245. * Creates a new instance MotionBlurPostProcess
  137246. * @param name The name of the effect.
  137247. * @param scene The scene containing the objects to blur according to their velocity.
  137248. * @param options The required width/height ratio to downsize to before computing the render pass.
  137249. * @param camera The camera to apply the render pass to.
  137250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137251. * @param engine The engine which the post process will be applied. (default: current engine)
  137252. * @param reusable If the post process can be reused on the same frame. (default: false)
  137253. * @param textureType Type of textures used when performing the post process. (default: 0)
  137254. * @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)
  137255. */
  137256. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137257. /**
  137258. * Excludes the given skinned mesh from computing bones velocities.
  137259. * 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.
  137260. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137261. */
  137262. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137263. /**
  137264. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137265. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137266. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137267. */
  137268. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137269. /**
  137270. * Disposes the post process.
  137271. * @param camera The camera to dispose the post process on.
  137272. */
  137273. dispose(camera?: Camera): void;
  137274. }
  137275. }
  137276. declare module BABYLON {
  137277. /** @hidden */
  137278. export var refractionPixelShader: {
  137279. name: string;
  137280. shader: string;
  137281. };
  137282. }
  137283. declare module BABYLON {
  137284. /**
  137285. * Post process which applies a refractin texture
  137286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137287. */
  137288. export class RefractionPostProcess extends PostProcess {
  137289. /** the base color of the refraction (used to taint the rendering) */
  137290. color: Color3;
  137291. /** simulated refraction depth */
  137292. depth: number;
  137293. /** the coefficient of the base color (0 to remove base color tainting) */
  137294. colorLevel: number;
  137295. private _refTexture;
  137296. private _ownRefractionTexture;
  137297. /**
  137298. * Gets or sets the refraction texture
  137299. * Please note that you are responsible for disposing the texture if you set it manually
  137300. */
  137301. get refractionTexture(): Texture;
  137302. set refractionTexture(value: Texture);
  137303. /**
  137304. * Initializes the RefractionPostProcess
  137305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137306. * @param name The name of the effect.
  137307. * @param refractionTextureUrl Url of the refraction texture to use
  137308. * @param color the base color of the refraction (used to taint the rendering)
  137309. * @param depth simulated refraction depth
  137310. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  137311. * @param camera The camera to apply the render pass to.
  137312. * @param options The required width/height ratio to downsize to before computing the render pass.
  137313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137314. * @param engine The engine which the post process will be applied. (default: current engine)
  137315. * @param reusable If the post process can be reused on the same frame. (default: false)
  137316. */
  137317. constructor(name: string, refractionTextureUrl: string,
  137318. /** the base color of the refraction (used to taint the rendering) */
  137319. color: Color3,
  137320. /** simulated refraction depth */
  137321. depth: number,
  137322. /** the coefficient of the base color (0 to remove base color tainting) */
  137323. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137324. /**
  137325. * Disposes of the post process
  137326. * @param camera Camera to dispose post process on
  137327. */
  137328. dispose(camera: Camera): void;
  137329. }
  137330. }
  137331. declare module BABYLON {
  137332. /** @hidden */
  137333. export var sharpenPixelShader: {
  137334. name: string;
  137335. shader: string;
  137336. };
  137337. }
  137338. declare module BABYLON {
  137339. /**
  137340. * The SharpenPostProcess applies a sharpen kernel to every pixel
  137341. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137342. */
  137343. export class SharpenPostProcess extends PostProcess {
  137344. /**
  137345. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  137346. */
  137347. colorAmount: number;
  137348. /**
  137349. * How much sharpness should be applied (default: 0.3)
  137350. */
  137351. edgeAmount: number;
  137352. /**
  137353. * Creates a new instance ConvolutionPostProcess
  137354. * @param name The name of the effect.
  137355. * @param options The required width/height ratio to downsize to before computing the render pass.
  137356. * @param camera The camera to apply the render pass to.
  137357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137358. * @param engine The engine which the post process will be applied. (default: current engine)
  137359. * @param reusable If the post process can be reused on the same frame. (default: false)
  137360. * @param textureType Type of textures used when performing the post process. (default: 0)
  137361. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  137362. */
  137363. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137364. }
  137365. }
  137366. declare module BABYLON {
  137367. /**
  137368. * PostProcessRenderPipeline
  137369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137370. */
  137371. export class PostProcessRenderPipeline {
  137372. private engine;
  137373. private _renderEffects;
  137374. private _renderEffectsForIsolatedPass;
  137375. /**
  137376. * List of inspectable custom properties (used by the Inspector)
  137377. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  137378. */
  137379. inspectableCustomProperties: IInspectable[];
  137380. /**
  137381. * @hidden
  137382. */
  137383. protected _cameras: Camera[];
  137384. /** @hidden */
  137385. _name: string;
  137386. /**
  137387. * Gets pipeline name
  137388. */
  137389. get name(): string;
  137390. /** Gets the list of attached cameras */
  137391. get cameras(): Camera[];
  137392. /**
  137393. * Initializes a PostProcessRenderPipeline
  137394. * @param engine engine to add the pipeline to
  137395. * @param name name of the pipeline
  137396. */
  137397. constructor(engine: Engine, name: string);
  137398. /**
  137399. * Gets the class name
  137400. * @returns "PostProcessRenderPipeline"
  137401. */
  137402. getClassName(): string;
  137403. /**
  137404. * If all the render effects in the pipeline are supported
  137405. */
  137406. get isSupported(): boolean;
  137407. /**
  137408. * Adds an effect to the pipeline
  137409. * @param renderEffect the effect to add
  137410. */
  137411. addEffect(renderEffect: PostProcessRenderEffect): void;
  137412. /** @hidden */
  137413. _rebuild(): void;
  137414. /** @hidden */
  137415. _enableEffect(renderEffectName: string, cameras: Camera): void;
  137416. /** @hidden */
  137417. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  137418. /** @hidden */
  137419. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137420. /** @hidden */
  137421. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137422. /** @hidden */
  137423. _attachCameras(cameras: Camera, unique: boolean): void;
  137424. /** @hidden */
  137425. _attachCameras(cameras: Camera[], unique: boolean): void;
  137426. /** @hidden */
  137427. _detachCameras(cameras: Camera): void;
  137428. /** @hidden */
  137429. _detachCameras(cameras: Nullable<Camera[]>): void;
  137430. /** @hidden */
  137431. _update(): void;
  137432. /** @hidden */
  137433. _reset(): void;
  137434. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  137435. /**
  137436. * Disposes of the pipeline
  137437. */
  137438. dispose(): void;
  137439. }
  137440. }
  137441. declare module BABYLON {
  137442. /**
  137443. * PostProcessRenderPipelineManager class
  137444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137445. */
  137446. export class PostProcessRenderPipelineManager {
  137447. private _renderPipelines;
  137448. /**
  137449. * Initializes a PostProcessRenderPipelineManager
  137450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137451. */
  137452. constructor();
  137453. /**
  137454. * Gets the list of supported render pipelines
  137455. */
  137456. get supportedPipelines(): PostProcessRenderPipeline[];
  137457. /**
  137458. * Adds a pipeline to the manager
  137459. * @param renderPipeline The pipeline to add
  137460. */
  137461. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  137462. /**
  137463. * Attaches a camera to the pipeline
  137464. * @param renderPipelineName The name of the pipeline to attach to
  137465. * @param cameras the camera to attach
  137466. * @param unique if the camera can be attached multiple times to the pipeline
  137467. */
  137468. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  137469. /**
  137470. * Detaches a camera from the pipeline
  137471. * @param renderPipelineName The name of the pipeline to detach from
  137472. * @param cameras the camera to detach
  137473. */
  137474. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  137475. /**
  137476. * Enables an effect by name on a pipeline
  137477. * @param renderPipelineName the name of the pipeline to enable the effect in
  137478. * @param renderEffectName the name of the effect to enable
  137479. * @param cameras the cameras that the effect should be enabled on
  137480. */
  137481. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137482. /**
  137483. * Disables an effect by name on a pipeline
  137484. * @param renderPipelineName the name of the pipeline to disable the effect in
  137485. * @param renderEffectName the name of the effect to disable
  137486. * @param cameras the cameras that the effect should be disabled on
  137487. */
  137488. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137489. /**
  137490. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  137491. */
  137492. update(): void;
  137493. /** @hidden */
  137494. _rebuild(): void;
  137495. /**
  137496. * Disposes of the manager and pipelines
  137497. */
  137498. dispose(): void;
  137499. }
  137500. }
  137501. declare module BABYLON {
  137502. interface Scene {
  137503. /** @hidden (Backing field) */
  137504. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137505. /**
  137506. * Gets the postprocess render pipeline manager
  137507. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137508. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137509. */
  137510. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137511. }
  137512. /**
  137513. * Defines the Render Pipeline scene component responsible to rendering pipelines
  137514. */
  137515. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  137516. /**
  137517. * The component name helpfull to identify the component in the list of scene components.
  137518. */
  137519. readonly name: string;
  137520. /**
  137521. * The scene the component belongs to.
  137522. */
  137523. scene: Scene;
  137524. /**
  137525. * Creates a new instance of the component for the given scene
  137526. * @param scene Defines the scene to register the component in
  137527. */
  137528. constructor(scene: Scene);
  137529. /**
  137530. * Registers the component in a given scene
  137531. */
  137532. register(): void;
  137533. /**
  137534. * Rebuilds the elements related to this component in case of
  137535. * context lost for instance.
  137536. */
  137537. rebuild(): void;
  137538. /**
  137539. * Disposes the component and the associated ressources
  137540. */
  137541. dispose(): void;
  137542. private _gatherRenderTargets;
  137543. }
  137544. }
  137545. declare module BABYLON {
  137546. /**
  137547. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  137548. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137549. */
  137550. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  137551. private _scene;
  137552. private _camerasToBeAttached;
  137553. /**
  137554. * ID of the sharpen post process,
  137555. */
  137556. private readonly SharpenPostProcessId;
  137557. /**
  137558. * @ignore
  137559. * ID of the image processing post process;
  137560. */
  137561. readonly ImageProcessingPostProcessId: string;
  137562. /**
  137563. * @ignore
  137564. * ID of the Fast Approximate Anti-Aliasing post process;
  137565. */
  137566. readonly FxaaPostProcessId: string;
  137567. /**
  137568. * ID of the chromatic aberration post process,
  137569. */
  137570. private readonly ChromaticAberrationPostProcessId;
  137571. /**
  137572. * ID of the grain post process
  137573. */
  137574. private readonly GrainPostProcessId;
  137575. /**
  137576. * Sharpen post process which will apply a sharpen convolution to enhance edges
  137577. */
  137578. sharpen: SharpenPostProcess;
  137579. private _sharpenEffect;
  137580. private bloom;
  137581. /**
  137582. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  137583. */
  137584. depthOfField: DepthOfFieldEffect;
  137585. /**
  137586. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  137587. */
  137588. fxaa: FxaaPostProcess;
  137589. /**
  137590. * Image post processing pass used to perform operations such as tone mapping or color grading.
  137591. */
  137592. imageProcessing: ImageProcessingPostProcess;
  137593. /**
  137594. * Chromatic aberration post process which will shift rgb colors in the image
  137595. */
  137596. chromaticAberration: ChromaticAberrationPostProcess;
  137597. private _chromaticAberrationEffect;
  137598. /**
  137599. * Grain post process which add noise to the image
  137600. */
  137601. grain: GrainPostProcess;
  137602. private _grainEffect;
  137603. /**
  137604. * Glow post process which adds a glow to emissive areas of the image
  137605. */
  137606. private _glowLayer;
  137607. /**
  137608. * Animations which can be used to tweak settings over a period of time
  137609. */
  137610. animations: Animation[];
  137611. private _imageProcessingConfigurationObserver;
  137612. private _sharpenEnabled;
  137613. private _bloomEnabled;
  137614. private _depthOfFieldEnabled;
  137615. private _depthOfFieldBlurLevel;
  137616. private _fxaaEnabled;
  137617. private _imageProcessingEnabled;
  137618. private _defaultPipelineTextureType;
  137619. private _bloomScale;
  137620. private _chromaticAberrationEnabled;
  137621. private _grainEnabled;
  137622. private _buildAllowed;
  137623. /**
  137624. * Gets active scene
  137625. */
  137626. get scene(): Scene;
  137627. /**
  137628. * Enable or disable the sharpen process from the pipeline
  137629. */
  137630. set sharpenEnabled(enabled: boolean);
  137631. get sharpenEnabled(): boolean;
  137632. private _resizeObserver;
  137633. private _hardwareScaleLevel;
  137634. private _bloomKernel;
  137635. /**
  137636. * Specifies the size of the bloom blur kernel, relative to the final output size
  137637. */
  137638. get bloomKernel(): number;
  137639. set bloomKernel(value: number);
  137640. /**
  137641. * Specifies the weight of the bloom in the final rendering
  137642. */
  137643. private _bloomWeight;
  137644. /**
  137645. * Specifies the luma threshold for the area that will be blurred by the bloom
  137646. */
  137647. private _bloomThreshold;
  137648. private _hdr;
  137649. /**
  137650. * The strength of the bloom.
  137651. */
  137652. set bloomWeight(value: number);
  137653. get bloomWeight(): number;
  137654. /**
  137655. * The strength of the bloom.
  137656. */
  137657. set bloomThreshold(value: number);
  137658. get bloomThreshold(): number;
  137659. /**
  137660. * The scale of the bloom, lower value will provide better performance.
  137661. */
  137662. set bloomScale(value: number);
  137663. get bloomScale(): number;
  137664. /**
  137665. * Enable or disable the bloom from the pipeline
  137666. */
  137667. set bloomEnabled(enabled: boolean);
  137668. get bloomEnabled(): boolean;
  137669. private _rebuildBloom;
  137670. /**
  137671. * If the depth of field is enabled.
  137672. */
  137673. get depthOfFieldEnabled(): boolean;
  137674. set depthOfFieldEnabled(enabled: boolean);
  137675. /**
  137676. * Blur level of the depth of field effect. (Higher blur will effect performance)
  137677. */
  137678. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  137679. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  137680. /**
  137681. * If the anti aliasing is enabled.
  137682. */
  137683. set fxaaEnabled(enabled: boolean);
  137684. get fxaaEnabled(): boolean;
  137685. private _samples;
  137686. /**
  137687. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  137688. */
  137689. set samples(sampleCount: number);
  137690. get samples(): number;
  137691. /**
  137692. * If image processing is enabled.
  137693. */
  137694. set imageProcessingEnabled(enabled: boolean);
  137695. get imageProcessingEnabled(): boolean;
  137696. /**
  137697. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  137698. */
  137699. set glowLayerEnabled(enabled: boolean);
  137700. get glowLayerEnabled(): boolean;
  137701. /**
  137702. * Gets the glow layer (or null if not defined)
  137703. */
  137704. get glowLayer(): Nullable<GlowLayer>;
  137705. /**
  137706. * Enable or disable the chromaticAberration process from the pipeline
  137707. */
  137708. set chromaticAberrationEnabled(enabled: boolean);
  137709. get chromaticAberrationEnabled(): boolean;
  137710. /**
  137711. * Enable or disable the grain process from the pipeline
  137712. */
  137713. set grainEnabled(enabled: boolean);
  137714. get grainEnabled(): boolean;
  137715. /**
  137716. * @constructor
  137717. * @param name - The rendering pipeline name (default: "")
  137718. * @param hdr - If high dynamic range textures should be used (default: true)
  137719. * @param scene - The scene linked to this pipeline (default: the last created scene)
  137720. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  137721. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  137722. */
  137723. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  137724. /**
  137725. * Get the class name
  137726. * @returns "DefaultRenderingPipeline"
  137727. */
  137728. getClassName(): string;
  137729. /**
  137730. * Force the compilation of the entire pipeline.
  137731. */
  137732. prepare(): void;
  137733. private _hasCleared;
  137734. private _prevPostProcess;
  137735. private _prevPrevPostProcess;
  137736. private _setAutoClearAndTextureSharing;
  137737. private _depthOfFieldSceneObserver;
  137738. private _buildPipeline;
  137739. private _disposePostProcesses;
  137740. /**
  137741. * Adds a camera to the pipeline
  137742. * @param camera the camera to be added
  137743. */
  137744. addCamera(camera: Camera): void;
  137745. /**
  137746. * Removes a camera from the pipeline
  137747. * @param camera the camera to remove
  137748. */
  137749. removeCamera(camera: Camera): void;
  137750. /**
  137751. * Dispose of the pipeline and stop all post processes
  137752. */
  137753. dispose(): void;
  137754. /**
  137755. * Serialize the rendering pipeline (Used when exporting)
  137756. * @returns the serialized object
  137757. */
  137758. serialize(): any;
  137759. /**
  137760. * Parse the serialized pipeline
  137761. * @param source Source pipeline.
  137762. * @param scene The scene to load the pipeline to.
  137763. * @param rootUrl The URL of the serialized pipeline.
  137764. * @returns An instantiated pipeline from the serialized object.
  137765. */
  137766. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  137767. }
  137768. }
  137769. declare module BABYLON {
  137770. /** @hidden */
  137771. export var lensHighlightsPixelShader: {
  137772. name: string;
  137773. shader: string;
  137774. };
  137775. }
  137776. declare module BABYLON {
  137777. /** @hidden */
  137778. export var depthOfFieldPixelShader: {
  137779. name: string;
  137780. shader: string;
  137781. };
  137782. }
  137783. declare module BABYLON {
  137784. /**
  137785. * BABYLON.JS Chromatic Aberration GLSL Shader
  137786. * Author: Olivier Guyot
  137787. * Separates very slightly R, G and B colors on the edges of the screen
  137788. * Inspired by Francois Tarlier & Martins Upitis
  137789. */
  137790. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  137791. /**
  137792. * @ignore
  137793. * The chromatic aberration PostProcess id in the pipeline
  137794. */
  137795. LensChromaticAberrationEffect: string;
  137796. /**
  137797. * @ignore
  137798. * The highlights enhancing PostProcess id in the pipeline
  137799. */
  137800. HighlightsEnhancingEffect: string;
  137801. /**
  137802. * @ignore
  137803. * The depth-of-field PostProcess id in the pipeline
  137804. */
  137805. LensDepthOfFieldEffect: string;
  137806. private _scene;
  137807. private _depthTexture;
  137808. private _grainTexture;
  137809. private _chromaticAberrationPostProcess;
  137810. private _highlightsPostProcess;
  137811. private _depthOfFieldPostProcess;
  137812. private _edgeBlur;
  137813. private _grainAmount;
  137814. private _chromaticAberration;
  137815. private _distortion;
  137816. private _highlightsGain;
  137817. private _highlightsThreshold;
  137818. private _dofDistance;
  137819. private _dofAperture;
  137820. private _dofDarken;
  137821. private _dofPentagon;
  137822. private _blurNoise;
  137823. /**
  137824. * @constructor
  137825. *
  137826. * Effect parameters are as follow:
  137827. * {
  137828. * chromatic_aberration: number; // from 0 to x (1 for realism)
  137829. * edge_blur: number; // from 0 to x (1 for realism)
  137830. * distortion: number; // from 0 to x (1 for realism)
  137831. * grain_amount: number; // from 0 to 1
  137832. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  137833. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  137834. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  137835. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  137836. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  137837. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  137838. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  137839. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  137840. * }
  137841. * Note: if an effect parameter is unset, effect is disabled
  137842. *
  137843. * @param name The rendering pipeline name
  137844. * @param parameters - An object containing all parameters (see above)
  137845. * @param scene The scene linked to this pipeline
  137846. * @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)
  137847. * @param cameras The array of cameras that the rendering pipeline will be attached to
  137848. */
  137849. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  137850. /**
  137851. * Get the class name
  137852. * @returns "LensRenderingPipeline"
  137853. */
  137854. getClassName(): string;
  137855. /**
  137856. * Gets associated scene
  137857. */
  137858. get scene(): Scene;
  137859. /**
  137860. * Gets or sets the edge blur
  137861. */
  137862. get edgeBlur(): number;
  137863. set edgeBlur(value: number);
  137864. /**
  137865. * Gets or sets the grain amount
  137866. */
  137867. get grainAmount(): number;
  137868. set grainAmount(value: number);
  137869. /**
  137870. * Gets or sets the chromatic aberration amount
  137871. */
  137872. get chromaticAberration(): number;
  137873. set chromaticAberration(value: number);
  137874. /**
  137875. * Gets or sets the depth of field aperture
  137876. */
  137877. get dofAperture(): number;
  137878. set dofAperture(value: number);
  137879. /**
  137880. * Gets or sets the edge distortion
  137881. */
  137882. get edgeDistortion(): number;
  137883. set edgeDistortion(value: number);
  137884. /**
  137885. * Gets or sets the depth of field distortion
  137886. */
  137887. get dofDistortion(): number;
  137888. set dofDistortion(value: number);
  137889. /**
  137890. * Gets or sets the darken out of focus amount
  137891. */
  137892. get darkenOutOfFocus(): number;
  137893. set darkenOutOfFocus(value: number);
  137894. /**
  137895. * Gets or sets a boolean indicating if blur noise is enabled
  137896. */
  137897. get blurNoise(): boolean;
  137898. set blurNoise(value: boolean);
  137899. /**
  137900. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  137901. */
  137902. get pentagonBokeh(): boolean;
  137903. set pentagonBokeh(value: boolean);
  137904. /**
  137905. * Gets or sets the highlight grain amount
  137906. */
  137907. get highlightsGain(): number;
  137908. set highlightsGain(value: number);
  137909. /**
  137910. * Gets or sets the highlight threshold
  137911. */
  137912. get highlightsThreshold(): number;
  137913. set highlightsThreshold(value: number);
  137914. /**
  137915. * Sets the amount of blur at the edges
  137916. * @param amount blur amount
  137917. */
  137918. setEdgeBlur(amount: number): void;
  137919. /**
  137920. * Sets edge blur to 0
  137921. */
  137922. disableEdgeBlur(): void;
  137923. /**
  137924. * Sets the amout of grain
  137925. * @param amount Amount of grain
  137926. */
  137927. setGrainAmount(amount: number): void;
  137928. /**
  137929. * Set grain amount to 0
  137930. */
  137931. disableGrain(): void;
  137932. /**
  137933. * Sets the chromatic aberration amount
  137934. * @param amount amount of chromatic aberration
  137935. */
  137936. setChromaticAberration(amount: number): void;
  137937. /**
  137938. * Sets chromatic aberration amount to 0
  137939. */
  137940. disableChromaticAberration(): void;
  137941. /**
  137942. * Sets the EdgeDistortion amount
  137943. * @param amount amount of EdgeDistortion
  137944. */
  137945. setEdgeDistortion(amount: number): void;
  137946. /**
  137947. * Sets edge distortion to 0
  137948. */
  137949. disableEdgeDistortion(): void;
  137950. /**
  137951. * Sets the FocusDistance amount
  137952. * @param amount amount of FocusDistance
  137953. */
  137954. setFocusDistance(amount: number): void;
  137955. /**
  137956. * Disables depth of field
  137957. */
  137958. disableDepthOfField(): void;
  137959. /**
  137960. * Sets the Aperture amount
  137961. * @param amount amount of Aperture
  137962. */
  137963. setAperture(amount: number): void;
  137964. /**
  137965. * Sets the DarkenOutOfFocus amount
  137966. * @param amount amount of DarkenOutOfFocus
  137967. */
  137968. setDarkenOutOfFocus(amount: number): void;
  137969. private _pentagonBokehIsEnabled;
  137970. /**
  137971. * Creates a pentagon bokeh effect
  137972. */
  137973. enablePentagonBokeh(): void;
  137974. /**
  137975. * Disables the pentagon bokeh effect
  137976. */
  137977. disablePentagonBokeh(): void;
  137978. /**
  137979. * Enables noise blur
  137980. */
  137981. enableNoiseBlur(): void;
  137982. /**
  137983. * Disables noise blur
  137984. */
  137985. disableNoiseBlur(): void;
  137986. /**
  137987. * Sets the HighlightsGain amount
  137988. * @param amount amount of HighlightsGain
  137989. */
  137990. setHighlightsGain(amount: number): void;
  137991. /**
  137992. * Sets the HighlightsThreshold amount
  137993. * @param amount amount of HighlightsThreshold
  137994. */
  137995. setHighlightsThreshold(amount: number): void;
  137996. /**
  137997. * Disables highlights
  137998. */
  137999. disableHighlights(): void;
  138000. /**
  138001. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138002. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138003. */
  138004. dispose(disableDepthRender?: boolean): void;
  138005. private _createChromaticAberrationPostProcess;
  138006. private _createHighlightsPostProcess;
  138007. private _createDepthOfFieldPostProcess;
  138008. private _createGrainTexture;
  138009. }
  138010. }
  138011. declare module BABYLON {
  138012. /** @hidden */
  138013. export var ssao2PixelShader: {
  138014. name: string;
  138015. shader: string;
  138016. };
  138017. }
  138018. declare module BABYLON {
  138019. /** @hidden */
  138020. export var ssaoCombinePixelShader: {
  138021. name: string;
  138022. shader: string;
  138023. };
  138024. }
  138025. declare module BABYLON {
  138026. /**
  138027. * Render pipeline to produce ssao effect
  138028. */
  138029. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138030. /**
  138031. * @ignore
  138032. * The PassPostProcess id in the pipeline that contains the original scene color
  138033. */
  138034. SSAOOriginalSceneColorEffect: string;
  138035. /**
  138036. * @ignore
  138037. * The SSAO PostProcess id in the pipeline
  138038. */
  138039. SSAORenderEffect: string;
  138040. /**
  138041. * @ignore
  138042. * The horizontal blur PostProcess id in the pipeline
  138043. */
  138044. SSAOBlurHRenderEffect: string;
  138045. /**
  138046. * @ignore
  138047. * The vertical blur PostProcess id in the pipeline
  138048. */
  138049. SSAOBlurVRenderEffect: string;
  138050. /**
  138051. * @ignore
  138052. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138053. */
  138054. SSAOCombineRenderEffect: string;
  138055. /**
  138056. * The output strength of the SSAO post-process. Default value is 1.0.
  138057. */
  138058. totalStrength: number;
  138059. /**
  138060. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138061. */
  138062. maxZ: number;
  138063. /**
  138064. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138065. */
  138066. minZAspect: number;
  138067. private _samples;
  138068. /**
  138069. * Number of samples used for the SSAO calculations. Default value is 8
  138070. */
  138071. set samples(n: number);
  138072. get samples(): number;
  138073. private _textureSamples;
  138074. /**
  138075. * Number of samples to use for antialiasing
  138076. */
  138077. set textureSamples(n: number);
  138078. get textureSamples(): number;
  138079. /**
  138080. * Ratio object used for SSAO ratio and blur ratio
  138081. */
  138082. private _ratio;
  138083. /**
  138084. * Dynamically generated sphere sampler.
  138085. */
  138086. private _sampleSphere;
  138087. /**
  138088. * Blur filter offsets
  138089. */
  138090. private _samplerOffsets;
  138091. private _expensiveBlur;
  138092. /**
  138093. * If bilateral blur should be used
  138094. */
  138095. set expensiveBlur(b: boolean);
  138096. get expensiveBlur(): boolean;
  138097. /**
  138098. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138099. */
  138100. radius: number;
  138101. /**
  138102. * The base color of the SSAO post-process
  138103. * The final result is "base + ssao" between [0, 1]
  138104. */
  138105. base: number;
  138106. /**
  138107. * Support test.
  138108. */
  138109. static get IsSupported(): boolean;
  138110. private _scene;
  138111. private _depthTexture;
  138112. private _normalTexture;
  138113. private _randomTexture;
  138114. private _originalColorPostProcess;
  138115. private _ssaoPostProcess;
  138116. private _blurHPostProcess;
  138117. private _blurVPostProcess;
  138118. private _ssaoCombinePostProcess;
  138119. /**
  138120. * Gets active scene
  138121. */
  138122. get scene(): Scene;
  138123. /**
  138124. * @constructor
  138125. * @param name The rendering pipeline name
  138126. * @param scene The scene linked to this pipeline
  138127. * @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 }
  138128. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138129. */
  138130. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138131. /**
  138132. * Get the class name
  138133. * @returns "SSAO2RenderingPipeline"
  138134. */
  138135. getClassName(): string;
  138136. /**
  138137. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138138. */
  138139. dispose(disableGeometryBufferRenderer?: boolean): void;
  138140. private _createBlurPostProcess;
  138141. /** @hidden */
  138142. _rebuild(): void;
  138143. private _bits;
  138144. private _radicalInverse_VdC;
  138145. private _hammersley;
  138146. private _hemisphereSample_uniform;
  138147. private _generateHemisphere;
  138148. private _createSSAOPostProcess;
  138149. private _createSSAOCombinePostProcess;
  138150. private _createRandomTexture;
  138151. /**
  138152. * Serialize the rendering pipeline (Used when exporting)
  138153. * @returns the serialized object
  138154. */
  138155. serialize(): any;
  138156. /**
  138157. * Parse the serialized pipeline
  138158. * @param source Source pipeline.
  138159. * @param scene The scene to load the pipeline to.
  138160. * @param rootUrl The URL of the serialized pipeline.
  138161. * @returns An instantiated pipeline from the serialized object.
  138162. */
  138163. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138164. }
  138165. }
  138166. declare module BABYLON {
  138167. /** @hidden */
  138168. export var ssaoPixelShader: {
  138169. name: string;
  138170. shader: string;
  138171. };
  138172. }
  138173. declare module BABYLON {
  138174. /**
  138175. * Render pipeline to produce ssao effect
  138176. */
  138177. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138178. /**
  138179. * @ignore
  138180. * The PassPostProcess id in the pipeline that contains the original scene color
  138181. */
  138182. SSAOOriginalSceneColorEffect: string;
  138183. /**
  138184. * @ignore
  138185. * The SSAO PostProcess id in the pipeline
  138186. */
  138187. SSAORenderEffect: string;
  138188. /**
  138189. * @ignore
  138190. * The horizontal blur PostProcess id in the pipeline
  138191. */
  138192. SSAOBlurHRenderEffect: string;
  138193. /**
  138194. * @ignore
  138195. * The vertical blur PostProcess id in the pipeline
  138196. */
  138197. SSAOBlurVRenderEffect: string;
  138198. /**
  138199. * @ignore
  138200. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138201. */
  138202. SSAOCombineRenderEffect: string;
  138203. /**
  138204. * The output strength of the SSAO post-process. Default value is 1.0.
  138205. */
  138206. totalStrength: number;
  138207. /**
  138208. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138209. */
  138210. radius: number;
  138211. /**
  138212. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138213. * Must not be equal to fallOff and superior to fallOff.
  138214. * Default value is 0.0075
  138215. */
  138216. area: number;
  138217. /**
  138218. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138219. * Must not be equal to area and inferior to area.
  138220. * Default value is 0.000001
  138221. */
  138222. fallOff: number;
  138223. /**
  138224. * The base color of the SSAO post-process
  138225. * The final result is "base + ssao" between [0, 1]
  138226. */
  138227. base: number;
  138228. private _scene;
  138229. private _depthTexture;
  138230. private _randomTexture;
  138231. private _originalColorPostProcess;
  138232. private _ssaoPostProcess;
  138233. private _blurHPostProcess;
  138234. private _blurVPostProcess;
  138235. private _ssaoCombinePostProcess;
  138236. private _firstUpdate;
  138237. /**
  138238. * Gets active scene
  138239. */
  138240. get scene(): Scene;
  138241. /**
  138242. * @constructor
  138243. * @param name - The rendering pipeline name
  138244. * @param scene - The scene linked to this pipeline
  138245. * @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 }
  138246. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138247. */
  138248. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138249. /**
  138250. * Get the class name
  138251. * @returns "SSAORenderingPipeline"
  138252. */
  138253. getClassName(): string;
  138254. /**
  138255. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138256. */
  138257. dispose(disableDepthRender?: boolean): void;
  138258. private _createBlurPostProcess;
  138259. /** @hidden */
  138260. _rebuild(): void;
  138261. private _createSSAOPostProcess;
  138262. private _createSSAOCombinePostProcess;
  138263. private _createRandomTexture;
  138264. }
  138265. }
  138266. declare module BABYLON {
  138267. /** @hidden */
  138268. export var standardPixelShader: {
  138269. name: string;
  138270. shader: string;
  138271. };
  138272. }
  138273. declare module BABYLON {
  138274. /**
  138275. * Standard rendering pipeline
  138276. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138277. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  138278. */
  138279. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138280. /**
  138281. * Public members
  138282. */
  138283. /**
  138284. * Post-process which contains the original scene color before the pipeline applies all the effects
  138285. */
  138286. originalPostProcess: Nullable<PostProcess>;
  138287. /**
  138288. * Post-process used to down scale an image x4
  138289. */
  138290. downSampleX4PostProcess: Nullable<PostProcess>;
  138291. /**
  138292. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  138293. */
  138294. brightPassPostProcess: Nullable<PostProcess>;
  138295. /**
  138296. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  138297. */
  138298. blurHPostProcesses: PostProcess[];
  138299. /**
  138300. * Post-process array storing all the vertical blur post-processes used by the pipeline
  138301. */
  138302. blurVPostProcesses: PostProcess[];
  138303. /**
  138304. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  138305. */
  138306. textureAdderPostProcess: Nullable<PostProcess>;
  138307. /**
  138308. * Post-process used to create volumetric lighting effect
  138309. */
  138310. volumetricLightPostProcess: Nullable<PostProcess>;
  138311. /**
  138312. * Post-process used to smooth the previous volumetric light post-process on the X axis
  138313. */
  138314. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  138315. /**
  138316. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  138317. */
  138318. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  138319. /**
  138320. * Post-process used to merge the volumetric light effect and the real scene color
  138321. */
  138322. volumetricLightMergePostProces: Nullable<PostProcess>;
  138323. /**
  138324. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  138325. */
  138326. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  138327. /**
  138328. * Base post-process used to calculate the average luminance of the final image for HDR
  138329. */
  138330. luminancePostProcess: Nullable<PostProcess>;
  138331. /**
  138332. * Post-processes used to create down sample post-processes in order to get
  138333. * the average luminance of the final image for HDR
  138334. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  138335. */
  138336. luminanceDownSamplePostProcesses: PostProcess[];
  138337. /**
  138338. * Post-process used to create a HDR effect (light adaptation)
  138339. */
  138340. hdrPostProcess: Nullable<PostProcess>;
  138341. /**
  138342. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  138343. */
  138344. textureAdderFinalPostProcess: Nullable<PostProcess>;
  138345. /**
  138346. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  138347. */
  138348. lensFlareFinalPostProcess: Nullable<PostProcess>;
  138349. /**
  138350. * Post-process used to merge the final HDR post-process and the real scene color
  138351. */
  138352. hdrFinalPostProcess: Nullable<PostProcess>;
  138353. /**
  138354. * Post-process used to create a lens flare effect
  138355. */
  138356. lensFlarePostProcess: Nullable<PostProcess>;
  138357. /**
  138358. * Post-process that merges the result of the lens flare post-process and the real scene color
  138359. */
  138360. lensFlareComposePostProcess: Nullable<PostProcess>;
  138361. /**
  138362. * Post-process used to create a motion blur effect
  138363. */
  138364. motionBlurPostProcess: Nullable<PostProcess>;
  138365. /**
  138366. * Post-process used to create a depth of field effect
  138367. */
  138368. depthOfFieldPostProcess: Nullable<PostProcess>;
  138369. /**
  138370. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138371. */
  138372. fxaaPostProcess: Nullable<FxaaPostProcess>;
  138373. /**
  138374. * Represents the brightness threshold in order to configure the illuminated surfaces
  138375. */
  138376. brightThreshold: number;
  138377. /**
  138378. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  138379. */
  138380. blurWidth: number;
  138381. /**
  138382. * Sets if the blur for highlighted surfaces must be only horizontal
  138383. */
  138384. horizontalBlur: boolean;
  138385. /**
  138386. * Gets the overall exposure used by the pipeline
  138387. */
  138388. get exposure(): number;
  138389. /**
  138390. * Sets the overall exposure used by the pipeline
  138391. */
  138392. set exposure(value: number);
  138393. /**
  138394. * Texture used typically to simulate "dirty" on camera lens
  138395. */
  138396. lensTexture: Nullable<Texture>;
  138397. /**
  138398. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  138399. */
  138400. volumetricLightCoefficient: number;
  138401. /**
  138402. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  138403. */
  138404. volumetricLightPower: number;
  138405. /**
  138406. * Used the set the blur intensity to smooth the volumetric lights
  138407. */
  138408. volumetricLightBlurScale: number;
  138409. /**
  138410. * Light (spot or directional) used to generate the volumetric lights rays
  138411. * The source light must have a shadow generate so the pipeline can get its
  138412. * depth map
  138413. */
  138414. sourceLight: Nullable<SpotLight | DirectionalLight>;
  138415. /**
  138416. * For eye adaptation, represents the minimum luminance the eye can see
  138417. */
  138418. hdrMinimumLuminance: number;
  138419. /**
  138420. * For eye adaptation, represents the decrease luminance speed
  138421. */
  138422. hdrDecreaseRate: number;
  138423. /**
  138424. * For eye adaptation, represents the increase luminance speed
  138425. */
  138426. hdrIncreaseRate: number;
  138427. /**
  138428. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138429. */
  138430. get hdrAutoExposure(): boolean;
  138431. /**
  138432. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138433. */
  138434. set hdrAutoExposure(value: boolean);
  138435. /**
  138436. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  138437. */
  138438. lensColorTexture: Nullable<Texture>;
  138439. /**
  138440. * The overall strengh for the lens flare effect
  138441. */
  138442. lensFlareStrength: number;
  138443. /**
  138444. * Dispersion coefficient for lens flare ghosts
  138445. */
  138446. lensFlareGhostDispersal: number;
  138447. /**
  138448. * Main lens flare halo width
  138449. */
  138450. lensFlareHaloWidth: number;
  138451. /**
  138452. * Based on the lens distortion effect, defines how much the lens flare result
  138453. * is distorted
  138454. */
  138455. lensFlareDistortionStrength: number;
  138456. /**
  138457. * Configures the blur intensity used for for lens flare (halo)
  138458. */
  138459. lensFlareBlurWidth: number;
  138460. /**
  138461. * Lens star texture must be used to simulate rays on the flares and is available
  138462. * in the documentation
  138463. */
  138464. lensStarTexture: Nullable<Texture>;
  138465. /**
  138466. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  138467. * flare effect by taking account of the dirt texture
  138468. */
  138469. lensFlareDirtTexture: Nullable<Texture>;
  138470. /**
  138471. * Represents the focal length for the depth of field effect
  138472. */
  138473. depthOfFieldDistance: number;
  138474. /**
  138475. * Represents the blur intensity for the blurred part of the depth of field effect
  138476. */
  138477. depthOfFieldBlurWidth: number;
  138478. /**
  138479. * Gets how much the image is blurred by the movement while using the motion blur post-process
  138480. */
  138481. get motionStrength(): number;
  138482. /**
  138483. * Sets how much the image is blurred by the movement while using the motion blur post-process
  138484. */
  138485. set motionStrength(strength: number);
  138486. /**
  138487. * Gets wether or not the motion blur post-process is object based or screen based.
  138488. */
  138489. get objectBasedMotionBlur(): boolean;
  138490. /**
  138491. * Sets wether or not the motion blur post-process should be object based or screen based
  138492. */
  138493. set objectBasedMotionBlur(value: boolean);
  138494. /**
  138495. * List of animations for the pipeline (IAnimatable implementation)
  138496. */
  138497. animations: Animation[];
  138498. /**
  138499. * Private members
  138500. */
  138501. private _scene;
  138502. private _currentDepthOfFieldSource;
  138503. private _basePostProcess;
  138504. private _fixedExposure;
  138505. private _currentExposure;
  138506. private _hdrAutoExposure;
  138507. private _hdrCurrentLuminance;
  138508. private _motionStrength;
  138509. private _isObjectBasedMotionBlur;
  138510. private _floatTextureType;
  138511. private _camerasToBeAttached;
  138512. private _ratio;
  138513. private _bloomEnabled;
  138514. private _depthOfFieldEnabled;
  138515. private _vlsEnabled;
  138516. private _lensFlareEnabled;
  138517. private _hdrEnabled;
  138518. private _motionBlurEnabled;
  138519. private _fxaaEnabled;
  138520. private _motionBlurSamples;
  138521. private _volumetricLightStepsCount;
  138522. private _samples;
  138523. /**
  138524. * @ignore
  138525. * Specifies if the bloom pipeline is enabled
  138526. */
  138527. get BloomEnabled(): boolean;
  138528. set BloomEnabled(enabled: boolean);
  138529. /**
  138530. * @ignore
  138531. * Specifies if the depth of field pipeline is enabed
  138532. */
  138533. get DepthOfFieldEnabled(): boolean;
  138534. set DepthOfFieldEnabled(enabled: boolean);
  138535. /**
  138536. * @ignore
  138537. * Specifies if the lens flare pipeline is enabed
  138538. */
  138539. get LensFlareEnabled(): boolean;
  138540. set LensFlareEnabled(enabled: boolean);
  138541. /**
  138542. * @ignore
  138543. * Specifies if the HDR pipeline is enabled
  138544. */
  138545. get HDREnabled(): boolean;
  138546. set HDREnabled(enabled: boolean);
  138547. /**
  138548. * @ignore
  138549. * Specifies if the volumetric lights scattering effect is enabled
  138550. */
  138551. get VLSEnabled(): boolean;
  138552. set VLSEnabled(enabled: boolean);
  138553. /**
  138554. * @ignore
  138555. * Specifies if the motion blur effect is enabled
  138556. */
  138557. get MotionBlurEnabled(): boolean;
  138558. set MotionBlurEnabled(enabled: boolean);
  138559. /**
  138560. * Specifies if anti-aliasing is enabled
  138561. */
  138562. get fxaaEnabled(): boolean;
  138563. set fxaaEnabled(enabled: boolean);
  138564. /**
  138565. * Specifies the number of steps used to calculate the volumetric lights
  138566. * Typically in interval [50, 200]
  138567. */
  138568. get volumetricLightStepsCount(): number;
  138569. set volumetricLightStepsCount(count: number);
  138570. /**
  138571. * Specifies the number of samples used for the motion blur effect
  138572. * Typically in interval [16, 64]
  138573. */
  138574. get motionBlurSamples(): number;
  138575. set motionBlurSamples(samples: number);
  138576. /**
  138577. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138578. */
  138579. get samples(): number;
  138580. set samples(sampleCount: number);
  138581. /**
  138582. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138583. * @constructor
  138584. * @param name The rendering pipeline name
  138585. * @param scene The scene linked to this pipeline
  138586. * @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)
  138587. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  138588. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138589. */
  138590. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  138591. private _buildPipeline;
  138592. private _createDownSampleX4PostProcess;
  138593. private _createBrightPassPostProcess;
  138594. private _createBlurPostProcesses;
  138595. private _createTextureAdderPostProcess;
  138596. private _createVolumetricLightPostProcess;
  138597. private _createLuminancePostProcesses;
  138598. private _createHdrPostProcess;
  138599. private _createLensFlarePostProcess;
  138600. private _createDepthOfFieldPostProcess;
  138601. private _createMotionBlurPostProcess;
  138602. private _getDepthTexture;
  138603. private _disposePostProcesses;
  138604. /**
  138605. * Dispose of the pipeline and stop all post processes
  138606. */
  138607. dispose(): void;
  138608. /**
  138609. * Serialize the rendering pipeline (Used when exporting)
  138610. * @returns the serialized object
  138611. */
  138612. serialize(): any;
  138613. /**
  138614. * Parse the serialized pipeline
  138615. * @param source Source pipeline.
  138616. * @param scene The scene to load the pipeline to.
  138617. * @param rootUrl The URL of the serialized pipeline.
  138618. * @returns An instantiated pipeline from the serialized object.
  138619. */
  138620. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  138621. /**
  138622. * Luminance steps
  138623. */
  138624. static LuminanceSteps: number;
  138625. }
  138626. }
  138627. declare module BABYLON {
  138628. /** @hidden */
  138629. export var tonemapPixelShader: {
  138630. name: string;
  138631. shader: string;
  138632. };
  138633. }
  138634. declare module BABYLON {
  138635. /** Defines operator used for tonemapping */
  138636. export enum TonemappingOperator {
  138637. /** Hable */
  138638. Hable = 0,
  138639. /** Reinhard */
  138640. Reinhard = 1,
  138641. /** HejiDawson */
  138642. HejiDawson = 2,
  138643. /** Photographic */
  138644. Photographic = 3
  138645. }
  138646. /**
  138647. * Defines a post process to apply tone mapping
  138648. */
  138649. export class TonemapPostProcess extends PostProcess {
  138650. private _operator;
  138651. /** Defines the required exposure adjustement */
  138652. exposureAdjustment: number;
  138653. /**
  138654. * Creates a new TonemapPostProcess
  138655. * @param name defines the name of the postprocess
  138656. * @param _operator defines the operator to use
  138657. * @param exposureAdjustment defines the required exposure adjustement
  138658. * @param camera defines the camera to use (can be null)
  138659. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  138660. * @param engine defines the hosting engine (can be ignore if camera is set)
  138661. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138662. */
  138663. constructor(name: string, _operator: TonemappingOperator,
  138664. /** Defines the required exposure adjustement */
  138665. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  138666. }
  138667. }
  138668. declare module BABYLON {
  138669. /** @hidden */
  138670. export var volumetricLightScatteringPixelShader: {
  138671. name: string;
  138672. shader: string;
  138673. };
  138674. }
  138675. declare module BABYLON {
  138676. /** @hidden */
  138677. export var volumetricLightScatteringPassVertexShader: {
  138678. name: string;
  138679. shader: string;
  138680. };
  138681. }
  138682. declare module BABYLON {
  138683. /** @hidden */
  138684. export var volumetricLightScatteringPassPixelShader: {
  138685. name: string;
  138686. shader: string;
  138687. };
  138688. }
  138689. declare module BABYLON {
  138690. /**
  138691. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  138692. */
  138693. export class VolumetricLightScatteringPostProcess extends PostProcess {
  138694. private _volumetricLightScatteringPass;
  138695. private _volumetricLightScatteringRTT;
  138696. private _viewPort;
  138697. private _screenCoordinates;
  138698. private _cachedDefines;
  138699. /**
  138700. * If not undefined, the mesh position is computed from the attached node position
  138701. */
  138702. attachedNode: {
  138703. position: Vector3;
  138704. };
  138705. /**
  138706. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  138707. */
  138708. customMeshPosition: Vector3;
  138709. /**
  138710. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  138711. */
  138712. useCustomMeshPosition: boolean;
  138713. /**
  138714. * If the post-process should inverse the light scattering direction
  138715. */
  138716. invert: boolean;
  138717. /**
  138718. * The internal mesh used by the post-process
  138719. */
  138720. mesh: Mesh;
  138721. /**
  138722. * @hidden
  138723. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  138724. */
  138725. get useDiffuseColor(): boolean;
  138726. set useDiffuseColor(useDiffuseColor: boolean);
  138727. /**
  138728. * Array containing the excluded meshes not rendered in the internal pass
  138729. */
  138730. excludedMeshes: AbstractMesh[];
  138731. /**
  138732. * Controls the overall intensity of the post-process
  138733. */
  138734. exposure: number;
  138735. /**
  138736. * Dissipates each sample's contribution in range [0, 1]
  138737. */
  138738. decay: number;
  138739. /**
  138740. * Controls the overall intensity of each sample
  138741. */
  138742. weight: number;
  138743. /**
  138744. * Controls the density of each sample
  138745. */
  138746. density: number;
  138747. /**
  138748. * @constructor
  138749. * @param name The post-process name
  138750. * @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)
  138751. * @param camera The camera that the post-process will be attached to
  138752. * @param mesh The mesh used to create the light scattering
  138753. * @param samples The post-process quality, default 100
  138754. * @param samplingModeThe post-process filtering mode
  138755. * @param engine The babylon engine
  138756. * @param reusable If the post-process is reusable
  138757. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  138758. */
  138759. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  138760. /**
  138761. * Returns the string "VolumetricLightScatteringPostProcess"
  138762. * @returns "VolumetricLightScatteringPostProcess"
  138763. */
  138764. getClassName(): string;
  138765. private _isReady;
  138766. /**
  138767. * Sets the new light position for light scattering effect
  138768. * @param position The new custom light position
  138769. */
  138770. setCustomMeshPosition(position: Vector3): void;
  138771. /**
  138772. * Returns the light position for light scattering effect
  138773. * @return Vector3 The custom light position
  138774. */
  138775. getCustomMeshPosition(): Vector3;
  138776. /**
  138777. * Disposes the internal assets and detaches the post-process from the camera
  138778. */
  138779. dispose(camera: Camera): void;
  138780. /**
  138781. * Returns the render target texture used by the post-process
  138782. * @return the render target texture used by the post-process
  138783. */
  138784. getPass(): RenderTargetTexture;
  138785. private _meshExcluded;
  138786. private _createPass;
  138787. private _updateMeshScreenCoordinates;
  138788. /**
  138789. * Creates a default mesh for the Volumeric Light Scattering post-process
  138790. * @param name The mesh name
  138791. * @param scene The scene where to create the mesh
  138792. * @return the default mesh
  138793. */
  138794. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  138795. }
  138796. }
  138797. declare module BABYLON {
  138798. interface Scene {
  138799. /** @hidden (Backing field) */
  138800. _boundingBoxRenderer: BoundingBoxRenderer;
  138801. /** @hidden (Backing field) */
  138802. _forceShowBoundingBoxes: boolean;
  138803. /**
  138804. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  138805. */
  138806. forceShowBoundingBoxes: boolean;
  138807. /**
  138808. * Gets the bounding box renderer associated with the scene
  138809. * @returns a BoundingBoxRenderer
  138810. */
  138811. getBoundingBoxRenderer(): BoundingBoxRenderer;
  138812. }
  138813. interface AbstractMesh {
  138814. /** @hidden (Backing field) */
  138815. _showBoundingBox: boolean;
  138816. /**
  138817. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  138818. */
  138819. showBoundingBox: boolean;
  138820. }
  138821. /**
  138822. * Component responsible of rendering the bounding box of the meshes in a scene.
  138823. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  138824. */
  138825. export class BoundingBoxRenderer implements ISceneComponent {
  138826. /**
  138827. * The component name helpfull to identify the component in the list of scene components.
  138828. */
  138829. readonly name: string;
  138830. /**
  138831. * The scene the component belongs to.
  138832. */
  138833. scene: Scene;
  138834. /**
  138835. * Color of the bounding box lines placed in front of an object
  138836. */
  138837. frontColor: Color3;
  138838. /**
  138839. * Color of the bounding box lines placed behind an object
  138840. */
  138841. backColor: Color3;
  138842. /**
  138843. * Defines if the renderer should show the back lines or not
  138844. */
  138845. showBackLines: boolean;
  138846. /**
  138847. * @hidden
  138848. */
  138849. renderList: SmartArray<BoundingBox>;
  138850. private _colorShader;
  138851. private _vertexBuffers;
  138852. private _indexBuffer;
  138853. private _fillIndexBuffer;
  138854. private _fillIndexData;
  138855. /**
  138856. * Instantiates a new bounding box renderer in a scene.
  138857. * @param scene the scene the renderer renders in
  138858. */
  138859. constructor(scene: Scene);
  138860. /**
  138861. * Registers the component in a given scene
  138862. */
  138863. register(): void;
  138864. private _evaluateSubMesh;
  138865. private _activeMesh;
  138866. private _prepareRessources;
  138867. private _createIndexBuffer;
  138868. /**
  138869. * Rebuilds the elements related to this component in case of
  138870. * context lost for instance.
  138871. */
  138872. rebuild(): void;
  138873. /**
  138874. * @hidden
  138875. */
  138876. reset(): void;
  138877. /**
  138878. * Render the bounding boxes of a specific rendering group
  138879. * @param renderingGroupId defines the rendering group to render
  138880. */
  138881. render(renderingGroupId: number): void;
  138882. /**
  138883. * In case of occlusion queries, we can render the occlusion bounding box through this method
  138884. * @param mesh Define the mesh to render the occlusion bounding box for
  138885. */
  138886. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  138887. /**
  138888. * Dispose and release the resources attached to this renderer.
  138889. */
  138890. dispose(): void;
  138891. }
  138892. }
  138893. declare module BABYLON {
  138894. interface Scene {
  138895. /** @hidden (Backing field) */
  138896. _depthRenderer: {
  138897. [id: string]: DepthRenderer;
  138898. };
  138899. /**
  138900. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  138901. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  138902. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  138903. * @returns the created depth renderer
  138904. */
  138905. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  138906. /**
  138907. * Disables a depth renderer for a given camera
  138908. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  138909. */
  138910. disableDepthRenderer(camera?: Nullable<Camera>): void;
  138911. }
  138912. /**
  138913. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  138914. * in several rendering techniques.
  138915. */
  138916. export class DepthRendererSceneComponent implements ISceneComponent {
  138917. /**
  138918. * The component name helpfull to identify the component in the list of scene components.
  138919. */
  138920. readonly name: string;
  138921. /**
  138922. * The scene the component belongs to.
  138923. */
  138924. scene: Scene;
  138925. /**
  138926. * Creates a new instance of the component for the given scene
  138927. * @param scene Defines the scene to register the component in
  138928. */
  138929. constructor(scene: Scene);
  138930. /**
  138931. * Registers the component in a given scene
  138932. */
  138933. register(): void;
  138934. /**
  138935. * Rebuilds the elements related to this component in case of
  138936. * context lost for instance.
  138937. */
  138938. rebuild(): void;
  138939. /**
  138940. * Disposes the component and the associated ressources
  138941. */
  138942. dispose(): void;
  138943. private _gatherRenderTargets;
  138944. private _gatherActiveCameraRenderTargets;
  138945. }
  138946. }
  138947. declare module BABYLON {
  138948. /** @hidden */
  138949. export var outlinePixelShader: {
  138950. name: string;
  138951. shader: string;
  138952. };
  138953. }
  138954. declare module BABYLON {
  138955. /** @hidden */
  138956. export var outlineVertexShader: {
  138957. name: string;
  138958. shader: string;
  138959. };
  138960. }
  138961. declare module BABYLON {
  138962. interface Scene {
  138963. /** @hidden */
  138964. _outlineRenderer: OutlineRenderer;
  138965. /**
  138966. * Gets the outline renderer associated with the scene
  138967. * @returns a OutlineRenderer
  138968. */
  138969. getOutlineRenderer(): OutlineRenderer;
  138970. }
  138971. interface AbstractMesh {
  138972. /** @hidden (Backing field) */
  138973. _renderOutline: boolean;
  138974. /**
  138975. * Gets or sets a boolean indicating if the outline must be rendered as well
  138976. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  138977. */
  138978. renderOutline: boolean;
  138979. /** @hidden (Backing field) */
  138980. _renderOverlay: boolean;
  138981. /**
  138982. * Gets or sets a boolean indicating if the overlay must be rendered as well
  138983. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  138984. */
  138985. renderOverlay: boolean;
  138986. }
  138987. /**
  138988. * This class is responsible to draw bothe outline/overlay of meshes.
  138989. * It should not be used directly but through the available method on mesh.
  138990. */
  138991. export class OutlineRenderer implements ISceneComponent {
  138992. /**
  138993. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  138994. */
  138995. private static _StencilReference;
  138996. /**
  138997. * The name of the component. Each component must have a unique name.
  138998. */
  138999. name: string;
  139000. /**
  139001. * The scene the component belongs to.
  139002. */
  139003. scene: Scene;
  139004. /**
  139005. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139006. */
  139007. zOffset: number;
  139008. private _engine;
  139009. private _effect;
  139010. private _cachedDefines;
  139011. private _savedDepthWrite;
  139012. /**
  139013. * Instantiates a new outline renderer. (There could be only one per scene).
  139014. * @param scene Defines the scene it belongs to
  139015. */
  139016. constructor(scene: Scene);
  139017. /**
  139018. * Register the component to one instance of a scene.
  139019. */
  139020. register(): void;
  139021. /**
  139022. * Rebuilds the elements related to this component in case of
  139023. * context lost for instance.
  139024. */
  139025. rebuild(): void;
  139026. /**
  139027. * Disposes the component and the associated ressources.
  139028. */
  139029. dispose(): void;
  139030. /**
  139031. * Renders the outline in the canvas.
  139032. * @param subMesh Defines the sumesh to render
  139033. * @param batch Defines the batch of meshes in case of instances
  139034. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139035. */
  139036. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139037. /**
  139038. * Returns whether or not the outline renderer is ready for a given submesh.
  139039. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139040. * @param subMesh Defines the submesh to check readyness for
  139041. * @param useInstances Defines wheter wee are trying to render instances or not
  139042. * @returns true if ready otherwise false
  139043. */
  139044. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139045. private _beforeRenderingMesh;
  139046. private _afterRenderingMesh;
  139047. }
  139048. }
  139049. declare module BABYLON {
  139050. /**
  139051. * Defines the basic options interface of a Sprite Frame Source Size.
  139052. */
  139053. export interface ISpriteJSONSpriteSourceSize {
  139054. /**
  139055. * number of the original width of the Frame
  139056. */
  139057. w: number;
  139058. /**
  139059. * number of the original height of the Frame
  139060. */
  139061. h: number;
  139062. }
  139063. /**
  139064. * Defines the basic options interface of a Sprite Frame Data.
  139065. */
  139066. export interface ISpriteJSONSpriteFrameData {
  139067. /**
  139068. * number of the x offset of the Frame
  139069. */
  139070. x: number;
  139071. /**
  139072. * number of the y offset of the Frame
  139073. */
  139074. y: number;
  139075. /**
  139076. * number of the width of the Frame
  139077. */
  139078. w: number;
  139079. /**
  139080. * number of the height of the Frame
  139081. */
  139082. h: number;
  139083. }
  139084. /**
  139085. * Defines the basic options interface of a JSON Sprite.
  139086. */
  139087. export interface ISpriteJSONSprite {
  139088. /**
  139089. * string name of the Frame
  139090. */
  139091. filename: string;
  139092. /**
  139093. * ISpriteJSONSpriteFrame basic object of the frame data
  139094. */
  139095. frame: ISpriteJSONSpriteFrameData;
  139096. /**
  139097. * boolean to flag is the frame was rotated.
  139098. */
  139099. rotated: boolean;
  139100. /**
  139101. * boolean to flag is the frame was trimmed.
  139102. */
  139103. trimmed: boolean;
  139104. /**
  139105. * ISpriteJSONSpriteFrame basic object of the source data
  139106. */
  139107. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139108. /**
  139109. * ISpriteJSONSpriteFrame basic object of the source data
  139110. */
  139111. sourceSize: ISpriteJSONSpriteSourceSize;
  139112. }
  139113. /**
  139114. * Defines the basic options interface of a JSON atlas.
  139115. */
  139116. export interface ISpriteJSONAtlas {
  139117. /**
  139118. * Array of objects that contain the frame data.
  139119. */
  139120. frames: Array<ISpriteJSONSprite>;
  139121. /**
  139122. * object basic object containing the sprite meta data.
  139123. */
  139124. meta?: object;
  139125. }
  139126. }
  139127. declare module BABYLON {
  139128. /** @hidden */
  139129. export var spriteMapPixelShader: {
  139130. name: string;
  139131. shader: string;
  139132. };
  139133. }
  139134. declare module BABYLON {
  139135. /** @hidden */
  139136. export var spriteMapVertexShader: {
  139137. name: string;
  139138. shader: string;
  139139. };
  139140. }
  139141. declare module BABYLON {
  139142. /**
  139143. * Defines the basic options interface of a SpriteMap
  139144. */
  139145. export interface ISpriteMapOptions {
  139146. /**
  139147. * Vector2 of the number of cells in the grid.
  139148. */
  139149. stageSize?: Vector2;
  139150. /**
  139151. * Vector2 of the size of the output plane in World Units.
  139152. */
  139153. outputSize?: Vector2;
  139154. /**
  139155. * Vector3 of the position of the output plane in World Units.
  139156. */
  139157. outputPosition?: Vector3;
  139158. /**
  139159. * Vector3 of the rotation of the output plane.
  139160. */
  139161. outputRotation?: Vector3;
  139162. /**
  139163. * number of layers that the system will reserve in resources.
  139164. */
  139165. layerCount?: number;
  139166. /**
  139167. * number of max animation frames a single cell will reserve in resources.
  139168. */
  139169. maxAnimationFrames?: number;
  139170. /**
  139171. * number cell index of the base tile when the system compiles.
  139172. */
  139173. baseTile?: number;
  139174. /**
  139175. * boolean flip the sprite after its been repositioned by the framing data.
  139176. */
  139177. flipU?: boolean;
  139178. /**
  139179. * Vector3 scalar of the global RGB values of the SpriteMap.
  139180. */
  139181. colorMultiply?: Vector3;
  139182. }
  139183. /**
  139184. * Defines the IDisposable interface in order to be cleanable from resources.
  139185. */
  139186. export interface ISpriteMap extends IDisposable {
  139187. /**
  139188. * String name of the SpriteMap.
  139189. */
  139190. name: string;
  139191. /**
  139192. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139193. */
  139194. atlasJSON: ISpriteJSONAtlas;
  139195. /**
  139196. * Texture of the SpriteMap.
  139197. */
  139198. spriteSheet: Texture;
  139199. /**
  139200. * The parameters to initialize the SpriteMap with.
  139201. */
  139202. options: ISpriteMapOptions;
  139203. }
  139204. /**
  139205. * Class used to manage a grid restricted sprite deployment on an Output plane.
  139206. */
  139207. export class SpriteMap implements ISpriteMap {
  139208. /** The Name of the spriteMap */
  139209. name: string;
  139210. /** The JSON file with the frame and meta data */
  139211. atlasJSON: ISpriteJSONAtlas;
  139212. /** The systems Sprite Sheet Texture */
  139213. spriteSheet: Texture;
  139214. /** Arguments passed with the Constructor */
  139215. options: ISpriteMapOptions;
  139216. /** Public Sprite Storage array, parsed from atlasJSON */
  139217. sprites: Array<ISpriteJSONSprite>;
  139218. /** Returns the Number of Sprites in the System */
  139219. get spriteCount(): number;
  139220. /** Returns the Position of Output Plane*/
  139221. get position(): Vector3;
  139222. /** Returns the Position of Output Plane*/
  139223. set position(v: Vector3);
  139224. /** Returns the Rotation of Output Plane*/
  139225. get rotation(): Vector3;
  139226. /** Returns the Rotation of Output Plane*/
  139227. set rotation(v: Vector3);
  139228. /** Sets the AnimationMap*/
  139229. get animationMap(): RawTexture;
  139230. /** Sets the AnimationMap*/
  139231. set animationMap(v: RawTexture);
  139232. /** Scene that the SpriteMap was created in */
  139233. private _scene;
  139234. /** Texture Buffer of Float32 that holds tile frame data*/
  139235. private _frameMap;
  139236. /** Texture Buffers of Float32 that holds tileMap data*/
  139237. private _tileMaps;
  139238. /** Texture Buffer of Float32 that holds Animation Data*/
  139239. private _animationMap;
  139240. /** Custom ShaderMaterial Central to the System*/
  139241. private _material;
  139242. /** Custom ShaderMaterial Central to the System*/
  139243. private _output;
  139244. /** Systems Time Ticker*/
  139245. private _time;
  139246. /**
  139247. * Creates a new SpriteMap
  139248. * @param name defines the SpriteMaps Name
  139249. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  139250. * @param spriteSheet is the Texture that the Sprites are on.
  139251. * @param options a basic deployment configuration
  139252. * @param scene The Scene that the map is deployed on
  139253. */
  139254. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  139255. /**
  139256. * Returns tileID location
  139257. * @returns Vector2 the cell position ID
  139258. */
  139259. getTileID(): Vector2;
  139260. /**
  139261. * Gets the UV location of the mouse over the SpriteMap.
  139262. * @returns Vector2 the UV position of the mouse interaction
  139263. */
  139264. getMousePosition(): Vector2;
  139265. /**
  139266. * Creates the "frame" texture Buffer
  139267. * -------------------------------------
  139268. * Structure of frames
  139269. * "filename": "Falling-Water-2.png",
  139270. * "frame": {"x":69,"y":103,"w":24,"h":32},
  139271. * "rotated": true,
  139272. * "trimmed": true,
  139273. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  139274. * "sourceSize": {"w":32,"h":32}
  139275. * @returns RawTexture of the frameMap
  139276. */
  139277. private _createFrameBuffer;
  139278. /**
  139279. * Creates the tileMap texture Buffer
  139280. * @param buffer normally and array of numbers, or a false to generate from scratch
  139281. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  139282. * @returns RawTexture of the tileMap
  139283. */
  139284. private _createTileBuffer;
  139285. /**
  139286. * Modifies the data of the tileMaps
  139287. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  139288. * @param pos is the iVector2 Coordinates of the Tile
  139289. * @param tile The SpriteIndex of the new Tile
  139290. */
  139291. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  139292. /**
  139293. * Creates the animationMap texture Buffer
  139294. * @param buffer normally and array of numbers, or a false to generate from scratch
  139295. * @returns RawTexture of the animationMap
  139296. */
  139297. private _createTileAnimationBuffer;
  139298. /**
  139299. * Modifies the data of the animationMap
  139300. * @param cellID is the Index of the Sprite
  139301. * @param _frame is the target Animation frame
  139302. * @param toCell is the Target Index of the next frame of the animation
  139303. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  139304. * @param speed is a global scalar of the time variable on the map.
  139305. */
  139306. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  139307. /**
  139308. * Exports the .tilemaps file
  139309. */
  139310. saveTileMaps(): void;
  139311. /**
  139312. * Imports the .tilemaps file
  139313. * @param url of the .tilemaps file
  139314. */
  139315. loadTileMaps(url: string): void;
  139316. /**
  139317. * Release associated resources
  139318. */
  139319. dispose(): void;
  139320. }
  139321. }
  139322. declare module BABYLON {
  139323. /**
  139324. * Class used to manage multiple sprites of different sizes on the same spritesheet
  139325. * @see http://doc.babylonjs.com/babylon101/sprites
  139326. */
  139327. export class SpritePackedManager extends SpriteManager {
  139328. /** defines the packed manager's name */
  139329. name: string;
  139330. /**
  139331. * Creates a new sprite manager from a packed sprite sheet
  139332. * @param name defines the manager's name
  139333. * @param imgUrl defines the sprite sheet url
  139334. * @param capacity defines the maximum allowed number of sprites
  139335. * @param scene defines the hosting scene
  139336. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  139337. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  139338. * @param samplingMode defines the smapling mode to use with spritesheet
  139339. * @param fromPacked set to true; do not alter
  139340. */
  139341. constructor(
  139342. /** defines the packed manager's name */
  139343. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  139344. }
  139345. }
  139346. declare module BABYLON {
  139347. /**
  139348. * Defines the list of states available for a task inside a AssetsManager
  139349. */
  139350. export enum AssetTaskState {
  139351. /**
  139352. * Initialization
  139353. */
  139354. INIT = 0,
  139355. /**
  139356. * Running
  139357. */
  139358. RUNNING = 1,
  139359. /**
  139360. * Done
  139361. */
  139362. DONE = 2,
  139363. /**
  139364. * Error
  139365. */
  139366. ERROR = 3
  139367. }
  139368. /**
  139369. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  139370. */
  139371. export abstract class AbstractAssetTask {
  139372. /**
  139373. * Task name
  139374. */ name: string;
  139375. /**
  139376. * Callback called when the task is successful
  139377. */
  139378. onSuccess: (task: any) => void;
  139379. /**
  139380. * Callback called when the task is not successful
  139381. */
  139382. onError: (task: any, message?: string, exception?: any) => void;
  139383. /**
  139384. * Creates a new AssetsManager
  139385. * @param name defines the name of the task
  139386. */
  139387. constructor(
  139388. /**
  139389. * Task name
  139390. */ name: string);
  139391. private _isCompleted;
  139392. private _taskState;
  139393. private _errorObject;
  139394. /**
  139395. * Get if the task is completed
  139396. */
  139397. get isCompleted(): boolean;
  139398. /**
  139399. * Gets the current state of the task
  139400. */
  139401. get taskState(): AssetTaskState;
  139402. /**
  139403. * Gets the current error object (if task is in error)
  139404. */
  139405. get errorObject(): {
  139406. message?: string;
  139407. exception?: any;
  139408. };
  139409. /**
  139410. * Internal only
  139411. * @hidden
  139412. */
  139413. _setErrorObject(message?: string, exception?: any): void;
  139414. /**
  139415. * Execute the current task
  139416. * @param scene defines the scene where you want your assets to be loaded
  139417. * @param onSuccess is a callback called when the task is successfully executed
  139418. * @param onError is a callback called if an error occurs
  139419. */
  139420. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139421. /**
  139422. * Execute the current task
  139423. * @param scene defines the scene where you want your assets to be loaded
  139424. * @param onSuccess is a callback called when the task is successfully executed
  139425. * @param onError is a callback called if an error occurs
  139426. */
  139427. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139428. /**
  139429. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  139430. * This can be used with failed tasks that have the reason for failure fixed.
  139431. */
  139432. reset(): void;
  139433. private onErrorCallback;
  139434. private onDoneCallback;
  139435. }
  139436. /**
  139437. * Define the interface used by progress events raised during assets loading
  139438. */
  139439. export interface IAssetsProgressEvent {
  139440. /**
  139441. * Defines the number of remaining tasks to process
  139442. */
  139443. remainingCount: number;
  139444. /**
  139445. * Defines the total number of tasks
  139446. */
  139447. totalCount: number;
  139448. /**
  139449. * Defines the task that was just processed
  139450. */
  139451. task: AbstractAssetTask;
  139452. }
  139453. /**
  139454. * Class used to share progress information about assets loading
  139455. */
  139456. export class AssetsProgressEvent implements IAssetsProgressEvent {
  139457. /**
  139458. * Defines the number of remaining tasks to process
  139459. */
  139460. remainingCount: number;
  139461. /**
  139462. * Defines the total number of tasks
  139463. */
  139464. totalCount: number;
  139465. /**
  139466. * Defines the task that was just processed
  139467. */
  139468. task: AbstractAssetTask;
  139469. /**
  139470. * Creates a AssetsProgressEvent
  139471. * @param remainingCount defines the number of remaining tasks to process
  139472. * @param totalCount defines the total number of tasks
  139473. * @param task defines the task that was just processed
  139474. */
  139475. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  139476. }
  139477. /**
  139478. * Define a task used by AssetsManager to load meshes
  139479. */
  139480. export class MeshAssetTask extends AbstractAssetTask {
  139481. /**
  139482. * Defines the name of the task
  139483. */
  139484. name: string;
  139485. /**
  139486. * Defines the list of mesh's names you want to load
  139487. */
  139488. meshesNames: any;
  139489. /**
  139490. * Defines the root url to use as a base to load your meshes and associated resources
  139491. */
  139492. rootUrl: string;
  139493. /**
  139494. * Defines the filename of the scene to load from
  139495. */
  139496. sceneFilename: string;
  139497. /**
  139498. * Gets the list of loaded meshes
  139499. */
  139500. loadedMeshes: Array<AbstractMesh>;
  139501. /**
  139502. * Gets the list of loaded particle systems
  139503. */
  139504. loadedParticleSystems: Array<IParticleSystem>;
  139505. /**
  139506. * Gets the list of loaded skeletons
  139507. */
  139508. loadedSkeletons: Array<Skeleton>;
  139509. /**
  139510. * Gets the list of loaded animation groups
  139511. */
  139512. loadedAnimationGroups: Array<AnimationGroup>;
  139513. /**
  139514. * Callback called when the task is successful
  139515. */
  139516. onSuccess: (task: MeshAssetTask) => void;
  139517. /**
  139518. * Callback called when the task is successful
  139519. */
  139520. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  139521. /**
  139522. * Creates a new MeshAssetTask
  139523. * @param name defines the name of the task
  139524. * @param meshesNames defines the list of mesh's names you want to load
  139525. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  139526. * @param sceneFilename defines the filename of the scene to load from
  139527. */
  139528. constructor(
  139529. /**
  139530. * Defines the name of the task
  139531. */
  139532. name: string,
  139533. /**
  139534. * Defines the list of mesh's names you want to load
  139535. */
  139536. meshesNames: any,
  139537. /**
  139538. * Defines the root url to use as a base to load your meshes and associated resources
  139539. */
  139540. rootUrl: string,
  139541. /**
  139542. * Defines the filename of the scene to load from
  139543. */
  139544. sceneFilename: string);
  139545. /**
  139546. * Execute the current task
  139547. * @param scene defines the scene where you want your assets to be loaded
  139548. * @param onSuccess is a callback called when the task is successfully executed
  139549. * @param onError is a callback called if an error occurs
  139550. */
  139551. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139552. }
  139553. /**
  139554. * Define a task used by AssetsManager to load text content
  139555. */
  139556. export class TextFileAssetTask extends AbstractAssetTask {
  139557. /**
  139558. * Defines the name of the task
  139559. */
  139560. name: string;
  139561. /**
  139562. * Defines the location of the file to load
  139563. */
  139564. url: string;
  139565. /**
  139566. * Gets the loaded text string
  139567. */
  139568. text: string;
  139569. /**
  139570. * Callback called when the task is successful
  139571. */
  139572. onSuccess: (task: TextFileAssetTask) => void;
  139573. /**
  139574. * Callback called when the task is successful
  139575. */
  139576. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  139577. /**
  139578. * Creates a new TextFileAssetTask object
  139579. * @param name defines the name of the task
  139580. * @param url defines the location of the file to load
  139581. */
  139582. constructor(
  139583. /**
  139584. * Defines the name of the task
  139585. */
  139586. name: string,
  139587. /**
  139588. * Defines the location of the file to load
  139589. */
  139590. url: string);
  139591. /**
  139592. * Execute the current task
  139593. * @param scene defines the scene where you want your assets to be loaded
  139594. * @param onSuccess is a callback called when the task is successfully executed
  139595. * @param onError is a callback called if an error occurs
  139596. */
  139597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139598. }
  139599. /**
  139600. * Define a task used by AssetsManager to load binary data
  139601. */
  139602. export class BinaryFileAssetTask extends AbstractAssetTask {
  139603. /**
  139604. * Defines the name of the task
  139605. */
  139606. name: string;
  139607. /**
  139608. * Defines the location of the file to load
  139609. */
  139610. url: string;
  139611. /**
  139612. * Gets the lodaded data (as an array buffer)
  139613. */
  139614. data: ArrayBuffer;
  139615. /**
  139616. * Callback called when the task is successful
  139617. */
  139618. onSuccess: (task: BinaryFileAssetTask) => void;
  139619. /**
  139620. * Callback called when the task is successful
  139621. */
  139622. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  139623. /**
  139624. * Creates a new BinaryFileAssetTask object
  139625. * @param name defines the name of the new task
  139626. * @param url defines the location of the file to load
  139627. */
  139628. constructor(
  139629. /**
  139630. * Defines the name of the task
  139631. */
  139632. name: string,
  139633. /**
  139634. * Defines the location of the file to load
  139635. */
  139636. url: string);
  139637. /**
  139638. * Execute the current task
  139639. * @param scene defines the scene where you want your assets to be loaded
  139640. * @param onSuccess is a callback called when the task is successfully executed
  139641. * @param onError is a callback called if an error occurs
  139642. */
  139643. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139644. }
  139645. /**
  139646. * Define a task used by AssetsManager to load images
  139647. */
  139648. export class ImageAssetTask extends AbstractAssetTask {
  139649. /**
  139650. * Defines the name of the task
  139651. */
  139652. name: string;
  139653. /**
  139654. * Defines the location of the image to load
  139655. */
  139656. url: string;
  139657. /**
  139658. * Gets the loaded images
  139659. */
  139660. image: HTMLImageElement;
  139661. /**
  139662. * Callback called when the task is successful
  139663. */
  139664. onSuccess: (task: ImageAssetTask) => void;
  139665. /**
  139666. * Callback called when the task is successful
  139667. */
  139668. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  139669. /**
  139670. * Creates a new ImageAssetTask
  139671. * @param name defines the name of the task
  139672. * @param url defines the location of the image to load
  139673. */
  139674. constructor(
  139675. /**
  139676. * Defines the name of the task
  139677. */
  139678. name: string,
  139679. /**
  139680. * Defines the location of the image to load
  139681. */
  139682. url: string);
  139683. /**
  139684. * Execute the current task
  139685. * @param scene defines the scene where you want your assets to be loaded
  139686. * @param onSuccess is a callback called when the task is successfully executed
  139687. * @param onError is a callback called if an error occurs
  139688. */
  139689. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139690. }
  139691. /**
  139692. * Defines the interface used by texture loading tasks
  139693. */
  139694. export interface ITextureAssetTask<TEX extends BaseTexture> {
  139695. /**
  139696. * Gets the loaded texture
  139697. */
  139698. texture: TEX;
  139699. }
  139700. /**
  139701. * Define a task used by AssetsManager to load 2D textures
  139702. */
  139703. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  139704. /**
  139705. * Defines the name of the task
  139706. */
  139707. name: string;
  139708. /**
  139709. * Defines the location of the file to load
  139710. */
  139711. url: string;
  139712. /**
  139713. * Defines if mipmap should not be generated (default is false)
  139714. */
  139715. noMipmap?: boolean | undefined;
  139716. /**
  139717. * Defines if texture must be inverted on Y axis (default is false)
  139718. */
  139719. invertY?: boolean | undefined;
  139720. /**
  139721. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139722. */
  139723. samplingMode: number;
  139724. /**
  139725. * Gets the loaded texture
  139726. */
  139727. texture: Texture;
  139728. /**
  139729. * Callback called when the task is successful
  139730. */
  139731. onSuccess: (task: TextureAssetTask) => void;
  139732. /**
  139733. * Callback called when the task is successful
  139734. */
  139735. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  139736. /**
  139737. * Creates a new TextureAssetTask object
  139738. * @param name defines the name of the task
  139739. * @param url defines the location of the file to load
  139740. * @param noMipmap defines if mipmap should not be generated (default is false)
  139741. * @param invertY defines if texture must be inverted on Y axis (default is false)
  139742. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139743. */
  139744. constructor(
  139745. /**
  139746. * Defines the name of the task
  139747. */
  139748. name: string,
  139749. /**
  139750. * Defines the location of the file to load
  139751. */
  139752. url: string,
  139753. /**
  139754. * Defines if mipmap should not be generated (default is false)
  139755. */
  139756. noMipmap?: boolean | undefined,
  139757. /**
  139758. * Defines if texture must be inverted on Y axis (default is false)
  139759. */
  139760. invertY?: boolean | undefined,
  139761. /**
  139762. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139763. */
  139764. samplingMode?: number);
  139765. /**
  139766. * Execute the current task
  139767. * @param scene defines the scene where you want your assets to be loaded
  139768. * @param onSuccess is a callback called when the task is successfully executed
  139769. * @param onError is a callback called if an error occurs
  139770. */
  139771. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139772. }
  139773. /**
  139774. * Define a task used by AssetsManager to load cube textures
  139775. */
  139776. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  139777. /**
  139778. * Defines the name of the task
  139779. */
  139780. name: string;
  139781. /**
  139782. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139783. */
  139784. url: string;
  139785. /**
  139786. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139787. */
  139788. extensions?: string[] | undefined;
  139789. /**
  139790. * Defines if mipmaps should not be generated (default is false)
  139791. */
  139792. noMipmap?: boolean | undefined;
  139793. /**
  139794. * Defines the explicit list of files (undefined by default)
  139795. */
  139796. files?: string[] | undefined;
  139797. /**
  139798. * Gets the loaded texture
  139799. */
  139800. texture: CubeTexture;
  139801. /**
  139802. * Callback called when the task is successful
  139803. */
  139804. onSuccess: (task: CubeTextureAssetTask) => void;
  139805. /**
  139806. * Callback called when the task is successful
  139807. */
  139808. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  139809. /**
  139810. * Creates a new CubeTextureAssetTask
  139811. * @param name defines the name of the task
  139812. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139813. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139814. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139815. * @param files defines the explicit list of files (undefined by default)
  139816. */
  139817. constructor(
  139818. /**
  139819. * Defines the name of the task
  139820. */
  139821. name: string,
  139822. /**
  139823. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139824. */
  139825. url: string,
  139826. /**
  139827. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139828. */
  139829. extensions?: string[] | undefined,
  139830. /**
  139831. * Defines if mipmaps should not be generated (default is false)
  139832. */
  139833. noMipmap?: boolean | undefined,
  139834. /**
  139835. * Defines the explicit list of files (undefined by default)
  139836. */
  139837. files?: string[] | undefined);
  139838. /**
  139839. * Execute the current task
  139840. * @param scene defines the scene where you want your assets to be loaded
  139841. * @param onSuccess is a callback called when the task is successfully executed
  139842. * @param onError is a callback called if an error occurs
  139843. */
  139844. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139845. }
  139846. /**
  139847. * Define a task used by AssetsManager to load HDR cube textures
  139848. */
  139849. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  139850. /**
  139851. * Defines the name of the task
  139852. */
  139853. name: string;
  139854. /**
  139855. * Defines the location of the file to load
  139856. */
  139857. url: string;
  139858. /**
  139859. * Defines the desired size (the more it increases the longer the generation will be)
  139860. */
  139861. size: number;
  139862. /**
  139863. * Defines if mipmaps should not be generated (default is false)
  139864. */
  139865. noMipmap: boolean;
  139866. /**
  139867. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139868. */
  139869. generateHarmonics: boolean;
  139870. /**
  139871. * 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)
  139872. */
  139873. gammaSpace: boolean;
  139874. /**
  139875. * Internal Use Only
  139876. */
  139877. reserved: boolean;
  139878. /**
  139879. * Gets the loaded texture
  139880. */
  139881. texture: HDRCubeTexture;
  139882. /**
  139883. * Callback called when the task is successful
  139884. */
  139885. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  139886. /**
  139887. * Callback called when the task is successful
  139888. */
  139889. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  139890. /**
  139891. * Creates a new HDRCubeTextureAssetTask object
  139892. * @param name defines the name of the task
  139893. * @param url defines the location of the file to load
  139894. * @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.
  139895. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139896. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139897. * @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)
  139898. * @param reserved Internal use only
  139899. */
  139900. constructor(
  139901. /**
  139902. * Defines the name of the task
  139903. */
  139904. name: string,
  139905. /**
  139906. * Defines the location of the file to load
  139907. */
  139908. url: string,
  139909. /**
  139910. * Defines the desired size (the more it increases the longer the generation will be)
  139911. */
  139912. size: number,
  139913. /**
  139914. * Defines if mipmaps should not be generated (default is false)
  139915. */
  139916. noMipmap?: boolean,
  139917. /**
  139918. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139919. */
  139920. generateHarmonics?: boolean,
  139921. /**
  139922. * 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)
  139923. */
  139924. gammaSpace?: boolean,
  139925. /**
  139926. * Internal Use Only
  139927. */
  139928. reserved?: boolean);
  139929. /**
  139930. * Execute the current task
  139931. * @param scene defines the scene where you want your assets to be loaded
  139932. * @param onSuccess is a callback called when the task is successfully executed
  139933. * @param onError is a callback called if an error occurs
  139934. */
  139935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139936. }
  139937. /**
  139938. * Define a task used by AssetsManager to load Equirectangular cube textures
  139939. */
  139940. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  139941. /**
  139942. * Defines the name of the task
  139943. */
  139944. name: string;
  139945. /**
  139946. * Defines the location of the file to load
  139947. */
  139948. url: string;
  139949. /**
  139950. * Defines the desired size (the more it increases the longer the generation will be)
  139951. */
  139952. size: number;
  139953. /**
  139954. * Defines if mipmaps should not be generated (default is false)
  139955. */
  139956. noMipmap: boolean;
  139957. /**
  139958. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  139959. * but the standard material would require them in Gamma space) (default is true)
  139960. */
  139961. gammaSpace: boolean;
  139962. /**
  139963. * Gets the loaded texture
  139964. */
  139965. texture: EquiRectangularCubeTexture;
  139966. /**
  139967. * Callback called when the task is successful
  139968. */
  139969. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  139970. /**
  139971. * Callback called when the task is successful
  139972. */
  139973. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  139974. /**
  139975. * Creates a new EquiRectangularCubeTextureAssetTask object
  139976. * @param name defines the name of the task
  139977. * @param url defines the location of the file to load
  139978. * @param size defines the desired size (the more it increases the longer the generation will be)
  139979. * If the size is omitted this implies you are using a preprocessed cubemap.
  139980. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139981. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  139982. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  139983. * (default is true)
  139984. */
  139985. constructor(
  139986. /**
  139987. * Defines the name of the task
  139988. */
  139989. name: string,
  139990. /**
  139991. * Defines the location of the file to load
  139992. */
  139993. url: string,
  139994. /**
  139995. * Defines the desired size (the more it increases the longer the generation will be)
  139996. */
  139997. size: number,
  139998. /**
  139999. * Defines if mipmaps should not be generated (default is false)
  140000. */
  140001. noMipmap?: boolean,
  140002. /**
  140003. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140004. * but the standard material would require them in Gamma space) (default is true)
  140005. */
  140006. gammaSpace?: boolean);
  140007. /**
  140008. * Execute the current task
  140009. * @param scene defines the scene where you want your assets to be loaded
  140010. * @param onSuccess is a callback called when the task is successfully executed
  140011. * @param onError is a callback called if an error occurs
  140012. */
  140013. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140014. }
  140015. /**
  140016. * This class can be used to easily import assets into a scene
  140017. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140018. */
  140019. export class AssetsManager {
  140020. private _scene;
  140021. private _isLoading;
  140022. protected _tasks: AbstractAssetTask[];
  140023. protected _waitingTasksCount: number;
  140024. protected _totalTasksCount: number;
  140025. /**
  140026. * Callback called when all tasks are processed
  140027. */
  140028. onFinish: (tasks: AbstractAssetTask[]) => void;
  140029. /**
  140030. * Callback called when a task is successful
  140031. */
  140032. onTaskSuccess: (task: AbstractAssetTask) => void;
  140033. /**
  140034. * Callback called when a task had an error
  140035. */
  140036. onTaskError: (task: AbstractAssetTask) => void;
  140037. /**
  140038. * Callback called when a task is done (whatever the result is)
  140039. */
  140040. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140041. /**
  140042. * Observable called when all tasks are processed
  140043. */
  140044. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140045. /**
  140046. * Observable called when a task had an error
  140047. */
  140048. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140049. /**
  140050. * Observable called when all tasks were executed
  140051. */
  140052. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140053. /**
  140054. * Observable called when a task is done (whatever the result is)
  140055. */
  140056. onProgressObservable: Observable<IAssetsProgressEvent>;
  140057. /**
  140058. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140059. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140060. */
  140061. useDefaultLoadingScreen: boolean;
  140062. /**
  140063. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140064. * when all assets have been downloaded.
  140065. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140066. */
  140067. autoHideLoadingUI: boolean;
  140068. /**
  140069. * Creates a new AssetsManager
  140070. * @param scene defines the scene to work on
  140071. */
  140072. constructor(scene: Scene);
  140073. /**
  140074. * Add a MeshAssetTask to the list of active tasks
  140075. * @param taskName defines the name of the new task
  140076. * @param meshesNames defines the name of meshes to load
  140077. * @param rootUrl defines the root url to use to locate files
  140078. * @param sceneFilename defines the filename of the scene file
  140079. * @returns a new MeshAssetTask object
  140080. */
  140081. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140082. /**
  140083. * Add a TextFileAssetTask to the list of active tasks
  140084. * @param taskName defines the name of the new task
  140085. * @param url defines the url of the file to load
  140086. * @returns a new TextFileAssetTask object
  140087. */
  140088. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140089. /**
  140090. * Add a BinaryFileAssetTask to the list of active tasks
  140091. * @param taskName defines the name of the new task
  140092. * @param url defines the url of the file to load
  140093. * @returns a new BinaryFileAssetTask object
  140094. */
  140095. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140096. /**
  140097. * Add a ImageAssetTask to the list of active tasks
  140098. * @param taskName defines the name of the new task
  140099. * @param url defines the url of the file to load
  140100. * @returns a new ImageAssetTask object
  140101. */
  140102. addImageTask(taskName: string, url: string): ImageAssetTask;
  140103. /**
  140104. * Add a TextureAssetTask to the list of active tasks
  140105. * @param taskName defines the name of the new task
  140106. * @param url defines the url of the file to load
  140107. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140108. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140109. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140110. * @returns a new TextureAssetTask object
  140111. */
  140112. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140113. /**
  140114. * Add a CubeTextureAssetTask to the list of active tasks
  140115. * @param taskName defines the name of the new task
  140116. * @param url defines the url of the file to load
  140117. * @param extensions defines the extension to use to load the cube map (can be null)
  140118. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140119. * @param files defines the list of files to load (can be null)
  140120. * @returns a new CubeTextureAssetTask object
  140121. */
  140122. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140123. /**
  140124. *
  140125. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140126. * @param taskName defines the name of the new task
  140127. * @param url defines the url of the file to load
  140128. * @param size defines the size you want for the cubemap (can be null)
  140129. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140130. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140131. * @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)
  140132. * @param reserved Internal use only
  140133. * @returns a new HDRCubeTextureAssetTask object
  140134. */
  140135. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140136. /**
  140137. *
  140138. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140139. * @param taskName defines the name of the new task
  140140. * @param url defines the url of the file to load
  140141. * @param size defines the size you want for the cubemap (can be null)
  140142. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140143. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140144. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140145. * @returns a new EquiRectangularCubeTextureAssetTask object
  140146. */
  140147. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140148. /**
  140149. * Remove a task from the assets manager.
  140150. * @param task the task to remove
  140151. */
  140152. removeTask(task: AbstractAssetTask): void;
  140153. private _decreaseWaitingTasksCount;
  140154. private _runTask;
  140155. /**
  140156. * Reset the AssetsManager and remove all tasks
  140157. * @return the current instance of the AssetsManager
  140158. */
  140159. reset(): AssetsManager;
  140160. /**
  140161. * Start the loading process
  140162. * @return the current instance of the AssetsManager
  140163. */
  140164. load(): AssetsManager;
  140165. /**
  140166. * Start the loading process as an async operation
  140167. * @return a promise returning the list of failed tasks
  140168. */
  140169. loadAsync(): Promise<void>;
  140170. }
  140171. }
  140172. declare module BABYLON {
  140173. /**
  140174. * Wrapper class for promise with external resolve and reject.
  140175. */
  140176. export class Deferred<T> {
  140177. /**
  140178. * The promise associated with this deferred object.
  140179. */
  140180. readonly promise: Promise<T>;
  140181. private _resolve;
  140182. private _reject;
  140183. /**
  140184. * The resolve method of the promise associated with this deferred object.
  140185. */
  140186. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140187. /**
  140188. * The reject method of the promise associated with this deferred object.
  140189. */
  140190. get reject(): (reason?: any) => void;
  140191. /**
  140192. * Constructor for this deferred object.
  140193. */
  140194. constructor();
  140195. }
  140196. }
  140197. declare module BABYLON {
  140198. /**
  140199. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  140200. */
  140201. export class MeshExploder {
  140202. private _centerMesh;
  140203. private _meshes;
  140204. private _meshesOrigins;
  140205. private _toCenterVectors;
  140206. private _scaledDirection;
  140207. private _newPosition;
  140208. private _centerPosition;
  140209. /**
  140210. * Explodes meshes from a center mesh.
  140211. * @param meshes The meshes to explode.
  140212. * @param centerMesh The mesh to be center of explosion.
  140213. */
  140214. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  140215. private _setCenterMesh;
  140216. /**
  140217. * Get class name
  140218. * @returns "MeshExploder"
  140219. */
  140220. getClassName(): string;
  140221. /**
  140222. * "Exploded meshes"
  140223. * @returns Array of meshes with the centerMesh at index 0.
  140224. */
  140225. getMeshes(): Array<Mesh>;
  140226. /**
  140227. * Explodes meshes giving a specific direction
  140228. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  140229. */
  140230. explode(direction?: number): void;
  140231. }
  140232. }
  140233. declare module BABYLON {
  140234. /**
  140235. * Class used to help managing file picking and drag'n'drop
  140236. */
  140237. export class FilesInput {
  140238. /**
  140239. * List of files ready to be loaded
  140240. */
  140241. static get FilesToLoad(): {
  140242. [key: string]: File;
  140243. };
  140244. /**
  140245. * Callback called when a file is processed
  140246. */
  140247. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  140248. private _engine;
  140249. private _currentScene;
  140250. private _sceneLoadedCallback;
  140251. private _progressCallback;
  140252. private _additionalRenderLoopLogicCallback;
  140253. private _textureLoadingCallback;
  140254. private _startingProcessingFilesCallback;
  140255. private _onReloadCallback;
  140256. private _errorCallback;
  140257. private _elementToMonitor;
  140258. private _sceneFileToLoad;
  140259. private _filesToLoad;
  140260. /**
  140261. * Creates a new FilesInput
  140262. * @param engine defines the rendering engine
  140263. * @param scene defines the hosting scene
  140264. * @param sceneLoadedCallback callback called when scene is loaded
  140265. * @param progressCallback callback called to track progress
  140266. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  140267. * @param textureLoadingCallback callback called when a texture is loading
  140268. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  140269. * @param onReloadCallback callback called when a reload is requested
  140270. * @param errorCallback callback call if an error occurs
  140271. */
  140272. 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);
  140273. private _dragEnterHandler;
  140274. private _dragOverHandler;
  140275. private _dropHandler;
  140276. /**
  140277. * Calls this function to listen to drag'n'drop events on a specific DOM element
  140278. * @param elementToMonitor defines the DOM element to track
  140279. */
  140280. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  140281. /**
  140282. * Release all associated resources
  140283. */
  140284. dispose(): void;
  140285. private renderFunction;
  140286. private drag;
  140287. private drop;
  140288. private _traverseFolder;
  140289. private _processFiles;
  140290. /**
  140291. * Load files from a drop event
  140292. * @param event defines the drop event to use as source
  140293. */
  140294. loadFiles(event: any): void;
  140295. private _processReload;
  140296. /**
  140297. * Reload the current scene from the loaded files
  140298. */
  140299. reload(): void;
  140300. }
  140301. }
  140302. declare module BABYLON {
  140303. /**
  140304. * Defines the root class used to create scene optimization to use with SceneOptimizer
  140305. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140306. */
  140307. export class SceneOptimization {
  140308. /**
  140309. * Defines the priority of this optimization (0 by default which means first in the list)
  140310. */
  140311. priority: number;
  140312. /**
  140313. * Gets a string describing the action executed by the current optimization
  140314. * @returns description string
  140315. */
  140316. getDescription(): string;
  140317. /**
  140318. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140319. * @param scene defines the current scene where to apply this optimization
  140320. * @param optimizer defines the current optimizer
  140321. * @returns true if everything that can be done was applied
  140322. */
  140323. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140324. /**
  140325. * Creates the SceneOptimization object
  140326. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140327. * @param desc defines the description associated with the optimization
  140328. */
  140329. constructor(
  140330. /**
  140331. * Defines the priority of this optimization (0 by default which means first in the list)
  140332. */
  140333. priority?: number);
  140334. }
  140335. /**
  140336. * Defines an optimization used to reduce the size of render target textures
  140337. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140338. */
  140339. export class TextureOptimization extends SceneOptimization {
  140340. /**
  140341. * Defines the priority of this optimization (0 by default which means first in the list)
  140342. */
  140343. priority: number;
  140344. /**
  140345. * 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
  140346. */
  140347. maximumSize: number;
  140348. /**
  140349. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140350. */
  140351. step: number;
  140352. /**
  140353. * Gets a string describing the action executed by the current optimization
  140354. * @returns description string
  140355. */
  140356. getDescription(): string;
  140357. /**
  140358. * Creates the TextureOptimization object
  140359. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140360. * @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
  140361. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140362. */
  140363. constructor(
  140364. /**
  140365. * Defines the priority of this optimization (0 by default which means first in the list)
  140366. */
  140367. priority?: number,
  140368. /**
  140369. * 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
  140370. */
  140371. maximumSize?: number,
  140372. /**
  140373. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140374. */
  140375. step?: number);
  140376. /**
  140377. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140378. * @param scene defines the current scene where to apply this optimization
  140379. * @param optimizer defines the current optimizer
  140380. * @returns true if everything that can be done was applied
  140381. */
  140382. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140383. }
  140384. /**
  140385. * Defines an optimization used to increase or decrease the rendering resolution
  140386. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140387. */
  140388. export class HardwareScalingOptimization extends SceneOptimization {
  140389. /**
  140390. * Defines the priority of this optimization (0 by default which means first in the list)
  140391. */
  140392. priority: number;
  140393. /**
  140394. * Defines the maximum scale to use (2 by default)
  140395. */
  140396. maximumScale: number;
  140397. /**
  140398. * Defines the step to use between two passes (0.5 by default)
  140399. */
  140400. step: number;
  140401. private _currentScale;
  140402. private _directionOffset;
  140403. /**
  140404. * Gets a string describing the action executed by the current optimization
  140405. * @return description string
  140406. */
  140407. getDescription(): string;
  140408. /**
  140409. * Creates the HardwareScalingOptimization object
  140410. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140411. * @param maximumScale defines the maximum scale to use (2 by default)
  140412. * @param step defines the step to use between two passes (0.5 by default)
  140413. */
  140414. constructor(
  140415. /**
  140416. * Defines the priority of this optimization (0 by default which means first in the list)
  140417. */
  140418. priority?: number,
  140419. /**
  140420. * Defines the maximum scale to use (2 by default)
  140421. */
  140422. maximumScale?: number,
  140423. /**
  140424. * Defines the step to use between two passes (0.5 by default)
  140425. */
  140426. step?: number);
  140427. /**
  140428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140429. * @param scene defines the current scene where to apply this optimization
  140430. * @param optimizer defines the current optimizer
  140431. * @returns true if everything that can be done was applied
  140432. */
  140433. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140434. }
  140435. /**
  140436. * Defines an optimization used to remove shadows
  140437. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140438. */
  140439. export class ShadowsOptimization extends SceneOptimization {
  140440. /**
  140441. * Gets a string describing the action executed by the current optimization
  140442. * @return description string
  140443. */
  140444. getDescription(): string;
  140445. /**
  140446. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140447. * @param scene defines the current scene where to apply this optimization
  140448. * @param optimizer defines the current optimizer
  140449. * @returns true if everything that can be done was applied
  140450. */
  140451. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140452. }
  140453. /**
  140454. * Defines an optimization used to turn post-processes off
  140455. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140456. */
  140457. export class PostProcessesOptimization extends SceneOptimization {
  140458. /**
  140459. * Gets a string describing the action executed by the current optimization
  140460. * @return description string
  140461. */
  140462. getDescription(): string;
  140463. /**
  140464. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140465. * @param scene defines the current scene where to apply this optimization
  140466. * @param optimizer defines the current optimizer
  140467. * @returns true if everything that can be done was applied
  140468. */
  140469. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140470. }
  140471. /**
  140472. * Defines an optimization used to turn lens flares off
  140473. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140474. */
  140475. export class LensFlaresOptimization extends SceneOptimization {
  140476. /**
  140477. * Gets a string describing the action executed by the current optimization
  140478. * @return description string
  140479. */
  140480. getDescription(): string;
  140481. /**
  140482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140483. * @param scene defines the current scene where to apply this optimization
  140484. * @param optimizer defines the current optimizer
  140485. * @returns true if everything that can be done was applied
  140486. */
  140487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140488. }
  140489. /**
  140490. * Defines an optimization based on user defined callback.
  140491. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140492. */
  140493. export class CustomOptimization extends SceneOptimization {
  140494. /**
  140495. * Callback called to apply the custom optimization.
  140496. */
  140497. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  140498. /**
  140499. * Callback called to get custom description
  140500. */
  140501. onGetDescription: () => string;
  140502. /**
  140503. * Gets a string describing the action executed by the current optimization
  140504. * @returns description string
  140505. */
  140506. getDescription(): string;
  140507. /**
  140508. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140509. * @param scene defines the current scene where to apply this optimization
  140510. * @param optimizer defines the current optimizer
  140511. * @returns true if everything that can be done was applied
  140512. */
  140513. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140514. }
  140515. /**
  140516. * Defines an optimization used to turn particles off
  140517. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140518. */
  140519. export class ParticlesOptimization extends SceneOptimization {
  140520. /**
  140521. * Gets a string describing the action executed by the current optimization
  140522. * @return description string
  140523. */
  140524. getDescription(): string;
  140525. /**
  140526. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140527. * @param scene defines the current scene where to apply this optimization
  140528. * @param optimizer defines the current optimizer
  140529. * @returns true if everything that can be done was applied
  140530. */
  140531. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140532. }
  140533. /**
  140534. * Defines an optimization used to turn render targets off
  140535. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140536. */
  140537. export class RenderTargetsOptimization extends SceneOptimization {
  140538. /**
  140539. * Gets a string describing the action executed by the current optimization
  140540. * @return description string
  140541. */
  140542. getDescription(): string;
  140543. /**
  140544. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140545. * @param scene defines the current scene where to apply this optimization
  140546. * @param optimizer defines the current optimizer
  140547. * @returns true if everything that can be done was applied
  140548. */
  140549. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140550. }
  140551. /**
  140552. * Defines an optimization used to merge meshes with compatible materials
  140553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140554. */
  140555. export class MergeMeshesOptimization extends SceneOptimization {
  140556. private static _UpdateSelectionTree;
  140557. /**
  140558. * Gets or sets a boolean which defines if optimization octree has to be updated
  140559. */
  140560. static get UpdateSelectionTree(): boolean;
  140561. /**
  140562. * Gets or sets a boolean which defines if optimization octree has to be updated
  140563. */
  140564. static set UpdateSelectionTree(value: boolean);
  140565. /**
  140566. * Gets a string describing the action executed by the current optimization
  140567. * @return description string
  140568. */
  140569. getDescription(): string;
  140570. private _canBeMerged;
  140571. /**
  140572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140573. * @param scene defines the current scene where to apply this optimization
  140574. * @param optimizer defines the current optimizer
  140575. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  140576. * @returns true if everything that can be done was applied
  140577. */
  140578. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  140579. }
  140580. /**
  140581. * Defines a list of options used by SceneOptimizer
  140582. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140583. */
  140584. export class SceneOptimizerOptions {
  140585. /**
  140586. * Defines the target frame rate to reach (60 by default)
  140587. */
  140588. targetFrameRate: number;
  140589. /**
  140590. * Defines the interval between two checkes (2000ms by default)
  140591. */
  140592. trackerDuration: number;
  140593. /**
  140594. * Gets the list of optimizations to apply
  140595. */
  140596. optimizations: SceneOptimization[];
  140597. /**
  140598. * Creates a new list of options used by SceneOptimizer
  140599. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  140600. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  140601. */
  140602. constructor(
  140603. /**
  140604. * Defines the target frame rate to reach (60 by default)
  140605. */
  140606. targetFrameRate?: number,
  140607. /**
  140608. * Defines the interval between two checkes (2000ms by default)
  140609. */
  140610. trackerDuration?: number);
  140611. /**
  140612. * Add a new optimization
  140613. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  140614. * @returns the current SceneOptimizerOptions
  140615. */
  140616. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  140617. /**
  140618. * Add a new custom optimization
  140619. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  140620. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  140621. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140622. * @returns the current SceneOptimizerOptions
  140623. */
  140624. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  140625. /**
  140626. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  140627. * @param targetFrameRate defines the target frame rate (60 by default)
  140628. * @returns a SceneOptimizerOptions object
  140629. */
  140630. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140631. /**
  140632. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  140633. * @param targetFrameRate defines the target frame rate (60 by default)
  140634. * @returns a SceneOptimizerOptions object
  140635. */
  140636. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140637. /**
  140638. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  140639. * @param targetFrameRate defines the target frame rate (60 by default)
  140640. * @returns a SceneOptimizerOptions object
  140641. */
  140642. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140643. }
  140644. /**
  140645. * Class used to run optimizations in order to reach a target frame rate
  140646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140647. */
  140648. export class SceneOptimizer implements IDisposable {
  140649. private _isRunning;
  140650. private _options;
  140651. private _scene;
  140652. private _currentPriorityLevel;
  140653. private _targetFrameRate;
  140654. private _trackerDuration;
  140655. private _currentFrameRate;
  140656. private _sceneDisposeObserver;
  140657. private _improvementMode;
  140658. /**
  140659. * Defines an observable called when the optimizer reaches the target frame rate
  140660. */
  140661. onSuccessObservable: Observable<SceneOptimizer>;
  140662. /**
  140663. * Defines an observable called when the optimizer enables an optimization
  140664. */
  140665. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  140666. /**
  140667. * Defines an observable called when the optimizer is not able to reach the target frame rate
  140668. */
  140669. onFailureObservable: Observable<SceneOptimizer>;
  140670. /**
  140671. * Gets a boolean indicating if the optimizer is in improvement mode
  140672. */
  140673. get isInImprovementMode(): boolean;
  140674. /**
  140675. * Gets the current priority level (0 at start)
  140676. */
  140677. get currentPriorityLevel(): number;
  140678. /**
  140679. * Gets the current frame rate checked by the SceneOptimizer
  140680. */
  140681. get currentFrameRate(): number;
  140682. /**
  140683. * Gets or sets the current target frame rate (60 by default)
  140684. */
  140685. get targetFrameRate(): number;
  140686. /**
  140687. * Gets or sets the current target frame rate (60 by default)
  140688. */
  140689. set targetFrameRate(value: number);
  140690. /**
  140691. * Gets or sets the current interval between two checks (every 2000ms by default)
  140692. */
  140693. get trackerDuration(): number;
  140694. /**
  140695. * Gets or sets the current interval between two checks (every 2000ms by default)
  140696. */
  140697. set trackerDuration(value: number);
  140698. /**
  140699. * Gets the list of active optimizations
  140700. */
  140701. get optimizations(): SceneOptimization[];
  140702. /**
  140703. * Creates a new SceneOptimizer
  140704. * @param scene defines the scene to work on
  140705. * @param options defines the options to use with the SceneOptimizer
  140706. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  140707. * @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)
  140708. */
  140709. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  140710. /**
  140711. * Stops the current optimizer
  140712. */
  140713. stop(): void;
  140714. /**
  140715. * Reset the optimizer to initial step (current priority level = 0)
  140716. */
  140717. reset(): void;
  140718. /**
  140719. * Start the optimizer. By default it will try to reach a specific framerate
  140720. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  140721. */
  140722. start(): void;
  140723. private _checkCurrentState;
  140724. /**
  140725. * Release all resources
  140726. */
  140727. dispose(): void;
  140728. /**
  140729. * Helper function to create a SceneOptimizer with one single line of code
  140730. * @param scene defines the scene to work on
  140731. * @param options defines the options to use with the SceneOptimizer
  140732. * @param onSuccess defines a callback to call on success
  140733. * @param onFailure defines a callback to call on failure
  140734. * @returns the new SceneOptimizer object
  140735. */
  140736. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  140737. }
  140738. }
  140739. declare module BABYLON {
  140740. /**
  140741. * Class used to serialize a scene into a string
  140742. */
  140743. export class SceneSerializer {
  140744. /**
  140745. * Clear cache used by a previous serialization
  140746. */
  140747. static ClearCache(): void;
  140748. /**
  140749. * Serialize a scene into a JSON compatible object
  140750. * @param scene defines the scene to serialize
  140751. * @returns a JSON compatible object
  140752. */
  140753. static Serialize(scene: Scene): any;
  140754. /**
  140755. * Serialize a mesh into a JSON compatible object
  140756. * @param toSerialize defines the mesh to serialize
  140757. * @param withParents defines if parents must be serialized as well
  140758. * @param withChildren defines if children must be serialized as well
  140759. * @returns a JSON compatible object
  140760. */
  140761. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  140762. }
  140763. }
  140764. declare module BABYLON {
  140765. /**
  140766. * Class used to host texture specific utilities
  140767. */
  140768. export class TextureTools {
  140769. /**
  140770. * Uses the GPU to create a copy texture rescaled at a given size
  140771. * @param texture Texture to copy from
  140772. * @param width defines the desired width
  140773. * @param height defines the desired height
  140774. * @param useBilinearMode defines if bilinear mode has to be used
  140775. * @return the generated texture
  140776. */
  140777. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  140778. }
  140779. }
  140780. declare module BABYLON {
  140781. /**
  140782. * This represents the different options available for the video capture.
  140783. */
  140784. export interface VideoRecorderOptions {
  140785. /** Defines the mime type of the video. */
  140786. mimeType: string;
  140787. /** Defines the FPS the video should be recorded at. */
  140788. fps: number;
  140789. /** Defines the chunk size for the recording data. */
  140790. recordChunckSize: number;
  140791. /** The audio tracks to attach to the recording. */
  140792. audioTracks?: MediaStreamTrack[];
  140793. }
  140794. /**
  140795. * This can help with recording videos from BabylonJS.
  140796. * This is based on the available WebRTC functionalities of the browser.
  140797. *
  140798. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  140799. */
  140800. export class VideoRecorder {
  140801. private static readonly _defaultOptions;
  140802. /**
  140803. * Returns whether or not the VideoRecorder is available in your browser.
  140804. * @param engine Defines the Babylon Engine.
  140805. * @returns true if supported otherwise false.
  140806. */
  140807. static IsSupported(engine: Engine): boolean;
  140808. private readonly _options;
  140809. private _canvas;
  140810. private _mediaRecorder;
  140811. private _recordedChunks;
  140812. private _fileName;
  140813. private _resolve;
  140814. private _reject;
  140815. /**
  140816. * True when a recording is already in progress.
  140817. */
  140818. get isRecording(): boolean;
  140819. /**
  140820. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  140821. * @param engine Defines the BabylonJS Engine you wish to record.
  140822. * @param options Defines options that can be used to customize the capture.
  140823. */
  140824. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  140825. /**
  140826. * Stops the current recording before the default capture timeout passed in the startRecording function.
  140827. */
  140828. stopRecording(): void;
  140829. /**
  140830. * Starts recording the canvas for a max duration specified in parameters.
  140831. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  140832. * If null no automatic download will start and you can rely on the promise to get the data back.
  140833. * @param maxDuration Defines the maximum recording time in seconds.
  140834. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  140835. * @return A promise callback at the end of the recording with the video data in Blob.
  140836. */
  140837. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  140838. /**
  140839. * Releases internal resources used during the recording.
  140840. */
  140841. dispose(): void;
  140842. private _handleDataAvailable;
  140843. private _handleError;
  140844. private _handleStop;
  140845. }
  140846. }
  140847. declare module BABYLON {
  140848. /**
  140849. * Class containing a set of static utilities functions for screenshots
  140850. */
  140851. export class ScreenshotTools {
  140852. /**
  140853. * Captures a screenshot of the current rendering
  140854. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140855. * @param engine defines the rendering engine
  140856. * @param camera defines the source camera
  140857. * @param size This parameter can be set to a single number or to an object with the
  140858. * following (optional) properties: precision, width, height. If a single number is passed,
  140859. * it will be used for both width and height. If an object is passed, the screenshot size
  140860. * will be derived from the parameters. The precision property is a multiplier allowing
  140861. * rendering at a higher or lower resolution
  140862. * @param successCallback defines the callback receives a single parameter which contains the
  140863. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  140864. * src parameter of an <img> to display it
  140865. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  140866. * Check your browser for supported MIME types
  140867. */
  140868. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  140869. /**
  140870. * Captures a screenshot of the current rendering
  140871. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140872. * @param engine defines the rendering engine
  140873. * @param camera defines the source camera
  140874. * @param size This parameter can be set to a single number or to an object with the
  140875. * following (optional) properties: precision, width, height. If a single number is passed,
  140876. * it will be used for both width and height. If an object is passed, the screenshot size
  140877. * will be derived from the parameters. The precision property is a multiplier allowing
  140878. * rendering at a higher or lower resolution
  140879. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  140880. * Check your browser for supported MIME types
  140881. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  140882. * to the src parameter of an <img> to display it
  140883. */
  140884. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  140885. /**
  140886. * Generates an image screenshot from the specified camera.
  140887. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140888. * @param engine The engine to use for rendering
  140889. * @param camera The camera to use for rendering
  140890. * @param size This parameter can be set to a single number or to an object with the
  140891. * following (optional) properties: precision, width, height. If a single number is passed,
  140892. * it will be used for both width and height. If an object is passed, the screenshot size
  140893. * will be derived from the parameters. The precision property is a multiplier allowing
  140894. * rendering at a higher or lower resolution
  140895. * @param successCallback The callback receives a single parameter which contains the
  140896. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  140897. * src parameter of an <img> to display it
  140898. * @param mimeType The MIME type of the screenshot image (default: image/png).
  140899. * Check your browser for supported MIME types
  140900. * @param samples Texture samples (default: 1)
  140901. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  140902. * @param fileName A name for for the downloaded file.
  140903. */
  140904. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  140905. /**
  140906. * Generates an image screenshot from the specified camera.
  140907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140908. * @param engine The engine to use for rendering
  140909. * @param camera The camera to use for rendering
  140910. * @param size This parameter can be set to a single number or to an object with the
  140911. * following (optional) properties: precision, width, height. If a single number is passed,
  140912. * it will be used for both width and height. If an object is passed, the screenshot size
  140913. * will be derived from the parameters. The precision property is a multiplier allowing
  140914. * rendering at a higher or lower resolution
  140915. * @param mimeType The MIME type of the screenshot image (default: image/png).
  140916. * Check your browser for supported MIME types
  140917. * @param samples Texture samples (default: 1)
  140918. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  140919. * @param fileName A name for for the downloaded file.
  140920. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  140921. * to the src parameter of an <img> to display it
  140922. */
  140923. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  140924. /**
  140925. * Gets height and width for screenshot size
  140926. * @private
  140927. */
  140928. private static _getScreenshotSize;
  140929. }
  140930. }
  140931. declare module BABYLON {
  140932. /**
  140933. * Interface for a data buffer
  140934. */
  140935. export interface IDataBuffer {
  140936. /**
  140937. * Reads bytes from the data buffer.
  140938. * @param byteOffset The byte offset to read
  140939. * @param byteLength The byte length to read
  140940. * @returns A promise that resolves when the bytes are read
  140941. */
  140942. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  140943. /**
  140944. * The byte length of the buffer.
  140945. */
  140946. readonly byteLength: number;
  140947. }
  140948. /**
  140949. * Utility class for reading from a data buffer
  140950. */
  140951. export class DataReader {
  140952. /**
  140953. * The data buffer associated with this data reader.
  140954. */
  140955. readonly buffer: IDataBuffer;
  140956. /**
  140957. * The current byte offset from the beginning of the data buffer.
  140958. */
  140959. byteOffset: number;
  140960. private _dataView;
  140961. private _dataByteOffset;
  140962. /**
  140963. * Constructor
  140964. * @param buffer The buffer to read
  140965. */
  140966. constructor(buffer: IDataBuffer);
  140967. /**
  140968. * Loads the given byte length.
  140969. * @param byteLength The byte length to load
  140970. * @returns A promise that resolves when the load is complete
  140971. */
  140972. loadAsync(byteLength: number): Promise<void>;
  140973. /**
  140974. * Read a unsigned 32-bit integer from the currently loaded data range.
  140975. * @returns The 32-bit integer read
  140976. */
  140977. readUint32(): number;
  140978. /**
  140979. * Read a byte array from the currently loaded data range.
  140980. * @param byteLength The byte length to read
  140981. * @returns The byte array read
  140982. */
  140983. readUint8Array(byteLength: number): Uint8Array;
  140984. /**
  140985. * Read a string from the currently loaded data range.
  140986. * @param byteLength The byte length to read
  140987. * @returns The string read
  140988. */
  140989. readString(byteLength: number): string;
  140990. /**
  140991. * Skips the given byte length the currently loaded data range.
  140992. * @param byteLength The byte length to skip
  140993. */
  140994. skipBytes(byteLength: number): void;
  140995. }
  140996. }
  140997. declare module BABYLON {
  140998. /**
  140999. * A cursor which tracks a point on a path
  141000. */
  141001. export class PathCursor {
  141002. private path;
  141003. /**
  141004. * Stores path cursor callbacks for when an onchange event is triggered
  141005. */
  141006. private _onchange;
  141007. /**
  141008. * The value of the path cursor
  141009. */
  141010. value: number;
  141011. /**
  141012. * The animation array of the path cursor
  141013. */
  141014. animations: Animation[];
  141015. /**
  141016. * Initializes the path cursor
  141017. * @param path The path to track
  141018. */
  141019. constructor(path: Path2);
  141020. /**
  141021. * Gets the cursor point on the path
  141022. * @returns A point on the path cursor at the cursor location
  141023. */
  141024. getPoint(): Vector3;
  141025. /**
  141026. * Moves the cursor ahead by the step amount
  141027. * @param step The amount to move the cursor forward
  141028. * @returns This path cursor
  141029. */
  141030. moveAhead(step?: number): PathCursor;
  141031. /**
  141032. * Moves the cursor behind by the step amount
  141033. * @param step The amount to move the cursor back
  141034. * @returns This path cursor
  141035. */
  141036. moveBack(step?: number): PathCursor;
  141037. /**
  141038. * Moves the cursor by the step amount
  141039. * If the step amount is greater than one, an exception is thrown
  141040. * @param step The amount to move the cursor
  141041. * @returns This path cursor
  141042. */
  141043. move(step: number): PathCursor;
  141044. /**
  141045. * Ensures that the value is limited between zero and one
  141046. * @returns This path cursor
  141047. */
  141048. private ensureLimits;
  141049. /**
  141050. * Runs onchange callbacks on change (used by the animation engine)
  141051. * @returns This path cursor
  141052. */
  141053. private raiseOnChange;
  141054. /**
  141055. * Executes a function on change
  141056. * @param f A path cursor onchange callback
  141057. * @returns This path cursor
  141058. */
  141059. onchange(f: (cursor: PathCursor) => void): PathCursor;
  141060. }
  141061. }
  141062. declare module BABYLON {
  141063. /** @hidden */
  141064. export var blurPixelShader: {
  141065. name: string;
  141066. shader: string;
  141067. };
  141068. }
  141069. declare module BABYLON {
  141070. /** @hidden */
  141071. export var pointCloudVertexDeclaration: {
  141072. name: string;
  141073. shader: string;
  141074. };
  141075. }
  141076. // Mixins
  141077. interface Window {
  141078. mozIndexedDB: IDBFactory;
  141079. webkitIndexedDB: IDBFactory;
  141080. msIndexedDB: IDBFactory;
  141081. webkitURL: typeof URL;
  141082. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  141083. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  141084. WebGLRenderingContext: WebGLRenderingContext;
  141085. MSGesture: MSGesture;
  141086. CANNON: any;
  141087. AudioContext: AudioContext;
  141088. webkitAudioContext: AudioContext;
  141089. PointerEvent: any;
  141090. Math: Math;
  141091. Uint8Array: Uint8ArrayConstructor;
  141092. Float32Array: Float32ArrayConstructor;
  141093. mozURL: typeof URL;
  141094. msURL: typeof URL;
  141095. VRFrameData: any; // WebVR, from specs 1.1
  141096. DracoDecoderModule: any;
  141097. setImmediate(handler: (...args: any[]) => void): number;
  141098. }
  141099. interface HTMLCanvasElement {
  141100. requestPointerLock(): void;
  141101. msRequestPointerLock?(): void;
  141102. mozRequestPointerLock?(): void;
  141103. webkitRequestPointerLock?(): void;
  141104. /** Track wether a record is in progress */
  141105. isRecording: boolean;
  141106. /** Capture Stream method defined by some browsers */
  141107. captureStream(fps?: number): MediaStream;
  141108. }
  141109. interface CanvasRenderingContext2D {
  141110. msImageSmoothingEnabled: boolean;
  141111. }
  141112. interface MouseEvent {
  141113. mozMovementX: number;
  141114. mozMovementY: number;
  141115. webkitMovementX: number;
  141116. webkitMovementY: number;
  141117. msMovementX: number;
  141118. msMovementY: number;
  141119. }
  141120. interface Navigator {
  141121. mozGetVRDevices: (any: any) => any;
  141122. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141123. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141124. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141125. webkitGetGamepads(): Gamepad[];
  141126. msGetGamepads(): Gamepad[];
  141127. webkitGamepads(): Gamepad[];
  141128. }
  141129. interface HTMLVideoElement {
  141130. mozSrcObject: any;
  141131. }
  141132. interface Math {
  141133. fround(x: number): number;
  141134. imul(a: number, b: number): number;
  141135. }
  141136. interface WebGLRenderingContext {
  141137. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  141138. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  141139. vertexAttribDivisor(index: number, divisor: number): void;
  141140. createVertexArray(): any;
  141141. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  141142. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  141143. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  141144. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  141145. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  141146. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  141147. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  141148. // Queries
  141149. createQuery(): WebGLQuery;
  141150. deleteQuery(query: WebGLQuery): void;
  141151. beginQuery(target: number, query: WebGLQuery): void;
  141152. endQuery(target: number): void;
  141153. getQueryParameter(query: WebGLQuery, pname: number): any;
  141154. getQuery(target: number, pname: number): any;
  141155. MAX_SAMPLES: number;
  141156. RGBA8: number;
  141157. READ_FRAMEBUFFER: number;
  141158. DRAW_FRAMEBUFFER: number;
  141159. UNIFORM_BUFFER: number;
  141160. HALF_FLOAT_OES: number;
  141161. RGBA16F: number;
  141162. RGBA32F: number;
  141163. R32F: number;
  141164. RG32F: number;
  141165. RGB32F: number;
  141166. R16F: number;
  141167. RG16F: number;
  141168. RGB16F: number;
  141169. RED: number;
  141170. RG: number;
  141171. R8: number;
  141172. RG8: number;
  141173. UNSIGNED_INT_24_8: number;
  141174. DEPTH24_STENCIL8: number;
  141175. MIN: number;
  141176. MAX: number;
  141177. /* Multiple Render Targets */
  141178. drawBuffers(buffers: number[]): void;
  141179. readBuffer(src: number): void;
  141180. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  141181. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  141182. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  141183. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  141184. // Occlusion Query
  141185. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  141186. ANY_SAMPLES_PASSED: number;
  141187. QUERY_RESULT_AVAILABLE: number;
  141188. QUERY_RESULT: number;
  141189. }
  141190. interface WebGLProgram {
  141191. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  141192. }
  141193. interface EXT_disjoint_timer_query {
  141194. QUERY_COUNTER_BITS_EXT: number;
  141195. TIME_ELAPSED_EXT: number;
  141196. TIMESTAMP_EXT: number;
  141197. GPU_DISJOINT_EXT: number;
  141198. QUERY_RESULT_EXT: number;
  141199. QUERY_RESULT_AVAILABLE_EXT: number;
  141200. queryCounterEXT(query: WebGLQuery, target: number): void;
  141201. createQueryEXT(): WebGLQuery;
  141202. beginQueryEXT(target: number, query: WebGLQuery): void;
  141203. endQueryEXT(target: number): void;
  141204. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  141205. deleteQueryEXT(query: WebGLQuery): void;
  141206. }
  141207. interface WebGLUniformLocation {
  141208. _currentState: any;
  141209. }
  141210. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  141211. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  141212. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  141213. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  141214. interface WebGLRenderingContext {
  141215. readonly RASTERIZER_DISCARD: number;
  141216. readonly DEPTH_COMPONENT24: number;
  141217. readonly TEXTURE_3D: number;
  141218. readonly TEXTURE_2D_ARRAY: number;
  141219. readonly TEXTURE_COMPARE_FUNC: number;
  141220. readonly TEXTURE_COMPARE_MODE: number;
  141221. readonly COMPARE_REF_TO_TEXTURE: number;
  141222. readonly TEXTURE_WRAP_R: number;
  141223. readonly HALF_FLOAT: number;
  141224. readonly RGB8: number;
  141225. readonly RED_INTEGER: number;
  141226. readonly RG_INTEGER: number;
  141227. readonly RGB_INTEGER: number;
  141228. readonly RGBA_INTEGER: number;
  141229. readonly R8_SNORM: number;
  141230. readonly RG8_SNORM: number;
  141231. readonly RGB8_SNORM: number;
  141232. readonly RGBA8_SNORM: number;
  141233. readonly R8I: number;
  141234. readonly RG8I: number;
  141235. readonly RGB8I: number;
  141236. readonly RGBA8I: number;
  141237. readonly R8UI: number;
  141238. readonly RG8UI: number;
  141239. readonly RGB8UI: number;
  141240. readonly RGBA8UI: number;
  141241. readonly R16I: number;
  141242. readonly RG16I: number;
  141243. readonly RGB16I: number;
  141244. readonly RGBA16I: number;
  141245. readonly R16UI: number;
  141246. readonly RG16UI: number;
  141247. readonly RGB16UI: number;
  141248. readonly RGBA16UI: number;
  141249. readonly R32I: number;
  141250. readonly RG32I: number;
  141251. readonly RGB32I: number;
  141252. readonly RGBA32I: number;
  141253. readonly R32UI: number;
  141254. readonly RG32UI: number;
  141255. readonly RGB32UI: number;
  141256. readonly RGBA32UI: number;
  141257. readonly RGB10_A2UI: number;
  141258. readonly R11F_G11F_B10F: number;
  141259. readonly RGB9_E5: number;
  141260. readonly RGB10_A2: number;
  141261. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  141262. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  141263. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  141264. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  141265. readonly DEPTH_COMPONENT32F: number;
  141266. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  141267. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  141268. 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;
  141269. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  141270. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  141271. readonly TRANSFORM_FEEDBACK: number;
  141272. readonly INTERLEAVED_ATTRIBS: number;
  141273. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  141274. createTransformFeedback(): WebGLTransformFeedback;
  141275. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  141276. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  141277. beginTransformFeedback(primitiveMode: number): void;
  141278. endTransformFeedback(): void;
  141279. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  141280. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141281. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141282. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141283. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  141284. }
  141285. interface ImageBitmap {
  141286. readonly width: number;
  141287. readonly height: number;
  141288. close(): void;
  141289. }
  141290. interface WebGLQuery extends WebGLObject {
  141291. }
  141292. declare var WebGLQuery: {
  141293. prototype: WebGLQuery;
  141294. new(): WebGLQuery;
  141295. };
  141296. interface WebGLSampler extends WebGLObject {
  141297. }
  141298. declare var WebGLSampler: {
  141299. prototype: WebGLSampler;
  141300. new(): WebGLSampler;
  141301. };
  141302. interface WebGLSync extends WebGLObject {
  141303. }
  141304. declare var WebGLSync: {
  141305. prototype: WebGLSync;
  141306. new(): WebGLSync;
  141307. };
  141308. interface WebGLTransformFeedback extends WebGLObject {
  141309. }
  141310. declare var WebGLTransformFeedback: {
  141311. prototype: WebGLTransformFeedback;
  141312. new(): WebGLTransformFeedback;
  141313. };
  141314. interface WebGLVertexArrayObject extends WebGLObject {
  141315. }
  141316. declare var WebGLVertexArrayObject: {
  141317. prototype: WebGLVertexArrayObject;
  141318. new(): WebGLVertexArrayObject;
  141319. };
  141320. // Type definitions for WebVR API
  141321. // Project: https://w3c.github.io/webvr/
  141322. // Definitions by: six a <https://github.com/lostfictions>
  141323. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  141324. interface VRDisplay extends EventTarget {
  141325. /**
  141326. * Dictionary of capabilities describing the VRDisplay.
  141327. */
  141328. readonly capabilities: VRDisplayCapabilities;
  141329. /**
  141330. * z-depth defining the far plane of the eye view frustum
  141331. * enables mapping of values in the render target depth
  141332. * attachment to scene coordinates. Initially set to 10000.0.
  141333. */
  141334. depthFar: number;
  141335. /**
  141336. * z-depth defining the near plane of the eye view frustum
  141337. * enables mapping of values in the render target depth
  141338. * attachment to scene coordinates. Initially set to 0.01.
  141339. */
  141340. depthNear: number;
  141341. /**
  141342. * An identifier for this distinct VRDisplay. Used as an
  141343. * association point in the Gamepad API.
  141344. */
  141345. readonly displayId: number;
  141346. /**
  141347. * A display name, a user-readable name identifying it.
  141348. */
  141349. readonly displayName: string;
  141350. readonly isConnected: boolean;
  141351. readonly isPresenting: boolean;
  141352. /**
  141353. * If this VRDisplay supports room-scale experiences, the optional
  141354. * stage attribute contains details on the room-scale parameters.
  141355. */
  141356. readonly stageParameters: VRStageParameters | null;
  141357. /**
  141358. * Passing the value returned by `requestAnimationFrame` to
  141359. * `cancelAnimationFrame` will unregister the callback.
  141360. * @param handle Define the hanle of the request to cancel
  141361. */
  141362. cancelAnimationFrame(handle: number): void;
  141363. /**
  141364. * Stops presenting to the VRDisplay.
  141365. * @returns a promise to know when it stopped
  141366. */
  141367. exitPresent(): Promise<void>;
  141368. /**
  141369. * Return the current VREyeParameters for the given eye.
  141370. * @param whichEye Define the eye we want the parameter for
  141371. * @returns the eye parameters
  141372. */
  141373. getEyeParameters(whichEye: string): VREyeParameters;
  141374. /**
  141375. * Populates the passed VRFrameData with the information required to render
  141376. * the current frame.
  141377. * @param frameData Define the data structure to populate
  141378. * @returns true if ok otherwise false
  141379. */
  141380. getFrameData(frameData: VRFrameData): boolean;
  141381. /**
  141382. * Get the layers currently being presented.
  141383. * @returns the list of VR layers
  141384. */
  141385. getLayers(): VRLayer[];
  141386. /**
  141387. * Return a VRPose containing the future predicted pose of the VRDisplay
  141388. * when the current frame will be presented. The value returned will not
  141389. * change until JavaScript has returned control to the browser.
  141390. *
  141391. * The VRPose will contain the position, orientation, velocity,
  141392. * and acceleration of each of these properties.
  141393. * @returns the pose object
  141394. */
  141395. getPose(): VRPose;
  141396. /**
  141397. * Return the current instantaneous pose of the VRDisplay, with no
  141398. * prediction applied.
  141399. * @returns the current instantaneous pose
  141400. */
  141401. getImmediatePose(): VRPose;
  141402. /**
  141403. * The callback passed to `requestAnimationFrame` will be called
  141404. * any time a new frame should be rendered. When the VRDisplay is
  141405. * presenting the callback will be called at the native refresh
  141406. * rate of the HMD. When not presenting this function acts
  141407. * identically to how window.requestAnimationFrame acts. Content should
  141408. * make no assumptions of frame rate or vsync behavior as the HMD runs
  141409. * asynchronously from other displays and at differing refresh rates.
  141410. * @param callback Define the eaction to run next frame
  141411. * @returns the request handle it
  141412. */
  141413. requestAnimationFrame(callback: FrameRequestCallback): number;
  141414. /**
  141415. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  141416. * Repeat calls while already presenting will update the VRLayers being displayed.
  141417. * @param layers Define the list of layer to present
  141418. * @returns a promise to know when the request has been fulfilled
  141419. */
  141420. requestPresent(layers: VRLayer[]): Promise<void>;
  141421. /**
  141422. * Reset the pose for this display, treating its current position and
  141423. * orientation as the "origin/zero" values. VRPose.position,
  141424. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  141425. * updated when calling resetPose(). This should be called in only
  141426. * sitting-space experiences.
  141427. */
  141428. resetPose(): void;
  141429. /**
  141430. * The VRLayer provided to the VRDisplay will be captured and presented
  141431. * in the HMD. Calling this function has the same effect on the source
  141432. * canvas as any other operation that uses its source image, and canvases
  141433. * created without preserveDrawingBuffer set to true will be cleared.
  141434. * @param pose Define the pose to submit
  141435. */
  141436. submitFrame(pose?: VRPose): void;
  141437. }
  141438. declare var VRDisplay: {
  141439. prototype: VRDisplay;
  141440. new(): VRDisplay;
  141441. };
  141442. interface VRLayer {
  141443. leftBounds?: number[] | Float32Array | null;
  141444. rightBounds?: number[] | Float32Array | null;
  141445. source?: HTMLCanvasElement | null;
  141446. }
  141447. interface VRDisplayCapabilities {
  141448. readonly canPresent: boolean;
  141449. readonly hasExternalDisplay: boolean;
  141450. readonly hasOrientation: boolean;
  141451. readonly hasPosition: boolean;
  141452. readonly maxLayers: number;
  141453. }
  141454. interface VREyeParameters {
  141455. /** @deprecated */
  141456. readonly fieldOfView: VRFieldOfView;
  141457. readonly offset: Float32Array;
  141458. readonly renderHeight: number;
  141459. readonly renderWidth: number;
  141460. }
  141461. interface VRFieldOfView {
  141462. readonly downDegrees: number;
  141463. readonly leftDegrees: number;
  141464. readonly rightDegrees: number;
  141465. readonly upDegrees: number;
  141466. }
  141467. interface VRFrameData {
  141468. readonly leftProjectionMatrix: Float32Array;
  141469. readonly leftViewMatrix: Float32Array;
  141470. readonly pose: VRPose;
  141471. readonly rightProjectionMatrix: Float32Array;
  141472. readonly rightViewMatrix: Float32Array;
  141473. readonly timestamp: number;
  141474. }
  141475. interface VRPose {
  141476. readonly angularAcceleration: Float32Array | null;
  141477. readonly angularVelocity: Float32Array | null;
  141478. readonly linearAcceleration: Float32Array | null;
  141479. readonly linearVelocity: Float32Array | null;
  141480. readonly orientation: Float32Array | null;
  141481. readonly position: Float32Array | null;
  141482. readonly timestamp: number;
  141483. }
  141484. interface VRStageParameters {
  141485. sittingToStandingTransform?: Float32Array;
  141486. sizeX?: number;
  141487. sizeY?: number;
  141488. }
  141489. interface Navigator {
  141490. getVRDisplays(): Promise<VRDisplay[]>;
  141491. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  141492. }
  141493. interface Window {
  141494. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  141495. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  141496. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  141497. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  141498. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  141499. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  141500. }
  141501. interface Gamepad {
  141502. readonly displayId: number;
  141503. }
  141504. type XRSessionMode =
  141505. | "inline"
  141506. | "immersive-vr"
  141507. | "immersive-ar";
  141508. type XRReferenceSpaceType =
  141509. | "viewer"
  141510. | "local"
  141511. | "local-floor"
  141512. | "bounded-floor"
  141513. | "unbounded";
  141514. type XREnvironmentBlendMode =
  141515. | "opaque"
  141516. | "additive"
  141517. | "alpha-blend";
  141518. type XRVisibilityState =
  141519. | "visible"
  141520. | "visible-blurred"
  141521. | "hidden";
  141522. type XRHandedness =
  141523. | "none"
  141524. | "left"
  141525. | "right";
  141526. type XRTargetRayMode =
  141527. | "gaze"
  141528. | "tracked-pointer"
  141529. | "screen";
  141530. type XREye =
  141531. | "none"
  141532. | "left"
  141533. | "right";
  141534. interface XRSpace extends EventTarget {
  141535. }
  141536. interface XRRenderState {
  141537. depthNear?: number;
  141538. depthFar?: number;
  141539. inlineVerticalFieldOfView?: number;
  141540. baseLayer?: XRWebGLLayer;
  141541. }
  141542. interface XRInputSource {
  141543. handedness: XRHandedness;
  141544. targetRayMode: XRTargetRayMode;
  141545. targetRaySpace: XRSpace;
  141546. gripSpace: XRSpace | undefined;
  141547. gamepad: Gamepad | undefined;
  141548. profiles: Array<string>;
  141549. }
  141550. interface XRSession extends XRAnchorCreator {
  141551. addEventListener: Function;
  141552. removeEventListener: Function;
  141553. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  141554. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  141555. requestAnimationFrame: Function;
  141556. end(): Promise<void>;
  141557. renderState: XRRenderState;
  141558. inputSources: Array<XRInputSource>;
  141559. // AR hit test
  141560. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141561. updateWorldTrackingState(options: {
  141562. planeDetectionState?: { enabled: boolean; }
  141563. }): void;
  141564. }
  141565. interface XRReferenceSpace extends XRSpace {
  141566. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  141567. onreset: any;
  141568. }
  141569. type XRPlaneSet = Set<XRPlane>;
  141570. type XRAnchorSet = Set<XRAnchor>;
  141571. interface XRFrame {
  141572. session: XRSession;
  141573. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  141574. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  141575. // Anchors
  141576. trackedAnchors?: XRAnchorSet;
  141577. // Planes
  141578. worldInformation: {
  141579. detectedPlanes?: XRPlaneSet;
  141580. };
  141581. }
  141582. interface XRViewerPose extends XRPose {
  141583. views: Array<XRView>;
  141584. }
  141585. interface XRPose {
  141586. transform: XRRigidTransform;
  141587. emulatedPosition: boolean;
  141588. }
  141589. interface XRWebGLLayerOptions {
  141590. antialias?: boolean;
  141591. depth?: boolean;
  141592. stencil?: boolean;
  141593. alpha?: boolean;
  141594. multiview?: boolean;
  141595. framebufferScaleFactor?: number;
  141596. }
  141597. declare var XRWebGLLayer: {
  141598. prototype: XRWebGLLayer;
  141599. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  141600. };
  141601. interface XRWebGLLayer {
  141602. framebuffer: WebGLFramebuffer;
  141603. framebufferWidth: number;
  141604. framebufferHeight: number;
  141605. getViewport: Function;
  141606. }
  141607. declare class XRRigidTransform {
  141608. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  141609. position: DOMPointReadOnly;
  141610. orientation: DOMPointReadOnly;
  141611. matrix: Float32Array;
  141612. inverse: XRRigidTransform;
  141613. }
  141614. interface XRView {
  141615. eye: XREye;
  141616. projectionMatrix: Float32Array;
  141617. transform: XRRigidTransform;
  141618. }
  141619. interface XRInputSourceChangeEvent {
  141620. session: XRSession;
  141621. removed: Array<XRInputSource>;
  141622. added: Array<XRInputSource>;
  141623. }
  141624. interface XRInputSourceEvent extends Event {
  141625. readonly frame: XRFrame;
  141626. readonly inputSource: XRInputSource;
  141627. }
  141628. // Experimental(er) features
  141629. declare class XRRay {
  141630. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  141631. origin: DOMPointReadOnly;
  141632. direction: DOMPointReadOnly;
  141633. matrix: Float32Array;
  141634. }
  141635. interface XRHitResult {
  141636. hitMatrix: Float32Array;
  141637. }
  141638. interface XRAnchor {
  141639. // remove?
  141640. id?: string;
  141641. anchorSpace: XRSpace;
  141642. lastChangedTime: number;
  141643. detach(): void;
  141644. }
  141645. interface XRPlane extends XRAnchorCreator {
  141646. orientation: "Horizontal" | "Vertical";
  141647. planeSpace: XRSpace;
  141648. polygon: Array<DOMPointReadOnly>;
  141649. lastChangedTime: number;
  141650. }
  141651. interface XRAnchorCreator {
  141652. // AR Anchors
  141653. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  141654. }